mirror of
https://github.com/Joxit/docker-registry-ui.git
synced 2025-04-29 00:19:54 +03:00
[add] Add add dialog and tag for menu
This commit is contained in:
parent
b13a8ab206
commit
b3d8989d97
4 changed files with 74 additions and 3 deletions
58
add.tag
Normal file
58
add.tag
Normal file
|
@ -0,0 +1,58 @@
|
|||
<!--
|
||||
Copyright (C) 2016 Jones Magloire @Joxit
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<add>
|
||||
<dialog id="add-server-dialog" class="mdl-dialog">
|
||||
<h4 class="mdl-dialog__title">Add your Server ?</h4>
|
||||
<div class="mdl-dialog__content">
|
||||
<div class="mdl-textfield mdl-js-textfield">
|
||||
<input class="mdl-textfield__input" type="text" id="add-server-input">
|
||||
<label class="mdl-textfield__label" for="add-server-input">Server url</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mdl-dialog__actions">
|
||||
<button type="button" class="mdl-button change" onClick="registryUI.addTag.add();">Add</button>
|
||||
<button type="button" class="mdl-button close" onClick="registryUI.addTag.close();">Cancel</button>
|
||||
</div>
|
||||
</dialog> <script type="text/javascript">
|
||||
registryUI.addTag = registryUI.addTag || {};
|
||||
registryUI.addTag.update = this.update;
|
||||
this.on('updated', function () {
|
||||
componentHandler.upgradeElements(this['add-server-dialog']);
|
||||
registryUI.addTag.dialog = registryUI.addTag.dialog
|
||||
|| document.querySelector('#add-server-dialog');
|
||||
registryUI.addTag.addServer = registryUI.addTag.tileServerList
|
||||
|| registryUI.addTag.dialog.querySelector('#add-server-input');
|
||||
if (!registryUI.addTag.dialog.showModal) {
|
||||
dialogPolyfill.registerDialog(registryUI.addTag.dialog);
|
||||
}
|
||||
});
|
||||
registryUI.addTag.show = function() {
|
||||
registryUI.addTag.dialog.showModal();
|
||||
};
|
||||
registryUI.addTag.add = function() {
|
||||
if (registryUI.addTag.addServer.value && registryUI.addTag.addServer.value.length > 0) {
|
||||
registryUI.addServer(registryUI.addTag.addServer.value);
|
||||
}
|
||||
registryUI.addTag.addServer.value = '';
|
||||
registryUI.addTag.dialog.close();
|
||||
};
|
||||
registryUI.addTag.close = function() {
|
||||
registryUI.addTag.dialog.close();
|
||||
};
|
||||
registryUI.addTag.update();
|
||||
</script>
|
||||
</add>
|
|
@ -42,6 +42,7 @@
|
|||
</div>
|
||||
</main>
|
||||
<change></change>
|
||||
<add></add>
|
||||
<footer class="mdl-mini-footer">
|
||||
<div class="mdl-mini-footer__left-section">
|
||||
<div class="mdl-logo">Docker Registry UI</div>
|
||||
|
@ -54,6 +55,7 @@
|
|||
</div>
|
||||
<script src="catalog.tag" type="riot/tag"></script>
|
||||
<script src="taglist.tag" type="riot/tag"></script>
|
||||
<script src="add.tag" type="riot/tag"></script>
|
||||
<script src="change.tag" type="riot/tag"></script>
|
||||
<script src="menu.tag" type="riot/tag"></script>
|
||||
<script src="node_modules/riot/riot+compiler.min.js"></script>
|
||||
|
|
2
menu.tag
2
menu.tag
|
@ -20,7 +20,7 @@
|
|||
<i class="material-icons">more_vert</i>
|
||||
</button>
|
||||
<ul class="mdl-menu mdl-menu--bottom-right mdl-js-menu mdl-js-ripple-effect" for="registry-menu">
|
||||
<li class="mdl-menu__item">Add URL</li>
|
||||
<li class="mdl-menu__item" onclick="registryUI.addTag.show();">Add URL</li>
|
||||
<li class="mdl-menu__item" onclick="registryUI.changeTag.show();">Change URL</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
15
script.js
15
script.js
|
@ -22,10 +22,20 @@ registryUI.getRegistryServer = function (i) {
|
|||
try {
|
||||
var res = JSON.parse(localStorage.getItem('registryServer'));
|
||||
if (res instanceof Array) {
|
||||
return i ? res[i] : res;
|
||||
return (!isNaN(i)) ? res[i] : res;
|
||||
}
|
||||
} catch (e) {}
|
||||
return i ? '' : [];
|
||||
return (!isNaN(i)) ? '' : [];
|
||||
}
|
||||
registryUI.addServer = function (url) {
|
||||
var registryServer = registryUI.getRegistryServer();
|
||||
url = url.trim();
|
||||
var index = registryServer.indexOf(url);
|
||||
if (index != -1) {
|
||||
return;
|
||||
}
|
||||
registryServer.push(url);
|
||||
localStorage.setItem('registryServer', JSON.stringify(registryServer));
|
||||
}
|
||||
registryUI.changeServer = function (url) {
|
||||
var registryServer = registryUI.getRegistryServer();
|
||||
|
@ -44,5 +54,6 @@ registryUI.taglist = {};
|
|||
|
||||
riot.mount('catalog');
|
||||
riot.mount('taglist');
|
||||
riot.mount('add');
|
||||
riot.mount('change');
|
||||
riot.mount('menu');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue