feat: merge static version with latest and add license

BREAKING CHANGE: Now only one tag will be published: `latest`. This tag will include both the standard and latest version
This commit is contained in:
Joxit
2021-03-31 07:10:50 +02:00
parent 7d095916db
commit 1173453f72
24 changed files with 151 additions and 288 deletions

View File

@@ -18,7 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<header>
<material-navbar>
<div class="logo">Docker Registry UI</div>
<dialogs-menu on-notify="{ notifySnackbar }" on-server-change="{ onServerChange }"></dialogs-menu>
<dialogs-menu if="{props.singleRegistry !== 'true'}" on-notify="{ notifySnackbar }"
on-server-change="{ onServerChange }"></dialogs-menu>
</material-navbar>
</header>
<main>
@@ -66,7 +67,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import TagHistory from './tag-history/tag-history.riot';
import DialogsMenu from './dialogs/dialogs-menu.riot';
import {
stripHttps
stripHttps,
getRegistryServers
} from '../scripts/utils';
import router from '../scripts/router';
@@ -84,8 +86,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
state.snackbarMessage = undefined;
},
onBeforeMount(props) {
this.state.registryUrl = props.registryUrl || (window.location.origin + window.location.pathname.replace(/\/+$/,
''));
// props.singleRegistry === 'true' means old static version
this.state.registryUrl = props.registryUrl ||
(props.singleRegistry === 'true' ? undefined : (router.getUrlQueryParam() || getRegistryServers(0))) ||
(window.location.origin + window.location.pathname.replace(/\/+$/, ''));
this.state.name = props.name || stripHttps(props.registryUrl);
this.state.catalogElementsLimit = props.catalogElementsLimit || 100000;
this.state.pullUrl = this.pullUrl(this.state.registryUrl, props.pullUrl);

View File

@@ -34,57 +34,17 @@
</head>
<body>
<script>
const URL_QUERY_PARAM_REGEX = /[&?]url=/;
const URL_PARAM_REGEX = /^url=/;
function getUrlQueryParam() {
const search = window.location.search;
if (URL_QUERY_PARAM_REGEX.test(search)) {
const param = search.split(/^\?|&/).find(function (param) {
return param && URL_PARAM_REGEX.test(param);
});
return param ? param.replace(URL_PARAM_REGEX, '') : param;
}
}
function getRegistryServer(i) {
try {
const res = JSON.parse(localStorage.getItem('registryServer'));
if (res instanceof Array) {
return (!isNaN(i)) ? res[i] : res.map(function (url) {
return url.trim().replace(/\/*$/, '');
});
}
} catch (e) {}
return (!isNaN(i)) ? '' : [];
}
function rDecodeURI(url) {
if (!url) {
return;
}
return url.startsWith('http') ? window.decodeURIComponent(url) : atob(url);
}
function getRegistryURL() {
let url = getUrlQueryParam();
if (url) {
try {
return rDecodeURI(url);
} catch (e) {
console.log(e);
}
}
return getRegistryServer(0);
}
const tag = document.createElement('docker-registry-ui');
tag.setAttribute('registry-url', getRegistryURL());
tag.setAttribute('show-content-digest', true);
tag.setAttribute('is-image-remove-activated', true);
document.getElementsByTagName('body').item(0).appendChild(tag);
</script>
<!-- build:keep production -->
<docker-registry-ui registry-url="${URL}" name="${REGISTRY_TITLE}" pull-url="${PULL_URL}"
show-content-digest="${SHOW_CONTENT_DIGEST}" is-image-remove-activated="${DELETE_IMAGES}"
catalog-elements-limit="${CATALOG_ELEMENTS_LIMIT}" single-registry="${SINGLE_REGISTRY}">
</docker-registry-ui>
<!-- endbuild -->
<!-- build:keep developement -->
<docker-registry-ui registry-url="" name="Developement Registry" pull-url="" show-content-digest="true"
is-image-remove-activated="true" catalog-elements-limit="1000" single-registry="false">
</docker-registry-ui>
<!-- endbuild -->
<!-- build:js docker-registry-ui.js -->
<script src="../node_modules/riot/riot+compiler.min.js"></script>
<script src="../node_modules/riot-route/dist/route.js"></script>

View File

@@ -1,4 +1,5 @@
import { component, register } from 'riot';
import {
MaterialCard,
MaterialSpinner,
@@ -11,7 +12,7 @@ import {
MaterialSnackbar,
MaterialDropdownList,
MaterialPopup,
MaterialInput
MaterialInput,
} from 'riot-mui';
import DockerRegistryUI from './components/docker-registry-ui.riot';

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { router, getCurrentRoute } from '@riotjs/route';
import { encodeURI } from './utils';
import { encodeURI, decodeURI } from './utils';
function getQueryParams() {
const queries = {};
@@ -44,7 +44,7 @@ function updateQueryParams(qs) {
function toSearchString(queries) {
let search = [];
for (let key in queries) {
if (queries[key] !== undefined) {
if (key && queries[key] !== undefined) {
search.push(`${key}=${queries[key]}`);
}
}
@@ -83,6 +83,17 @@ export default {
updateUrlQueryParam(url) {
this.updateQueryString({ url: encodeURI(url) });
},
getUrlQueryParam() {
const queries = getQueryParams();
const url = queries['url'];
if (url) {
try {
return decodeURI(url);
} catch (e) {
console.error(`Can't decode query parameter URL: ${url}`, e);
}
}
},
updatePageQueryParam(page) {
this.updateQueryString({ page });
},