Add icon beside the selected templates in Function attributes tab 49/116749/1
authorAhmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Tue, 12 Jan 2021 11:07:45 +0000 (13:07 +0200)
committerAhmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Tue, 12 Jan 2021 11:07:45 +0000 (13:07 +0200)
update create_resource_dictionary API

Issue-ID: CCSDK-3082
Issue-ID: CCSDK-3078

Signed-off-by: Ahmedeldeeb50 <ahmed.eldeeb.ext@orange.com>
Change-Id: Ic5038dfba0c7b59c5e51096b9864aa0baff56c2b

cds-ui/designer-client/src/app/common/constants/app-constants.ts
cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.html
cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/dictionary-creation.service.ts
cds-ui/designer-client/src/app/modules/feature-modules/resource-dictionary/resource-dictionary-creation/resource-dictionary-creation.component.ts
cds-ui/server/src/controllers/data-dictionary.controller.ts
cds-ui/server/src/datasources/resource-dictionary.datasource-template.ts
cds-ui/server/src/services/resource-dictionary.service.ts

index 51b1836..6f64ee1 100644 (file)
@@ -25,63 +25,63 @@ export const GlobalContants = {
     endpoints: {},
     cbawizard: {
         stepsRequired:
+        {
+            stepCount: 4,
+            steps: [{
+                name: 'CBA Metadata',
+                componentURL: '/controllerBlueprint/selectTemplate',
+                label: 'CBA Metadata',
+                link: '/blueprint/selectTemplate',
+                index: 0,
+                component: 'SelectTemplateComponent'
+            },
             {
-                stepCount: 4,
-                steps: [{
-                    name: 'CBA Metadata',
-                    componentURL: '/controllerBlueprint/selectTemplate',
-                    label: 'CBA Metadata',
-                    link: '/blueprint/selectTemplate',
-                    index: 0,
-                    component: 'SelectTemplateComponent'
-                },
-                    {
-                        name: 'Controller Blueprint Designer',
-                        componentURL: '/controllerBlueprint/modifyTemplate',
-                        label: 'Controller Blueprint Designer',
-                        link: '/blueprint/modifyTemplate',
-                        index: 1,
-                        component: 'ModifyTemplateComponent'
-                    },
-                    {
-                        name: 'Test',
-                        componentURL: '/controllerBlueprint/testTemplate',
-                        label: 'Test',
-                        link: '/blueprint/testTemplate',
-                        index: 2,
-                        component: 'TestTemplateComponent'
-                    },
-                    {
-                        name: 'Deploy',
-                        componentURL: '/controllerBlueprint/deployTemplate',
-                        label: 'Deploy',
-                        link: '/blueprint/deployTemplate',
-                        index: 3,
-                        component: 'DeployTemplateComponent'
-                    }]
-            }
+                name: 'Controller Blueprint Designer',
+                componentURL: '/controllerBlueprint/modifyTemplate',
+                label: 'Controller Blueprint Designer',
+                link: '/blueprint/modifyTemplate',
+                index: 1,
+                component: 'ModifyTemplateComponent'
+            },
+            {
+                name: 'Test',
+                componentURL: '/controllerBlueprint/testTemplate',
+                label: 'Test',
+                link: '/blueprint/testTemplate',
+                index: 2,
+                component: 'TestTemplateComponent'
+            },
+            {
+                name: 'Deploy',
+                componentURL: '/controllerBlueprint/deployTemplate',
+                label: 'Deploy',
+                link: '/blueprint/deployTemplate',
+                index: 3,
+                component: 'DeployTemplateComponent'
+            }]
+        }
     },
     datadictionary: {
         stepsRequired:
-            {
-                stepCount: 3,
-                steps: [{
-                    name: 'Resource Creation', componentURL: '/dataDictionary/selectTemplate',
-                    label: 'Resource Creation',
-                    component: 'ResourceCreationComponent'
+        {
+            stepCount: 3,
+            steps: [{
+                name: 'Resource Creation', componentURL: '/dataDictionary/selectTemplate',
+                label: 'Resource Creation',
+                component: 'ResourceCreationComponent'
 
-                },
-                    {
-                        name: 'Edit/Validate', componentURL: '/dataDictionary/modifyTemplate',
-                        label: 'Edit/Validate',
-                        component: 'ResourceEditComponent'
-                    },
-                    {
-                        name: 'Save', componentURL: '/dataDictionary/saveTemplate',
-                        label: 'Save Resource',
-                        component: 'SaveResourceComponent'
-                    }]
-            }
+            },
+            {
+                name: 'Edit/Validate', componentURL: '/dataDictionary/modifyTemplate',
+                label: 'Edit/Validate',
+                component: 'ResourceEditComponent'
+            },
+            {
+                name: 'Save', componentURL: '/dataDictionary/saveTemplate',
+                label: 'Save Resource',
+                component: 'SaveResourceComponent'
+            }]
+        }
 
     }
 };
