mirror of
https://github.com/Joxit/docker-registry-ui.git
synced 2025-04-28 16:09:54 +03:00
[fix-image-history] Add some query optimization
This commit is contained in:
parent
581975b99e
commit
fe2fcc1104
3 changed files with 43 additions and 32 deletions
|
@ -52,7 +52,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
route.routeName = 'home';
|
route.routeName = 'home';
|
||||||
if (registryUI.catalog.display) {
|
if (registryUI.catalog.display) {
|
||||||
registryUI.catalog.loadend = false;
|
registryUI.catalog.loadend = false;
|
||||||
registryUI.catalog.display();
|
|
||||||
}
|
}
|
||||||
registryUI.appTag.update();
|
registryUI.appTag.update();
|
||||||
});
|
});
|
||||||
|
@ -61,7 +60,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
registryUI.taglist.name = image;
|
registryUI.taglist.name = image;
|
||||||
if (registryUI.taglist.display) {
|
if (registryUI.taglist.display) {
|
||||||
registryUI.taglist.loadend = false;
|
registryUI.taglist.loadend = false;
|
||||||
registryUI.taglist.display();
|
|
||||||
}
|
}
|
||||||
registryUI.appTag.update();
|
registryUI.appTag.update();
|
||||||
});
|
});
|
||||||
|
@ -73,7 +71,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
if (registryUI.taghistory.display) {
|
if (registryUI.taghistory.display) {
|
||||||
registryUI.taghistory.loadend = false;
|
registryUI.taghistory.loadend = false;
|
||||||
registryUI.taghistory.display();
|
|
||||||
}
|
}
|
||||||
registryUI.appTag.update();
|
registryUI.appTag.update();
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,9 +15,17 @@ 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>
|
||||||
<button title="This will show the history of given tag"
|
<button ref="button" title="This will show the history of given tag">
|
||||||
onclick="registryUI.taghistory.go('{ opts.image.name }', '{ opts.image.tag }');">
|
|
||||||
<i class="material-icons">history</i>
|
<i class="material-icons">history</i>
|
||||||
</button>
|
</button>
|
||||||
|
<script>
|
||||||
|
this.on('mount', function() {
|
||||||
|
const self = this;
|
||||||
|
this.refs.button.onclick = function() {
|
||||||
|
registryUI.taghistory._image = self.opts.image;
|
||||||
|
registryUI.taghistory.go(self.opts.image.name, self.opts.image.tag);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
this.update()
|
||||||
|
</script>
|
||||||
</tag-history-button>
|
</tag-history-button>
|
|
@ -34,7 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
</material-card>
|
</material-card>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
const self = this;
|
const self = this;
|
||||||
self.eltIdx = function(e) {
|
const eltIdx = function(e) {
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case 'id': return 1;
|
case 'id': return 1;
|
||||||
case 'created': return 2;
|
case 'created': return 2;
|
||||||
|
@ -48,11 +48,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.eltSort = function(e1, e2) {
|
const eltSort = function(e1, e2) {
|
||||||
return self.eltIdx(e1.key) - self.eltIdx(e2.key);
|
return eltIdx(e1.key) - eltIdx(e2.key);
|
||||||
};
|
};
|
||||||
|
|
||||||
self.modifySpecificAttributeTypes = function(attribute, value) {
|
const modifySpecificAttributeTypes = function(attribute, value) {
|
||||||
switch (attribute) {
|
switch (attribute) {
|
||||||
case 'created':
|
case 'created':
|
||||||
return new Date(value).toLocaleString();
|
return new Date(value).toLocaleString();
|
||||||
|
@ -75,7 +75,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
return value || '';
|
return value || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
self.getConfig = function(blobs) {
|
const getConfig = function(blobs) {
|
||||||
const res = ['architecture', 'User', 'created', 'docker_version', 'os', 'Cmd', 'Entrypoint', 'Env', 'Labels', 'User', 'Volumes', 'WorkingDir', 'author', 'id', 'ExposedPorts'].reduce(function(acc, e) {
|
const res = ['architecture', 'User', 'created', 'docker_version', 'os', 'Cmd', 'Entrypoint', 'Env', 'Labels', 'User', 'Volumes', 'WorkingDir', 'author', 'id', 'ExposedPorts'].reduce(function(acc, e) {
|
||||||
const value = blobs[e] || blobs.config[e];
|
const value = blobs[e] || blobs.config[e];
|
||||||
if (value) {
|
if (value) {
|
||||||
|
@ -92,31 +92,37 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const processBlobs = function(blobs) {
|
||||||
|
function exec(elt) {
|
||||||
|
const guiElements = [];
|
||||||
|
for (const attribute in elt) {
|
||||||
|
if (elt.hasOwnProperty(attribute) && attribute != 'empty_layer') {
|
||||||
|
const value = elt[attribute];
|
||||||
|
const guiElement = {
|
||||||
|
"key": attribute,
|
||||||
|
"value": modifySpecificAttributeTypes(attribute, value)
|
||||||
|
};
|
||||||
|
guiElements.push(guiElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return guiElements.sort(eltSort);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.elements.push(exec(getConfig(blobs)));
|
||||||
|
blobs.history.reverse().forEach(function(elt) { self.elements.push(exec(elt)) });
|
||||||
|
registryUI.taghistory.loadend = true;
|
||||||
|
self.update();
|
||||||
|
};
|
||||||
|
|
||||||
registryUI.taghistory.display = function() {
|
registryUI.taghistory.display = function() {
|
||||||
self.elements = []
|
self.elements = []
|
||||||
|
const blobs = registryUI.taghistory._image && registryUI.taghistory._image.blobs;
|
||||||
|
if (blobs) {
|
||||||
|
return processBlobs(blobs)
|
||||||
|
}
|
||||||
const image = new registryUI.DockerImage(registryUI.taghistory.image, registryUI.taghistory.tag);
|
const image = new registryUI.DockerImage(registryUI.taghistory.image, registryUI.taghistory.tag);
|
||||||
image.fillInfo()
|
image.fillInfo()
|
||||||
image.on('blobs', function(blobs) {
|
image.on('blobs', processBlobs);
|
||||||
function exec(elt) {
|
|
||||||
const guiElements = [];
|
|
||||||
for (const attribute in elt) {
|
|
||||||
if (elt.hasOwnProperty(attribute) && attribute != 'empty_layer') {
|
|
||||||
const value = elt[attribute];
|
|
||||||
const guiElement = {
|
|
||||||
"key": attribute,
|
|
||||||
"value": self.modifySpecificAttributeTypes(attribute, value)
|
|
||||||
};
|
|
||||||
guiElements.push(guiElement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return guiElements.sort(self.eltSort);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.elements.push(exec(self.getConfig(blobs)));
|
|
||||||
blobs.history.reverse().forEach(function(elt) { self.elements.push(exec(elt)) });
|
|
||||||
registryUI.taghistory.loadend = true;
|
|
||||||
self.update();
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
registryUI.taghistory.display();
|
registryUI.taghistory.display();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue