This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/static/js/services/image-metadata-service.js
Joseph Schorr 1d60414a23 Cleanup display of image commands to be better shared
Also moves the work into a TS component
2017-06-23 14:53:02 -04:00

31 lines
No EOL
704 B
JavaScript

/**
* Helper service for returning information extracted from repository image metadata.
*/
angular.module('quay').factory('ImageMetadataService', [function() {
var metadataService = {};
metadataService.getImageCommand = function(image, imageId) {
if (!image) {
return null;
}
if (!image.__imageMap) {
image.__imageMap = {};
image.__imageMap[image.id] = image;
for (var i = 0; i < image.history.length; ++i) {
var cimage = image.history[i];
image.__imageMap[cimage.id] = cimage;
}
}
var found = image.__imageMap[imageId];
if (!found) {
return null;
}
return found.command;
};
return metadataService;
}]);