Designer-view component for top-nav 23/28323/2
authorIdan Amit <ia096e@intl.att.com>
Mon, 15 Jan 2018 12:31:42 +0000 (14:31 +0200)
committerMichael Lando <ml636r@att.com>
Tue, 16 Jan 2018 16:58:47 +0000 (16:58 +0000)
Create a designer-view component for opening a designer view from the top-nav
Updated the API to return the designers as a list and not as an object
Created a designer-frame component that will get a designer url to open in the dedicated position

Change-Id: Ic42f7695277e88aacdeaa74d4d0f95b49ce44999
Issue-ID: SDC-884
Signed-off-by: Idan Amit <ia096e@intl.att.com>
25 files changed:
catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/DesignerStatusBL.java
catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigServlet.java
catalog-fe/src/main/resources/config/designers-configuration.yaml
catalog-fe/src/test/java/org/openecomp/sdc/fe/servlets/DesignerStatusBLTest.java
catalog-ui/src/app/app.ts
catalog-ui/src/app/models.ts
catalog-ui/src/app/models/designers-config.ts [new file with mode: 0644]
catalog-ui/src/app/modules/view-model-module.ts
catalog-ui/src/app/ng2/app.module.ts
catalog-ui/src/app/ng2/components/layout/top-nav/top-nav.component.ts
catalog-ui/src/app/ng2/components/ui/designer/designer-frame.component.html [new file with mode: 0644]
catalog-ui/src/app/ng2/components/ui/designer/designer-frame.component.less [new file with mode: 0644]
catalog-ui/src/app/ng2/components/ui/designer/designer-frame.component.ts [new file with mode: 0644]
catalog-ui/src/app/ng2/components/ui/designer/designer-frame.module.ts [new file with mode: 0644]
catalog-ui/src/app/ng2/pipes/global-pipes.module.ts
catalog-ui/src/app/ng2/pipes/safeUrlSanitizer.pipe.ts [new file with mode: 0644]
catalog-ui/src/app/ng2/services/config.service.ts
catalog-ui/src/app/utils/menu-handler.ts
catalog-ui/src/app/view-models/designers/designers-view-model.ts [new file with mode: 0644]
catalog-ui/src/app/view-models/designers/designers-view.html [new file with mode: 0644]
common-app-api/src/main/java/org/openecomp/sdc/fe/config/ConfigurationManager.java
common-app-api/src/main/java/org/openecomp/sdc/fe/config/DesignersConfiguration.java
sdc-os-chef/environments/Template.json
sdc-os-chef/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/recipes/FE_2_setup_configuration.rb
sdc-os-chef/sdc-frontend/chef-repo/cookbooks/sdc-catalog-fe/templates/default/FE-designers-configuration.yaml.erb

index cadaf19..eb43df6 100644 (file)
@@ -1,8 +1,8 @@
 package org.openecomp.sdc.fe.impl;
 
 import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpHead;
@@ -32,31 +32,31 @@ public class DesignerStatusBL {
                                
        }
 
