updates for replication-job logs download and data loading.

This commit is contained in:
kunw 2016-06-16 17:36:06 +08:00
parent 30918db231
commit eb571af668
2 changed files with 26 additions and 10 deletions

View File

@ -4,7 +4,7 @@
<div class="input-group">
<input type="text" class="form-control" placeholder="" ng-model="vm.replicationPolicyName" size="30">
<span class="input-group-btn">
<button class="btn btn-primary" type="button" ng-click="vm.search()"><span class="glyphicon glyphicon-search"></span></button>
<button class="btn btn-primary" type="button" ng-click="vm.searchReplicationPolicy()"><span class="glyphicon glyphicon-search"></span></button>
</span>
</div>
<button ng-if="!vm.isOpen" class="btn btn-success" type="button" ng-click="vm.addReplication()" data-toggle="modal" data-target="#createPolicyModal"><span class="glyphicon glyphicon-plus"></span>New Replication</button>
@ -55,9 +55,9 @@
<hr class="hr-line"/>
<div class="form-inline">
<div class="input-group">
<input type="text" class="form-control" placeholder="" ng-model="vm.replicationJobnName" size="30">
<input type="text" class="form-control" placeholder="" ng-model="vm.replicationJobName" size="30">
<span class="input-group-btn">
<button class="btn btn-primary" type="button" ng-click="vm.search()"><span class="glyphicon glyphicon-search"></span></button>
<button class="btn btn-primary" type="button" ng-click="vm.searchReplicationJob()"><span class="glyphicon glyphicon-search"></span></button>
</span>
</div>
</div>
@ -67,18 +67,20 @@
<thead>
<th width="20%">Name</th>
<th width="25%">Operation</th>
<th width="40%">Start Time</th>
<th width="25%">Start Time</th>
<th width="15%">Status</th>
<th width="15%">Logs</th>
</thead>
<tbody>
<tr ng-if="vm.replicationJobs.length == 0">
<td colspan="4" height="100%" class="empty-hint" ><h3 class="text-muted">No replication jobs.</h3></td>
</tr>
<tr ng-if="vm.replicationJobs.length > 0" ng-repeat="r in vm.replicationJobs">
<td>//r.tags != null ? r.tags.join(',') : 'N/A'//</td>
<td>//r.repository//</td>
<td>//r.operation//</td>
<td>//r.update_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
<td>//r.status//</td>
<td><a href="javascript:void(0);" ng-click="vm.downloadLog(r.id)"><span style="margin-left: 10px;" class="glyphicon glyphicon-file"></span></a></td>
</tr>
</tbody>
</table>

View File

@ -6,9 +6,9 @@
.module('harbor.replication')
.directive('listReplication', listReplication);
ListReplicationController.$inject = ['$scope', 'getParameterByName', '$location', 'ListReplicationPolicyService', 'ToggleReplicationPolicyService', 'ListReplicationJobService'];
ListReplicationController.$inject = ['$scope', 'getParameterByName', '$location', 'ListReplicationPolicyService', 'ToggleReplicationPolicyService', 'ListReplicationJobService', '$window'];
function ListReplicationController($scope, getParameterByName, $location, ListReplicationPolicyService, ToggleReplicationPolicyService, ListReplicationJobService) {
function ListReplicationController($scope, getParameterByName, $location, ListReplicationPolicyService, ToggleReplicationPolicyService, ListReplicationJobService, $window) {
var vm = this;
$scope.$on('$locationChangeSuccess', function() {
@ -19,19 +19,30 @@
vm.addReplication = addReplication;
vm.editReplication = editReplication;
vm.search = search;
vm.searchReplicationPolicy = searchReplicationPolicy;
vm.searchReplicationJob = searchReplicationJob;
vm.retrievePolicy = retrievePolicy;
vm.retrieveJob = retrieveJob;
vm.togglePolicy = togglePolicy;
vm.downloadLog = downloadLog;
vm.last = false;
vm.projectId = getParameterByName('project_id', $location.absUrl());
vm.retrievePolicy();
function search() {
function searchReplicationPolicy() {
vm.retrievePolicy();
}
function searchReplicationJob() {
if(vm.lastPolicyId !== -1) {
vm.retrieveJob(vm.lastPolicyId);
}
}
function retrievePolicy() {
ListReplicationPolicyService('', vm.projectId, vm.replicationPolicyName)
.success(listReplicationPolicySuccess)
@ -88,6 +99,9 @@
console.log('Failed toggle replication policy.');
}
function downloadLog(policyId) {
$window.open('/api/jobs/replication/' + policyId + '/log', '_blank');
}
}
function listReplication($timeout) {