2016-06-07 10:49:38 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.system.management')
|
|
|
|
.directive('destination', destination);
|
|
|
|
|
2016-06-22 13:03:12 +02:00
|
|
|
DestinationController.$inject = ['$scope', 'ListDestinationService', 'DeleteDestinationService', '$filter', 'trFilter'];
|
2016-06-07 10:49:38 +02:00
|
|
|
|
2016-06-22 13:03:12 +02:00
|
|
|
function DestinationController($scope, ListDestinationService, DeleteDestinationService, $filter, trFilter) {
|
2016-06-07 10:49:38 +02:00
|
|
|
var vm = this;
|
|
|
|
|
|
|
|
vm.retrieve = retrieve;
|
|
|
|
vm.search = search;
|
2016-06-14 12:47:32 +02:00
|
|
|
vm.addDestination = addDestination;
|
|
|
|
vm.editDestination = editDestination;
|
2016-06-20 11:05:48 +02:00
|
|
|
vm.confirmToDelete = confirmToDelete;
|
2016-06-14 12:47:32 +02:00
|
|
|
vm.deleteDestination = deleteDestination;
|
|
|
|
|
2016-06-07 10:49:38 +02:00
|
|
|
vm.retrieve();
|
|
|
|
|
|
|
|
function retrieve() {
|
2016-06-15 11:46:23 +02:00
|
|
|
ListDestinationService('', vm.destinationName)
|
2016-06-07 10:49:38 +02:00
|
|
|
.success(listDestinationSuccess)
|
|
|
|
.error(listDestinationFailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
function search() {
|
|
|
|
vm.retrieve();
|
|
|
|
}
|
|
|
|
|
2016-06-14 12:47:32 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-06-20 11:05:48 +02:00
|
|
|
function confirmToDelete(targetId) {
|
|
|
|
vm.selectedTargetId = targetId;
|
2016-06-24 12:44:54 +02:00
|
|
|
vm.modalDialogTitle = $filter('tr')('confirm_to_delete_destination_title');
|
|
|
|
vm.modalDialogMessage = $filter('tr')('confirm_to_delete_destination');
|
|
|
|
$scope.$broadcast('showDialog', true);
|
2016-06-20 11:05:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteDestination() {
|
|
|
|
DeleteDestinationService(vm.selectedTargetId)
|
2016-06-14 12:47:32 +02:00
|
|
|
.success(deleteDestinationSuccess)
|
|
|
|
.error(deleteDestinationFailed);
|
|
|
|
}
|
|
|
|
|
2016-06-07 10:49:38 +02:00
|
|
|
function listDestinationSuccess(data, status) {
|
2016-06-20 13:15:45 +02:00
|
|
|
vm.destinations = data || [];
|
2016-06-07 10:49:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function listDestinationFailed(data, status) {
|
|
|
|
console.log('Failed list destination:' + data);
|
|
|
|
}
|
|
|
|
|
2016-06-14 12:47:32 +02:00
|
|
|
function deleteDestinationSuccess(data, status) {
|
|
|
|
console.log('Successful delete destination.');
|
|
|
|
vm.retrieve();
|
|
|
|
}
|
2016-06-07 10:49:38 +02:00
|
|
|
|
2016-06-14 12:47:32 +02:00
|
|
|
function deleteDestinationFailed(data, status) {
|
|
|
|
console.log('Failed delete destination.');
|
2016-06-24 12:44:54 +02:00
|
|
|
alert($filter('tr')('failed_delete_destination', []) + data);
|
2016-06-14 12:47:32 +02:00
|
|
|
}
|
2016-06-07 10:49:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function destination() {
|
|
|
|
var directive = {
|
|
|
|
'restrict': 'E',
|
2016-06-16 08:10:35 +02:00
|
|
|
'templateUrl': '/static/resources/js/components/system-management/destination.directive.html',
|
2016-06-07 10:49:38 +02:00
|
|
|
'scope': true,
|
|
|
|
'controller': DestinationController,
|
|
|
|
'controllerAs': 'vm',
|
|
|
|
'bindToController': true
|
|
|
|
};
|
|
|
|
return directive;
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|