summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/services
diff options
context:
space:
mode:
authorTal Gitelman <tg851x@intl.att.com>2017-12-10 18:55:03 +0200
committerTal Gitelman <tg851x@intl.att.com>2017-12-10 19:33:38 +0200
commit51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 (patch)
tree3ac236a864d74d19b0f5c9020891a7a7e5c31b44 /catalog-ui/src/app/services
parentb5cc2e0695f195716d6ccdc65e73807a6632ec70 (diff)
Final commit to master merge from
Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507 Issue-ID: SDC-714 Signed-off-by: Tal Gitelman <tg851x@intl.att.com>
Diffstat (limited to 'catalog-ui/src/app/services')
-rw-r--r--catalog-ui/src/app/services/components/component-service.ts28
-rw-r--r--catalog-ui/src/app/services/entity-service.ts3
-rw-r--r--catalog-ui/src/app/services/loader-service.ts8
-rw-r--r--catalog-ui/src/app/services/user-resource-service.ts123
4 files changed, 32 insertions, 130 deletions
diff --git a/catalog-ui/src/app/services/components/component-service.ts b/catalog-ui/src/app/services/components/component-service.ts
index bedfed5ee5..90ae850899 100644
--- a/catalog-ui/src/app/services/components/component-service.ts
+++ b/catalog-ui/src/app/services/components/component-service.ts
@@ -52,6 +52,7 @@ export interface IComponentService {
deleteComponentInstance(componentId:string, componentInstanceId:string):ng.IPromise<ComponentInstance>;
createRelation(componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel>;
deleteRelation(componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel>;
+ fetchRelation(componentId:string, linkId:string):ng.IPromise<RelationshipModel>;
getRequirementsCapabilities(componentId:string):ng.IPromise<any>;
updateInstanceProperty(componentId:string, property:PropertyModel):ng.IPromise<PropertyModel>;
updateInstanceAttribute(componentId:string, attribute:AttributeModel):ng.IPromise<AttributeModel>;
@@ -513,7 +514,12 @@ export class ComponentService implements IComponentService {
public createRelation = (componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel> => {
let deferred = this.$q.defer();
- this.restangular.one(componentId).one("resourceInstance").one("associate").customPOST(JSON.stringify(link)).then((response:any) => {
+ const linkPayload:RelationshipModel = new RelationshipModel(link);
+ linkPayload.relationships.forEach((rel) => {
+ delete rel.capability;
+ delete rel.requirement;
+ });
+ this.restangular.one(componentId).one("resourceInstance").one("associate").customPOST(JSON.stringify(linkPayload)).then((response:any) => {
let relation:RelationshipModel = new RelationshipModel(response.plain());
console.log("Link created successfully ", relation);
deferred.resolve(relation);
@@ -526,7 +532,12 @@ export class ComponentService implements IComponentService {
public deleteRelation = (componentId:string, link:RelationshipModel):ng.IPromise<RelationshipModel> => {
let deferred = this.$q.defer();
- this.restangular.one(componentId).one("resourceInstance").one("dissociate").customPUT(JSON.stringify(link)).then((response:any) => {
+ const linkPayload:RelationshipModel = new RelationshipModel(link);
+ linkPayload.relationships.forEach((rel) => {
+ delete rel.capability;
+ delete rel.requirement;
+ });
+ this.restangular.one(componentId).one("resourceInstance").one("dissociate").customPUT(JSON.stringify(linkPayload)).then((response:any) => {
let relation:RelationshipModel = new RelationshipModel(response);
console.log("Link deleted successfully ", relation);
deferred.resolve(relation);
@@ -537,6 +548,19 @@ export class ComponentService implements IComponentService {
return deferred.promise;
};
+ public fetchRelation = (componentId:string, linkId:string):ng.IPromise<RelationshipModel> => {
+ let deferred = this.$q.defer<RelationshipModel>();
+ this.restangular.one(componentId).one("relationId").one(linkId).get().then((response:any) => {
+ let relation:RelationshipModel = new RelationshipModel(response);
+ console.log("Link fetched successfully ", relation);
+ deferred.resolve(relation);
+ }, (err)=> {
+ console.log("Failed to fetch Link Id: " + linkId);
+ deferred.reject(err);
+ });
+ return deferred.promise;
+ };
+
public getRequirementsCapabilities = (componentId:string):ng.IPromise<any> => {
let deferred = this.$q.defer();
this.restangular.one(componentId).one("requirmentsCapabilities").get().then((response:any) => {
diff --git a/catalog-ui/src/app/services/entity-service.ts b/catalog-ui/src/app/services/entity-service.ts
index 75ea036b3e..27b0513b39 100644
--- a/catalog-ui/src/app/services/entity-service.ts
+++ b/catalog-ui/src/app/services/entity-service.ts
@@ -23,6 +23,7 @@ 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():ng.IPromise<Array<Component>>;
@@ -48,7 +49,7 @@ export class EntityService implements IEntityService {
getCatalog = ():ng.IPromise<Array<Component>> => {
let defer = this.$q.defer<Array<Component>>();
- this.$http.get(this.api.root + this.api.GET_catalog)
+ 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();
diff --git a/catalog-ui/src/app/services/loader-service.ts b/catalog-ui/src/app/services/loader-service.ts
index 2f8746cbd8..6085eb16bf 100644
--- a/catalog-ui/src/app/services/loader-service.ts
+++ b/catalog-ui/src/app/services/loader-service.ts
@@ -32,12 +32,12 @@ export class LoaderService {
}
- public showLoader(...args) {
- this.eventListenerService.notifyObservers(EVENTS.SHOW_LOADER_EVENT, ...args);
+ public showLoader(loaderType:string, ...args) {
+ this.eventListenerService.notifyObservers(EVENTS.SHOW_LOADER_EVENT + loaderType, ...args);
}
- public hideLoader(...args) {
- this.eventListenerService.notifyObservers(EVENTS.HIDE_LOADER_EVENT, ...args);
+ public hideLoader(loaderType:string, ...args) {
+ this.eventListenerService.notifyObservers(EVENTS.HIDE_LOADER_EVENT + loaderType, ...args);
}
}
diff --git a/catalog-ui/src/app/services/user-resource-service.ts b/catalog-ui/src/app/services/user-resource-service.ts
deleted file mode 100644
index bdd9fc3303..0000000000
--- a/catalog-ui/src/app/services/user-resource-service.ts
+++ /dev/null
@@ -1,123 +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 {IUserProperties} from "../models/user";
-import {ICookie, IAppConfigurtaion} from "../models/app-config";
-import {CookieService} from "./cookie-service";
-
-// Define an interface of the object you want to use, providing it's properties
-export interface IUserResource extends IUserProperties,ng.resource.IResource<IUserResource> {
-
-}
-
-// Define your resource, adding the signature of the custom actions
-export interface IUserResourceClass extends ng.resource.IResourceClass<IUserResource> {
- authorize():IUserResource;
- getLoggedinUser():IUserResource;
- setLoggedinUser(user:IUserResource):void;
- getAllUsers(success?:Function, error?:Function):Array<IUserResource>;
- createUser(IResourceResource, success?:Function, error?:Function):void;
- editUserRole(IResourceResource, success?:Function, error?:Function):void;
- deleteUser(IResourceResource, success?:Function, error?:Function):void;
-}
-
-export class UserResourceService {
-
- public static getResource = ($resource:ng.resource.IResourceService,
- sdcConfig:IAppConfigurtaion,
- cookieService:CookieService):IUserResourceClass => {
-
- let url:string = sdcConfig.api.root + sdcConfig.api.GET_user;
- let authorizeUrl:string = sdcConfig.api.root + sdcConfig.api.GET_user_authorize;
- let authorizeActionHeaders:any = {};
- let cookie:ICookie = sdcConfig.cookie;
- authorizeActionHeaders[cookie.userFirstName] = cookieService.getFirstName();
- authorizeActionHeaders[cookie.userLastName] = cookieService.getLastName();
- authorizeActionHeaders[cookie.userEmail] = cookieService.getEmail();
- authorizeActionHeaders[cookie.userIdSuffix] = cookieService.getUserId();
-
- // Define your custom actions here as IActionDescriptor
- let authorizeAction:ng.resource.IActionDescriptor = {
- method: 'GET',
- isArray: false,
- url: authorizeUrl,
- headers: authorizeActionHeaders
- };
-
- let getAllUsers:ng.resource.IActionDescriptor = {
- method: 'GET',
- isArray: true,
- url: sdcConfig.api.root + sdcConfig.api.GET_all_users
- };
-
- let editUserRole:ng.resource.IActionDescriptor = {
- method: 'POST',
- isArray: false,
- url: sdcConfig.api.root + sdcConfig.api.POST_edit_user_role,
- transformRequest: (data, headers)=> {
- data.payloadData = undefined;
- data.payloadName = undefined;
- return JSON.stringify(data);
- }
- };
-
- let deleteUser:ng.resource.IActionDescriptor = {
- method: 'DELETE',
- isArray: false,
- url: sdcConfig.api.root + sdcConfig.api.DELETE_delete_user
- };
-
- let createUser:ng.resource.IActionDescriptor = {
- method: 'POST',
- isArray: false,
- url: sdcConfig.api.root + sdcConfig.api.POST_create_user,
- transformRequest: (data, headers)=> {
- data.payloadData = undefined;
- data.payloadName = undefined;
- return JSON.stringify(data);
- }
- };
- let userResource:IUserResourceClass = <IUserResourceClass>$resource(
- url,
- {id: '@id'},
- {
- authorize: authorizeAction,
- getAllUsers: getAllUsers,
- createUser: createUser,
- editUserRole: editUserRole,
- deleteUser: deleteUser
- }
- );
-
- let _loggedinUser:IUserResource;
-
- userResource.getLoggedinUser = () => {
- return _loggedinUser;
- };
-
- userResource.setLoggedinUser = (loggedinUser:IUserResource) => {
- _loggedinUser = loggedinUser;
- };
-
- return userResource;
- }
-}
-UserResourceService.getResource.$inject = ['$resource', 'sdcConfig', 'Sdc.Services.CookieService'];