From ba6d817b41a2131ad6dcfade04f8c47b6be597f2 Mon Sep 17 00:00:00 2001 From: Joxit Date: Wed, 23 Mar 2022 09:18:20 +0100 Subject: [PATCH] feat: expose some custom labels --- README.md | 1 + bin/entrypoint | 3 +- src/components/docker-registry-ui.riot | 8 +- .../tag-history/tag-history-element.riot | 28 ++-- src/components/tag-history/tag-history.riot | 129 ++++++++++------- src/index.html | 133 ++++++++++-------- src/scripts/utils.js | 9 +- 7 files changed, 182 insertions(+), 129 deletions(-) diff --git a/README.md b/README.md index 67a9254..6540290 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ Some env options are available for use this interface for **only one server**. - `DEFAULT_REGISTRIES`: List of comma separated registry URLs (e.g `http://registry.example.com,http://registry:5000`), available only when `SINGLE_REGISTRY=false`. (default: ` `). - `READ_ONLY_REGISTRIES`: Desactivate dialog for remove and add new registries, available only when `SINGLE_REGISTRY=false`. (default: `false`). - `SHOW_CATALOG_NB_TAGS`: Show number of tags per images on catalog page. This will produce + nb images requests, not recommended on large registries. (default: `false`). +- `HISTORY_CUSTOM_LABELS`: Expose custom labels in history page, custom labels will be processed like maintainer label. There are some examples with [docker-compose](https://docs.docker.com/compose/) and docker-registry-ui as proxy [here](https://github.com/Joxit/docker-registry-ui/tree/main/examples/ui-as-proxy/) or docker-registry-ui as standalone [here](https://github.com/Joxit/docker-registry-ui/tree/main/examples/ui-as-standalone/). diff --git a/bin/entrypoint b/bin/entrypoint index ca0b934..81a0031 100755 --- a/bin/entrypoint +++ b/bin/entrypoint @@ -9,6 +9,7 @@ sed -i "s~\${SHOW_CONTENT_DIGEST}~${SHOW_CONTENT_DIGEST}~" index.html sed -i "s~\${DEFAULT_REGISTRIES}~${DEFAULT_REGISTRIES}~" index.html sed -i "s~\${READ_ONLY_REGISTRIES}~${READ_ONLY_REGISTRIES}~" index.html sed -i "s~\${SHOW_CATALOG_NB_TAGS}~${SHOW_CATALOG_NB_TAGS}~" index.html +sed -i "s~\${HISTORY_CUSTOM_LABELS}~${HISTORY_CUSTOM_LABELS}~" index.html if [ -z "${DELETE_IMAGES}" ] || [ "${DELETE_IMAGES}" = false ] ; then sed -i "s/\${DELETE_IMAGES}/false/" index.html @@ -64,4 +65,4 @@ if [ "$(whoami)" != "root" ]; then sed -i "s,/var/run/nginx.pid,/tmp/nginx.pid," /etc/nginx/nginx.conf fi -sed -i "s,listen 80;,listen $NGINX_LISTEN_PORT;," /etc/nginx/conf.d/default.conf \ No newline at end of file +sed -i "s,listen 80;,listen $NGINX_LISTEN_PORT;," /etc/nginx/conf.d/default.conf diff --git a/src/components/docker-registry-ui.riot b/src/components/docker-registry-ui.riot index 094efed..dc2e3f4 100644 --- a/src/components/docker-registry-ui.riot +++ b/src/components/docker-registry-ui.riot @@ -42,7 +42,7 @@ along with this program. If not, see . + on-authentication="{ onAuthentication }" history-custom-labels="{ stringToArray(props.historyCustomLabels) }"> . stripHttps, getRegistryServers, setRegistryServers, - truthy + truthy, + stringToArray } from '../scripts/utils'; import router from '../scripts/router'; @@ -175,7 +176,8 @@ along with this program. If not, see . baseRoute: '([^#]*?)/(\\?[^#]*?)?(#!)?(/?)', router, version, - truthy + truthy, + stringToArray } \ No newline at end of file diff --git a/src/components/tag-history/tag-history-element.riot b/src/components/tag-history/tag-history-element.riot index f25720e..cd3050a 100644 --- a/src/components/tag-history/tag-history-element.riot +++ b/src/components/tag-history/tag-history-element.riot @@ -15,17 +15,16 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . --> -
{ state.icon } +
+ { state.icon }

{ state.name }

-
{ state.value }
-
{ value }
+
{ state.value }
+
{ value }
- \ No newline at end of file + diff --git a/src/components/tag-history/tag-history.riot b/src/components/tag-history/tag-history.riot index 2ce8c1e..1fc659f 100644 --- a/src/components/tag-history/tag-history.riot +++ b/src/components/tag-history/tag-history.riot @@ -20,33 +20,35 @@ along with this program. If not, see . arrow_back -

- History of { props.image }:{ props.tag } history -

+

History of { props.image }:{ props.tag } history

- +
- + - + - \ No newline at end of file + diff --git a/src/index.html b/src/index.html index 9a96ddb..d836429 100644 --- a/src/index.html +++ b/src/index.html @@ -16,63 +16,78 @@ --> + + + + + + + + + + + + + + Docker Registry UI + - - - - - - - - - - - - - - Docker Registry UI - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/scripts/utils.js b/src/scripts/utils.js index ac82090..cd61701 100644 --- a/src/scripts/utils.js +++ b/src/scripts/utils.js @@ -76,7 +76,10 @@ export function getHistoryIcon(attribute) { case 'ExposedPorts': return 'router'; default: - ''; + if (attribute.startsWith('custom-label-')) { + return 'label'; + } + return ''; } } @@ -201,3 +204,7 @@ export function decodeURI(url) { export function truthy(value) { return value === true || value === 'true'; } + +export function stringToArray(value) { + return value && typeof value === 'string' ? value.split(',') : []; +}