summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml
blob: ad0002d1c5e30f7b68117789beb2d2446eb0278d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.openecomp.sdc.onboarding</groupId>
    <artifactId>action-library-rest</artifactId>
    <name>action-library-rest</name>
    <packaging>pom</packaging>

    <parent>
        <groupId>org.openecomp.sdc</groupId>
        <artifactId>openecomp-sdc-rest-webapp</artifactId>
        <version>1.4.0-SNAPSHOT</version>
        <relativePath>../</relativePath>
    </parent>
    <modules>
        <module>/action-library-rest-services</module>
        <module>/action-library-rest-types</module>
    </modules>
</project>
/ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
import {Injectable} from "@angular/core";
import {ITreeNode} from "angular-tree-component/dist/defs/api";
import * as _ from 'lodash';
import {NgRedux} from "@angular-redux/store";
import {AppState} from "../../../shared/store/reducers";
import {FeatureFlagsService, Features} from "../../../shared/services/featureFlag/feature-flags.service";
import {ServiceInstanceActions} from "../../../shared/models/serviceInstanceActions";

@Injectable()
export class  DrawingBoardTreeService {
  constructor(private store: NgRedux<AppState>){}
  isVFModuleMissingData(node: ITreeNode, serviceModelId : string): boolean {
    if(node.data.type === 'VFmodule' &&!_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs) &&  !_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.parent.data.vnfStoreKey])){
      if(!_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.parent.data.vnfStoreKey].vfModules)
        && !_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.parent.data.vnfStoreKey].vfModules[node.data.modelName])
        && !_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.parent.data.vnfStoreKey].vfModules[node.data.modelName][node.data.dynamicModelName])){

        return this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.parent.data.vnfStoreKey].vfModules[node.data.modelName][node.data.dynamicModelName].isMissingData;
      }
    }
    return false;
  }

  isVNFMissingData(node : ITreeNode, serviceModelId : string) : boolean {
    if(node.data.type == 'VF'  && !_.isNil(this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.data.vnfStoreKey])){
      return  this.store.getState().service.serviceInstance[serviceModelId].vnfs[node.data.vnfStoreKey].isMissingData;
    }
  }

  isViewEditFlagTrue():boolean{
    return FeatureFlagsService.getFlagState(Features.FLAG_1902_NEW_VIEW_EDIT, this.store);
  }

  /**********************************************
   return all drawing board context menu options
   ***********************************************/
  generateContextMenuOptions() : TreeNodeContextMenuModel[]{
    return [
      new TreeNodeContextMenuModel('edit', 'context-menu-edit', 'Edit', 'edit-file-o'),
      new TreeNodeContextMenuModel('duplicate', 'context-menu-duplicate', 'Duplicate', 'copy-o'),
      new TreeNodeContextMenuModel('showAuditInfo', 'context-menu-showAuditInfo', 'Show audit info', 'eye-o'),
      new TreeNodeContextMenuModel('addGroupMember', 'context-menu-addGroupMember', 'Add group members', 'plus'),
      new TreeNodeContextMenuModel('delete', 'context-menu-delete', 'Delete', 'trash-o'),
      new TreeNodeContextMenuModel('remove', 'context-menu-remove', 'Remove', 'trash-o'),
      new TreeNodeContextMenuModel('undoDelete', 'context-menu-undoDelete', 'Undo Delete', 'undo-delete'),
      new TreeNodeContextMenuModel('changeAssociations', 'context-menu-changeAssociations', 'Change Associations', 'edit-file-o')
    ];
  }


  /*******************************************************************
    delete or remove all service child's on delete existing service
   *******************************************************************/
  deleteActionService(nodes : ITreeNode[], serviceModelId : string){
    if(!_.isNil(nodes)){
      for(let node of nodes){
        node.data = node;
        if(!_.isNil(node.children)){
          node.children.map((child)=>{
            child.data = child;
            child.parent = node;
          });
        }

        let menuActionsName : string = node.data.action === ServiceInstanceActions.Create ? 'remove' : 'delete';
        if(!_.isNil(node.data.menuActions) && !_.isNil(node.data.menuActions[menuActionsName])){
          node.data.menuActions[menuActionsName]['method'](node, serviceModelId)
        }

      }
    }
  }
  /*******************************************************************
   undo delete all service child's on undo delete existing service
   *******************************************************************/
  undoDeleteActionService(nodes : ITreeNode[], serviceModelId : string){
    if(!_.isNil(nodes)){
      for(let node of nodes){
        node.data = node;
        if(!_.isNil(node.children)){
          node.children.map((child)=>{
            child.data = child;
            child.parent = node;
          });
        }

        if(!_.isNil(node.data.menuActions) && !_.isNil(node.data.menuActions['undoDelete'])){
          node.data.menuActions['undoDelete']['method'](node, serviceModelId)
        }
      }
    }
  }

  /***********************************************************
   return true if should add line hover the instance name
   ***********************************************************/
  isTextDecoration(node) : boolean{
    return !_.isNil(node.data) && !_.isNil(node.data.action) && node.data.action.split('_').pop() === 'Delete';
  }


  /******************************************
   should create object of instances action
   ******************************************/
  generateServiceActionObject(nodes){
    let obj = {};
    let index = 0;
    for(let node of nodes){
      obj[index] = {};
      index++;
    }
  }
}

export class TreeNodeContextMenuModel {
  methodName: string;
  dataTestId: string;
  label: string;
  iconClass: string;

  constructor(methodName: string,
              dataTestId: string,
              label: string,
              iconClass: string) {
    this.methodName = methodName;
    this.dataTestId = dataTestId;
    this.label = label;
    this.iconClass = iconClass;
  }
}