/* Copyright (c) 2016 VMware, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ (function() { 'use strict'; angular .module('harbor.repository') .directive('popupDetails', popupDetails); PopupDetailsController.$inject = ['ListManifestService', '$filter', 'dateLFilter']; function PopupDetailsController(ListManifestService, $filter, dateLFilter) { var vm = this; vm.retrieve = retrieve; 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 to get manifest:' + data); } } function popupDetails() { var directive = { 'restrict': 'E', 'templateUrl': '/static/resources/js/components/repository/popup-details.directive.html', 'scope': { 'repoName': '@', 'tag': '@', 'index': '@' }, 'replace': true, 'link': link, 'controller': PopupDetailsController, 'controllerAs': 'vm', 'bindToController': true }; return directive; function link(scope, element, attrs, ctrl) { ctrl.retrieve(); scope.$watch('vm.manifest', function(current) { if(current) { element .popover({ 'template': '', 'title': '
', 'content': generateContent, 'html': true }) .on('shown.bs.popover', function(e){ var self = jQuery(this); $('[type="text"]:input', self.parent()) .on('click', function() { $(this).select(); }); self.parent().find('.glyphicon.glyphicon-remove-circle').on('click', function() { element.trigger('click'); }); }); } }); function generateContent() { var content = '
' + '
' + '' + '

' + '
' + '

' + '
' + '

' + ctrl.manifest['Created'] + '

' + '
' + '

' + (ctrl.manifest['Duration Days'] === '' ? 'N/A' : ctrl.manifest['Duration Days']) + ' days

' + '
' + '

' + (ctrl.manifest['Author'] === '' ? 'N/A' : ctrl.manifest['Author']) + '

' + '
' + '

' + (ctrl.manifest['Architecture'] === '' ? 'N/A' : ctrl.manifest['Architecture']) + '

' + '
' + '

' + (ctrl.manifest['Docker Version'] === '' ? 'N/A' : ctrl.manifest['Docker Version']) + '

' + '
' + '

' + (ctrl.manifest['OS'] === '' ? 'N/A' : ctrl.manifest['OS']) + '

' + '
'; return content; } } } })();