Merge "adding tour-guide to package dashboard"
[ccsdk/cds.git] / cds-ui / designer-client / src / app / modules / feature-modules / packages / package-creation / package-creation.service.ts
index cac2712..952fea3 100644 (file)
@@ -26,6 +26,7 @@ import {ApiService} from '../../../../common/core/services/api.service';
 import {BlueprintURLs, ResourceDictionaryURLs} from '../../../../common/constants/app-constants';
 import {PackagesApiService} from '../packages-api.service';
 import {PackagesStore} from '../packages.store';
+import {ResourceDictionary} from './mapping-models/ResourceDictionary.model';
 
 @Injectable({
     providedIn: 'root'
@@ -40,6 +41,10 @@ export class PackageCreationService {
         return this.api.post(BlueprintURLs.save, body, {responseType: 'text'});
     }
 
+    private enrichBlueprint(body: any | null, options?: any): Observable<any> {
+        return this.api.post(BlueprintURLs.enrich, body, {responseType: 'text'});
+    }
+
     async checkBluePrintNameAndVersion(name: string, version: string): Promise<boolean> {
         return await this.packagesListService.checkBluePrintIfItExists(name, version)
             .then(bluePrintModelsResult => bluePrintModelsResult != null && bluePrintModelsResult.length > 0);
@@ -50,19 +55,22 @@ export class PackageCreationService {
     }
 
     savePackage(blob) {
+        const formData = this.getFormData(blob);
+        return this.saveBlueprint(formData);
+    }
+
+    enrichPackage(blob) {
+        const formData = this.getFormData(blob);
+        return this.enrichBlueprint(formData);
+    }
 
+    private getFormData(blob) {
         const formData = new FormData();
         formData.append('file', blob);
-        this.saveBlueprint(formData)
-            .subscribe(
-                data => {
-                    console.log('Success:' + JSON.stringify(data));
-                }, error => {
-                    console.log('Error -' + error.message);
-                });
+        return formData;
     }
 
-    getTemplateAndMapping(variables: string[]): Observable<any> {
+    getTemplateAndMapping(variables: string[]): Observable<ResourceDictionary[]> {
         return this.api.post(ResourceDictionaryURLs.searchResourceDictionaryByNames, variables);
     }
 }