Added basic search functionality to each repository pane.

This commit is contained in:
Josh Stark 2019-06-02 11:31:04 +01:00
parent 9aa48e4303
commit bee04db820
7 changed files with 112 additions and 14 deletions

6
.gitignore vendored
View File

@ -31,4 +31,8 @@ config/fleet.properties
src/main/resources/assets/js/all*.js
src/main/resources/assets/css/all*.css
src/main/resources/log4j2.xml
.gradle/
.gradle/
.classpath
.project
.settings/

View File

@ -19,6 +19,8 @@ package io.linuxserver.fleet.dockerhub.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects;
public class DockerHubV2Tag {
@JsonProperty("name")
@ -27,6 +29,9 @@ public class DockerHubV2Tag {
@JsonProperty("full_size")
private long fullSize;
@JsonProperty("last_updated")
private String lastUpdated;
public String getName() {
return name;
}
@ -35,6 +40,10 @@ public class DockerHubV2Tag {
return fullSize;
}
public String getLastUpdated() {
return lastUpdated;
}
@Override
public String toString() {
return name;
@ -42,7 +51,7 @@ public class DockerHubV2Tag {
@Override
public int hashCode() {
return name.hashCode();
return Objects.hash(name, fullSize);
}
@Override
@ -56,6 +65,7 @@ public class DockerHubV2Tag {
return true;
}
return name.equals(((DockerHubV2Tag) other).name);
DockerHubV2Tag otherTag = (DockerHubV2Tag) other;
return name.equals(otherTag.name) && fullSize == otherTag.fullSize;
}
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2019 LinuxServer.io
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package io.linuxserver.fleet.model;
public class DockerHubTag {
private final String name;
private final long size;
private final String buildDate;
public DockerHubTag(String name, long size, String buildDate) {
this.name = name;
this.size = size;
this.buildDate = buildDate;
}
public String getName() {
return name;
}
public long getSize() {
return size;
}
public String getBuildDate() {
return buildDate;
}
}

View File

@ -17,6 +17,12 @@ h2 {
margin-bottom: 20px;
}
input[type="text"], textarea {
outline: none;
box-shadow:none !important;
border:1px solid #ccc !important;
}
.navbar-brand {
font-family: 'Pacifico', cursive;

View File

@ -335,6 +335,39 @@ var imageListManager = (function($) {
}(jQuery));
var imageSearchManager = (function($) {
var performSearch = function() {
var $searchBox = $(this);
var currentSearch = $.trim($searchBox.val());
var activeTable = $('#' + $searchBox.data('repository-id') + '_images');
var rows = activeTable.find('tbody tr');
rows.each(function(i, row) {
var $row = $(row);
var imageName = $row.data('image-name');
if (imageName.startsWith(currentSearch) || currentSearch.length === 0) {
$row.show();
} else {
$row.hide();
}
});
};
var init = function() {
$('input.image-search').on('keyup', performSearch);
};
return {
init: init
}
}(jQuery));
var synchronisationManager = (function($) {
var onMessage = function(event) {

View File

@ -81,6 +81,7 @@
<#if context="home">
imageListManager.init();
imageSearchManager.init();
</#if>
<#if context="setup" || context="login">

View File

@ -24,15 +24,7 @@
<div class="tab-pane<#if populatedRepository?index == 0> show active</#if>" id="repository_#{populatedRepository.repository.id}" role="tabpanel" aria-labelledby="repository-tab_#{populatedRepository.repository.id}">
<div class="container">
<#if populatedRepository.everyImageStable>
<div class="row my-3">
<div class="col-12">
<div class="fleet-alert fleet-alert--success">
<i class="fas fa-check text-success"></i> No issues reported
</div>
</div>
</div>
<#else>
<#if !populatedRepository.everyImageStable>
<div class="row my-3">
<div class="col-12">
<div class="fleet-alert fleet-alert--warning">
@ -44,9 +36,17 @@
<#if populatedRepository.images?size &gt; 0>
<div class="row">
<div class="col-12">
<div class="input-group mb-3 mt-3">
<div class="input-group-prepend">
<span class="input-group-text" id="searchLabel_#{populatedRepository.repository.id}"><i class="fas fa-search"></i></span>
</div>
<input type="text" class="form-control image-search" id="search_#{populatedRepository.repository.id}" data-repository-id="#{populatedRepository.repository.id}" aria-describedby="searchLabel_#{populatedRepository.repository.id}">
</div>
</div>
<div class="col-12">
<div class="table-responsive">
<div class="table-responsive" id="#{populatedRepository.repository.id}_images">
<table class="table table--sortable">
<thead>
<tr>
@ -64,7 +64,7 @@
<#if !image.hidden || __AUTHENTICATED_USER?has_content>
<tr class="<#if image.hidden>hidden-image</#if><#if image.deprecated>deprecated-image</#if>" data-image-id="#{image.id}" data-image-name="${image.name}">
<td class="image-name">
<span class="image-name--repository">${populatedRepository.repository.name} /</span> <a target="_blank" href="https://hub.docker.com/r/${populatedRepository.repository.name}/${image.name}">${image.name}</a>
<span class="image-name--repository">${populatedRepository.repository.name} /</span> <a target="_blank" href="https://hub.docker.com/r/${populatedRepository.repository.name}/${image.name}"><span class="image-name__image">${image.name}</span></a>
<#if image.deprecated>
<span class="deprecation-message" title="This image has been deprecated: ${image.deprecationReason!""}"><i class="fas fa-exclamation-circle"></i></span>
</#if>