Optimize routing and code format

This commit is contained in:
Lennart Blom 2018-12-01 20:49:59 +01:00
parent 5bb7dfce7d
commit cf883cbfc7
2 changed files with 108 additions and 106 deletions

View file

@ -15,15 +15,15 @@ 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<tag-history-button> <tag-history-button>
<a href="#" title="This will show the history of given tag" onclick="registryUI.taghistory.go('{ opts.image.name }', '{ opts.image.tag }');"> <a href="#" title="This will show the history of given tag"
<i class="material-icons">history</i> onclick="registryUI.taghistory.go('{ opts.image.name }', '{ opts.image.tag }');">
</a> <i class="material-icons">history</i>
</a>
<script type="text/javascript"> <script type="text/javascript">
registryUI.taghistory.instance = this; registryUI.taghistory.go = function (image, tag) {
registryUI.taghistory.go = function (image, tag) { route('/taghistory/image/' + image + '/tag/' + tag);
route('taglist/joxit/docker-registry-ui'); };
}; </script>
</script>
</tag-history-button> </tag-history-button>

View file

@ -15,117 +15,119 @@ 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/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
--> -->
<tag-history> <tag-history>
<material-card ref="tag-history-tag" class="tag-history"> <material-card ref="tag-history-tag" class="tag-history">
<div class="material-card-title-action"> <div class="material-card-title-action">
<a href="#!taglist/{registryUI.taghistory.image}" onclick="registryUI.home();"> <a href="#!taglist/{registryUI.taghistory.image}" onclick="registryUI.home();">
<i class="material-icons">arrow_back</i> <i class="material-icons">arrow_back</i>
</a> </a>
<h2>History of Image Tag | { registryUI.taghistory.image }:{ registryUI.taghistory.tag } <i class="material-icons">history</i> </h2> <h2>
</div> History of Image Tag |
<div hide="{ registryUI.taghistory.loadend }" class="spinner-wrapper"> { registryUI.taghistory.image }:{ registryUI.taghistory.tag } <i class="material-icons">history</i>
<material-spinner></material-spinner> </h2>
</div>
<div hide="{ registryUI.taghistory.loadend }" class="spinner-wrapper">
<material-spinner></material-spinner>
</div>
<div show="{ registryUI.taghistory.loadend }">
<material-card each="{ guiElement in registryUI.taghistory.elements }" class="tag-history-element">
<div each="{ entry in guiElement }" class="{ entry.key }">
<div class="headline"><i class="material-icons"></i>
<p>{ entry.key }</p></div>
<div class="value"> { entry.value }</div>
</div> </div>
<div show="{ registryUI.taghistory.loadend }"> </material-card>
</div>
<material-card each="{ guiElement in registryUI.taghistory.elements }" class="tag-history-element"> </material-card>
<div each="{ entry in guiElement }" class="{ entry.key }">
<div class="headline"><i class="material-icons"></i> <p>{ entry.key }</p></div>
<div class="value"> { entry.value } </div>
</div>
</material-card> <script type="text/javascript">
</div> console.log("taghistory script area");
</material-card> registryUI.taghistory.instance = this;
registryUI.taghistory.display = function () {
var oReq = new Http();
registryUI.taghistory.instance.update();
oReq.addEventListener('load', function () {
console.log("taghistory addEventListener::load");
registryUI.taghistory.elements = [];
<script type="text/javascript"> function modifySpecificAttributeTypes(value) {
console.log("taghistory script area"); if (attribute == "created") {
let date = new Date(value);
let year = date.getFullYear();
let month = date.getMonth();
let day = date.getDay();
let minutes = date.getMinutes();
let hours = date.getUTCHours();
let seconds = date.getSeconds();
let milliSeconds = date.getMilliseconds();
if (month < 10) {
month = '0' + month;
}
if (minutes < 10) {
minutes = '0' + minutes;
}
if (hours < 10) {
hours = '0' + hours;
}
registryUI.taghistory.instance = this; value = day + "." + month + "." + year + " | " + hours + ":" + minutes + ":" + seconds + "." + milliSeconds;
registryUI.taghistory.display = function () { } else if (attribute == "container_config" || attribute == "config") {
var oReq = new Http(); value = "";
registryUI.taghistory.instance.update(); }
oReq.addEventListener('load', function () { return value;
console.log("taghistory addEventListener::load"); }
registryUI.taghistory.elements = [];
function modifySpecificAttributeTypes(value) { if (this.status == 200) {
if (attribute == "created") { var elements = JSON.parse(this.responseText).history || [];
let date = new Date(value); for (var index in elements) {
let year = date.getFullYear(); var parsedNestedElements = JSON.parse(elements[index].v1Compatibility || {});
let month = date.getMonth();
let day = date.getDay();
let minutes = date.getMinutes();
let hours = date.getUTCHours();
let seconds = date.getSeconds();
let milliSeconds = date.getMilliseconds();
if (month < 10) { var guiElements = [];
month = '0' + month; var guiElement = {};
}
if (minutes < 10) { for (var attribute in parsedNestedElements) {
minutes = '0' + minutes; if (parsedNestedElements.hasOwnProperty(attribute)) {
} var value = parsedNestedElements[attribute];
if (hours < 10) {
hours = '0' + hours;
}
value = day + "." + month + "." + year+ " | " + hours + ":" + minutes + ":" + seconds + "." + milliSeconds; value = modifySpecificAttributeTypes(value);
} else if (attribute == "container_config" || attribute == "config") { guiElement = {
value = ""; "key": attribute,
} "value": value
return value; };
} guiElements.push(guiElement);
}
if (this.status == 200) { }
var elements = JSON.parse(this.responseText).history || [];
for(var index in elements){
var parsedNestedElements = JSON.parse(elements[index].v1Compatibility || {});
var guiElements = []; registryUI.taghistory.elements.push(guiElements);
var guiElement = {}; }
} else if (this.status == 404) {
for(var attribute in parsedNestedElements){ registryUI.snackbar('Manifest could not be fetched', true);
if(parsedNestedElements.hasOwnProperty(attribute)){ } else {
var value = parsedNestedElements[attribute]; registryUI.snackbar(this.responseText);
}
value = modifySpecificAttributeTypes(value); });
guiElement = { oReq.addEventListener('error', function () {
"key": attribute, registryUI.snackbar(this.getErrorMessage(), true);
"value": value registryUI.taghistory.elements = [];
}; });
guiElements.push(guiElement); oReq.addEventListener('loadend', function () {
} registryUI.taghistory.loadend = true;
}
registryUI.taghistory.elements.push(guiElements);
}
} else if (this.status == 404) {
registryUI.snackbar('Manifest could not be fetched', true);
} else {
registryUI.snackbar(this.responseText);
}
});
oReq.addEventListener('error', function () {
registryUI.snackbar(this.getErrorMessage(), true);
registryUI.taghistory.elements = [];
});
oReq.addEventListener('loadend', function () {
registryUI.taghistory.loadend = true;
registryUI.taghistory.instance.update();
});
console.log("Trying to create GET call with image='" + registryUI.taghistory.image + "' and tag='" + registryUI.taghistory.tag + "'")
oReq.open('GET', registryUI.url() + '/v2/' + registryUI.taghistory.image + '/manifests/' + registryUI.taghistory.tag);
oReq.send();
};
registryUI.taghistory.display();
registryUI.taghistory.instance.update(); registryUI.taghistory.instance.update();
</script> });
console.log("Trying to create GET call with image='" + registryUI.taghistory.image + "' and tag='" + registryUI.taghistory.tag + "'")
oReq.open('GET', registryUI.url() + '/v2/' + registryUI.taghistory.image + '/manifests/' + registryUI.taghistory.tag);
oReq.send();
};
registryUI.taghistory.display();
registryUI.taghistory.instance.update();
</script>
</tag-history> </tag-history>