mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-30 22:24:14 +01:00
79 lines
2.0 KiB
JavaScript
79 lines
2.0 KiB
JavaScript
(function() {
|
|
|
|
'use strict';
|
|
|
|
angular
|
|
.module('harbor.system.management')
|
|
.directive('destination', destination);
|
|
|
|
DestinationController.$inject = ['$scope', 'ListDestinationService', 'DeleteDestinationService'];
|
|
|
|
function DestinationController($scope, ListDestinationService, DeleteDestinationService) {
|
|
var vm = this;
|
|
|
|
vm.retrieve = retrieve;
|
|
vm.search = search;
|
|
vm.addDestination = addDestination;
|
|
vm.editDestination = editDestination;
|
|
vm.deleteDestination = deleteDestination;
|
|
|
|
vm.retrieve();
|
|
|
|
function retrieve() {
|
|
ListDestinationService('', vm.destinationName)
|
|
.success(listDestinationSuccess)
|
|
.error(listDestinationFailed);
|
|
}
|
|
|
|
function search() {
|
|
vm.retrieve();
|
|
}
|
|
|
|
function addDestination() {
|
|
vm.action = 'ADD_NEW';
|
|
console.log('Action for destination:' + vm.action);
|
|
}
|
|
|
|
function editDestination(targetId) {
|
|
vm.action = 'EDIT';
|
|
vm.targetId = targetId;
|
|
console.log('Action for destination:' + vm.action + ', target ID:' + vm.targetId);
|
|
}
|
|
|
|
function deleteDestination(targetId) {
|
|
DeleteDestinationService(targetId)
|
|
.success(deleteDestinationSuccess)
|
|
.error(deleteDestinationFailed);
|
|
}
|
|
|
|
function listDestinationSuccess(data, status) {
|
|
vm.destinations = data;
|
|
}
|
|
|
|
function listDestinationFailed(data, status) {
|
|
console.log('Failed list destination:' + data);
|
|
}
|
|
|
|
function deleteDestinationSuccess(data, status) {
|
|
console.log('Successful delete destination.');
|
|
vm.retrieve();
|
|
}
|
|
|
|
function deleteDestinationFailed(data, status) {
|
|
console.log('Failed delete destination.');
|
|
}
|
|
}
|
|
|
|
function destination() {
|
|
var directive = {
|
|
'restrict': 'E',
|
|
'templateUrl': '/static/resources/js/components/system-management/destination.directive.html',
|
|
'scope': true,
|
|
'controller': DestinationController,
|
|
'controllerAs': 'vm',
|
|
'bindToController': true
|
|
};
|
|
return directive;
|
|
}
|
|
|
|
})(); |