From bee04db820349469431fca26a7821bccbfb848a0 Mon Sep 17 00:00:00 2001 From: Josh Stark Date: Sun, 2 Jun 2019 11:31:04 +0100 Subject: [PATCH] Added basic search functionality to each repository pane. --- .gitignore | 6 ++- .../fleet/dockerhub/model/DockerHubV2Tag.java | 14 +++++- .../linuxserver/fleet/model/DockerHubTag.java | 44 +++++++++++++++++++ src/main/resources/assets/css/fleet.css | 6 +++ src/main/resources/assets/js/fleet.js | 33 ++++++++++++++ .../spark/template/freemarker/base.ftl | 1 + .../spark/template/freemarker/home.ftl | 22 +++++----- 7 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 src/main/java/io/linuxserver/fleet/model/DockerHubTag.java diff --git a/.gitignore b/.gitignore index d82baf6..55c4764 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ \ No newline at end of file +.gradle/ + +.classpath +.project +.settings/ \ No newline at end of file diff --git a/src/main/java/io/linuxserver/fleet/dockerhub/model/DockerHubV2Tag.java b/src/main/java/io/linuxserver/fleet/dockerhub/model/DockerHubV2Tag.java index 5e8dd28..d25c750 100644 --- a/src/main/java/io/linuxserver/fleet/dockerhub/model/DockerHubV2Tag.java +++ b/src/main/java/io/linuxserver/fleet/dockerhub/model/DockerHubV2Tag.java @@ -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; } } diff --git a/src/main/java/io/linuxserver/fleet/model/DockerHubTag.java b/src/main/java/io/linuxserver/fleet/model/DockerHubTag.java new file mode 100644 index 0000000..fff1a6c --- /dev/null +++ b/src/main/java/io/linuxserver/fleet/model/DockerHubTag.java @@ -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 . + */ + +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; + } +} diff --git a/src/main/resources/assets/css/fleet.css b/src/main/resources/assets/css/fleet.css index bab428c..3229020 100644 --- a/src/main/resources/assets/css/fleet.css +++ b/src/main/resources/assets/css/fleet.css @@ -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; diff --git a/src/main/resources/assets/js/fleet.js b/src/main/resources/assets/js/fleet.js index 94e738f..0fe2882 100644 --- a/src/main/resources/assets/js/fleet.js +++ b/src/main/resources/assets/js/fleet.js @@ -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) { diff --git a/src/main/resources/spark/template/freemarker/base.ftl b/src/main/resources/spark/template/freemarker/base.ftl index bbc95b4..ac9cf55 100644 --- a/src/main/resources/spark/template/freemarker/base.ftl +++ b/src/main/resources/spark/template/freemarker/base.ftl @@ -81,6 +81,7 @@ <#if context="home"> imageListManager.init(); + imageSearchManager.init(); <#if context="setup" || context="login"> diff --git a/src/main/resources/spark/template/freemarker/home.ftl b/src/main/resources/spark/template/freemarker/home.ftl index 33ad929..8573817 100644 --- a/src/main/resources/spark/template/freemarker/home.ftl +++ b/src/main/resources/spark/template/freemarker/home.ftl @@ -24,15 +24,7 @@
- <#if populatedRepository.everyImageStable> -
-
-
- No issues reported -
-
-
- <#else> + <#if !populatedRepository.everyImageStable>
@@ -44,9 +36,17 @@ <#if populatedRepository.images?size > 0>
+
+
+
+ +
+ +
+
-
+
@@ -64,7 +64,7 @@ <#if !image.hidden || __AUTHENTICATED_USER?has_content>
- ${populatedRepository.repository.name} / ${image.name} + ${populatedRepository.repository.name} / ${image.name} <#if image.deprecated>