2016-05-05 12:35:52 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.repository')
|
|
|
|
.directive('popupDetails', popupDetails);
|
|
|
|
|
|
|
|
PopupDetailsController.$inject = ['ListManifestService', '$filter', 'dateLFilter'];
|
|
|
|
|
|
|
|
function PopupDetailsController(ListManifestService, $filter, dateLFilter) {
|
|
|
|
var vm = this;
|
2016-05-24 04:53:52 +02:00
|
|
|
|
2016-05-05 12:35:52 +02:00
|
|
|
vm.retrieve = retrieve;
|
2016-05-24 04:53:52 +02:00
|
|
|
|
2016-05-05 12:35:52 +02:00
|
|
|
function retrieve() {
|
|
|
|
ListManifestService(vm.repoName, vm.tag)
|
|
|
|
.success(getManifestSuccess)
|
|
|
|
.error(getManifestFailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getManifestSuccess(data, status) {
|
|
|
|
console.log('Successful get manifest:' + data);
|
|
|
|
vm.manifest = data;
|
|
|
|
vm.manifest['Created'] = $filter('dateL')(vm.manifest['Created'], 'YYYY-MM-DD HH:mm:ss');
|
|
|
|
}
|
|
|
|
|
|
|
|
function getManifestFailed(data, status) {
|
|
|
|
console.log('Failed get manifest:' + data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function popupDetails() {
|
|
|
|
var directive = {
|
|
|
|
'restrict': 'E',
|
|
|
|
'templateUrl': '/static/ng/resources/js/components/repository/popup-details.directive.html',
|
|
|
|
'scope': {
|
|
|
|
'repoName': '@',
|
2016-05-24 04:53:52 +02:00
|
|
|
'tag': '@',
|
|
|
|
'index': '@'
|
2016-05-05 12:35:52 +02:00
|
|
|
},
|
2016-05-24 07:50:09 +02:00
|
|
|
'replace': true,
|
2016-05-05 12:35:52 +02:00
|
|
|
'link': link,
|
|
|
|
'controller': PopupDetailsController,
|
|
|
|
'controllerAs': 'vm',
|
|
|
|
'bindToController': true
|
|
|
|
};
|
|
|
|
return directive;
|
|
|
|
|
|
|
|
function link(scope, element, attrs, ctrl) {
|
|
|
|
ctrl.retrieve();
|
2016-05-24 04:53:52 +02:00
|
|
|
scope.$watch('vm.manifest', function(current) {
|
2016-05-05 12:35:52 +02:00
|
|
|
if(current) {
|
2016-05-24 07:50:09 +02:00
|
|
|
|
2016-05-24 04:53:52 +02:00
|
|
|
element
|
|
|
|
.popover({
|
|
|
|
'template': '<div class="popover" role="tooltip"><div class="arrow"></div><div class="popover-title"></div><div class="popover-content"></div></div>',
|
|
|
|
'title': '<div class="pull-right clearfix"><a href="javascript:void(0);"><span class="glyphicon glyphicon-remove-circle"></span></a></div>',
|
|
|
|
'content': generateContent,
|
|
|
|
'html': true
|
|
|
|
})
|
2016-05-24 07:50:09 +02:00
|
|
|
.on('shown.bs.popover', function(e){
|
|
|
|
var self = jQuery(this);
|
|
|
|
$('[type="text"]:input', self.parent())
|
2016-05-24 04:53:52 +02:00
|
|
|
.select()
|
|
|
|
.end()
|
|
|
|
.on('click', function() {
|
|
|
|
$(this).select();
|
|
|
|
});
|
2016-05-24 07:50:09 +02:00
|
|
|
self.parent().find('.glyphicon.glyphicon-remove-circle').on('click', function() {
|
|
|
|
element.trigger('click');
|
2016-05-24 04:53:52 +02:00
|
|
|
});
|
|
|
|
});
|
2016-05-05 12:35:52 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
function generateContent() {
|
2016-05-24 04:53:52 +02:00
|
|
|
var content = '<form class="form-horizontal">' +
|
2016-05-05 12:35:52 +02:00
|
|
|
'<div class="form-group">' +
|
|
|
|
'<label class="col-sm-3 control-label">Id</label>' +
|
2016-05-24 04:53:52 +02:00
|
|
|
'<div class="col-sm-9"><p class="form-control-static long-line"><input type="text" id="txtImageId" value="' + ctrl.manifest['Id'] + '" readonly size="40"></p></div></div>' +
|
2016-05-05 12:35:52 +02:00
|
|
|
'<div class="form-group"><label class="col-sm-3 control-label">Parent</label>' +
|
|
|
|
'<div class="col-sm-9"><p class="form-control-static long-line">' + ctrl.manifest['Parent'] + '</p></div></div>' +
|
|
|
|
'<div class="form-group"><label class="col-sm-3 control-label">Created</label>' +
|
|
|
|
'<div class="col-sm-9"><p class="form-control-static">' + ctrl.manifest['Created'] + '</p></div></div>' +
|
|
|
|
'<div class="form-group"><label class="col-sm-3 control-label">Duration Days</label>' +
|
2016-05-23 12:29:17 +02:00
|
|
|
'<div class="col-sm-9"><p class="form-control-static">' + (ctrl.manifest['Duration Days'] === '' ? 'N/A' : ctrl.manifest['Duration Days']) + ' days</p></div></div>' +
|
2016-05-05 12:35:52 +02:00
|
|
|
'<div class="form-group"><label class="col-sm-3 control-label">Author</label>' +
|
2016-05-23 12:29:17 +02:00
|
|
|
'<div class="col-sm-9"><p class="form-control-static">' + (ctrl.manifest['Author'] === '' ? 'N/A' : ctrl.manifest['Author']) + '</p></div></div>' +
|
2016-05-05 12:35:52 +02:00
|
|
|
'<div class="form-group"><label class="col-sm-3 control-label">Architecture</label>' +
|
2016-05-23 12:29:17 +02:00
|
|
|
'<div class="col-sm-9"><p class="form-control-static">' + (ctrl.manifest['Architecture'] === '' ? 'N/A' : ctrl.manifest['Architecture']) + '</p></div></div>' +
|
2016-05-05 12:35:52 +02:00
|
|
|
'<div class="form-group"><label class="col-sm-3 control-label">Docker Version</label>' +
|
2016-05-23 12:29:17 +02:00
|
|
|
'<div class="col-sm-9"><p class="form-control-static">' + (ctrl.manifest['Docker Version'] === '' ? 'N/A' : ctrl.manifest['Docker Version']) + '</p></div></div>' +
|
2016-05-05 12:35:52 +02:00
|
|
|
'<div class="form-group"><label class="col-sm-3 control-label">OS</label>' +
|
2016-05-23 12:29:17 +02:00
|
|
|
'<div class="col-sm-9"><p class="form-control-static">' + (ctrl.manifest['OS'] === '' ? 'N/A' : ctrl.manifest['OS']) + '</p></div></div>' +
|
2016-05-05 12:35:52 +02:00
|
|
|
'</form>';
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|