@@ -16,11 +16,10 @@
Name |
Description |
- Destination |
+ Destination |
Start Time |
- Status |
Activation |
- Actions |
+ Actions |
@@ -30,10 +29,21 @@
//r.name// |
//r.description// |
//r.destination// |
- //r.start_time// |
- //r.status// |
- //r.activation// |
- |
+ //r.start_time | dateL : 'YYYY-MM-DD HH:mm:ss'// |
+
+ Enabled
+ Disabled
+ |
+
+
+
+
+
+
+ |
diff --git a/static/ng/resources/js/components/replication/list-replication.directive.js b/static/ng/resources/js/components/replication/list-replication.directive.js
index 6afe0a3d7..252b35c51 100644
--- a/static/ng/resources/js/components/replication/list-replication.directive.js
+++ b/static/ng/resources/js/components/replication/list-replication.directive.js
@@ -6,22 +6,26 @@
.module('harbor.replication')
.directive('listReplication', listReplication);
- ListReplicationController.$inject = ['getParameterByName', '$location', 'ListReplicationPolicyService', 'ListReplicationJobService'];
+ ListReplicationController.$inject = ['getParameterByName', '$location', 'ListReplicationPolicyService', 'ToggleReplicationPolicyService', 'ListReplicationJobService'];
- function ListReplicationController(getParameterByName, $location, ListReplicationPolicyService, ListReplicationJobService) {
+ function ListReplicationController(getParameterByName, $location, ListReplicationPolicyService, ToggleReplicationPolicyService, ListReplicationJobService) {
var vm = this;
vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.addReplication = addReplication;
+ vm.editReplication = editReplication;
+
vm.retrievePolicy = retrievePolicy;
vm.retrieveJob = retrieveJob;
- vm.last = false;
+ vm.togglePolicy = togglePolicy;
+ vm.last = false;
vm.retrievePolicy();
+
function retrievePolicy() {
- ListReplicationPolicyService(vm.projectId, vm.replicationName)
+ ListReplicationPolicyService('', vm.projectId, vm.replicationName)
.success(listReplicationPolicySuccess)
.error(listReplicationPolicyFailed);
}
@@ -50,8 +54,30 @@
function addReplication() {
vm.modalTitle = 'Create New Policy';
+ vm.action = 'ADD_NEW';
}
+ function editReplication(policyId) {
+ vm.policyId = policyId;
+ vm.modalTitle = 'Edit Policy';
+ vm.action = 'EDIT';
+ console.log('Selected policy ID:' + vm.policyId);
+ }
+
+ function togglePolicy(policyId, enabled) {
+ ToggleReplicationPolicyService(policyId, enabled)
+ .success(toggleReplicationPolicySuccess)
+ .error(toggleReplicationPolicyFailed);
+ }
+
+ function toggleReplicationPolicySuccess(data, status) {
+ console.log('Successful toggle replication policy.');
+ vm.retrievePolicy();
+ }
+
+ function toggleReplicationPolicyFailed(data, status) {
+ console.log('Failed toggle replication policy.');
+ }
}
function listReplication($timeout) {
@@ -93,25 +119,37 @@
$(document).off('mousedown');
$(document).off('mousemove');
}
+
+ ctrl.lastPolicyId = -1;
scope.$watch('vm.replicationPolicies', function(current) {
$timeout(function(){
if(current && current.length > 0) {
element.find('#upon-pane table>tbody>tr').on('click', trClickHandler);
- element.find('#upon-pane table>tbody>tr:eq(0)').trigger('click');
+ if(ctrl.lastPolicyId === -1) {
+ element.find('#upon-pane table>tbody>tr:eq(0)').trigger('click');
+ }else{
+ element.find('#upon-pane table>tbody>tr').filter('[policy_id="' + ctrl.lastPolicyId + '"]').trigger('click');
+ }
}
});
});
-
+
function trClickHandler(e) {
element
.find('#upon-pane table>tbody>tr')
.css({'background-color': '#FFFFFF'})
.css({'color': '#000'});
+ element
+ .find('#upon-pane table>tbody>tr a')
+ .css({'color': '#337ab7'});
$(this)
.css({'background-color': '#057ac9'})
.css({'color': '#fff'});
+ $('a', this)
+ .css({'color': '#fff'});
ctrl.retrieveJob($(this).attr('policy_id'));
+ ctrl.lastPolicyId = $(this).attr('policy_id');
}
}
}
diff --git a/static/ng/resources/js/components/system-management/destination.directive.js b/static/ng/resources/js/components/system-management/destination.directive.js
index 8e93d63d6..02d5ccc2a 100644
--- a/static/ng/resources/js/components/system-management/destination.directive.js
+++ b/static/ng/resources/js/components/system-management/destination.directive.js
@@ -16,7 +16,7 @@
vm.retrieve();
function retrieve() {
- ListDestinationService()
+ ListDestinationService('')
.success(listDestinationSuccess)
.error(listDestinationFailed);
}
diff --git a/static/ng/resources/js/layout/navigation/navigation-details.directive.js b/static/ng/resources/js/layout/navigation/navigation-details.directive.js
index f9cd4fa64..2bb0ee2c2 100644
--- a/static/ng/resources/js/layout/navigation/navigation-details.directive.js
+++ b/static/ng/resources/js/layout/navigation/navigation-details.directive.js
@@ -49,6 +49,7 @@
element.find('a:first').addClass('active');
}
+ ctrl.target = visited;
element.find('a').on('click', click);
function click(event) {
diff --git a/static/ng/resources/js/services/destination/services.list-destination.js b/static/ng/resources/js/services/destination/services.list-destination.js
index bdc2925b1..836d11069 100644
--- a/static/ng/resources/js/services/destination/services.list-destination.js
+++ b/static/ng/resources/js/services/destination/services.list-destination.js
@@ -10,9 +10,9 @@
function ListDestinationService($http) {
return listDestination;
- function listDestination(name) {
+ function listDestination(targetId, name) {
return $http
- .get('/api/targets', {
+ .get('/api/targets/' + targetId, {
'params': {
'name': name
}
diff --git a/static/ng/resources/js/services/destination/services.ping-destination.js b/static/ng/resources/js/services/destination/services.ping-destination.js
new file mode 100644
index 000000000..1fdf209fd
--- /dev/null
+++ b/static/ng/resources/js/services/destination/services.ping-destination.js
@@ -0,0 +1,30 @@
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('harbor.services.destination')
+ .factory('PingDestinationService', PingDestinationService);
+
+ PingDestinationService.$inject = ['$http'];
+
+ function PingDestinationService($http) {
+ return pingDestination;
+ function pingDestination(targetId) {
+ return $http({
+ 'method': 'POST',
+ 'url': '/api/targets/ping',
+ 'headers': {'Content-Type': 'application/x-www-form-urlencoded'},
+ 'transformRequest': function(obj) {
+ var str = [];
+ for(var p in obj) {
+ str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
+ }
+ return str.join("&");
+ },
+ 'data': {'id': targetId}
+ });
+ }
+ }
+
+})();
\ No newline at end of file
diff --git a/static/ng/resources/js/services/replication-policy/services.list-replication-policy.js b/static/ng/resources/js/services/replication-policy/services.list-replication-policy.js
index fa7061914..d1449bb2d 100644
--- a/static/ng/resources/js/services/replication-policy/services.list-replication-policy.js
+++ b/static/ng/resources/js/services/replication-policy/services.list-replication-policy.js
@@ -12,9 +12,9 @@
return listReplicationPolicy;
- function listReplicationPolicy(projectId, name) {
+ function listReplicationPolicy(policyId, projectId, name) {
return $http
- .get('/api/policies/replication', {
+ .get('/api/policies/replication/' + policyId, {
'params': {
'project_id': projectId,
'name': name
diff --git a/static/ng/resources/js/services/replication-policy/services.toggle-replication-policy.js b/static/ng/resources/js/services/replication-policy/services.toggle-replication-policy.js
new file mode 100644
index 000000000..c1bd2c931
--- /dev/null
+++ b/static/ng/resources/js/services/replication-policy/services.toggle-replication-policy.js
@@ -0,0 +1,21 @@
+(function() {
+
+ 'use strict';
+
+ angular
+ .module('harbor.services.replication.policy')
+ .factory('ToggleReplicationPolicyService', ToggleReplicationPolicyService);
+
+ ToggleReplicationPolicyService.$inject = ['$http'];
+
+ function ToggleReplicationPolicyService($http) {
+ return toggleReplicationPolicy;
+ function toggleReplicationPolicy(policyId, enabled) {
+ return $http
+ .put('/api/policies/replication/' + policyId + '/enablement', {
+ 'enabled': enabled
+ });
+ }
+ }
+
+})();
\ No newline at end of file
diff --git a/views/ng/sections/header-include.htm b/views/ng/sections/header-include.htm
index 91f0511ea..8fa2f1b34 100644
--- a/views/ng/sections/header-include.htm
+++ b/views/ng/sections/header-include.htm
@@ -138,6 +138,8 @@
+
+
@@ -145,6 +147,8 @@
+
+