aboutsummaryrefslogtreecommitdiffstats
path: root/gui/app/scripts/factory
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2017-08-11 09:26:22 +0000
committerchenjiankun <chenjiankun1@huawei.com>2017-08-24 03:29:25 +0000
commitefb4f088f14aee394599bea21973f82f1867c4fe (patch)
tree7dee3588a21ac0b3aa6d130a77d6d6a8f30a01d7 /gui/app/scripts/factory
parent4a5bc16d841221e8ac7853b3044e50af0c8143d2 (diff)
Add function to upload image from local/url in GUI
JIRA: YARDSTICK-782 As user, we need to upload image from local/url. If upload image from local, user need to choose local image, then we will load it to openstack. If upload image from url, we will download it and load it to openstack. Change-Id: Ia9a42fda15a1dfc91476643635343a2f77a94a6b Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'gui/app/scripts/factory')
-rw-r--r--gui/app/scripts/factory/main.factory.js39
1 files changed, 38 insertions, 1 deletions
diff --git a/gui/app/scripts/factory/main.factory.js b/gui/app/scripts/factory/main.factory.js
index 44fbeb39f..7637a9ff3 100644
--- a/gui/app/scripts/factory/main.factory.js
+++ b/gui/app/scripts/factory/main.factory.js
@@ -9,7 +9,7 @@ var Base_URL;
var Grafana_URL;
angular.module('yardStickGui2App')
- .factory('mainFactory', ['$resource','$rootScope','$http', '$location',function($resource, $rootScope,$http,$location) {
+ .factory('mainFactory', ['$resource','$rootScope','$http', '$location', 'toaster',function($resource, $rootScope ,$http ,$location, toaster) {
Base_URL = 'http://' + $location.host() + ':' + $location.port();
Grafana_URL = 'http://' + $location.host();
@@ -86,6 +86,20 @@ angular.module('yardStickGui2App')
}
})
},
+ getImage: function(){
+ return $resource(Base_URL + '/api/v2/yardstick/images/:imageId', {imageId: "@imageId"}, {
+ 'get': {
+ method: 'GET'
+ }
+ })
+ },
+ deleteImage: function() {
+ return $resource(Base_URL + '/api/v2/yardstick/images/:imageId', { imageId: '@imageId' }, {
+ 'delete': {
+ method: 'DELETE'
+ }
+ })
+ },
uploadImage: function() {
return $resource(Base_URL + '/api/v2/yardstick/images', {}, {
'post': {
@@ -93,6 +107,13 @@ angular.module('yardStickGui2App')
}
})
},
+ uploadImageByUrl: function() {
+ return $resource(Base_URL + '/api/v2/yardstick/images', {}, {
+ 'post': {
+ method: 'POST'
+ }
+ })
+ },
getPodDetail: function() {
return $resource(Base_URL + '/api/v2/yardstick/pods/:podId', { podId: "@podId" }, {
'get': {
@@ -249,6 +270,22 @@ angular.module('yardStickGui2App')
method: 'DELETE'
}
})
+ },
+ errorHandler1: function(response){
+ toaster.pop({
+ 'type': 'error',
+ 'title': 'error',
+ 'body': response.result,
+ 'showCloseButton': true
+ });
+ },
+ errorHandler2: function(response){
+ toaster.pop({
+ 'type': 'error',
+ 'title': response.status,
+ 'body': response.statusText,
+ 'showCloseButton': true
+ });
}
};