aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-04-15 10:03:58 +0100
committerChristophe Closset <christophe.closset@intl.att.com>2021-04-19 15:49:05 +0000
commit82ee153edbf6ffca0d69bd450b48037ee0465191 (patch)
treead3892d4f8cdb5f4acd8b905fce10572dc218877 /catalog-ui/src
parentaaf0b66c894b0a05fa3ce6a08a71047909e5a913 (diff)
Fix 'Unable to save changed attributes default value'
Implements missing functionality to save changed attribute Change-Id: I1bc828ef133c8a2bf2fd6333a51fb46fc41b6547 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3562
Diffstat (limited to 'catalog-ui/src')
-rw-r--r--catalog-ui/src/app/ng2/pages/attributes-outputs/attributes-outputs.page.component.ts60
1 files changed, 40 insertions, 20 deletions
diff --git a/catalog-ui/src/app/ng2/pages/attributes-outputs/attributes-outputs.page.component.ts b/catalog-ui/src/app/ng2/pages/attributes-outputs/attributes-outputs.page.component.ts
index d7db8f3c82..f97f8499ea 100644
--- a/catalog-ui/src/app/ng2/pages/attributes-outputs/attributes-outputs.page.component.ts
+++ b/catalog-ui/src/app/ng2/pages/attributes-outputs/attributes-outputs.page.component.ts
@@ -198,7 +198,6 @@ export class AttributesOutputsComponent {
event.preventDefault();
this.showUnsavedChangesAlert().then(() => {
this.$state.go(toState, toParams);
- }, () => {
});
}
});
@@ -390,7 +389,6 @@ export class AttributesOutputsComponent {
this.attributeOutputTabs.triggerTabChange(this.currentMainTab.title);
this.showUnsavedChangesAlert().then(() => {
this.attributeOutputTabs.selectTab(this.attributeOutputTabs.tabs.find((tab) => tab.title === event.title));
- }, () => {
});
return;
}
@@ -451,7 +449,7 @@ export class AttributesOutputsComponent {
let request;
let handleSuccess, handleError;
if (this.isAttributesTabSelected) {
- this.changedData.map((changedAttrib) => {
+ const changedAttribs = this.changedData.map((changedAttrib) => {
changedAttrib = <AttributeFEModel>changedAttrib;
const attribBE = new AttributeBEModel(changedAttrib);
attribBE.toscaPresentation = new ToscaPresentationData();
@@ -461,6 +459,28 @@ export class AttributesOutputsComponent {
delete attribBE.origName;
return attribBE;
});
+
+ if (this.selectedInstanceData instanceof ComponentInstance) {
+ if (this.isSelf()) {
+ console.log("changedAttribs", changedAttribs);
+ request = this.topologyTemplateService.updateServiceAttributes(this.component.uniqueId, _.map(changedAttribs, cp => {
+ delete cp.constraints;
+ return cp;
+ }));
+ } else {
+ request = this.componentInstanceServiceNg2
+ .updateInstanceAttributes(this.component.componentType, this.component.uniqueId, this.selectedInstanceData.uniqueId, changedAttribs);
+ }
+ handleSuccess = (response) => {
+ // reset each changed attribute with new value and remove it from changed attributes list
+ response.forEach((resAttrib) => {
+ const changedAttrib = <AttributeFEModel>this.changedData.shift();
+ this.attributesUtils.resetAttributeValue(changedAttrib, resAttrib.value);
+ });
+ resolve(response);
+ console.log("updated instance attributes: ", response);
+ };
+ }
} else if (this.isOutputsTabSelected) {
const changedOutputs: OutputBEModel[] = this.changedData.map((changedOutput) => {
changedOutput = <OutputFEModel>changedOutput;
@@ -468,8 +488,7 @@ export class AttributesOutputsComponent {
outputBE.defaultValue = changedOutput.getJSONDefaultValue();
return outputBE;
});
- request = this.componentServiceNg2
- .updateComponentOutputs(this.component, changedOutputs);
+ request = this.componentServiceNg2.updateComponentOutputs(this.component, changedOutputs);
handleSuccess = (response) => {
// reset each changed attribute with new value and remove it from changed attributes list
response.forEach((resOutput) => {
@@ -478,23 +497,24 @@ export class AttributesOutputsComponent {
changedOutput.required = resOutput.required;
});
}
- this.savingChangedData = true;
- request.subscribe(
- (response) => {
- this.savingChangedData = false;
- handleSuccess && handleSuccess(response);
- this.updateHasChangedData();
- resolve(response);
- },
- (error) => {
- this.savingChangedData = false;
- handleError && handleError(error);
- this.updateHasChangedData();
- reject(error);
- }
- );
}
+ this.savingChangedData = true;
+ request.subscribe(
+ (response) => {
+ this.savingChangedData = false;
+ handleSuccess && handleSuccess(response);
+ this.updateHasChangedData();
+ resolve(response);
+ },
+ (error) => {
+ this.savingChangedData = false;
+ handleError && handleError(error);
+ this.updateHasChangedData();
+ reject(error);
+ }
+ );
+
});
};