@@ -105,6 +105,7 @@ export const BlueprintURLs = {
 
 export const ResourceDictionaryURLs = {
     saveResourceDictionary: '/resourcedictionary/save',
+    saveDictionary: '/resourcedictionary/definition',
     searchResourceDictionaryByTags: '/resourcedictionary/search',
     searchResourceDictionaryByName: '',
     searchResourceDictionaryByNames: '/resourcedictionary/search/by-names',
index e619f3a..a3e662d 100644 (file)
                 <div class="row">
                     <div class="col-6" *ngFor="let file of  getKeys(templateAndMappingMap)">
                         <a class="template-mapping-list float" [class.active]="selectedTemplates.has(file)">
+                            <i *ngIf="selectedTemplates.has(file)" class="fa fa-check mx-1"></i>
                             <p (click)="setTemplate(file)">{{file}}</p>
                             <span *ngIf="getValue(file,templateAndMappingMap).isMapping">Mapping</span>
                             <span *ngIf="getValue(file,templateAndMappingMap).isTemplate">Template</span>
             </div>
         </div>
     </div>
-</div>
+</div>
\ No newline at end of file
index c406797..fb454ed 100644 (file)
@@ -25,6 +25,7 @@ import { Definition } from '../model/definition.model';
 import { DictionaryMetadataComponent } from './dictionary-metadata/dictionary-metadata.component';
 import { SourcesTemplateComponent } from './sources-template/sources-template.component';
 import { DictionaryCreationService } from './dictionary-creation.service';
+import { ToastrService } from 'ngx-toastr';
 
 @Component({
   selector: 'app-resource-dictionary-creation',
@@ -36,7 +37,8 @@ export class ResourceDictionaryCreationComponent implements OnInit {
   constructor(
     private router: Router,
     private dictionaryCreationStore: DictionaryCreationStore,
-    private dictionaryService: DictionaryCreationService
+    private dictionaryService: DictionaryCreationService,
+    private toaster: ToastrService
   ) {
   }
 
@@ -72,17 +74,20 @@ export class ResourceDictionaryCreationComponent implements OnInit {
   }
 
   createDictionary() {
+
     console.log('-----');
     this.metadataTabComponent.saveMetaDataToStore();
     this.dictionaryCreationStore.state$.subscribe(res => {
       console.log('---------------------------------------');
       console.log(res);
       this.dictionaryService.save(res.metaData).subscribe(data => {
-
+        this.toaster.success('Dictionary Resource created');
       }, err => {
+        this.toaster.error('An error happened ...');
+      }, () => {
 
       });
-    });
+    }).unsubscribe();
     // this.sourcesTemplateComponent.saveSorcesDataToStore();
   }
 
index 076d714..8dbb7eb 100644 (file)
@@ -64,13 +64,28 @@ export class DataDictionaryController {
       }
     },
   })
+  async saveDefinition(@requestBody({
+    content: { 'application/json': { schema: { 'x-ts-type': JSON } } },
+    accepts: { 'application/json': { schema: { 'x-ts-type': JSON } } }
+  }) resourceDictionary: JSON): Promise<any> {
+    return await this.rdservice.saveDefinition(resourceDictionary);
+  }
+
+  @post('/resourcedictionary/definition', {
+    responses: {
+      '200': {
+        content: { 'application/json': {} }
+      }
+    },
+  })
   async save(@requestBody({
     content: { 'application/json': { schema: { 'x-ts-type': JSON } } },
     accepts: { 'application/json': { schema: { 'x-ts-type': JSON } } }
   }) resourceDictionary: JSON): Promise<any> {
-    return await this.rdservice.save(resourceDictionary);
+    return await this.rdservice.saveDefinition(resourceDictionary);
   }
