2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 /*********** DEPRECATED -- replaced by prop assignments */
22 // import * as _ from "lodash";
23 // import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model";
24 // import {ComponentInstance, InstancesInputsOrPropertiesMapData, Resource, PropertyModel, InputModel} from "app/models";
25 // import {ModalsHandler} from "app/utils";
27 // export interface IInputsViewModelScope extends IWorkspaceViewModelScope {
28 // InstanceInputsProperties:InstancesInputsOrPropertiesMapData; //this is tha map object that hold the selected inputs and the inputs we already used
29 // vfInstancesList:Array<ComponentInstance>;
30 // component:Resource;
32 // onArrowPressed():void;
33 // getInputPropertiesForInstance(instanceId:string, instance:ComponentInstance):ng.IPromise<boolean> ;
34 // loadInputPropertiesForInstance(instanceId:string, input:InputModel):ng.IPromise<boolean> ;
35 // openEditValueModal(input:InputModel):void;
36 // openEditPropertyModal(property:PropertyModel):void;
39 // export class ResourceInputsViewModel {
41 // static '$inject' = [
47 // constructor(private $scope:IInputsViewModelScope, private $q:ng.IQService, private ModalsHandler:ModalsHandler) {
51 // private initScope = ():void => {
53 // this.$scope.InstanceInputsProperties = new InstancesInputsOrPropertiesMapData();
54 // this.$scope.vfInstancesList = this.$scope.component.componentInstances;
56 // // Need to cast all inputs to InputModel for the search to work
57 // let tmpInputs:Array<InputModel> = new Array<InputModel>();
58 // _.each(this.$scope.component.inputs, (input):void => {
59 // tmpInputs.push(new InputModel(input));
61 // this.$scope.component.inputs = tmpInputs;
62 // // This function is not supported for resource
63 // //this.$scope.component.getComponentInputs();
66 // * When clicking on instance input in the left or right table, this function will load all properties of the selected input
68 // this.$scope.getInputPropertiesForInstance = (instanceId:string, instance:ComponentInstance):ng.IPromise<boolean> => {
69 // let deferred = this.$q.defer<boolean>();
70 // instance.properties = this.$scope.component.componentInstancesProperties[instanceId];
71 // deferred.resolve(true);
72 // return deferred.promise;
76 // * When clicking on instance input in the left or right table, this function will load all properties of the selected input
78 // this.$scope.loadInputPropertiesForInstance = (instanceId:string, input:InputModel):ng.IPromise<boolean> => {
79 // let deferred = this.$q.defer<boolean>();
81 // let onSuccess = (properties:Array<PropertyModel>) => {
82 // input.properties = properties;
83 // deferred.resolve(true);
86 // let onError = () => {
87 // deferred.resolve(false)
90 // if (!input.properties) {
91 // this.$scope.component.getComponentInstanceInputProperties(instanceId, input.uniqueId).then(onSuccess, onError);
93 // deferred.resolve(true);
95 // return deferred.promise;
99 // * When pressing the arrow, we create service inputs from the inputs selected
101 // this.$scope.onArrowPressed = ():void => {
102 // let onSuccess = (inputsCreated:Array<InputModel>) => {
104 // //disabled all the inputs in the left table
105 // _.forEach(this.$scope.InstanceInputsProperties, (properties:Array<PropertyModel>) => {
106 // _.forEach(properties, (property:PropertyModel) => {
107 // property.isAlreadySelected = true;
111 // // Adding color to the new inputs (right table)
112 // _.forEach(inputsCreated, (input) => {
113 // input.isNew = true;
116 // // Removing color to the new inputs (right table)
117 // setTimeout(() => {
118 // _.forEach(inputsCreated, (input) => {
119 // input.isNew = false;
121 // this.$scope.$apply();
125 // this.$scope.component.createInputsFormInstances(this.$scope.InstanceInputsProperties).then(onSuccess);
128 // this.$scope.openEditValueModal = (input:InputModel) => {
129 // this.ModalsHandler.openEditInputValueModal(input);
132 // this.$scope.openEditPropertyModal = (property:PropertyModel):void => {
133 // this.ModalsHandler.openEditPropertyModal(property, this.$scope.component, this.$scope.component.componentInstancesProperties[property.resourceInstanceUniqueId], false).then(() => {