mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
add more restriction check on sync-image of UI.
This commit is contained in:
parent
210d2044b2
commit
32a52a42d3
@ -44,13 +44,13 @@
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="destinationName" class="col-md-3 control-label">// 'name' | tr //:</label>
|
||||
<div class="col-md-7">
|
||||
<select class="form-control form-control-custom" id="destinationName" ng-model="replication.destination.selection" ng-options="d as d.name for d in vm.destinations track by d.id" ng-click="vm.selectDestination(replication.destination.selection)"></select>
|
||||
<select class="form-control form-control-custom" id="destinationName" ng-model="replication.destination.selection" ng-options="d as d.name for d in vm.destinations track by d.id" ng-click="vm.selectDestination(replication.destination.selection)" ng-disabled="!vm.targetEditable"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="endpoint" class="col-md-3 control-label">// 'endpoint' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control form-control-custom" id="endpoint" ng-model="replication.destination.endpoint" name="uEndpoint" ng-value="vm.endpoint" required>
|
||||
<input type="text" class="form-control form-control-custom" id="endpoint" ng-model="replication.destination.endpoint" name="uEndpoint" ng-value="vm.endpoint" required ng-disabled="!vm.targetEditable">
|
||||
<div ng-messages="form.$submitted && form.uEndpoint.$error">
|
||||
<span ng-message="required">// 'endpoint_is_required' | tr //</span>
|
||||
</div>
|
||||
@ -59,7 +59,7 @@
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="username" class="col-md-3 control-label">// 'username' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" id="username" ng-model="replication.destination.username" name="uUsername" ng-value="vm.username" required>
|
||||
<input type="text" class="form-control" id="username" ng-model="replication.destination.username" name="uUsername" ng-value="vm.username" required ng-disabled="!vm.targetEditable">
|
||||
<div ng-messages="form.$submitted && form.uUsername.$error">
|
||||
<span ng-message="required">// 'username_is_required' | tr //</span>
|
||||
</div>
|
||||
@ -68,7 +68,7 @@
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="password" class="col-md-3 control-label">// 'password' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="password" class="form-control" id="password" ng-model="replication.destination.password" name="uPassword" ng-value="vm.password" required>
|
||||
<input type="password" class="form-control" id="password" ng-model="replication.destination.password" name="uPassword" ng-value="vm.password" required ng-disabled="!vm.targetEditable">
|
||||
<div ng-messages="form.$submitted && form.uPassword.$error">
|
||||
<span ng-message="required">// 'password_is_required' | tr //</span>
|
||||
</div>
|
||||
|
@ -6,9 +6,9 @@
|
||||
.module('harbor.replication')
|
||||
.directive('createPolicy', createPolicy);
|
||||
|
||||
CreatePolicyController.$inject = ['$scope', 'ListReplicationPolicyService', 'ListDestinationService', 'UpdateDestinationService', 'PingDestinationService', 'CreateReplicationPolicyService', 'UpdateReplicationPolicyService', '$location', 'getParameterByName'];
|
||||
CreatePolicyController.$inject = ['$scope', 'ListReplicationPolicyService', 'ListDestinationService', 'UpdateDestinationService', 'PingDestinationService', 'CreateReplicationPolicyService', 'UpdateReplicationPolicyService', 'ListDestinationPolicyService','$location', 'getParameterByName', '$filter', 'trFilter'];
|
||||
|
||||
function CreatePolicyController($scope, ListReplicationPolicyService, ListDestinationService, UpdateDestinationService, PingDestinationService, CreateReplicationPolicyService, UpdateReplicationPolicyService, $location, getParameterByName) {
|
||||
function CreatePolicyController($scope, ListReplicationPolicyService, ListDestinationService, UpdateDestinationService, PingDestinationService, CreateReplicationPolicyService, UpdateReplicationPolicyService, ListDestinationPolicyService, $location, getParameterByName, $filter, trFilter) {
|
||||
var vm = this;
|
||||
|
||||
//Since can not set value for textarea by using vm
|
||||
@ -33,6 +33,8 @@
|
||||
vm.create = create;
|
||||
vm.update = update;
|
||||
vm.pingDestination = pingDestination;
|
||||
|
||||
vm.targetEditable = true;
|
||||
|
||||
$scope.$watch('vm.destinations', function(current) {
|
||||
if(current) {
|
||||
@ -42,24 +44,7 @@
|
||||
vm1.password = vm1.selection.password;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$watch('vm.action+","+vm.policyId', function(current) {
|
||||
if(current) {
|
||||
console.log('Current action for replication policy:' + current);
|
||||
var parts = current.split(',');
|
||||
vm.action = parts[0];
|
||||
vm.policyId = Number(parts[1]);
|
||||
switch(parts[0]) {
|
||||
case 'ADD_NEW':
|
||||
vm.addNew();
|
||||
break;
|
||||
case 'EDIT':
|
||||
vm.edit(vm.policyId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function selectDestination(item) {
|
||||
vm1.selection = item;
|
||||
vm1.endpoint = item.endpoint;
|
||||
@ -74,6 +59,8 @@
|
||||
}
|
||||
|
||||
function addNew() {
|
||||
vm.targetEditable = true;
|
||||
$filter('tr')('add_new_policy', []);
|
||||
vm0.name = '';
|
||||
vm0.description = '';
|
||||
vm0.enabled = true;
|
||||
@ -81,6 +68,9 @@
|
||||
|
||||
function edit(policyId) {
|
||||
console.log('Edit policy ID:' + policyId);
|
||||
vm.policyId = policyId;
|
||||
vm.targetEditable = true;
|
||||
$filter('tr')('edit_policy', []);
|
||||
ListReplicationPolicyService(policyId)
|
||||
.success(listReplicationPolicySuccess)
|
||||
.error(listReplicationPolicyFailed);
|
||||
@ -129,12 +119,37 @@
|
||||
function listDestinationFailed(data, status) {
|
||||
console.log('Failed list destination:' + data);
|
||||
}
|
||||
|
||||
function listDestinationPolicySuccess(data, status) {
|
||||
vm.targetEditable = true;
|
||||
for(var i in data) {
|
||||
if(data[i].enabled === 1) {
|
||||
vm.targetEditable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
console.log('current target editable:' + vm.targetEditable + ', policy ID:' + vm.policyId);
|
||||
}
|
||||
|
||||
function listDestinationPolicyFailed(data, status) {
|
||||
console.log('Failed list destination policy:' + data);
|
||||
}
|
||||
|
||||
function listReplicationPolicySuccess(data, status) {
|
||||
console.log(data);
|
||||
var replicationPolicy = data;
|
||||
vm0.name = replicationPolicy.name;
|
||||
vm0.description = replicationPolicy.description;
|
||||
vm0.enabled = replicationPolicy.enabled == 1;
|
||||
vm.targetId = replicationPolicy.target_id;
|
||||
|
||||
if(vm0.enabled) {
|
||||
vm.targetEditable = false;
|
||||
}else{
|
||||
ListDestinationPolicyService(vm.targetId)
|
||||
.success(listDestinationPolicySuccess)
|
||||
.error(listDestinationPolicyFailed);
|
||||
}
|
||||
}
|
||||
function listReplicationPolicyFailed(data, status) {
|
||||
console.log('Failed list replication policy:' + data);
|
||||
@ -145,7 +160,7 @@
|
||||
}
|
||||
function createReplicationPolicyFailed(data, status) {
|
||||
if(status === 409) {
|
||||
alert('Policy name already exists.');
|
||||
alert($filter('tr')('policy_already_exists', []));
|
||||
}
|
||||
console.log('Failed create replication policy.');
|
||||
}
|
||||
@ -163,10 +178,10 @@
|
||||
console.log('Failed update destination.');
|
||||
}
|
||||
function pingDestinationSuccess(data, status) {
|
||||
alert('Successful ping target.');
|
||||
alert($filter('tr')('successful_ping_target', []));
|
||||
}
|
||||
function pingDestinationFailed(data, status) {
|
||||
alert('Failed ping target:' + data);
|
||||
alert($filter('tr')('failed_ping_target', []) + ':' + data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,11 +205,22 @@
|
||||
function link(scope, element, attr, ctrl) {
|
||||
|
||||
element.find('#createPolicyModal').on('show.bs.modal', function() {
|
||||
ctrl.prepareDestination();
|
||||
|
||||
scope.form.$setPristine();
|
||||
scope.form.$setUntouched();
|
||||
|
||||
ctrl.prepareDestination();
|
||||
switch(ctrl.action) {
|
||||
case 'ADD_NEW':
|
||||
ctrl.addNew();
|
||||
break;
|
||||
case 'EDIT':
|
||||
ctrl.edit(ctrl.policyId);
|
||||
break;
|
||||
}
|
||||
scope.$apply();
|
||||
});
|
||||
|
||||
|
||||
ctrl.save = save;
|
||||
|
||||
function save(form) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="name" class="col-md-3 control-label">// 'name' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control form-control-custom" id="name" ng-model="destination.name" name="uName" required>
|
||||
<input type="text" class="form-control form-control-custom" id="name" ng-model="destination.name" name="uName" required ng-disabled="!vm.editable">
|
||||
<div ng-messages="form.$submitted && form.uName.$error">
|
||||
<span ng-message="required">// 'name_is_required' | tr //</span>
|
||||
</div>
|
||||
@ -20,7 +20,7 @@
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="description" class="col-md-3 control-label">// 'endpoint' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control form-control-custom" id="endpoint" ng-model="destination.endpoint" name="uEndpoint" required >
|
||||
<input type="text" class="form-control form-control-custom" id="endpoint" ng-model="destination.endpoint" name="uEndpoint" required ng-disabled="!vm.editable">
|
||||
<div ng-messages="form.$submitted && form.uEndpoint.$error">
|
||||
<span ng-message="required">// 'endpoint_is_required' | tr //</span>
|
||||
</div>
|
||||
@ -29,7 +29,7 @@
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="username" class="col-md-3 control-label">// 'username' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" id="username" ng-model="destination.username" name="uUsername" required>
|
||||
<input type="text" class="form-control" id="username" ng-model="destination.username" name="uUsername" required ng-disabled="!vm.editable">
|
||||
<div ng-messages="form.$submitted && form.uUsername.$error">
|
||||
<span ng-message="required">// 'username_is_required' | tr //</span>
|
||||
</div>
|
||||
@ -38,7 +38,7 @@
|
||||
<div class="form-group col-md-12 form-group-custom">
|
||||
<label for="password" class="col-md-3 control-label">// 'password' | tr //:</label>
|
||||
<div class="col-md-9">
|
||||
<input type="password" class="form-control" id="password" ng-model="destination.password" name="uPassword" required>
|
||||
<input type="password" class="form-control" id="password" ng-model="destination.password" name="uPassword" required ng-disabled="!vm.editable">
|
||||
<div ng-messages="form.$submitted && form.uPassword.$error">
|
||||
<span ng-message="required">// 'password_is_required' | tr //</span>
|
||||
</div>
|
||||
|
@ -6,9 +6,9 @@
|
||||
.module('harbor.system.management')
|
||||
.directive('createDestination', createDestination);
|
||||
|
||||
CreateDestinationController.$inject = ['$scope', 'ListDestinationService', 'CreateDestinationService', 'UpdateDestinationService', 'PingDestinationService'];
|
||||
CreateDestinationController.$inject = ['$scope', 'ListDestinationService', 'CreateDestinationService', 'UpdateDestinationService', 'PingDestinationService', 'ListDestinationPolicyService', '$filter', 'trFilter'];
|
||||
|
||||
function CreateDestinationController($scope, ListDestinationService, CreateDestinationService, UpdateDestinationService, PingDestinationService) {
|
||||
function CreateDestinationController($scope, ListDestinationService, CreateDestinationService, UpdateDestinationService, PingDestinationService, ListDestinationPolicyService, $filter, trFilter) {
|
||||
var vm = this;
|
||||
|
||||
$scope.destination = {};
|
||||
@ -20,25 +20,11 @@
|
||||
vm.update = update;
|
||||
vm.pingDestination = pingDestination;
|
||||
|
||||
$scope.$watch('vm.action+","+vm.targetId', function(current) {
|
||||
if(current) {
|
||||
var parts = current.split(',');
|
||||
vm.action = parts[0];
|
||||
vm.targetId = parts[1];
|
||||
switch(vm.action) {
|
||||
case 'ADD_NEW':
|
||||
vm.modalTitle = 'Create destination';
|
||||
vm.addNew();
|
||||
break;
|
||||
case 'EDIT':
|
||||
vm.modalTitle = 'Edit destination';
|
||||
vm.edit(vm.targetId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
vm.editable = true;
|
||||
|
||||
function addNew() {
|
||||
vm.editable = true;
|
||||
vm.modalTitle = $filter('tr')('add_new_destination', []);
|
||||
vm0.name = '';
|
||||
vm0.endpoint = '';
|
||||
vm0.username = '';
|
||||
@ -46,7 +32,11 @@
|
||||
}
|
||||
|
||||
function edit(targetId) {
|
||||
getDestination(targetId);
|
||||
vm.editable = true;
|
||||
vm.modalTitle = $filter('tr')('edit_destination', []);
|
||||
ListDestinationService(targetId)
|
||||
.success(getDestinationSuccess)
|
||||
.error(getDestinationFailed);
|
||||
}
|
||||
|
||||
function create(destination) {
|
||||
@ -63,7 +53,7 @@
|
||||
|
||||
function createDestinationFailed(data, status) {
|
||||
if(status === 409) {
|
||||
alert('Destination already exists.');
|
||||
alert($filter('tr')('destination_already_exists', []));
|
||||
}
|
||||
console.log('Failed create destination:' + data);
|
||||
}
|
||||
@ -83,11 +73,6 @@
|
||||
console.log('Failed update destination.');
|
||||
}
|
||||
|
||||
function getDestination(targetId) {
|
||||
ListDestinationService(targetId)
|
||||
.success(getDestinationSuccess)
|
||||
.error(getDestinationFailed);
|
||||
}
|
||||
|
||||
function getDestinationSuccess(data, status) {
|
||||
var destination = data;
|
||||
@ -95,12 +80,29 @@
|
||||
vm0.endpoint = destination.endpoint;
|
||||
vm0.username = destination.username;
|
||||
vm0.password = destination.password;
|
||||
|
||||
ListDestinationPolicyService(destination.id)
|
||||
.success(listDestinationPolicySuccess)
|
||||
.error(listDestinationPolicyFailed);
|
||||
}
|
||||
|
||||
function getDestinationFailed(data, status) {
|
||||
console.log('Failed get destination.');
|
||||
}
|
||||
|
||||
function listDestinationPolicySuccess(data, status) {
|
||||
for(var i in data) {
|
||||
if(data[i].enabled === 1) {
|
||||
vm.editable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function listDestinationPolicyFailed(data, status) {
|
||||
console.log('Failed list destination policy:' + data);
|
||||
}
|
||||
|
||||
function pingDestination() {
|
||||
var target = {
|
||||
'name': vm0.name,
|
||||
@ -113,10 +115,10 @@
|
||||
.error(pingDestinationFailed);
|
||||
}
|
||||
function pingDestinationSuccess(data, status) {
|
||||
alert('Successful ping target.');
|
||||
alert($filter('tr')('successful_ping_target', []));
|
||||
}
|
||||
function pingDestinationFailed(data, status) {
|
||||
alert('Failed ping target:' + data);
|
||||
alert($filter('tr')('failed_ping_target', []) + ':' + data);
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,8 +141,19 @@
|
||||
function link(scope, element, attrs, ctrl) {
|
||||
|
||||
element.find('#createDestinationModal').on('show.bs.modal', function() {
|
||||
|
||||
scope.form.$setPristine();
|
||||
scope.form.$setUntouched();
|
||||
|
||||
switch(ctrl.action) {
|
||||
case 'ADD_NEW':
|
||||
ctrl.addNew();
|
||||
break;
|
||||
case 'EDIT':
|
||||
ctrl.edit(ctrl.targetId);
|
||||
break;
|
||||
}
|
||||
scope.$apply();
|
||||
});
|
||||
|
||||
ctrl.save = save;
|
||||
|
@ -6,9 +6,9 @@
|
||||
.module('harbor.system.management')
|
||||
.directive('destination', destination);
|
||||
|
||||
DestinationController.$inject = ['$scope', 'ListDestinationService', 'DeleteDestinationService'];
|
||||
DestinationController.$inject = ['$scope', 'ListDestinationService', 'DeleteDestinationService', '$filter', 'trFilter'];
|
||||
|
||||
function DestinationController($scope, ListDestinationService, DeleteDestinationService) {
|
||||
function DestinationController($scope, ListDestinationService, DeleteDestinationService, $filter, trFilter) {
|
||||
var vm = this;
|
||||
|
||||
vm.retrieve = retrieve;
|
||||
@ -66,6 +66,7 @@
|
||||
|
||||
function deleteDestinationFailed(data, status) {
|
||||
console.log('Failed delete destination.');
|
||||
alert($filter('tr')('failed_delete_destination', []) + ':' + data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
'ngCookies',
|
||||
'harbor.session',
|
||||
'harbor.layout.header',
|
||||
'harbor.layout.footer',
|
||||
'harbor.layout.navigation',
|
||||
'harbor.layout.sign.up',
|
||||
'harbor.layout.add.new',
|
||||
|
13
static/resources/js/layout/footer/footer.controller.js
Normal file
13
static/resources/js/layout/footer/footer.controller.js
Normal file
@ -0,0 +1,13 @@
|
||||
(function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('harbor.layout.footer')
|
||||
.controller('FooterController', FooterController);
|
||||
|
||||
function FooterController() {
|
||||
var vm = this;
|
||||
}
|
||||
|
||||
})();
|
8
static/resources/js/layout/footer/footer.module.js
Normal file
8
static/resources/js/layout/footer/footer.module.js
Normal file
@ -0,0 +1,8 @@
|
||||
(function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('harbor.layout.footer', []);
|
||||
|
||||
})();
|
@ -0,0 +1,19 @@
|
||||
(function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('harbor.services.destination')
|
||||
.factory('ListDestinationPolicyService', ListDestinationPolicyService);
|
||||
|
||||
ListDestinationPolicyService.$inject = ['$http'];
|
||||
|
||||
function ListDestinationPolicyService($http) {
|
||||
return listDestinationPolicy;
|
||||
function listDestinationPolicy(targetId) {
|
||||
return $http
|
||||
.get('/api/targets/' + targetId + '/policies/');
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
@ -160,6 +160,7 @@ var locale_messages = {
|
||||
'endpoint': 'Endpoint',
|
||||
'test_connection': 'Test connection',
|
||||
'add_new_destination': 'New Destination',
|
||||
'edit_destination': 'Edit Destination',
|
||||
'successful_changed_password': 'Password has been changed successfully.',
|
||||
'change_profile': 'Change Profile',
|
||||
'successful_changed_profile': 'User profile has been changed successfully.',
|
||||
@ -175,5 +176,12 @@ var locale_messages = {
|
||||
'edit_policy': 'Edit Policy',
|
||||
'add_new_title': 'Add User',
|
||||
'add_new': 'Add',
|
||||
'successful_added': 'Added new user successfully.'
|
||||
'successful_added': 'Added new user successfully.',
|
||||
'copyright': 'Copyright',
|
||||
'all_rights_reserved': 'All Rights Reserved.',
|
||||
'successful_ping_target': 'Pinged target successfully.',
|
||||
'failed_ping_target': 'Pinged target failed:',
|
||||
'policy_already_exists': 'Policy alreay exists.',
|
||||
'destination_already_exists': 'Destination already exists.',
|
||||
'failed_delete_destination': 'Delete destination failed:'
|
||||
};
|
@ -159,6 +159,7 @@ var locale_messages = {
|
||||
'endpoint_is_required': '终端URL为必填项。',
|
||||
'test_connection': '测试连接',
|
||||
'add_new_destination': '新建目标',
|
||||
'edit_destination': '编辑目标',
|
||||
'successful_changed_password': '修改密码操作成功。',
|
||||
'change_profile': '修改个人信息',
|
||||
'successful_changed_profile': '修改个人信息操作成功。',
|
||||
@ -174,5 +175,12 @@ var locale_messages = {
|
||||
'edit_policy': '修改策略',
|
||||
'add_new_title': '新增用户',
|
||||
'add_new': '新增',
|
||||
'successful_added': '新增用户成功。'
|
||||
'successful_added': '新增用户成功。',
|
||||
'copyright': '版权所有',
|
||||
'all_rights_reserved': '保留所有权利。',
|
||||
'successful_ping_target': 'Ping 目标成功。',
|
||||
'failed_ping_target': 'Ping 目标失败:',
|
||||
'policy_already_exists': '策略已存在。',
|
||||
'destination_already_exists': '目标已存在。',
|
||||
'failed_delete_destination': '删除目标失败:'
|
||||
};
|
@ -1,3 +1,3 @@
|
||||
<div class="footer-absolute footer">
|
||||
<p>Copyright © 2015-2016 VMware, Inc. All Rights Reserved.</p>
|
||||
<div class="footer-absolute footer" ng-controller="FooterController as vm">
|
||||
<p>// 'copyright' | tr // © 2015-2016 VMware, Inc. // 'all_rights_reserved' | tr //</p>
|
||||
</div>
|
||||
|
@ -48,6 +48,9 @@
|
||||
<script src="/static/resources/js/layout/header/header.module.js"></script>
|
||||
<script src="/static/resources/js/layout/header/header.controller.js"></script>
|
||||
|
||||
<script src="/static/resources/js/layout/footer/footer.module.js"></script>
|
||||
<script src="/static/resources/js/layout/footer/footer.controller.js"></script>
|
||||
|
||||
<script src="/static/resources/js/layout/navigation/navigation.module.js"></script>
|
||||
<script src="/static/resources/js/layout/navigation/navigation-header.directive.js"></script>
|
||||
<script src="/static/resources/js/layout/navigation/navigation-details.directive.js"></script>
|
||||
@ -154,6 +157,7 @@
|
||||
<script src="/static/resources/js/services/destination/services.ping-destination.js"></script>
|
||||
<script src="/static/resources/js/services/destination/services.update-destination.js"></script>
|
||||
<script src="/static/resources/js/services/destination/services.delete-destination.js"></script>
|
||||
<script src="/static/resources/js/services/destination/services.list-destination-policy.js"></script>
|
||||
|
||||
<script src="/static/resources/js/session/session.module.js"></script>
|
||||
<script src="/static/resources/js/session/session.current-user.js"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user