Merge pull request #504 from wknet123/master

fixed issues for #502, #503.
This commit is contained in:
kun wang 2016-07-09 11:52:23 +08:00 committed by GitHub
commit a2722a8b89
3 changed files with 33 additions and 5 deletions

View File

@ -56,8 +56,8 @@
</td> </td>
<td width="12%"> <td width="12%">
<div class="display-inline-block" ng-switch on="//r.enabled//"> <div class="display-inline-block" ng-switch on="//r.enabled//">
<a href="javascript:void(0);" ng-click="vm.togglePolicy(r.id, 0)" title="// 'disable' | tr //"><span ng-switch-when="1" class="glyphicon glyphicon-stop color-danger"></span></a> <a href="javascript:void(0);" ng-click="vm.confirmToTogglePolicy(r.id, 0, r.name)" title="// 'disable' | tr //"><span ng-switch-when="1" class="glyphicon glyphicon-stop color-danger"></span></a>
<a href="javascript:void(0);" ng-click="vm.togglePolicy(r.id, 1)" title="// 'enable' | tr //"><span ng-switch-when="0" class="glyphicon glyphicon-play color-success"></span></a> <a href="javascript:void(0);" ng-click="vm.confirmToTogglePolicy(r.id, 1, r.name)" title="// 'enable' | tr //"><span ng-switch-when="0" class="glyphicon glyphicon-play color-success"></span></a>
</div> </div>
&nbsp; &nbsp;
<a href="javascript:void(0);" data-toggle="modal" data-target="#createPolicyModal" ng-click="vm.editReplication(r.id)" title="// 'edit_policy' | tr //"><span class="glyphicon glyphicon-pencil"></span></a> <a href="javascript:void(0);" data-toggle="modal" data-target="#createPolicyModal" ng-click="vm.editReplication(r.id)" title="// 'edit_policy' | tr //"><span class="glyphicon glyphicon-pencil"></span></a>

View File

@ -29,6 +29,7 @@
var vm = this; var vm = this;
vm.retrieve = retrieve; vm.retrieve = retrieve;
vm.search = search; vm.search = search;
vm.confirmToTogglePolicy = confirmToTogglePolicy;
vm.togglePolicy = togglePolicy; vm.togglePolicy = togglePolicy;
vm.editReplication = editReplication; vm.editReplication = editReplication;
vm.retrieve(); vm.retrieve();
@ -54,8 +55,35 @@
console.log('Failed to list replication policy.'); console.log('Failed to list replication policy.');
} }
function togglePolicy(policyId, enabled) { function confirmToTogglePolicy(policyId, enabled, name) {
ToggleReplicationPolicyService(policyId, enabled) vm.policyId = policyId;
vm.enabled = enabled;
var status = $filter('tr')(vm.enabled === 1 ? 'enable':'disable');
var title;
var message;
if(enabled === 1){
title = $filter('tr')('confirm_to_toggle_enabled_policy_title');
message = $filter('tr')('confirm_to_toggle_enabled_policy');
}else{
title = $filter('tr')('confirm_to_toggle_disabled_policy_title');
message = $filter('tr')('confirm_to_toggle_disabled_policy');
}
$scope.$emit('modalTitle', title);
$scope.$emit('modalMessage', message);
var emitInfo = {
'contentType': 'text/html',
'confirmOnly': false,
'action': vm.togglePolicy
}
$scope.$emit('raiseInfo', emitInfo);
}
function togglePolicy() {
ToggleReplicationPolicyService(vm.policyId, vm.enabled)
.success(toggleReplicationPolicySuccess) .success(toggleReplicationPolicySuccess)
.error(toggleReplicationPolicyFailed); .error(toggleReplicationPolicyFailed);
} }

View File

@ -59,7 +59,7 @@
<tr ng-if="vm.projects.length > 0" ng-repeat="p in vm.projects"> <tr ng-if="vm.projects.length > 0" ng-repeat="p in vm.projects">
<td width="15%"><a href="/repository#/repositories?project_id=//p.project_id//&is_public=//p.public//">//p.name//</a></td> <td width="15%"><a href="/repository#/repositories?project_id=//p.project_id//&is_public=//p.public//">//p.name//</a></td>
<td width="20%">//p.repo_count//</td> <td width="20%">//p.repo_count//</td>
<td width="15%" ng-if="!vm.publicity">//vm.getProjectRole(p.current_user_role_id)//</td> <td width="15%" ng-if="!vm.publicity">//vm.getProjectRole(p.current_user_role_id) | tr//</td>
<td width="30%">//p.creation_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</td> <td width="30%">//p.creation_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
<td width="15%"><publicity-button is-public="p.public" owned="p.owner_id == vm.user.user_id" project-id="p.project_id"></publicity-button></td> <td width="15%"><publicity-button is-public="p.public" owned="p.owner_id == vm.user.user_id" project-id="p.project_id"></publicity-button></td>
</tr> </tr>