summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src
diff options
context:
space:
mode:
authorIdan Amit <ia096e@intl.att.com>2018-01-23 15:53:11 +0200
committerIdan Amit <ia096e@intl.att.com>2018-01-24 21:00:39 +0000
commitae4ab937ea76cbd15dfb572d67ddd7d672503336 (patch)
tree12c78406974589581a82c281146311180e18a00d /catalog-ui/src
parent45772e3924ee075e9674864eb32586d7cdb276b4 (diff)
Add designer service
Fixed a bug in the configuration Change-Id: I6a40bff70ed71d72d6b75104ffb1002d83ade1b2 Issue-ID: SDC-958 Signed-off-by: Idan Amit <ia096e@intl.att.com>
Diffstat (limited to 'catalog-ui/src')
-rw-r--r--catalog-ui/src/app/models/designers-config.ts2
-rw-r--r--catalog-ui/src/app/modules/service-module.ts8
-rw-r--r--catalog-ui/src/app/ng2/app.module.ts2
-rw-r--r--catalog-ui/src/app/ng2/services/designers.service.ts17
-rw-r--r--catalog-ui/src/app/view-models/designers/designers-view-model.ts18
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/designers/designers-tab-view-model.ts16
-rw-r--r--catalog-ui/src/app/view-models/workspace/workspace-view-model.ts2
7 files changed, 40 insertions, 25 deletions
diff --git a/catalog-ui/src/app/models/designers-config.ts b/catalog-ui/src/app/models/designers-config.ts
index 6b4233fc1b..b60e4204e7 100644
--- a/catalog-ui/src/app/models/designers-config.ts
+++ b/catalog-ui/src/app/models/designers-config.ts
@@ -2,7 +2,7 @@
export class Designer {
designerId: string;
designerHost: string;
- designerPort: number;
+ designerPort: string;
designerPath: string;
designerStateUrl: string;
designerProtocol: string;
diff --git a/catalog-ui/src/app/modules/service-module.ts b/catalog-ui/src/app/modules/service-module.ts
index b677a6d842..c2ee61e69c 100644
--- a/catalog-ui/src/app/modules/service-module.ts
+++ b/catalog-ui/src/app/modules/service-module.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.
@@ -51,6 +51,7 @@ import {ServiceServiceNg2} from "../ng2/services/component-services/service.serv
import {ConnectionWizardService} from "../ng2/pages/connection-wizard/connection-wizard.service";
import {ComponentInstanceServiceNg2} from "../ng2/services/component-instance-services/component-instance.service";
import {UserService as UserServiceNg2} from "../ng2/services/user.service";
+import {DesignersService} from "../ng2/services/designers.service";
let moduleName:string = 'Sdc.Services';
let serviceModule:ng.IModule = angular.module(moduleName, []);
@@ -94,4 +95,5 @@ serviceModule.factory('ServiceServiceNg2', downgradeInjectable(ServiceServiceNg2
serviceModule.factory('ModalServiceNg2', downgradeInjectable(ModalService));
serviceModule.factory('ConnectionWizardServiceNg2', downgradeInjectable(ConnectionWizardService));
serviceModule.factory('ComponentInstanceServiceNg2', downgradeInjectable(ComponentInstanceServiceNg2));
-serviceModule.factory('UserServiceNg2', downgradeInjectable(UserServiceNg2)); \ No newline at end of file
+serviceModule.factory('UserServiceNg2', downgradeInjectable(UserServiceNg2));
+serviceModule.factory('DesignersService', downgradeInjectable(DesignersService));
diff --git a/catalog-ui/src/app/ng2/app.module.ts b/catalog-ui/src/app/ng2/app.module.ts
index ecaa26e1ce..5cf4d80075 100644
--- a/catalog-ui/src/app/ng2/app.module.ts
+++ b/catalog-ui/src/app/ng2/app.module.ts
@@ -47,6 +47,7 @@ import {SdcConfig} from "./config/sdc-config.config";
import { TranslateModule } from "./shared/translator/translate.module";
import { TranslationServiceConfig } from "./config/translation.service.config";
import {DesignerFrameModule} from "./components/ui/designer/designer-frame.module";
+import {DesignersService} from "./services/designers.service";
export const upgradeAdapter = new UpgradeAdapter(forwardRef(() => AppModule));
@@ -97,6 +98,7 @@ export function configServiceFactory(config:ConfigService) {
SdcConfig,
ComponentInstanceServiceNg2,
TranslationServiceConfig,
+ DesignersService,
{
provide: APP_INITIALIZER,
useFactory: configServiceFactory,
diff --git a/catalog-ui/src/app/ng2/services/designers.service.ts b/catalog-ui/src/app/ng2/services/designers.service.ts
new file mode 100644
index 0000000000..283b54b964
--- /dev/null
+++ b/catalog-ui/src/app/ng2/services/designers.service.ts
@@ -0,0 +1,17 @@
+import { Injectable } from '@angular/core';
+import {Designer, DesignersConfiguration} from "app/models";
+
+@Injectable()
+export class DesignersService {
+
+ constructor() {
+ }
+
+ public getDesignerByStateUrl = (stateUrl: string) => {
+ let designerKey: any = _.findKey(DesignersConfiguration.designers, (designerConfig: Designer) =>{
+ return designerConfig.designerStateUrl === stateUrl;
+ });
+
+ return DesignersConfiguration.designers[designerKey];
+ }
+}
diff --git a/catalog-ui/src/app/view-models/designers/designers-view-model.ts b/catalog-ui/src/app/view-models/designers/designers-view-model.ts
index 42c1194258..380e093cb2 100644
--- a/catalog-ui/src/app/view-models/designers/designers-view-model.ts
+++ b/catalog-ui/src/app/view-models/designers/designers-view-model.ts
@@ -1,6 +1,7 @@
-import {Designer, IUserProperties, DesignersConfiguration} from "app/models";
+import {Designer, IUserProperties} from "app/models";
import {CacheService} from "app/services";
import {MenuItemGroup} from "app/utils";
+import {DesignersService} from "../../ng2/services/designers.service";
interface IDesignerViewModelScope extends ng.IScope {
@@ -14,25 +15,20 @@ export class DesignersViewModel {
static '$inject' = [
'$scope',
'$stateParams',
- '$sce',
- 'Sdc.Services.CacheService'
+ 'Sdc.Services.CacheService',
+ 'DesignersService'
];
constructor(private $scope:IDesignerViewModelScope,
private $stateParams:any,
- private $sce:any,
- private cacheService:CacheService) {
+ private cacheService:CacheService,
+ private designersService:DesignersService) {
this.initScope();
}
private initScope = ():void => {
- // get the designer object by using the path parameter
- let designerKey: any = _.findKey(DesignersConfiguration.designers, (designerConfig: Designer) =>{
- return designerConfig.designerStateUrl === this.$stateParams.path;
- });
-
- this.$scope.designer = DesignersConfiguration.designers[designerKey];
+ this.$scope.designer = this.designersService.getDesignerByStateUrl(this.$stateParams.path);
this.$scope.version = this.cacheService.get('version');
this.$scope.topNavMenuModel = [];
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/designers/designers-tab-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/designers/designers-tab-view-model.ts
index 03ce83ee18..2f4e1dafac 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/designers/designers-tab-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/designers/designers-tab-view-model.ts
@@ -1,4 +1,5 @@
-import {Designer, DesignersConfiguration} from "app/models";
+import {Designer} from "app/models";
+import {DesignersService} from "../../../../ng2/services/designers.service";
interface IDesignerTabViewModelScope extends ng.IScope {
@@ -8,21 +9,18 @@ interface IDesignerTabViewModelScope extends ng.IScope {
export class DesignersTabViewModel {
static '$inject' = [
'$scope',
- '$stateParams'
+ '$stateParams',
+ 'DesignersService'
];
constructor(private $scope:IDesignerTabViewModelScope,
- private $stateParams:any) {
+ private $stateParams:any,
+ private designersService:DesignersService) {
this.initScope();
}
private initScope = ():void => {
- // get the designer object by using the path parameter
- let designerKey: any = _.findKey(DesignersConfiguration.designers, (designerConfig: Designer) =>{
- return designerConfig.designerStateUrl === this.$stateParams.path;
- });
-
- this.$scope.designer = DesignersConfiguration.designers[designerKey];
+ this.$scope.designer = this.designersService.getDesignerByStateUrl(this.$stateParams.path);
}
}
diff --git a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
index 3846cf075e..87d8367e5d 100644
--- a/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/workspace-view-model.ts
@@ -725,7 +725,7 @@ export class WorkspaceViewModel {
if (designer.designerDisplayOptions["context"]) {
let displayOptions : DesignerDisplayOptions = designer.designerDisplayOptions["context"];
- if (displayOptions.displayContext.indexOf(this.$scope.component.getComponentSubType()) !== -1) {
+ if (displayOptions.displayContext.indexOf(this.$scope.component.componentType) !== -1) {
menuItemsObjects.push({
text: displayOptions.displayName,
action: 'onMenuItemPressed',