summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/services
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/services')
-rw-r--r--catalog-ui/src/app/services/activity-log-service.ts48
-rw-r--r--catalog-ui/src/app/services/cache-service.ts54
-rw-r--r--catalog-ui/src/app/services/components/component-service.ts3
-rw-r--r--catalog-ui/src/app/services/components/resource-service.ts2
-rw-r--r--catalog-ui/src/app/services/components/service-service.ts2
-rw-r--r--catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts7
-rw-r--r--catalog-ui/src/app/services/entity-service.ts104
-rw-r--r--catalog-ui/src/app/services/event-listener-service.ts30
-rw-r--r--catalog-ui/src/app/services/header-interceptor.ts76
-rw-r--r--catalog-ui/src/app/services/http-error-interceptor.ts119
-rw-r--r--catalog-ui/src/app/services/onboarding-service.ts112
-rw-r--r--catalog-ui/src/app/services/sharing-service.ts40
12 files changed, 64 insertions, 533 deletions
diff --git a/catalog-ui/src/app/services/activity-log-service.ts b/catalog-ui/src/app/services/activity-log-service.ts
deleted file mode 100644
index 97d26d4f44..0000000000
--- a/catalog-ui/src/app/services/activity-log-service.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-'use strict';
-import {Activity} from "../models/activity";
-import {IAppConfigurtaion, IApi} from "../models/app-config";
-
-// Define an interface of the object you want to use, providing it's properties
-export interface IActivityLogService {
- getActivityLogService(type:string, id:string):ng.IPromise<Array<Activity>>;
-}
-
-export class ActivityLogService implements IActivityLogService {
-
-
- static '$inject' = ['$http', '$q', 'sdcConfig'];
- private api:IApi;
-
- constructor(private $http:ng.IHttpService, private $q:ng.IQService, sdcConfig:IAppConfigurtaion) {
- this.api = sdcConfig.api;
- }
-
- getActivityLogService = (type:string, id:string):ng.IPromise<Array<Activity>> => {
- let defer = this.$q.defer<any>();
- this.$http.get(this.api.root + this.api.GET_activity_log.replace(':type', type).replace(':id', id))
- .then((activityLog:any) => {
- defer.resolve(activityLog.data);
- });
- return defer.promise;
- }
-}
diff --git a/catalog-ui/src/app/services/cache-service.ts b/catalog-ui/src/app/services/cache-service.ts
deleted file mode 100644
index 4d10db0066..0000000000
--- a/catalog-ui/src/app/services/cache-service.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-'use strict';
-import {Dictionary} from "app/utils";
-
-interface ICacheService {
- get(key:string):any;
- set(key:string, value:any):void;
-}
-
-export class CacheService implements ICacheService {
-
- private storage:Dictionary<string, any>;
-
- constructor() {
- this.storage = new Dictionary<string, any>();
- };
-
- public get = (key:string):any => {
- return this.storage.getValue(key);
- };
-
- public set = (key:string, value:any):void => {
- this.storage.setValue(key, value);
- };
-
- public remove = (key:string):void => {
- if (this.storage.containsKey(key)) {
- this.storage.remove(key);
- }
- };
-
- public contains = (key:string):boolean => {
- return this.storage.containsKey(key);
- };
-}
diff --git a/catalog-ui/src/app/services/components/component-service.ts b/catalog-ui/src/app/services/components/component-service.ts
index 25203e7732..c7ab975e6e 100644
--- a/catalog-ui/src/app/services/components/component-service.ts
+++ b/catalog-ui/src/app/services/components/component-service.ts
@@ -22,7 +22,7 @@ import * as _ from "lodash";
import {ArtifactModel, IFileDownload, InstancesInputsPropertiesMap, InputModel, IValidate, RelationshipModel, PropertyModel, Component, ComponentInstance,
AttributeModel, IAppConfigurtaion, Resource, Module, DisplayModule, ArtifactGroupModel, InputsAndProperties} from "app/models";
import {ComponentInstanceFactory, CommonUtils} from "app/utils";
-import {SharingService} from "../sharing-service";
+import {SharingService} from "app/services-ng2";
import {ComponentMetadata} from "../../models/component-metadata";
export interface IComponentService {
@@ -683,7 +683,6 @@ export class ComponentService implements IComponentService {
public getComponentInstanceProperties = (componentId:string, instanceId:string):ng.IPromise<Array<PropertyModel>> => {
-
let deferred = this.$q.defer<Array<PropertyModel>>();
this.restangular.one(componentId).one("componentInstances").one(instanceId).one("properties").get().then((response:any) => {
console.log("component instance properties return successfully: ", response);
diff --git a/catalog-ui/src/app/services/components/resource-service.ts b/catalog-ui/src/app/services/components/resource-service.ts
index cb30107a69..3a00da1171 100644
--- a/catalog-ui/src/app/services/components/resource-service.ts
+++ b/catalog-ui/src/app/services/components/resource-service.ts
@@ -25,7 +25,7 @@
import * as _ from "lodash";
import {IComponentService, ComponentService} from "./component-service";
import {PropertyModel, IAppConfigurtaion, Resource, Component} from "../../models";
-import {SharingService} from "../sharing-service";
+import {SharingService} from "app/services-ng2";
export interface IResourceService extends IComponentService {
updateResourceGroupProperties(uniqueId:string, groupId:string, properties:Array<PropertyModel>):ng.IPromise<Array<PropertyModel>>
diff --git a/catalog-ui/src/app/services/components/service-service.ts b/catalog-ui/src/app/services/components/service-service.ts
index f258c7be98..6c318bd6d6 100644
--- a/catalog-ui/src/app/services/components/service-service.ts
+++ b/catalog-ui/src/app/services/components/service-service.ts
@@ -25,7 +25,7 @@
import * as _ from "lodash";
import {IComponentService, ComponentService} from "./component-service";
import {Distribution, DistributionComponent, Service, PropertyModel, Component, IAppConfigurtaion} from "app/models";
-import {SharingService} from "../sharing-service";
+import {SharingService} from "app/services-ng2";
export interface IServiceService extends IComponentService {
getDistributionsList(uuid:string):ng.IPromise<Array<Distribution>>;
diff --git a/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts b/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts
index 99be788547..b47c5e019b 100644
--- a/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts
+++ b/catalog-ui/src/app/services/components/utils/composition-left-palette-service.ts
@@ -32,11 +32,13 @@ import {ComponentMetadata} from "app/models/component-metadata";
import {GroupMetadata, GroupTpes} from "app/models/group-metadata";
import {PolicyMetadata, PolicyTpes} from "app/models/policy-metadata";
import {Resource} from "app/models/components/resource";
+import IHttpPromiseCallbackArg = angular.IHttpPromiseCallbackArg;
export class LeftPaletteLoaderService {
static '$inject' = [
'Restangular',
+ '$http',
'sdcConfig',
'$q',
'ComponentFactory',
@@ -45,6 +47,7 @@ export class LeftPaletteLoaderService {
];
constructor(protected restangular:restangular.IElement,
+ protected $http:ng.IHttpService,
protected sdcConfig:IAppConfigurtaion,
protected $q:ng.IQService,
protected ComponentFactory:ComponentFactory,
@@ -64,7 +67,9 @@ export class LeftPaletteLoaderService {
private updateLeftPalette = (componentInternalType:string):void => {
/* add components */
- this.restangular.one("resources").one('/latestversion/notabstract/metadata').get({'internalComponentType': componentInternalType}).then((leftPaletteComponentMetadata:Array<ComponentMetadata>) => {
+ const leftPaletteUrl = this.sdcConfig.api.uicache_root + this.sdcConfig.api.GET_uicache_left_palette;
+ this.$http.get(leftPaletteUrl, {params: {'internalComponentType': componentInternalType}}).then((res) => res.data).then((leftPaletteComponentMetadata:Array<ComponentMetadata>) => {
+ // this.restangular.one("resources").one('/latestversion/notabstract/metadata').get({'internalComponentType': componentInternalType}).then((leftPaletteComponentMetadata:Array<ComponentMetadata>) => {
_.forEach(leftPaletteComponentMetadata, (componentMetadata:ComponentMetadata) => {
this.leftPanelComponents.push(new LeftPaletteComponent(LeftPaletteMetadataTypes.Component, componentMetadata));
});
diff --git a/catalog-ui/src/app/services/entity-service.ts b/catalog-ui/src/app/services/entity-service.ts
deleted file mode 100644
index 2e7b2e1eed..0000000000
--- a/catalog-ui/src/app/services/entity-service.ts
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-'use strict';
-import * as _ from "lodash";
-import { Service, IApi, IAppConfigurtaion, Resource, Component} from "../models";
-import {SharingService} from "./sharing-service";
-import {ComponentFactory} from "../utils/component-factory";
-import {CacheService} from "./cache-service";
-import {ResourceType} from "app/utils";
-
-interface IEntityService {
- getAllComponents(smallObjects?:boolean):ng.IPromise<Array<Component>>;
-}
-
-interface IComponentsArray {
- services:Array<Service>;
- resources:Array<Resource>;
-}
-
-export class EntityService implements IEntityService {
- static '$inject' = ['$http', '$q', 'sdcConfig', 'Sdc.Services.SharingService', 'ComponentFactory', 'Sdc.Services.CacheService'];
- private _smallObjectAttributes = ['uniqueId', 'name', 'componentType', 'resourceType', 'lastUpdateDate', 'lifecycleState', 'distributionStatus', 'icon', 'version'];
- private api:IApi;
-
- constructor(private $http:ng.IHttpService,
- private $q:ng.IQService,
- private sdcConfig:IAppConfigurtaion,
- private sharingService:SharingService,
- private ComponentFactory:ComponentFactory,
- private cacheService:CacheService) {
- this.api = sdcConfig.api;
- }
-
- getCatalog = ():ng.IPromise<Array<Component>> => {
- let defer = this.$q.defer<Array<Component>>();
- this.$http.get(this.api.root + this.api.GET_catalog, {params: {excludeTypes: [ResourceType.VFCMT, ResourceType.CONFIGURATION]}})
- .then((response:any) => {
- let followedResponse: IComponentsArray = response.data;
- let componentsList:Array<Component> = new Array();
-
- followedResponse.services && followedResponse.services.forEach((serviceResponse:Service) => {
- let component:Service = this.ComponentFactory.createService(serviceResponse); // new Service(serviceResponse);
- componentsList.push(component);
- this.sharingService.addUuidValue(component.uniqueId, component.uuid);
- });
-
- followedResponse.resources && followedResponse.resources.forEach((resourceResponse:Resource) => {
- let component:Resource = this.ComponentFactory.createResource(resourceResponse);
- componentsList.push(component);
- this.sharingService.addUuidValue(component.uniqueId, component.uuid);
- });
-
- defer.resolve(componentsList);
- },(responce) => {
- defer.reject(responce);
- });
- return defer.promise;
- };
-
- getAllComponents = (smallObjects?:boolean):ng.IPromise<Array<Component>> => {
- let defer = this.$q.defer<Array<Component>>();
- this.$http.get(this.api.root + this.api.GET_element)
- .then((response:any) => {
- let componentResponse:IComponentsArray = response.data;
- let componentsList:Array<Component> = [];
-
- componentResponse.services && componentResponse.services.forEach((serviceResponse:Service) => {
- serviceResponse = (smallObjects) ? _.pick(serviceResponse, this._smallObjectAttributes) : serviceResponse;
- let component:Service = this.ComponentFactory.createService(serviceResponse);
- componentsList.push(component);
- this.sharingService.addUuidValue(component.uniqueId, component.uuid);
- });
-
- componentResponse.resources && componentResponse.resources.forEach((resourceResponse:Resource) => {
- resourceResponse = (smallObjects) ? _.pick(resourceResponse, this._smallObjectAttributes) : resourceResponse;
- let component:Resource = this.ComponentFactory.createResource(resourceResponse);
- componentsList.push(component);
- this.sharingService.addUuidValue(component.uniqueId, component.uuid);
- });
-
- defer.resolve(componentsList);
- });
-
- return defer.promise;
- };
-}
diff --git a/catalog-ui/src/app/services/event-listener-service.ts b/catalog-ui/src/app/services/event-listener-service.ts
index 360edad700..2d3c4a6fc8 100644
--- a/catalog-ui/src/app/services/event-listener-service.ts
+++ b/catalog-ui/src/app/services/event-listener-service.ts
@@ -23,22 +23,21 @@
'use strict';
import * as _ from "lodash";
import {Dictionary} from "../utils/dictionary/dictionary";
+import {Injectable} from "@angular/core";
-interface IEventListenerService {
-
-}
interface ICallbackData {
- callback:Function;
- args:any[];
+ callback: Function;
+ args: any[];
}
-export class EventListenerService implements IEventListenerService {
+@Injectable()
+export class EventListenerService {
- public observerCallbacks:Dictionary<string, ICallbackData[]> = new Dictionary<string, Array<ICallbackData>>();
+ public observerCallbacks: Dictionary<string, ICallbackData[]> = new Dictionary<string, Array<ICallbackData>>();
//register an observer + callback
- public registerObserverCallback = (eventName:string, callback:Function, ...args) => {
+ public registerObserverCallback = (eventName: string, callback: Function, ...args) => {
let callbackData = {
callback: callback,
args: args
@@ -62,11 +61,11 @@ export class EventListenerService implements IEventListenerService {
};
//unregister an observer
- public unRegisterObserver = (eventName:string, callbackFunc?:Function) => {
+ public unRegisterObserver = (eventName: string, callbackFunc?: Function) => {
if (this.observerCallbacks.containsKey(eventName)) {
- let callbacks: ICallbackData[] = this.observerCallbacks.getValue(eventName);
- if(callbacks.length === 1) {
+ let callbacks: ICallbackData[] = this.observerCallbacks.getValue(eventName);
+ if (callbacks.length === 1) {
this.observerCallbacks.remove(eventName);
} else {
let filterCallbacks = _.filter(callbacks, (callBackObj) => {
@@ -74,13 +73,12 @@ export class EventListenerService implements IEventListenerService {
});
this.observerCallbacks.setValue(eventName, filterCallbacks);
}
-
}
};
- public notifyObservers = function (eventName:string, ...args) {
- _.forEach(this.observerCallbacks.getValue(eventName), (callbackData:ICallbackData) => {
- callbackData.callback(...args);
- });
+ public notifyObservers = function (eventName: string, ...args) {
+ _.forEach(this.observerCallbacks.getValue(eventName), (callbackData: ICallbackData) => {
+ callbackData.callback(...args);
+ });
};
}
diff --git a/catalog-ui/src/app/services/header-interceptor.ts b/catalog-ui/src/app/services/header-interceptor.ts
index 931b292d60..5f4819ae88 100644
--- a/catalog-ui/src/app/services/header-interceptor.ts
+++ b/catalog-ui/src/app/services/header-interceptor.ts
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,17 +19,19 @@
*/
'use strict';
-import {IAppConfigurtaion} from "../models/app-config";
-import {Dictionary} from "../utils/dictionary/dictionary";
-import {SharingService} from "./sharing-service";
-
-//Method name should be exactly "response" - http://docs.angularjs.org/api/ng/service/$http
-export interface IInterceptor {
- request:Function;
+import { SharingService } from 'app/services-ng2';
+import { IAppConfigurtaion } from '../models/app-config';
+import { ServerErrorResponse } from '../models/server-error-response';
+import { Dictionary } from '../utils/dictionary/dictionary';
+// Method name should be exactly "response" - http://docs.angularjs.org/api/ng/service/$http
+export interface Interceptor {
+ request: Function;
+ response: Function;
+ responseError: Function;
}
-export class HeaderInterceptor implements IInterceptor {
+export class HeaderInterceptor implements Interceptor {
public static $inject = [
'$injector',
'$q',
@@ -39,51 +41,55 @@ export class HeaderInterceptor implements IInterceptor {
'$location'
];
- public static Factory($injector:ng.auto.IInjectorService,
- $q:ng.IQService,
- uuid4:any,
- sharingService:SharingService,
- sdcConfig:IAppConfigurtaion,
- $location:ng.ILocationService) {
- return new HeaderInterceptor($injector, $q, uuid4, sharingService, sdcConfig, $location);
- }
-
- constructor(private $injector:ng.auto.IInjectorService,
- private $q:ng.IQService,
- private uuid4:any,
- private sharingService:SharingService,
- private sdcConfig:IAppConfigurtaion,
- private $location:ng.ILocationService) {
- console.debug('header-interceptor: initializing AuthenticationInterceptor');
+ constructor(private $injector: ng.auto.IInjectorService,
+ private $q: ng.IQService,
+ private uuid4: any,
+ private sharingService: SharingService,
+ private sdcConfig: IAppConfigurtaion,
+ private $location: ng.ILocationService) {
}
- public request = (requestSuccess):ng.IPromise<any> => {
+ public request = (requestSuccess): ng.IPromise<any> => {
requestSuccess.headers['X-ECOMP-RequestID'] = this.uuid4.generate();
/**
* For every request to the server, that the service id, or resource id is sent in the URL, need to pass UUID in the header.
* Check if the unique id exists in uuidMap, and if so get the UUID and add it to the header.
*/
- let map:Dictionary<string, string> = this.sharingService.getUuidMap();
+ const map: Dictionary<string, string> = this.sharingService.getUuidMap();
if (map && requestSuccess.url.indexOf(this.sdcConfig.api.root) === 0) {
- console.log("header-interceptor: url: " + requestSuccess.url);
- map.forEach((key:string) => {
+ map.forEach((key: string) => {
if (requestSuccess.url.indexOf(key) !== -1) {
requestSuccess.headers['X-ECOMP-ServiceID'] = this.sharingService.getUuidValue(key);
}
});
}
return requestSuccess;
- };
+ }
- public response = (responseSuccess):ng.IPromise<any> => {
- let responseData = responseSuccess.data;
+ public response = (responseSuccess): ng.IPromise<any> => {
+ const responseData = responseSuccess.data;
if (responseData) {
- let data = JSON.stringify(responseData);
- if (data && (data.indexOf("Global Logon: Login") > 0)) {
+ const data = JSON.stringify(responseData);
+ if (data && (data.indexOf('Global Logon: Login') > 0)) {
this.$location.path('dashboard/welcome');
window.location.reload();
}
}
return responseSuccess;
}
+
+ public responseError = (response): ng.IPromise<any> => {
+ const errorResponse: ServerErrorResponse = new ServerErrorResponse(response, true);
+ const modalService = this.$injector.get('ModalServiceSdcUI');
+
+ const errorDetails = {
+ 'Error Code': errorResponse.messageId,
+ 'Status Code': errorResponse.status
+ };
+ if (errorResponse.ecompRequestId) {
+ errorDetails['Transaction ID'] = errorResponse.ecompRequestId;
+ }
+ modalService.openErrorDetailModal('Error', errorResponse.message, 'error-modal', errorDetails);
+ return this.$q.reject(errorResponse);
+ }
}
diff --git a/catalog-ui/src/app/services/http-error-interceptor.ts b/catalog-ui/src/app/services/http-error-interceptor.ts
deleted file mode 100644
index cef8c30716..0000000000
--- a/catalog-ui/src/app/services/http-error-interceptor.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-'use strict';
-import {IServerMessageModalModel} from "../view-models/modals/message-modal/message-server-modal/server-message-modal-view-model";
-import {SEVERITY} from "../utils/constants";
-import 'app/utils/prototypes.ts';
-
-export class HttpErrorInterceptor {
- public static $inject = ['$injector', '$q'];
-
- public static Factory($injector:ng.auto.IInjectorService, $q:angular.IQService) {
- return new HttpErrorInterceptor($injector, $q);
- }
-
- constructor(private $injector:ng.auto.IInjectorService, private $q:angular.IQService) {
- }
-
- public formatMessageArrays = (message:string, variables:Array<string>)=> {
- return message.replace(/\[%(\d+)\]/g, function (_, m) {
- let tmp = [];
- let list = variables[--m].split(";");
- list.forEach(function (item) {
- tmp.push("<li>" + item + "</li>");
- });
- return "<ul>" + tmp.join("") + "</ul>";
- });
- };
-
- public responseError = (rejection:any)=> {
-
- let text:string;
- let variables;
- let messageId:string = "";
- let isKnownException = false;
-
- if (rejection.data && rejection.data.serviceException) {
- text = rejection.data.serviceException.text;
- variables = rejection.data.serviceException.variables;
- messageId = rejection.data.serviceException.messageId;
- isKnownException = true;
- } else if (rejection.data && rejection.data.requestError && rejection.data.requestError.serviceException) {
- text = rejection.data.requestError.serviceException.text;
- variables = rejection.data.requestError.serviceException.variables;
- messageId = rejection.data.requestError.serviceException.messageId;
- isKnownException = true;
- } else if (rejection.data && rejection.data.requestError && rejection.data.requestError.policyException) {
- text = rejection.data.requestError.policyException.text;
- variables = rejection.data.requestError.policyException.variables;
- messageId = rejection.data.requestError.policyException.messageId;
- isKnownException = true;
- } else if (rejection.data) {
- text = 'Wrong error format from server';
- console.error(text);
- isKnownException = false;
- }
-
- let data:IServerMessageModalModel;
- if (isKnownException) {
- // Remove the "Error: " text at the begining
- if (text.trim().indexOf("Error:") === 0) {
- text = text.replace("Error:", "").trim();
- }
-
- //mshitrit DE199895 bug fix
- let count:number = 0;
- variables.forEach(function (item) {
- variables[count] = item ? item.replace('<', '&lt').replace('>', '&gt') : '';
- count++;
- });
-
- // Format the message in case has array to <ul><li>
- text = this.formatMessageArrays(text, variables);
-
- // Format the message %1 %2
- text = text.format(variables);
-
- // Need to inject the MessageService manually to prevent circular componentsToUpgrade (because MessageService use $templateCache that use $http).
- data = {
- title: 'Error',
- message: text,
- messageId: messageId,
- status: rejection.status,
- severity: SEVERITY.ERROR
- };
- } else {
- // Need to inject the MessageService manually to prevent circular componentsToUpgrade (because MessageService use $templateCache that use $http).
- data = {
- title: 'Error',
- message: rejection.status !== -1 ? rejection.statusText : "Error getting response from server",
- messageId: messageId,
- status: rejection.status,
- severity: SEVERITY.ERROR
- };
- }
-
- let modalsHandler = this.$injector.get('ModalsHandler');
- modalsHandler.openServerMessageModal(data);
-
- return this.$q.reject(rejection);
- }
-}
diff --git a/catalog-ui/src/app/services/onboarding-service.ts b/catalog-ui/src/app/services/onboarding-service.ts
deleted file mode 100644
index 3a6e940c6e..0000000000
--- a/catalog-ui/src/app/services/onboarding-service.ts
+++ /dev/null
@@ -1,112 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-'use strict';
-import {Component, IComponent} from "../models/components/component";
-import {ICsarComponent} from "../models/csar-component";
-import {IAppConfigurtaion, IApi} from "../models/app-config";
-import {IFileDownload} from "../models/file-download";
-import {Resource} from "../models/components/resource";
-import {ComponentFactory} from "../utils/component-factory";
-
-interface IOnboardingService {
- getOnboardingComponents():ng.IPromise<Array<IComponent>>;
- getComponentFromCsarUuid(csarUuid:string):ng.IPromise<Component>;
- downloadOnboardingCsar(packageId:string):ng.IPromise<IFileDownload>;
-}
-
-export class OnboardingService implements IOnboardingService {
-
- static '$inject' = ['$http', '$q', 'sdcConfig', 'ComponentFactory'];
- private api:IApi;
-
- constructor(private $http:ng.IHttpService,
- private $q:ng.IQService,
- private sdcConfig:IAppConfigurtaion,
- private ComponentFactory:ComponentFactory) {
- this.api = sdcConfig.api;
- }
-
- getOnboardingVSPs = ():ng.IPromise<Array<ICsarComponent>> =>{
- let defer = this.$q.defer<Array<ICsarComponent>>();
- this.$http.get(this.api.GET_onboarding)
- .then((response:any) => {
- defer.resolve(response.data.results);
- },(response) => {
- defer.reject(response);
- });
-
- return defer.promise;
- };
-
- getOnboardingComponents = ():ng.IPromise<Array<IComponent>> => {
- let defer = this.$q.defer<Array<IComponent>>();
- this.getOnboardingVSPs().then((onboardingComponents:Array<ICsarComponent>) => {
- let componentsList:Array<IComponent> = new Array();
-
- onboardingComponents.forEach((obc:ICsarComponent) => {
- let component:Component = this.ComponentFactory.createFromCsarComponent(obc);
- componentsList.push(component);
- });
-
- defer.resolve(componentsList);
- },(response) => {
- defer.reject(response);
- });
-
- return defer.promise;
- };
-
- downloadOnboardingCsar = (packageId:string):ng.IPromise<IFileDownload> => {
- let defer = this.$q.defer<IFileDownload>();
- this.$http({
- url: this.api.GET_onboarding + "/" + packageId,
- method: "get",
- responseType: "blob"
- })
- .then((response:any) => {
- defer.resolve(response.data);
- }, (err) => {
- defer.reject(err);
- });
-
- return defer.promise;
- };
-
- getComponentFromCsarUuid = (csarUuid:string):ng.IPromise<Component> => {
- let defer = this.$q.defer<Component>();
- this.$http.get(this.api.root + this.api.GET_component_from_csar_uuid.replace(':csar_uuid', csarUuid))
- .then((response:any) => {
- let component:Resource;
- // If the status is 400, this means that the component not found.
- // I do not want to return error from server, because a popup will appear in client with the error.
- // So returning success (200) with status 400.
- if (response.data.status !== 400) {
- component = new Resource(null, this.$q, <Resource>response.data);
- }
- defer.resolve(component);
- },(response) => {
- defer.reject(response.data);
- });
-
- return defer.promise;
- };
-
-}
diff --git a/catalog-ui/src/app/services/sharing-service.ts b/catalog-ui/src/app/services/sharing-service.ts
deleted file mode 100644
index f4cc2e6d5d..0000000000
--- a/catalog-ui/src/app/services/sharing-service.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-'use strict';
-import {Dictionary} from "app/utils";
-
-export class SharingService {
-
- private uuidMap:Dictionary<string, string> = new Dictionary<string,string>();
-
- public getUuidValue = (uniqueId:string):string => {
- return this.uuidMap.getValue(uniqueId);
- };
-
- public addUuidValue = (uniqueId:string, uuid:string):void => {
- this.uuidMap.setValue(uniqueId, uuid);
- };
-
- public getUuidMap = ():Dictionary<string, string> => {
- return this.uuidMap;
- };
-
-}