2016-06-07 10:49:38 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.system.management')
|
|
|
|
.directive('replication', replication);
|
|
|
|
|
2016-07-02 12:20:31 +02:00
|
|
|
ReplicationController.$inject = ['$scope', 'ListReplicationPolicyService', 'ToggleReplicationPolicyService', '$filter', 'trFilter'];
|
2016-06-07 10:49:38 +02:00
|
|
|
|
2016-07-02 12:20:31 +02:00
|
|
|
function ReplicationController($scope, ListReplicationPolicyService, ToggleReplicationPolicyService, $filter, trFilter) {
|
2016-06-26 06:56:58 +02:00
|
|
|
|
|
|
|
$scope.subsSubPane = 276;
|
|
|
|
|
2016-06-07 10:49:38 +02:00
|
|
|
var vm = this;
|
2016-06-15 11:46:23 +02:00
|
|
|
vm.retrieve = retrieve;
|
|
|
|
vm.search = search;
|
|
|
|
vm.togglePolicy = togglePolicy;
|
|
|
|
vm.editReplication = editReplication;
|
|
|
|
vm.retrieve();
|
|
|
|
|
|
|
|
function search() {
|
|
|
|
vm.retrieve();
|
|
|
|
}
|
|
|
|
|
|
|
|
function retrieve() {
|
|
|
|
ListReplicationPolicyService('', '', vm.replicationName)
|
|
|
|
.success(listReplicationPolicySuccess)
|
|
|
|
.error(listReplicationPolicyFailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
function listReplicationPolicySuccess(data, status) {
|
|
|
|
vm.replications = data || [];
|
|
|
|
}
|
|
|
|
|
|
|
|
function listReplicationPolicyFailed(data, status) {
|
2016-07-02 12:20:31 +02:00
|
|
|
$scope.$emit('modalTitle', $filter('tr')('error'));
|
2016-07-04 06:34:34 +02:00
|
|
|
$scope.$emit('modalMessage', $filter('tr')('failed_to_list_replication'));
|
2016-07-02 12:20:31 +02:00
|
|
|
$scope.$emit('raiseError', true);
|
2016-07-04 06:34:34 +02:00
|
|
|
console.log('Failed to list replication policy.');
|
2016-06-15 11:46:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function togglePolicy(policyId, enabled) {
|
|
|
|
ToggleReplicationPolicyService(policyId, enabled)
|
|
|
|
.success(toggleReplicationPolicySuccess)
|
|
|
|
.error(toggleReplicationPolicyFailed);
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleReplicationPolicySuccess(data, status) {
|
|
|
|
console.log('Successful toggle replication policy.');
|
|
|
|
vm.retrieve();
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleReplicationPolicyFailed(data, status) {
|
2016-07-02 12:20:31 +02:00
|
|
|
$scope.$emit('modalTitle', $filter('tr')('error'));
|
2016-07-04 06:34:34 +02:00
|
|
|
$scope.$emit('modalMessage', $filter('tr')('failed_to_toggle_policy'));
|
2016-07-02 12:20:31 +02:00
|
|
|
$scope.$emit('raiseError', true);
|
2016-07-04 06:34:34 +02:00
|
|
|
console.log('Failed to toggle replication policy.');
|
2016-06-15 11:46:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function editReplication(policyId) {
|
|
|
|
vm.action = 'EDIT';
|
|
|
|
vm.policyId = policyId;
|
|
|
|
}
|
2016-06-07 10:49:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function replication() {
|
|
|
|
var directive = {
|
|
|
|
'restrict': 'E',
|
2016-06-16 08:10:35 +02:00
|
|
|
'templateUrl': '/static/resources/js/components/system-management/replication.directive.html',
|
2016-06-07 10:49:38 +02:00
|
|
|
'scope': true,
|
|
|
|
'controller': ReplicationController,
|
|
|
|
'controllerAs': 'vm',
|
|
|
|
'bindToController': true
|
|
|
|
};
|
|
|
|
return directive;
|
|
|
|
}
|
|
|
|
|
|
|
|
})();
|