Optimize GUI elements and HTTP logic for content preperation

This commit is contained in:
Lennart Blom 2018-12-06 22:01:35 +01:00
parent c176a082d9
commit 7163150cf5
No known key found for this signature in database
GPG Key ID: F99999359018CF4D
2 changed files with 35 additions and 34 deletions

View File

@ -337,14 +337,16 @@ select {
cursor: pointer;
}
material-card.tag-history{
margin-bottom: 0;
}
.tag-history-element {
padding: 15px;
margin: 5px;
max-width: 100%;
margin-top:5px;
margin-bottom: 0;
}
.tag-history-element > div {
padding: 10px;
padding: 20px;
min-width: 100px;
}
@ -400,7 +402,7 @@ select {
background-size: 35px auto;
background-image: url("images/docker-logo.svg");
background-repeat: no-repeat;
background-position: 7px 10px;
background-position: 11px 20px;
}
.tag-history-element > div {

View File

@ -24,26 +24,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
History of { registryUI.taghistory.image }:{ registryUI.taghistory.tag } <i class="material-icons">history</i>
</h2>
</div>
<div hide="{ registryUI.taghistory.loadend }" class="spinner-wrapper">
<material-spinner></material-spinner>
<div class="material-card-title-action">
<p>Nested v1Compatibility history elements:</p>
</div>
</material-card>
<div hide="{ registryUI.taghistory.loadend }" class="spinner-wrapper">
<material-spinner></material-spinner>
</div>
<div show="{ registryUI.taghistory.loadend }">
<div class="material-card-title-action">
<p>Nested v1Compatibility history elements:</p>
</div>
<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>
</material-card>
<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>
</material-card>
<script type="text/javascript">
registryUI.taghistory.instance = this;
@ -53,32 +52,32 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
oReq.addEventListener('load', function() {
registryUI.taghistory.elements = [];
function modifySpecificAttributeTypes(value) {
if (attribute === "created") {
var date = new Date(value);
value = date.toLocaleString();
} else if (attribute === "container_config" || attribute === "config") {
value = "";
function modifySpecificAttributeTypes(attribute, value) {
switch (attribute) {
case "created":
return new Date(value).toLocaleString();
case "container_config":
case "config":
return "";
}
return value;
}
if (this.status == 200) {
let elements = JSON.parse(this.responseText).history || [];
for (var index in elements) {
let parsedNestedElements = JSON.parse(elements[index].v1Compatibility || {});
if (this.status === 200) {
const elements = JSON.parse(this.responseText).history || [];
for (const index in elements) {
const parsedNestedElements = JSON.parse(elements[index].v1Compatibility || {});
let guiElements = [];
let guiElement = {};
for (var attribute in parsedNestedElements) {
for (const attribute in parsedNestedElements) {
if (parsedNestedElements.hasOwnProperty(attribute)) {
let value = parsedNestedElements[attribute];
const value = parsedNestedElements[attribute];
value = modifySpecificAttributeTypes(value);
guiElement = {
"key": attribute,
"value": value
"value": modifySpecificAttributeTypes(attribute, value)
};
guiElements.push(guiElement);
}
@ -87,7 +86,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
registryUI.taghistory.elements.push(guiElements);
}
} else if (this.status == 404) {
} else if (this.status === 404) {
registryUI.snackbar('Manifest could not be fetched', true);
} else {
registryUI.snackbar(this.responseText);