Define dynamic parsing of history elements

This commit is contained in:
Lennart Blom 2018-12-01 11:03:23 +01:00
parent c857bd8db6
commit 8ab6ecbf19
3 changed files with 33 additions and 26 deletions

View file

@ -335,4 +335,9 @@ select {
.copy-to-clipboard a:hover { .copy-to-clipboard a:hover {
cursor: pointer; cursor: pointer;
}
.tag-history-element {
padding: 15px;
margin:5px;
} }

View file

@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<i class="material-icons">history</i> <i class="material-icons">history</i>
</a> </a>
<script> <script type="text/javascript">
registryUI.taghistory.instance = this; registryUI.taghistory.instance = this;
registryUI.taghistory.go = function (image, tag) { registryUI.taghistory.go = function (image, tag) {
route('taglist/joxit/docker-registry-ui'); route('taglist/joxit/docker-registry-ui');

View file

@ -23,31 +23,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<material-spinner></material-spinner> <material-spinner></material-spinner>
</div> </div>
<table show="{ registryUI.taghistory.loadend }" style="border: none;"> <div show="{ registryUI.taghistory.loadend }">
<thead>
<tr>
<th class="material-card-th-left">One</th>
<th>Two</th>
<th>Three</th>
</tr>
</thead>
<tbody>
<tr each="{ historyelement in registryUI.taghistory.elements }">
<td class="material-card-th-left">
{ historyelement.v1Compatibility }
</td>
<td class="copy-to-clipboard">
</td>
<td>
</td> <material-card each="{ guiElement in registryUI.taghistory.elements }" class="tag-history-element">
</tr> <p each="{ entry in guiElement }">
</tbody> { entry.key } { entry.value }
</table> </p>
</material-card>
</div>
</material-card> </material-card>
<script> <script type="text/javascript">
console.log("taghistory script area"); console.log("taghistory script area");
registryUI.taghistory.instance = this; registryUI.taghistory.instance = this;
@ -58,12 +46,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
console.log("taghistory addEventListener::load"); console.log("taghistory addEventListener::load");
registryUI.taghistory.elements = []; registryUI.taghistory.elements = [];
if (this.status == 200) { if (this.status == 200) {
var history = JSON.parse(this.responseText).history || []; var elements = JSON.parse(this.responseText).history || [];
for(var index in elements){
var parsedNestedElements = JSON.parse(elements[index].v1Compatibility || {});
console.log(parsedNestedElements);
for(historyElement in history){ var guiElements = [];
historyElement var guiElement = {};
for(var attribute in parsedNestedElements){
if(parsedNestedElements.hasOwnProperty(attribute)){
guiElement = {
"key": attribute,
"value": parsedNestedElements[attribute]
};
guiElements.push(guiElement);
}
}
registryUI.taghistory.elements.push(guiElements);
} }
} else if (this.status == 404) { } else if (this.status == 404) {
registryUI.snackbar('Manifest could not be fetched', true); registryUI.snackbar('Manifest could not be fetched', true);
} else { } else {