aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/view-models/workspace
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-08-10 12:08:45 +0300
committerMichael Lando <ml636r@att.com>2017-08-10 12:08:45 +0300
commit46f9fd57f24428f6a6fd0d290b0463e188975231 (patch)
tree7805037b80cbabf61bafc719e2d63b0dfff8f751 /catalog-ui/src/app/view-models/workspace
parent7f7925e39cf2f428061d161bc4ffe67cad80c76e (diff)
[SDC] code sync
Change-Id: Ia33a7874802b8ac2f49aed9199e109ea509e950e Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/src/app/view-models/workspace')
-rw-r--r--catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts56
1 files changed, 42 insertions, 14 deletions
diff --git a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
index 98539d6a3b..48fc9dbb42 100644
--- a/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
+++ b/catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
@@ -21,9 +21,10 @@
'use strict';
import {ModalsHandler, ValidationUtils, EVENTS, CHANGE_COMPONENT_CSAR_VERSION_FLAG, ComponentType, DEFAULT_ICON,
ResourceType} from "app/utils";
-import {CacheService, EventListenerService, ProgressService} from "app/services";
-import {IAppConfigurtaion, IValidate, IMainCategory, Resource, ISubCategory,Service} from "app/models";
+import {CacheService, EventListenerService, ProgressService, OnboardingService} from "app/services";
+import {IAppConfigurtaion, IValidate, IMainCategory, Resource, ISubCategory,Service, ICsarComponent} from "app/models";
import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model";
+import {Dictionary} from "lodash";
export class Validation {
componentNameValidationPattern:RegExp;
@@ -91,7 +92,8 @@ export class GeneralViewModel {
'Sdc.Services.ProgressService',
'$interval',
'$filter',
- '$timeout'
+ '$timeout',
+ 'Sdc.Services.OnboardingService'
];
constructor(private $scope:IGeneralScope,
@@ -113,7 +115,8 @@ export class GeneralViewModel {
private progressService:ProgressService,
protected $interval:any,
private $filter:ng.IFilterService,
- private $timeout:ng.ITimeoutService) {
+ private $timeout:ng.ITimeoutService,
+ private onBoardingService:OnboardingService) {
this.initScopeValidation();
this.initScopeMethods();
@@ -135,6 +138,40 @@ export class GeneralViewModel {
this.$scope.validation.projectCodeValidationPattern = this.ProjectCodeValidationPattern;
};
+ private initImportedToscaBrowseFile = ():void =>{
+ // Init the decision if to show onboarding
+ this.$scope.isShowOnboardingSelectionBrowse = false;
+ if (this.$scope.component.isResource() &&
+ this.$scope.isEditMode() &&
+ (<Resource>this.$scope.component).resourceType == ResourceType.VF &&
+ (<Resource>this.$scope.component).csarUUID) {
+ this.$scope.isShowOnboardingSelectionBrowse = true;
+ let onboardCsarFilesMap:Dictionary<string> = this.cacheService.get('onboardCsarFilesMap');
+ // The onboardCsarFilesMap in cache contains map of [packageId]:[vsp display name for brows]
+ // if the map is empty - Do request to BE
+ if(onboardCsarFilesMap) {
+ this.$scope.importedToscaBrowseFileText = onboardCsarFilesMap[(<Resource>this.$scope.component).csarUUID];
+ }
+ if(!onboardCsarFilesMap || !this.$scope.importedToscaBrowseFileText){
+
+ let onSuccess = (vsps:Array<ICsarComponent>): void =>{
+ onboardCsarFilesMap = {};
+ _.each(vsps, (vsp:ICsarComponent)=>{
+ onboardCsarFilesMap[vsp.packageId] = vsp.vspName + " (" + vsp.version + ")";
+ });
+ this.cacheService.set('onboardCsarFilesMap', onboardCsarFilesMap);
+ this.$scope.importedToscaBrowseFileText = onboardCsarFilesMap[(<Resource>this.$scope.component).csarUUID];
+ };
+
+ let onError = (): void =>{
+ console.log("Error getting onboarding list");
+ };
+
+ this.onBoardingService.getOnboardingVSPs().then(onSuccess, onError);
+ }
+ }
+ };
+
private initScope = ():void => {
// Work around to change the csar version
@@ -142,7 +179,6 @@ export class GeneralViewModel {
(<Resource>this.$scope.component).csarVersion = this.cacheService.get(CHANGE_COMPONENT_CSAR_VERSION_FLAG);
}
- this.$scope.importedToscaBrowseFileText = this.$scope.component.name + " (" + (<Resource>this.$scope.component).csarVersion + ")";
this.$scope.importCsarProgressKey = "importCsarProgressKey";
this.$scope.browseFileLabel = this.$scope.component.isResource() && (<Resource>this.$scope.component).resourceType === ResourceType.VF ? "Upload file" : "Upload VFC";
this.$scope.progressService = this.progressService;
@@ -167,16 +203,8 @@ export class GeneralViewModel {
this.$scope.isShowFileBrowse = true;
}
}
- ;
- // Init the decision if to show onboarding
- this.$scope.isShowOnboardingSelectionBrowse = false;
- if (this.$scope.component.isResource() &&
- this.$scope.isEditMode() &&
- (<Resource>this.$scope.component).resourceType == ResourceType.VF &&
- (<Resource>this.$scope.component).csarUUID) {
- this.$scope.isShowOnboardingSelectionBrowse = true;
- }
+ this.initImportedToscaBrowseFile();
//init file extensions based on the file that was imported.
if (this.$scope.component.isResource() && (<Resource>this.$scope.component).importedFile) {