-  
+
+
   @post('/resourcedictionary/search/by-names', {
     responses: {
       '200': {
@@ -114,7 +129,7 @@ export class DataDictionaryController {
   @get('/resourcedictionary/model-type/by-definition/{type}', {
     responses: {
       '200': {
-        content: {'application/json': {}},
+        content: { 'application/json': {} },
       },
     },
   })
index 7373d06..07faa9a 100644 (file)
@@ -1,4 +1,4 @@
-import {processorApiConfig} from '../config/app-config';
+import { processorApiConfig } from '../config/app-config';
 
 export default {
     "name": "resourceDictionary",
@@ -7,134 +7,151 @@ export default {
     "crud": false,
     "debug": true,
     "operations": [{
-            "template": {
-                "method": "GET",
-                "url": processorApiConfig.http.url + "/dictionary/{name}",
-                "headers": {
-                    "accepts": "application/json",
-                    "content-type": "application/json",
-                    "authorization": processorApiConfig.http.authToken
-                },
-                "responsePath": "$.*"
+        "template": {
+            "method": "GET",
+            "url": processorApiConfig.http.url + "/dictionary/{name}",
+            "headers": {
+                "accepts": "application/json",
+                "content-type": "application/json",
+                "authorization": processorApiConfig.http.authToken
             },
-            "functions": {
-                "getByName": ["name"]
-
-            }
+            "responsePath": "$.*"
         },
-        {
-            "template": {
-                "method": "GET",
-                "url": processorApiConfig.http.url + "/dictionary/source-mapping",
-                "headers": {
-                    "accepts": "application/json",
-                    "content-type": "application/json",
-                    "authorization": processorApiConfig.http.authToken
-                },
-                "responsePath": "$.*"
-            },
-            "functions": {
-                "getSourceMapping": []
+        "functions": {
+            "getByName": ["name"]
 
-            }
-        },
-        {
-            "template": {
-                "method": "GET",
-                "url": processorApiConfig.http.url + "/dictionary/search/{tags}",
-                "headers": {
-                    "accepts": "application/json",
-                    "content-type": "application/json",
-                    "authorization": processorApiConfig.http.authToken
-                },
-                "responsePath": "$.*"
+        }
+    },
+    {
+        "template": {
+            "method": "GET",
+            "url": processorApiConfig.http.url + "/dictionary/source-mapping",
+            "headers": {
+                "accepts": "application/json",
+                "content-type": "application/json",
+                "authorization": processorApiConfig.http.authToken
             },
-            "functions": {
-                "getByTags": ["tags"]
-
-            }
+            "responsePath": "$.*"
         },
-        {
-            "template": {
-                "method": "POST",
-                "url": processorApiConfig.http.url + "/dictionary",
-                "headers": {
-                    "accepts": "application/json",
-                    "content-type": "application/json",
-                    "authorization": processorApiConfig.http.authToken
-                },
-                "body": "{resourceDictionary}",
-                "responsePath": "$.*"
-            },
-            "functions": {
-                "save": ["resourceDictionary"]
+        "functions": {
+            "getSourceMapping": []
 
-            }
-        },
-        {
-            "template": {
-                "method": "POST",
-                "url": processorApiConfig.http.url + "/dictionary/by-names",
-                "headers": {
-                    "accepts": "application/json",
-                    "content-type": "application/json",
-                    "authorization": processorApiConfig.http.authToken
-                },
-                "body": "{resourceDictionaryList}",
-                "responsePath": "$.*"
+        }
+    },
+    {
+        "template": {
+            "method": "GET",
+            "url": processorApiConfig.http.url + "/dictionary/search/{tags}",
+            "headers": {
+                "accepts": "application/json",
+                "content-type": "application/json",
+                "authorization": processorApiConfig.http.authToken
             },
-            "functions": {
-                "searchbyNames": ["resourceDictionaryList"]
+            "responsePath": "$.*"
+        },
+        "functions": {
+            "getByTags": ["tags"]
 
-            }
+        }
+    },
+    {
+        "template": {
+            "method": "POST",
+            "url": processorApiConfig.http.url + "/dictionary",
+            "headers": {
+                "accepts": "application/json",
+                "content-type": "application/json",
+                "authorization": processorApiConfig.http.authToken
+            },
+            "body": "{resourceDictionary}",
+            "responsePath": "$.*"
         },
-        {
-            "template": {
-                "method": "GET",
-                "url": processorApiConfig.http.url + "/model-type/{source}",
-                "headers": {
-                    "accepts": "application/json",
-                    "content-type": "application/json",
-                    "authorization": processorApiConfig.http.authToken
-                },
-                "responsePath": "$.*"
+        "functions": {
+            "save": ["resourceDictionary"]
+
+        }
+    },
+    {
+        "template": {
+            "method": "POST",
+            "url": processorApiConfig.http.url + "/dictionary/definition",
+            "headers": {
+                "accepts": "application/json",
+                "content-type": "application/json",
+                "authorization": processorApiConfig.http.authToken
             },
-            "functions": {
-                "getModelType": ["source"]
+            "body": "{resourceDictionary}",
+            "responsePath": "$.*"
+        },
+        "functions": {
+            "saveDefinition": ["resourceDictionary"]
 
-            }
+        }
+    },
+    {
+        "template": {
+            "method": "POST",
+            "url": processorApiConfig.http.url + "/dictionary/by-names",
+            "headers": {
+                "accepts": "application/json",
+                "content-type": "application/json",
+                "authorization": processorApiConfig.http.authToken
+            },
+            "body": "{resourceDictionaryList}",
+            "responsePath": "$.*"
         },
-        {
-            "template": {
-                "method": "GET",
-                "url": processorApiConfig.http.url + "/model-type/by-definition/data_type",
-                "headers": {
-                    "accepts": "application/json",
-                    "content-type": "application/json",
-                    "authorization": processorApiConfig.http.authToken
-                },
-                "responsePath": "$.*"
+        "functions": {
+            "searchbyNames": ["resourceDictionaryList"]
+
+        }
+    },
+    {
+        "template": {
+            "method": "GET",
+            "url": processorApiConfig.http.url + "/model-type/{source}",
+            "headers": {
+                "accepts": "application/json",
+                "content-type": "application/json",
+                "authorization": processorApiConfig.http.authToken
             },
-            "functions": {
-                "getDataTypes": []
+            "responsePath": "$.*"
+        },
+        "functions": {
+            "getModelType": ["source"]
 
-            }
+        }
+    },
+    {
+        "template": {
+            "method": "GET",
+            "url": processorApiConfig.http.url + "/model-type/by-definition/data_type",
+            "headers": {
+                "accepts": "application/json",
+                "content-type": "application/json",
+                "authorization": processorApiConfig.http.authToken
+            },
+            "responsePath": "$.*"
         },
-        {
-            "template": {
-                "method": "GET",
-                "url": processorApiConfig.http.url + "/model-type/by-definition/{type}",
-                "headers": {
-                    "accepts": "application/json",
-                    "content-type": "application/json",
-                    "authorization": processorApiConfig.http.authToken
-                },
-                "responsePath": "$.*"
+        "functions": {
+            "getDataTypes": []
+
+        }
+    },
+    {
+        "template": {
+            "method": "GET",
+            "url": processorApiConfig.http.url + "/model-type/by-definition/{type}",
+            "headers": {
+                "accepts": "application/json",
+                "content-type": "application/json",
+                "authorization": processorApiConfig.http.authToken
             },
-            "functions": {
-                "getResourceDictionaryByType": ["type"]
+            "responsePath": "$.*"
+        },
+        "functions": {
+            "getResourceDictionaryByType": ["type"]
 
-            }
         }
+    }
     ]
 };
index a36c7fe..6bf3f06 100644 (file)
@@ -1,12 +1,13 @@
-import {getService} from '@loopback/service-proxy';
-import {inject, Provider} from '@loopback/core';
-import {ResourceDictionaryDataSource} from '../datasources';
+import { getService } from '@loopback/service-proxy';
+import { inject, Provider } from '@loopback/core';
+import { ResourceDictionaryDataSource } from '../datasources';
 
 export interface ResourceDictionaryService {
   getByName(name: string): Promise<JSON>;
   getSourceMapping(): Promise<JSON>;
   getByTags(tags: string): Promise<JSON>;
   save(resourceDictionary: JSON): Promise<JSON>;
+  saveDefinition(resourceDictionary: JSON): Promise<JSON>;
   searchbyNames(resourceDictionaryList: JSON): Promise<JSON>;
   getModelType(source: string): Promise<JSON>;
   getDataTypes(): Promise<JSON>;
@@ -18,7 +19,7 @@ export class ResourceDictionaryServiceProvider implements Provider<ResourceDicti
     // resourceDictionary must match the name property in the datasource json file
     @inject('datasources.resourceDictionary')
     protected dataSource: ResourceDictionaryDataSource = new ResourceDictionaryDataSource(),
-  ) {}
+  ) { }
 
   value(): Promise<ResourceDictionaryService> {
     return getService(this.dataSource);