-       public String checkDesinerListAvailability() {
+       public String checkDesignerListAvailability() {
                String result = null;
 
-               DesignersConfiguration designersConfiguarion = ConfigurationManager.getConfigurationManager()
+               DesignersConfiguration designersConfiguration = ConfigurationManager.getConfigurationManager()
                                .getDesignersConfiguration();
 
-               if (designersConfiguarion == null || designersConfiguarion.getDesignersList() == null) {
+               if (designersConfiguration == null || designersConfiguration.getDesignersList() == null) {
                        log.warn("Configuration of type {} was not found", DesignersConfiguration.class);
                } else {
-                       log.debug("The value returned from getConfig is {}", designersConfiguarion);
+                       log.debug("The value returned from getConfig is {}", designersConfiguration);
 
-                       Map<String, Designer> avaiableDesignersMap = new HashMap<String, Designer>();
+                       List<Designer> availableDesignersList = new ArrayList<>();
 
-                       designersConfiguarion.getDesignersList().forEach((key, value) -> {
-                               if (CheckDesignerAvailabilty(value)) {
-                                       avaiableDesignersMap.put(key, value);
+                       designersConfiguration.getDesignersList().forEach(value -> {
+                               if (checkDesignerAvailability(value)) {
+                                       availableDesignersList.add(value);
                                }
 
                        });
-                       result = gson.toJson(avaiableDesignersMap);
+                       result = gson.toJson(availableDesignersList);
                }
                return result;
        }
 
-       private boolean CheckDesignerAvailabilty(Designer designer) {
+       private boolean checkDesignerAvailability(Designer designer) {
 
                StringBuilder requestString = new StringBuilder();
                boolean result = false;
index bcaf504..ba37e94 100644 (file)
@@ -124,7 +124,7 @@ public class ConfigServlet extends BasicServlet {
 
                DesignerStatusBL designerStatusBL = (DesignerStatusBL) context.getAttribute(Constants.DESIGNER_BL_COMPONENT);           
 
-               result = designerStatusBL.checkDesinerListAvailability();
+               result = designerStatusBL.checkDesignerListAvailability();
 
                return Response.status(Status.OK).entity(result).build();
 
index c8c041b..7064619 100644 (file)
@@ -1,13 +1,17 @@
 designersList:
-    DCAE:
-        displayName: DCAE
-        designerHost: 192.168.50.5
-        designerPort: 8080
-        designerPath: "/dcae"
-        designerProtocol: http
-    WORKFLOW:
-        displayName: WORKFLOW
-        designerHost: 192.168.50.5
-        designerPort: 9527
-        designerPath: ""
-        designerProtocol: http
\ No newline at end of file
+   - displayName: DCAE
+     designerHost: 192.168.50.5
+     designerPort: 8080
+     designerPath: "/dcae"
+     designerStateUrl: "dcae"
+     designerProtocol: http
+     buttonLocation: ["top", "tab"]
+     tabPresentation: ["VF", "SERVICE"]
+   - displayName: WORKFLOW
+     designerHost: 192.168.50.5
+     designerPort: 9527
+     designerPath: "/"
+     designerStateUrl: "workflowDesigner"
+     designerProtocol: http
+     buttonLocation: ["top"]
+     tabPresentation: []
\ No newline at end of file
index 0ad233f..00c2d20 100644 (file)
@@ -4,8 +4,8 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.http.StatusLine;
 import org.apache.http.client.ClientProtocolException;
@@ -30,12 +30,12 @@ public class DesignerStatusBLTest {
        private static  Gson gson = new GsonBuilder().setPrettyPrinting().create();
 
        final static ConfigurationManager configurationManager = Mockito.mock(ConfigurationManager.class);
-       final static DesignersConfiguration designersConfiguraiton = Mockito.mock(DesignersConfiguration.class);
+       final static DesignersConfiguration designersConfiguration = Mockito.mock(DesignersConfiguration.class);
        final static Designer offlineDesigner = new Designer();
-       final static Designer onlineDesinger = new Designer();  
+       final static Designer onlineDesigner = new Designer();
        final static CloseableHttpResponse httpResponse = Mockito.mock(CloseableHttpResponse.class);
        final static StatusLine statusLine = Mockito.mock(StatusLine.class); 
-       final static Map<String, Designer> testDesignersList = new HashMap<String, Designer>();
+       final static List<Designer> testDesignersList = new ArrayList<>();
 
        final static String offlineDesignerDisplayName = "offlineDesigner";
        final static String offlineDesignerHost = "192.168.10.1";
@@ -48,14 +48,11 @@ public class DesignerStatusBLTest {
        final static int onlineDesignerPort = 2000;
        final static String onlineDesignerPath = "/online";
        final static String onlineDesignerProtocol = "http";
-       
-       StringBuilder offlineRequestString = new StringBuilder();
-       StringBuilder onlineRequestString = new StringBuilder();
 
        @BeforeClass
        public static void beforeClass() {
                ConfigurationManager.setTestInstance(configurationManager);
-               when(configurationManager.getDesignersConfiguration()).thenReturn(designersConfiguraiton);
+               when(configurationManager.getDesignersConfiguration()).thenReturn(designersConfiguration);
                
                offlineDesigner.setDisplayName(offlineDesignerDisplayName);
                offlineDesigner.setDesignerHost(offlineDesignerHost);
@@ -67,11 +64,11 @@ public class DesignerStatusBLTest {
                offlineRequestString.append(offlineDesignerProtocol).append("://").append(onlineDesignerHost).append(":")
                                .append(offlineDesignerPort).append(offlineDesignerPath);
 
-               onlineDesinger.setDisplayName(onlineDesignerDisplayName);
-               onlineDesinger.setDesignerHost(onlineDesignerHost);
-               onlineDesinger.setDesignerPort(onlineDesignerPort);
-               onlineDesinger.setDesignerPath(onlineDesignerPath);
-               onlineDesinger.setDesignerProtocol(onlineDesignerProtocol);
+               onlineDesigner.setDisplayName(onlineDesignerDisplayName);
+               onlineDesigner.setDesignerHost(onlineDesignerHost);
+               onlineDesigner.setDesignerPort(onlineDesignerPort);
+               onlineDesigner.setDesignerPath(onlineDesignerPath);
+               onlineDesigner.setDesignerProtocol(onlineDesignerProtocol);
 
                StringBuilder onlineRequestString = new StringBuilder();
                onlineRequestString.append(onlineDesignerProtocol).append("://").append(onlineDesignerHost).append(":")
@@ -80,22 +77,22 @@ public class DesignerStatusBLTest {
        }
 
        @Test
-       public void TestOfflineDesignerNotBeingReturnedWhenCallingCheckDesinerListAvailability() throws ClientProtocolException, IOException {
-               testDesignersList.put("offlineDesigner", offlineDesigner);
-               when(designersConfiguraiton.getDesignersList()).thenReturn(testDesignersList);
+       public void TestOfflineDesignerNotBeingReturnedWhenCallingCheckDesignerListAvailability() throws ClientProtocolException, IOException {
+               testDesignersList.add(offlineDesigner);
+               when(designersConfiguration.getDesignersList()).thenReturn(testDesignersList);
                
                when(statusLine.getStatusCode()).thenReturn(404);               
                when(httpResponse.getStatusLine()).thenReturn(statusLine);              
                when(httpClient.execute(Mockito.any(HttpHead.class))).thenReturn(httpResponse);
                
-               assertTrue(designerStatusBL.checkDesinerListAvailability().equals("{}"));
+               assertTrue(designerStatusBL.checkDesignerListAvailability().equals("[]"));
                
        }
        
        @Test
-       public void TestOnlineDesignerNotBeingReturnedWhenCallingCheckDesinerListAvailability() throws ClientProtocolException, IOException {
-               testDesignersList.put("onlineDesigner", onlineDesinger);
-               when(designersConfiguraiton.getDesignersList()).thenReturn(testDesignersList);
+       public void TestOnlineDesignerNotBeingReturnedWhenCallingCheckDesignerListAvailability() throws ClientProtocolException, IOException {
+               testDesignersList.add(onlineDesigner);
+               when(designersConfiguration.getDesignersList()).thenReturn(testDesignersList);
                
                when(statusLine.getStatusCode()).thenReturn(200);               
                when(httpResponse.getStatusLine()).thenReturn(statusLine);              
@@ -103,7 +100,7 @@ public class DesignerStatusBLTest {
                
                String result = gson.toJson(testDesignersList);
                
-               assertTrue(designerStatusBL.checkDesinerListAvailability().equals(result));
+               assertTrue(designerStatusBL.checkDesignerListAvailability().contains(result));
                
        }
 
index 609ed48..a3a1ba9 100644 (file)
@@ -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.
@@ -58,6 +58,7 @@ import {ComponentMetadata} from "./models/component-metadata";
 import {Categories} from "./models/categories";
 import {IUserProperties} from "./models/user";
 import {SearchWithAutoCompleteComponent} from "./ng2/components/ui/search-with-autocomplete/search-with-autocomplete.component";
+import {DesignerFrameComponent} from "./ng2/components/ui/designer/designer-frame.component";
 
 
 let moduleName:string = 'sdcApp';
@@ -152,7 +153,7 @@ angular.module('sdcApp').directive('ng2SearchWithAutocomplete',
         inputs: ['searchPlaceholder', 'searchBarClass', 'autoCompleteValues'],
         outputs: ['searchChanged', 'searchButtonClicked']
     }) as angular.IDirectiveFactory);
-
+angular.module('sdcApp').directive('designerFrame', downgradeComponent( {component: DesignerFrameComponent, inputs: ['designer']} ) as angular.IDirectiveFactory);
 
 ng1appModule.config([
     '$stateProvider',
@@ -533,6 +534,14 @@ ng1appModule.config([
             }
         );
 
+        $stateProvider.state(
+            'designers', {
+                url: '/designers/*path',
+                templateUrl: './view-models/designers/designers-view.html',
+                controller: viewModelsModuleName + '.DesignersViewModel'
+            }
+        );
+
         // Build the states for all hosted apps dynamically
         _.each(hostedApplications, (hostedApp)=> {
             if (hostedApp.exists) {
index 0145253..4848fb5 100644 (file)
@@ -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.
@@ -26,6 +26,7 @@ export * from './models/activity';
 export * from './models/additional-information';
 export * from './models/app-config';
 export * from './models/validation-config';
+export * from './models/designers-config';
 export * from './models/artifacts';
 export * from './models/aschema-property';
 export * from './models/schema-attribute';
diff --git a/catalog-ui/src/app/models/designers-config.ts b/catalog-ui/src/app/models/designers-config.ts
new file mode 100644 (file)
index 0000000..c784be2
--- /dev/null
@@ -0,0 +1,17 @@
+
+export class Designer {
+    displayName: string;
+    designerHost: string;
+    designerPort: number;
+    designerPath: string;
+    designerStateUrl: string;
+    designerProtocol: string;
+    designerButtonLocation: Array<string>;
+    designerTabPresentation: Array<string>;
+}
+
+export type Designers = Array<Designer>;
+
+export class DesignersConfiguration {
+    static designers: Designers;
+}
index f94bfc3..63ca901 100644 (file)
@@ -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.
@@ -73,6 +73,7 @@ import {InputFormViewModel} from "../view-models/forms/input-form/input-form-vie
 import {HierarchyViewModel} from "../view-models/tabs/hierarchy/hierarchy-view-model";
 import {downgradeComponent} from "@angular/upgrade/static";
 import {ConformanceLevelModalViewModel} from "../view-models/modals/conformance-level-modal/conformance-level-modal-view-model";
+import {DesignersViewModel} from "../view-models/designers/designers-view-model";
 // import {NG2ExampleComponent} from "../ng2/view-ng2/ng2.example.component/ng2.example.component";
 // import {upgradeAdapter} from "../ng2/app.module";
 // import { UpgradeAdapter } from '@angular/upgrade';
@@ -135,9 +136,10 @@ viewModelModule
   .controller(moduleName + '.ServiceInputsViewModel', ServiceInputsViewModel)
   .controller(moduleName + '.ReqAndCapabilitiesViewModel', ReqAndCapabilitiesViewModel)
   .controller(moduleName + '.InputFormViewModel', InputFormViewModel)
+  .controller(moduleName + '.DesignersViewModel', DesignersViewModel)
   //
   // //TABS
-  .controller(moduleName + '.HierarchyViewModel', HierarchyViewModel)
+  .controller(moduleName + '.HierarchyViewModel', HierarchyViewModel);
 
     // NG2
   //.controller(moduleName +  '.NG2Example',  downgradeComponent({component: NG2Example2Component}) );
index 7108be9..ecaa26e 100644 (file)
@@ -46,6 +46,7 @@ import {UserService} from "./services/user.service";
 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";
 
 export const upgradeAdapter = new UpgradeAdapter(forwardRef(() => AppModule));
 
@@ -72,7 +73,8 @@ export function configServiceFactory(config:ConfigService) {
 
         //We need to import them here since we use them in angular1
         ConnectionWizardModule,
-        PropertiesAssignmentModule
+        PropertiesAssignmentModule,
+        DesignerFrameModule
     ],
     exports: [],
     entryComponents: [],
index f48aa48..846b84c 100644 (file)
@@ -24,6 +24,7 @@ import {MenuItemGroup, MenuItem} from "app/utils";
 import {UserService} from "../../../services/user.service";
 import {SdcConfigToken, ISdcConfig} from "../../../config/sdc-config.config";
 import {TranslateService} from "../../../shared/translator/translate.service";
+import {DesignersConfiguration, Designer} from "app/models";
 
 
 declare const window:any;
@@ -62,10 +63,20 @@ export class TopNavComponent {
         let result = -1;
 
         //set result to current state
-        this.topLvlMenu.menuItems.forEach((item:MenuItem, index:number)=> {
+        this.topLvlMenu.menuItems.every((item:MenuItem, index:number)=> {
             if (item.state === this.$state.current.name) {
-                result = index;
+                if (this.$state.current.name === 'designers') {
+                    const designerIdx = _.findIndex(DesignersConfiguration.designers, (designer: Designer) => designer.designerStateUrl === this.$state.params.path);
+                    if (designerIdx !== -1) {
+                        result = index + designerIdx;
+                        return false;
+                    }
+                } else {
+                    result = index;
+                    return false;
+                }
             }
+            return true;
         });
 
         //if it's a different state , checking previous state param
@@ -109,6 +120,10 @@ export class TopNavComponent {
                         tmpArray.push(new MenuItem(hostedApp.navTitle, null, hostedApp.defaultState, "goToState", null, null));
                     }
                 });
+
+                _.each(DesignersConfiguration.designers, (designer: Designer) => {
+                    tmpArray.push(new MenuItem(designer.displayName, null, "designers", "goToState", {path: designer.designerStateUrl}, null));
+                })
             }
 
             this.topLvlMenu = new MenuItemGroup(0, tmpArray, true);
@@ -124,9 +139,9 @@ export class TopNavComponent {
         }
     }
 
-    goToState(state:string, params:Array<any>):Promise<boolean> {
+    goToState(state:string, params:any):Promise<boolean> {
         return new Promise((resolve, reject) => {
-            this.$state.go(state, params && params.length > 0 ? [0] : undefined);
+            this.$state.go(state, params || undefined);
             resolve(true);
         });
     }
diff --git a/catalog-ui/src/app/ng2/components/ui/designer/designer-frame.component.html b/catalog-ui/src/app/ng2/components/ui/designer/designer-frame.component.html
new file mode 100644 (file)
index 0000000..752e49e
--- /dev/null
@@ -0,0 +1,5 @@
+<div class="designer-frame">
+    <div class="w-sdc-main-container">
+        <iframe class="designer-iframe" [src]="designerUrl | safeUrlSanitizer"></iframe>
+    </div>
+</div>
diff --git a/catalog-ui/src/app/ng2/components/ui/designer/designer-frame.component.less b/catalog-ui/src/app/ng2/components/ui/designer/designer-frame.component.less
new file mode 100644 (file)
index 0000000..4b9456b
--- /dev/null
@@ -0,0 +1,8 @@
+.designer-frame {
+
+    .designer-iframe {
+        width: 100%;
+        height: 100%;
+        border: none;
+    }
+}
diff --git a/catalog-ui/src/app/ng2/components/ui/designer/designer-frame.component.ts b/catalog-ui/src/app/ng2/components/ui/designer/designer-frame.component.ts
new file mode 100644 (file)
index 0000000..b66008f
--- /dev/null
@@ -0,0 +1,25 @@
+import {Component, OnInit, Input} from "@angular/core";
+import {Designer} from "app/models";
+
+@Component({
+    selector: 'designer-frame',
+    templateUrl: './designer-frame.component.html',
+    styleUrls:['designer-frame.component.less']
+})
+
+export class DesignerFrameComponent implements OnInit {
+
+    @Input() designer: Designer;
+    designerUrl: string;
+
+    constructor() {
+    }
+
+    ngOnInit(): void {
+
+        this.designerUrl = this.designer.designerProtocol + "://" +
+            this.designer.designerHost + ":" +
+            this.designer.designerPort +
+            this.designer.designerPath;
+    }
+}
diff --git a/catalog-ui/src/app/ng2/components/ui/designer/designer-frame.module.ts b/catalog-ui/src/app/ng2/components/ui/designer/designer-frame.module.ts
new file mode 100644 (file)
index 0000000..1edf195
--- /dev/null
@@ -0,0 +1,25 @@
+import {NgModule} from "@angular/core";
+import { CommonModule } from '@angular/common';
+import {DesignerFrameComponent} from "./designer-frame.component";
+import {LayoutModule} from "../../layout/layout.module";
+import {GlobalPipesModule} from "../../../pipes/global-pipes.module";
+
+
+@NgModule({
+    declarations: [
+        DesignerFrameComponent
+    ],
+    imports: [
+        CommonModule,
+        LayoutModule,
+        GlobalPipesModule
+    ],
+    entryComponents: [DesignerFrameComponent],
+    exports: [
+        DesignerFrameComponent
+    ],
+    providers: []
+})
+export class DesignerFrameModule {
+
+}
index 1d81a1a..e89a816 100644 (file)
@@ -3,21 +3,23 @@ import {SearchFilterPipe} from "./searchFilter.pipe";
 import {KeysPipe} from "./keys.pipe";
 import {GroupByPipe} from "./groupBy.pipe";
 import {NgModule} from "@angular/core";
+import {SafeUrlSanitizerPipe} from "./safeUrlSanitizer.pipe";
 
 @NgModule({
     declarations: [
         ContentAfterLastDotPipe,
         GroupByPipe,
         KeysPipe,
-        SearchFilterPipe
-        
+        SearchFilterPipe,
+        SafeUrlSanitizerPipe
     ],
-    
+
     exports: [
         ContentAfterLastDotPipe,
         GroupByPipe,
         KeysPipe,
-        SearchFilterPipe
+        SearchFilterPipe,
+        SafeUrlSanitizerPipe
     ]
 })
 
diff --git a/catalog-ui/src/app/ng2/pipes/safeUrlSanitizer.pipe.ts b/catalog-ui/src/app/ng2/pipes/safeUrlSanitizer.pipe.ts
new file mode 100644 (file)
index 0000000..9d85880
--- /dev/null
@@ -0,0 +1,10 @@
+import { Pipe, PipeTransform } from '@angular/core';
+import { DomSanitizer } from '@angular/platform-browser';
+
+@Pipe({ name: 'safeUrlSanitizer' })
+export class SafeUrlSanitizerPipe implements PipeTransform {
+    constructor(private sanitizer: DomSanitizer) {}
+    transform(url) {
+        return this.sanitizer.bypassSecurityTrustResourceUrl(url);
+    }
+}
index 1c0ee18..8675ea7 100644 (file)
@@ -25,7 +25,7 @@
 import { Injectable, Inject } from '@angular/core';
 import { Http, Response } from '@angular/http';
 import 'rxjs/add/operator/toPromise';
-import {IAppConfigurtaion, ValidationConfiguration, Validations} from "app/models";
+import {IAppConfigurtaion, ValidationConfiguration, Validations, Designers, DesignersConfiguration} from "app/models";
 import {IApi} from "app/models/app-config";
 import {SdcConfigToken, ISdcConfig} from "../config/sdc-config.config";
 
@@ -69,15 +69,18 @@ export class ConfigService {
         return promise;
     }
 
-    loadDesignersConfiguration(): void {
+    loadDesignersConfiguration(): Promise<DesignersConfiguration> {
         let url:string = this.api.no_proxy_root + this.api.GET_designers_configuration;
         let promise: Promise<any> = this.http.get(url).map((res: Response) => res.json()).toPromise();
-
-        promise.then((config:any) => {
-            console.log(config);
+        promise.then((designersData: Designers) => {
+            DesignersConfiguration.designers = designersData;
         }).catch((ex) => {
-            console.error('Error was:', ex);
-        })
+           console.error("Error loading designers configuration from BE", ex);
+
+            DesignersConfiguration.designers = [] as Designers;
+        });
+
+        return promise;
     }
 
 }
index 1a3215b..d48412a 100644 (file)
@@ -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.
@@ -29,7 +29,7 @@ export class MenuItem {
     callback:(...args:Array<any>) => ng.IPromise<boolean>;
     state:string;
     action:string;
-    params:Array<any>;
+    params:any;
     isDisabled:boolean;
     disabledRoles:Array<string>;
     blockedForTypes:Array<string>;  // This item will not be shown for specific components types.
@@ -42,7 +42,7 @@ export class MenuItem {
     url:string;                     // Data added to menu item, in case the function need to use it, example: for function "changeLifecycleState", I need to pass also the state "CHECKOUT" that I want the state to change to.
 
 
-    constructor(text:string, callback:(...args:Array<any>) => ng.IPromise<boolean>, state:string, action:string, params?:Array<any>, blockedForTypes?:Array<string>) {
+    constructor(text:string, callback:(...args:Array<any>) => ng.IPromise<boolean>, state:string, action:string, params?:any, blockedForTypes?:Array<string>) {
         this.text = text;
         this.callback = callback;
         this.state = state;
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
new file mode 100644 (file)
index 0000000..42c1194
--- /dev/null
@@ -0,0 +1,42 @@
+import {Designer, IUserProperties, DesignersConfiguration} from "app/models";
+import {CacheService} from "app/services";
+import {MenuItemGroup} from "app/utils";
+
+
+interface IDesignerViewModelScope extends ng.IScope {
+    designer: Designer
+    topNavMenuModel:Array<MenuItemGroup>;
+    user:IUserProperties;
+    version:string;
+}
+
+export class DesignersViewModel {
+    static '$inject' = [
+        '$scope',
+        '$stateParams',
+        '$sce',
+        'Sdc.Services.CacheService'
+    ];
+
+    constructor(private $scope:IDesignerViewModelScope,
+                private $stateParams:any,
+                private $sce:any,
+                private cacheService:CacheService) {
+
+        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.version = this.cacheService.get('version');
+        this.$scope.topNavMenuModel = [];
+
+        this.$scope.user = this.cacheService.get('user');
+    }
+}
diff --git a/catalog-ui/src/app/view-models/designers/designers-view.html b/catalog-ui/src/app/view-models/designers/designers-view.html
new file mode 100644 (file)
index 0000000..3ae9805
--- /dev/null
@@ -0,0 +1,7 @@
+<div class="sdc-catalog-container">
+
+    <top-nav [menuModel]="topNavMenuModel" [version]="version" [hideSearch]="true"></top-nav>
+
+    <designer-frame [designer]="designer"></designer-frame>
+
+</div>
index 0e1aabc..807189d 100644 (file)
@@ -94,7 +94,7 @@ public class ConfigurationManager implements FileChangeCallback, IEcompConfigura
        
        public DesignersConfiguration getDesignersConfiguration() {
                
-               log.info("requested designers configuration and got this:{}", (DesignersConfiguration) configurations.get(getKey(DesignersConfiguration.class)));
+               log.info("requested designers configuration and got this:{}", configurations.get(getKey(DesignersConfiguration.class)));
                
                return (DesignersConfiguration) configurations.get(getKey(DesignersConfiguration.class));
        }
index 1b89ba0..6803120 100644 (file)
 package org.openecomp.sdc.fe.config;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.openecomp.sdc.common.api.BasicConfiguration;
 
-public class DesignersConfiguration extends BasicConfiguration { 
-       
-       private Map<String,Designer> designersList;
-       
-       public Map<String,Designer> getDesignersList() {
-               return designersList;
-       }
-
-       public void setDesignersList(Map<String,Designer> designersList) {
-               this.designersList = designersList;
-       }
-       
-       public DesignersConfiguration() {
-               this.designersList = new HashMap<String, Designer>();
-       }
-
-       public static class Designer { 
-               
-               private String displayName;
-               private String designerHost;            
-               private Integer designerPort;           
-               private String designerPath;
-               private String designerProtocol;
-               
-
-               public String getDesignerProtocol() {
-                       return designerProtocol;
-               }
-
-               public void setDesignerProtocol(String designerProtocol) {
-                       this.designerProtocol = designerProtocol;
-               }
-
-               public String getDisplayName() {
-                       return displayName;
-               }
-
-               public void setDisplayName(String displayName) {
-                       this.displayName = displayName;
-               }
-
-               public String getDesignerHost() {
-                       return designerHost;
-               }
-
-               public void setDesignerHost(String designerHost) {
-                       this.designerHost = designerHost;
-               }
-
-               public Integer getDesignerPort() {
-                       return designerPort;
-               }
-
-               public void setDesignerPort(Integer designerPort) {
-                       this.designerPort = designerPort;
-               }
-
-               public String getDesignerPath() {
-                       return designerPath;
-               }
-
-               public void setDesignerPath(String designerPath) {
-                       this.designerPath = designerPath;
-               }
-
-       }
+public class DesignersConfiguration extends BasicConfiguration {
+
+    private List<Designer> designersList;
+
+    public List<Designer> getDesignersList() {
+        return designersList;
+    }
+
+    public void setDesignersList(List<Designer> designersList) {
+        this.designersList = designersList;
+    }
+
+    public DesignersConfiguration() {
+        this.designersList = new ArrayList<>();
+    }
+
+    public static class Designer {
+
+        private String displayName;
+        private String designerHost;
+        private Integer designerPort;
+        private String designerPath;
+        private String designerStateUrl;
+        private String designerProtocol;
+        private List<String> designerButtonLocation;
+        private List<String> designerTabPresentation;
+
+        public List<String> getDesignerButtonLocation() {
+            return designerButtonLocation;
+        }
+
+        public void setDesignerButtonLocation(List<String> designerButtonLocation) {
+            this.designerButtonLocation = designerButtonLocation;
+        }
+
+        public List<String> getDesignerTabPresentation() {
+            return designerTabPresentation;
+        }
+
+        public void setDesignerTabPresentation(List<String> designerTabPresentation) {
+            this.designerTabPresentation = designerTabPresentation;
+        }
+
+        public String getDesignerStateUrl() {
+            return designerStateUrl;
+        }
+
+        public void setDesignerStateUrl(String designerStateUrl) {
+            this.designerStateUrl = designerStateUrl;
+        }
+
+        public String getDesignerProtocol() {
+            return designerProtocol;
+        }
+
+        public void setDesignerProtocol(String designerProtocol) {
+            this.designerProtocol = designerProtocol;
+        }
+
+        public String getDisplayName() {
+            return displayName;
+        }
+
+        public void setDisplayName(String displayName) {
+            this.displayName = displayName;
+        }
+
+        public String getDesignerHost() {
+            return designerHost;
+        }
+
+        public void setDesignerHost(String designerHost) {
+            this.designerHost = designerHost;
+        }
+
+        public Integer getDesignerPort() {
+            return designerPort;
+        }
+
+        public void setDesignerPort(Integer designerPort) {
+            this.designerPort = designerPort;
+        }
+
+        public String getDesignerPath() {
+            return designerPath;
+        }
+
+        public void setDesignerPath(String designerPath) {
+            this.designerPath = designerPath;
+        }
+
+    }
 
 }
 
index d184712..d39eba3 100644 (file)
                 "dcae_host": "yyy",
                 "dcae_port": "yyy",
                 "dcae_path": "yyy",
-                "dcae_protocol": "yyy"
+                "dcae_state_url": "yyy",
+                "dcae_protocol": "yyy",
+                "dcae_button_position": ["xxx", "yyy"],
+                "dcae_tab_presentation": ["xxx", "yyy"]
             },
             "WORKFLOW": {
                 "workflow_host": "yyy",
                 "workflow_port": "yyy",
                 "workflow_path": "yyy",
-                "workflow_protocol": "yyy"
+                "workflow_state_url": "yyy",
+                "workflow_protocol": "yyy",
+                "workflow_button_position": ["xxx", "yyy"],
+                "workflow_tab_presentation": ["xxx", "yyy"]
             }
         }
     },
index 7dcf260..0d12e3b 100644 (file)
@@ -23,14 +23,20 @@ template "designers-fe-config" do
    group "jetty"
    mode "0755"
    variables({
-      :dcae_host         => node['Designers']['DCAE']['dcae_host'],
-      :dcae_port         => node['Designers']['DCAE']['dcae_port'],
-      :dcae_path         => node['Designers']['DCAE']['dcae_path'],
-      :dcae_protocol     => node['Designers']['DCAE']['dcae_protocol'],
-      :workflow_host     => node['Designers']['WORKFLOW']['workflow_host'],
-      :workflow_port     => node['Designers']['WORKFLOW']['workflow_port'],
-      :workflow_path     => node['Designers']['WORKFLOW']['workflow_path'],
-      :workflow_protocol => node['Designers']['WORKFLOW']['workflow_protocol']
+      :dcae_host                 => node['Designers']['DCAE']['dcae_host'],
+      :dcae_port                 => node['Designers']['DCAE']['dcae_port'],
+      :dcae_path                 => node['Designers']['DCAE']['dcae_path'],
+      :dcae_state_url            => node['Designers']['DCAE']['dcae_state_url'],
+      :dcae_protocol             => node['Designers']['DCAE']['dcae_protocol'],
+      :dcae_button_location      => node['Designers']['DCAE']['dcae_button_location'],
+      :dcae_tab_presentation     => node['Designers']['DCAE']['dcae_tab_presentation'],
+      :workflow_host             => node['Designers']['WORKFLOW']['workflow_host'],
+      :workflow_port             => node['Designers']['WORKFLOW']['workflow_port'],
+      :workflow_path             => node['Designers']['WORKFLOW']['workflow_path'],
+      :workflow_state_url        => node['Designers']['WORKFLOW']['workflow_state_url'],
+      :workflow_protocol         => node['Designers']['WORKFLOW']['workflow_protocol'],
+      :workflow_button_location  => node['Designers']['WORKFLOW']['workflow_button_location'],
+      :workflow_tab_presentation => node['Designers']['WORKFLOW']['workflow_tab_presentation']
    })
 end
 
index b509272..f8a7999 100644 (file)
@@ -1,13 +1,17 @@
 designersList:
-    DCAE:
-        displayName: DCAE
-        designerHost: <%= @dcae_host %>
-        designerPort: <%= @dcae_port %>
-        designerPath: <%= @dcae_path %>
-        designerProtocol: <%= @dcae_protocol %>
-    WORKFLOW:
-        displayName: WORKFLOW
-        designerHost: <%= @workflow_host %>
-        designerPort: <%= @workflow_port %>
-        designerPath: <%= @workflow_path %>
-        designerProtocol: <%= @workflow_protocol %>
\ No newline at end of file
+   - displayName: DCAE
+     designerHost: <%= @dcae_host %>
+     designerPort: <%= @dcae_port %>
+     designerPath: <%= @dcae_path %>
+     designerStateUrl: <%= @dcae_state_url %>
+     designerProtocol: <%= @dcae_protocol %>
+     designerButtonLocation: <%= @dcae_button_location %>
+     designerTabPresentation: <%= @dcae_tab_presentation %>
+   - displayName: WORKFLOW
+     designerHost: <%= @workflow_host %>
+     designerPort: <%= @workflow_port %>
+     designerPath: <%= @workflow_path %>
+     designerStateUrl: <%= @workflow_state_url %>
+     designerProtocol: <%= @workflow_protocol %>
+     designerButtonLocation: <%= @workflow_button_location %>
+     designerTabPresentation: <%= @workflow_tab_presentation %>
\ No newline at end of file