summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-ui/src/app/models')
-rw-r--r--catalog-ui/src/app/models/components/component.ts21
-rw-r--r--catalog-ui/src/app/models/components/resource.ts23
-rw-r--r--catalog-ui/src/app/models/graph/nodes/base-common-node.ts3
-rw-r--r--catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts24
-rw-r--r--catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts3
-rw-r--r--catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts3
-rw-r--r--catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts3
-rw-r--r--catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts3
-rw-r--r--catalog-ui/src/app/models/modal.ts4
-rw-r--r--catalog-ui/src/app/models/server-error-response.ts84
10 files changed, 139 insertions, 32 deletions
diff --git a/catalog-ui/src/app/models/components/component.ts b/catalog-ui/src/app/models/components/component.ts
index 9b2c942483..53e8f05cbe 100644
--- a/catalog-ui/src/app/models/components/component.ts
+++ b/catalog-ui/src/app/models/components/component.ts
@@ -923,16 +923,17 @@ export abstract class Component implements IComponent {
}
public toJSON = ():any => {
- this.componentService = undefined;
- this.filterTerm = undefined;
- this.iconSprite = undefined;
- this.mainCategory = undefined;
- this.subCategory = undefined;
- this.selectedInstance = undefined;
- this.showMenu = undefined;
- this.$q = undefined;
- this.selectedCategory = undefined;
- return this;
+ let temp = angular.copy(this);
+ temp.componentService = undefined;
+ temp.filterTerm = undefined;
+ temp.iconSprite = undefined;
+ temp.mainCategory = undefined;
+ temp.subCategory = undefined;
+ temp.selectedInstance = undefined;
+ temp.showMenu = undefined;
+ temp.$q = undefined;
+ temp.selectedCategory = undefined;
+ return temp;
};
}
diff --git a/catalog-ui/src/app/models/components/resource.ts b/catalog-ui/src/app/models/components/resource.ts
index 138b413028..cd839786c5 100644
--- a/catalog-ui/src/app/models/components/resource.ts
+++ b/catalog-ui/src/app/models/components/resource.ts
@@ -163,17 +163,18 @@ export class Resource extends Component {
};
public toJSON = ():any => {
- this.componentService = undefined;
- this.filterTerm = undefined;
- this.iconSprite = undefined;
- this.mainCategory = undefined;
- this.subCategory = undefined;
- this.selectedInstance = undefined;
- this.showMenu = undefined;
- this.$q = undefined;
- this.selectedCategory = undefined;
- this.importedFile = undefined;
- return this;
+ let temp = angular.copy(this);
+ temp.componentService = undefined;
+ temp.filterTerm = undefined;
+ temp.iconSprite = undefined;
+ temp.mainCategory = undefined;
+ temp.subCategory = undefined;
+ temp.selectedInstance = undefined;
+ temp.showMenu = undefined;
+ temp.$q = undefined;
+ temp.selectedCategory = undefined;
+ temp.importedFile = undefined;
+ return temp;
};
}
diff --git a/catalog-ui/src/app/models/graph/nodes/base-common-node.ts b/catalog-ui/src/app/models/graph/nodes/base-common-node.ts
index 153a18225d..fb43f46bbd 100644
--- a/catalog-ui/src/app/models/graph/nodes/base-common-node.ts
+++ b/catalog-ui/src/app/models/graph/nodes/base-common-node.ts
@@ -27,7 +27,8 @@ export abstract class CommonNodeBase {
public displayName:string;
public name:string;
- public img:string;
+ public img: string;
+ public imgWidth: number;
public certified:boolean;
public isGroup:boolean;
public imagesPath:string;
diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts
index 1e4a735a53..681cebc8d2 100644
--- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts
+++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-base.ts
@@ -21,7 +21,7 @@
import {ComponentInstance} from "../../../componentsInstances/componentInstance";
import {CommonCINodeBase} from "../common-ci-node-base";
import {ImageCreatorService} from "app/directives/graphs-v2/image-creator/image-creator.service";
-import {ImagesUrl} from "app/utils";
+import {ImagesUrl, GraphUIObjects} from "app/utils";
import {AngularJSBridge} from "app/services";
export interface ICompositionCiNodeBase {
@@ -51,13 +51,27 @@ export abstract class CompositionCiNodeBase extends CommonCINodeBase implements
}
- public initImage(node:Cy.Collection):string {
-
+ public initUncertifiedImage(node:Cy.Collection, nodeMinSize:number):string {
+
+ let uncertifiedIconWidth:number = GraphUIObjects.HANDLE_SIZE;
+ let nodeWidth:number = node.data('imgWidth') || node.width();
+ let uncertifiedCanvasWidth: number = nodeWidth;
+
+ if (nodeWidth < nodeMinSize) { //uncertified icon will overlap too much of the node, need to expand canvas.
+ uncertifiedCanvasWidth = nodeWidth + uncertifiedIconWidth/2; //expand canvas so that only half of the icon overlaps with the node
+ }
+
this.imageCreator.getImageBase64(this.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png',
- this.imagesPath + ImagesUrl.RESOURCE_ICONS + 'uncertified.png')
+ this.imagesPath + ImagesUrl.RESOURCE_ICONS + 'uncertified.png', nodeWidth, uncertifiedCanvasWidth, uncertifiedIconWidth)
.then(imageBase64 => {
this.img = imageBase64;
- node.style({'background-image': this.img});
+ node.style({
+ 'background-image': this.img,
+ 'background-width': uncertifiedCanvasWidth,
+ 'background-height': uncertifiedCanvasWidth,
+ 'width': uncertifiedCanvasWidth,
+ 'height': uncertifiedCanvasWidth
+ });
});
return this.img;
diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts
index 85534c78de..cded0ea104 100644
--- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts
+++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-cp.ts
@@ -22,7 +22,7 @@ import {CompositionCiNodeBase} from "./composition-ci-node-base";
import {ComponentInstance} from "../../../componentsInstances/componentInstance";
import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service";
import {AngularJSBridge} from "../../../../services/angular-js-bridge-service";
-import {ImagesUrl} from "../../../../utils/constants";
+import { ImagesUrl, GraphUIObjects} from "../../../../utils/constants";
export class CompositionCiNodeCp extends CompositionCiNodeBase {
@@ -35,6 +35,7 @@ export class CompositionCiNodeCp extends CompositionCiNodeBase {
private initCp():void {
let sdcConfig = AngularJSBridge.getAngularConfig();
this.img = sdcConfig.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png';
+ this.imgWidth = GraphUIObjects.SMALL_RESOURCE_WIDTH;
this.type = "basic-small-node";
//if the cp from type cpEndPointInstances create with another template
if (sdcConfig.cpEndPointInstances.indexOf(this.componentInstance.icon) > -1) {
diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts
index 3a9b8457fd..81ee61a14f 100644
--- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts
+++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-service.ts
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-import {ImagesUrl} from "../../../../utils/constants";
+import { ImagesUrl, GraphUIObjects} from "../../../../utils/constants";
import {ComponentInstance, CompositionCiNodeBase} from "../../../../models";
import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service";
export class CompositionCiNodeService extends CompositionCiNodeBase {
@@ -32,6 +32,7 @@ export class CompositionCiNodeService extends CompositionCiNodeBase {
private initService():void {
this.img = this.imagesPath + ImagesUrl.SERVICE_ICONS + this.componentInstance.icon + '.png';
+ this.imgWidth = GraphUIObjects.DEFAULT_RESOURCE_WIDTH;
this.classes = 'service-node'
if (!this.certified) {
this.classes = this.classes + ' not-certified';
diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts
index 5d37db30fc..005804c11f 100644
--- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts
+++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vf.ts
@@ -20,7 +20,7 @@
import {CompositionCiNodeBase} from "./composition-ci-node-base";
import {ComponentInstance} from "../../../componentsInstances/componentInstance";
import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service";
-import {ImagesUrl} from "../../../../utils/constants";
+import { ImagesUrl, GraphUIObjects} from "../../../../utils/constants";
export class CompositionCiNodeVf extends CompositionCiNodeBase {
@@ -32,6 +32,7 @@ export class CompositionCiNodeVf extends CompositionCiNodeBase {
private initVf():void {
this.img = this.imagesPath + ImagesUrl.RESOURCE_ICONS + this.componentInstance.icon + '.png';
+ this.imgWidth = GraphUIObjects.DEFAULT_RESOURCE_WIDTH;
this.classes = 'vf-node';
if (!this.certified) {
this.classes = this.classes + ' not-certified';
diff --git a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts
index db46e48ad7..bf52ec0408 100644
--- a/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts
+++ b/catalog-ui/src/app/models/graph/nodes/composition-graph-nodes/composition-ci-node-vl.ts
@@ -20,7 +20,7 @@
import {ComponentInstance} from "../../../componentsInstances/componentInstance";
import {ImageCreatorService} from "../../../../directives/graphs-v2/image-creator/image-creator.service";
import {CompositionCiNodeBase} from "./composition-ci-node-base";
-import {ImagesUrl} from "../../../../utils/constants";
+import { ImagesUrl, GraphUIObjects} from "../../../../utils/constants";
export class CompositionCiNodeVl extends CompositionCiNodeBase {
private toolTipText:string;
@@ -47,6 +47,7 @@ export class CompositionCiNodeVl extends CompositionCiNodeBase {
}
}
this.img = this.imagesPath + ImagesUrl.RESOURCE_ICONS + 'vl.png';
+ this.imgWidth = GraphUIObjects.SMALL_RESOURCE_WIDTH;
this.classes = 'vl-node';
if (!this.certified) {
diff --git a/catalog-ui/src/app/models/modal.ts b/catalog-ui/src/app/models/modal.ts
index 51aa5e19a7..b7bdf251fe 100644
--- a/catalog-ui/src/app/models/modal.ts
+++ b/catalog-ui/src/app/models/modal.ts
@@ -5,12 +5,14 @@ export class ModalModel {
title: string;
content: any;
buttons: Array<ButtonModel>;
+ type: string; 'standard|error|alert'
- constructor(size?: string, title?: string, content?: any, buttons?: Array<ButtonModel>) {
+ constructor(size?: string, title?: string, content?: any, buttons?: Array<ButtonModel>, type?:string) {
this.size = size;
this.title = title;
this.content = content;
this.buttons = buttons;
+ this.type = type || 'standard';
}
}
diff --git a/catalog-ui/src/app/models/server-error-response.ts b/catalog-ui/src/app/models/server-error-response.ts
new file mode 100644
index 0000000000..61d09af48b
--- /dev/null
+++ b/catalog-ui/src/app/models/server-error-response.ts
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+/**
+ * Created by ngordon on 7/27/2017.
+ */
+
+import { Response } from '@angular/http';
+import { SEVERITY, ServerErrors } from "../utils/constants";
+
+export class ServerErrorResponse {
+
+ title: string;
+ message: string;
+ messageId: string;
+ status: number;
+ severity: SEVERITY;
+
+ constructor(response?: Response) {
+
+ if (response) {
+ let rejectionObj: any = {};
+ if (response.text().length) {
+ let rejection = response.json();
+ rejectionObj = rejection.serviceException || rejection.requestError && (rejection.requestError.serviceException || rejection.requestError.policyException);
+ rejectionObj.text = this.getFormattedMessage(rejectionObj.text || ServerErrors.MESSAGE_ERROR, rejectionObj.variables);
+ }
+
+ this.title = ServerErrors.ERROR_TITLE;
+ this.message = rejectionObj.text || response.statusText || ServerErrors.DEFAULT_ERROR;
+ this.messageId = rejectionObj.messageId;
+ this.status = response.status;
+ this.severity = SEVERITY.ERROR;
+ }
+ }
+
+
+ private getFormattedMessage = (text: string, variables: Array<string>): string => { //OLD CODE
+ // Remove the "Error: " text at the begining
+ if (text.trim().indexOf("Error:") === 0) {
+ text = text.replace("Error:", "").trim();
+ }
+
+ //mshitrit DE199895 bug fix
+ let count: number = 0;
+ variables.forEach(function (item) {
+ variables[count] = item ? item.replace('<', '&lt').replace('>', '&gt') : '';
+ count++;
+ });
+
+ // Format the message in case has array to <ul><li>
+ text = text.replace(/\[%(\d+)\]/g, function (_, m) {
+ let tmp = [];
+ let list = variables[--m].split(";");
+ list.forEach(function (item) {
+ tmp.push("<li>" + item + "</li>");
+ });
+ return "<ul>" + tmp.join("") + "</ul>";
+ });
+
+ // Format the message %1 %2
+ text = text.format(variables);
+
+ return text;
+
+ };
+} \ No newline at end of file