summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuji7 <lu.ji3@zte.com.cn>2017-11-07 15:17:04 +0800
committerLuji7 <lu.ji3@zte.com.cn>2017-11-07 15:17:08 +0800
commit337f08fb45a5f84cbc0a17915ea387bb1b269221 (patch)
treef57b4db6e2406b6fd247de760a4f075c08fe8605
parentb52a4f74875fd4c8082268e7eb2cdb6f75ac5bb6 (diff)
add onboard result
Change-Id: I715eed694b35c469ea00fc3a78bf1bde8acac64c Issue-id: USECASEUI-55 Signed-off-by: Luji7 <lu.ji3@zte.com.cn>
-rw-r--r--usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/ServiceTemplateService.js96
-rw-r--r--usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js101
-rw-r--r--usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/view-models/lifecyclemanagement.html3
3 files changed, 177 insertions, 23 deletions
diff --git a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/ServiceTemplateService.js b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/ServiceTemplateService.js
index d46c35c4..09c40b56 100644
--- a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/ServiceTemplateService.js
+++ b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/ServiceTemplateService.js
@@ -266,6 +266,7 @@
uuid: ns.uuid,
invariantUUID: ns.invariantUUID,
name: ns.name,
+ version: ns.version,
type: 'NS'
})
});
@@ -274,6 +275,7 @@
uuid: vnf.uuid,
invariantUUID: vnf.invariantUUID,
name: vnf.name,
+ version: vnf.version,,
type: 'VF'
})
});
@@ -281,33 +283,83 @@
});
},
- packageOnboard: function (onboardPackage) {
+ nsPackageOnboard: function (onboardPackage, processFun) {
console.log('onboard...');
console.log(onboardPackage);
var requestBody = {
csarId: onboardPackage.uuid
};
- if(onboardPackage.type === 'NS') {
- return $http({
- url: url+'/ns-packages',
- method: 'POST',
- data: JSON.stringify(requestBody),
- headers: uuiHeaders
- }).then(function(response){
- console.log('onboard ns package response...');
- console.log(response.data);
- });
- } else {
- return $http({
- url: url+'/vf-packages',
- method: 'POST',
- data: JSON.stringify(requestBody),
- headers: uuiHeaders
- }).then(function(response){
- console.log('onboard vf package response...');
- console.log(response.data);
- });
- }
+ return $http({
+ url: url+'/ns-packages',
+ method: 'POST',
+ data: JSON.stringify(requestBody),
+ headers: uuiHeaders
+ }).then(function(response){
+ console.log('onboard ns package response...');
+ console.log(response.data);
+ processFun(response.data);
+ });
+ },
+
+ vfPackageOnboard: function (onboardPackage, processFun) {
+ console.log('onboard...');
+ console.log(onboardPackage);
+ var requestBody = {
+ csarId: onboardPackage.uuid
+ };
+ return $http({
+ url: url+'/vf-packages',
+ method: 'POST',
+ data: JSON.stringify(requestBody),
+ headers: uuiHeaders
+ }).then(function(response){
+ console.log('onboard vf package response...');
+ console.log(response.data);
+ processFun(response.data);
+ });
+ },
+
+ queryVfOnboardProgress: function (jobId, progressFun) {
+ return $http({
+ url: url+'/jobs/' + jobId,
+ method: 'GET',
+ data: null,
+ headers: uuiHeaders
+ }).then(function(response){
+ console.log('get progress response...');
+ console.log(response.data);
+ progressFun(response.data.responseDescriptor);
+ });
+ },
+
+ nsPackageDelete: function (deletePackage, processFun) {
+ console.log('delete package...');
+ console.log(deletePackage);
+ return $http({
+ url: url+'/ns-packages/' + deletePackage.uuid,
+ method: 'DELETE',
+ data: null,
+ headers: uuiHeaders
+ }).then(function(response){
+ console.log('delete ns package response...');
+ console.log(response.data);
+ processFun(response.data);
+ });
+ },
+
+ vfPackageDelete: function (deletePackage, processFun) {
+ console.log('delete package...');
+ console.log(deletePackage);
+ return $http({
+ url: url+'/vf-packages/' + deletePackage.uuid,
+ method: 'DELETE',
+ data: null,
+ headers: uuiHeaders
+ }).then(function(response){
+ console.log('delete vf package response...');
+ console.log(response.data);
+ processFun(response.data);
+ });
}
};
});
diff --git a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js
index d53fd945..0a23df92 100644
--- a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js
+++ b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/controller/lcmController.js
@@ -137,7 +137,67 @@ app.controller('lcmCtrl', ['$scope', '$uibModal', '$log', '$http', '$timeout', '
};
ctrl.packageOnboard = function (onboardPackage) {
- ServiceTemplateService.packageOnboard(onboardPackage);
+ if(onboardPackage.type === 'NS') {
+ var processFun = function (response) {
+ if('failed' === response.status) {
+ ctrl.alerts.push({type: 'danger',msg: 'Operation failed! ' + response.statusDescription});
+ } else {
+ ctrl.alerts.push({type: 'success',msg: 'Operation is finished!'});
+ }
+ };
+ ServiceTemplateService.nsPackageOnboard(onboardPackage, processFun);
+ } else {
+ var openOnboardProgressDialog = function (jobId, title, successFun, failFun) {
+ var onboardProgressInstance = $uibModal.open({
+ ariaLabelledBy: 'modal-title',
+ ariaDescribedBy: 'modal-body',
+ templateUrl : 'app/uui/fusion/scripts/view-models/progress-dialog.html',
+ controller : 'VfOnboardProgressCtrl',
+ controllerAs : 'ctrl',
+ resolve: {
+ jobId: function () {
+ return jobId;
+ },
+ operationTitle: function () {
+ return title;
+ }
+ }
+ });
+ onboardProgressInstance.result.then(
+ function (result) {
+ successFun(result);
+ },
+ function (reason) {
+ failFun(reason);
+ }
+ );
+ };
+ var successFun = function (result) {
+ ctrl.alerts.push({type: 'success',msg: 'Operation is finished!'});
+ };
+ var failFun = function (reason) {
+ ctrl.alerts.push({type: 'danger',msg: 'Operation is failed! ' + reason});
+ };
+ var processFun = function (response) {
+ openOnboardProgressDialog(response.jobId, 'VF Onboarding', successFun, failFun);
+ };
+ ServiceTemplateService.vfPackageOnboard(onboardPackage, processFun);
+ }
+ };
+
+ ctrl.packageDelete = function (deletePackage) {
+ var processFun = function (response) {
+ if('failed' === response.status) {
+ ctrl.alerts.push({type: 'danger',msg: 'Operation failed! ' + response.statusDescription});
+ } else {
+ ctrl.alerts.push({type: 'success',msg: 'Operation is finished!'});
+ }
+ };
+ if(deletePackage.type === 'NS') {
+ ServiceTemplateService.nsPackageDelete(deletePackage, processFun);
+ } else {
+ ServiceTemplateService.vfPackageDelete(deletePackage, processFun);
+ }
};
}
]
@@ -311,4 +371,43 @@ function ($uibModalInstance, ServiceTemplateService, serviceId, operationId, ope
$interval.cancel(timer);
});
}]
+).controller('VfOnboardProgressCtrl', ['$uibModalInstance', 'ServiceTemplateService', 'jobId', 'operationTitle', '$q', '$interval',
+function ($uibModalInstance, ServiceTemplateService, jobId, operationTitle, $q, $interval) {
+ var ctrl = this;
+ ctrl.title = operationTitle;
+ ctrl.operation = '';
+ ctrl.max = 100;
+ ctrl.dynamic = 0;
+
+ var timerDeferred = $q.defer();
+ var timerPromise = timerDeferred.promise;
+
+ var progressFun = function (responseDescriptor) {
+ if('finished' === responseDescriptor.status || 'error' === responseDescriptor.status) {
+ ctrl.dynamic = 100;
+ timerDeferred.resolve();
+ if('finished' === responseDescriptor.status) {
+ $uibModalInstance.close('');
+ } else if('error' === responseDescriptor.status) {
+ $uibModalInstance.dismiss(responseDescriptor.statusDescription);
+ }
+ console.log('timer finished!');
+ } else if('processing' === responseDescriptor.status) {
+ ctrl.dynamic = responseDescriptor.progress;
+ ctrl.operation = responseDescriptor.statusDescription;
+ console.log('timer processing ......');
+ }
+ };
+
+ var timer = $interval(function () {
+ ServiceTemplateService.queryVfOnboardProgress(jobId, progressFun);
+ }, 1000);
+
+ timerPromise.then(function () {
+ $interval.cancel(timer);
+ console.log('timer cancel ---- ');
+ },function () {
+ $interval.cancel(timer);
+ });
+}]
);
diff --git a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/view-models/lifecyclemanagement.html b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/view-models/lifecyclemanagement.html
index 37abd51f..9fb889a1 100644
--- a/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/view-models/lifecyclemanagement.html
+++ b/usecaseui-lcm/src/main/webapp/app/uui/fusion/scripts/view-models/lifecyclemanagement.html
@@ -67,6 +67,7 @@
<tr>
<th>Name</th>
<th>Type</th>
+ <th>Version</th>
<th>Action</th>
</tr>
</thead>
@@ -74,8 +75,10 @@
<tr ng-repeat="package in ctrl.packages">
<td>{{package.name}}</td>
<td>{{package.type}}</td>
+ <td>{{package.version}}</td>
<td>
<button class="btn btn-primary onboard-button" ng-click="ctrl.packageOnboard(package)">Onboard</button>
+ <button class="btn btn-primary delete-button" ng-click="ctrl.packageDelete(package)">Delete</button>
</td>
</tr>
</tbody>