summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/menus/new-menu/new-menu.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/menus/new-menu/new-menu.component.ts')
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/menus/new-menu/new-menu.component.ts267
1 files changed, 267 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/menus/new-menu/new-menu.component.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/menus/new-menu/new-menu.component.ts
new file mode 100644
index 00000000..6e5b0c1a
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/admin/menus/new-menu/new-menu.component.ts
@@ -0,0 +1,267 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2019 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ *
+ */
+
+import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
+import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
+import { AdminService } from '../../admin.service';
+import { SidebarComponent } from 'src/app/layout/components/sidebar/sidebar.component';
+import { Router } from '@angular/router';
+import { SidebarService } from 'src/app/shared/services';
+import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
+import { CookieService } from 'ngx-cookie-service';
+
+@Component({
+ selector: 'app-new-menu',
+ templateUrl: './new-menu.component.html',
+ styleUrls: ['./new-menu.component.scss']
+})
+export class NewMenuComponent implements OnInit {
+
+ menu = {
+ action: null,
+ active: false,
+ activeAsString: "false",
+ auditTrail: null,
+ auditUserId: null,
+ childMenus: [],
+ created: null,
+ createdId: null,
+ externalUrl: null,
+ functionCd: null,
+ id: null,
+ imageSrc: null,
+ label: null,
+ menuLevel: null,
+ menuSetCode: null,
+ modified: null,
+ modifiedId: null,
+ parentId: null,
+ parentIdAsString: null,
+ parentMenu: null,
+ queryString: null,
+ rowNum: null,
+ separator: false,
+ separatorAsString: false,
+ servlet: null,
+ sortOrder: null,
+ target: null
+ }
+ showSpinner: boolean;
+ result: any;
+ //menu: any;
+ @Input() selectedMenu: any;
+ @Input() isEditMode: boolean;
+ @Output() passEntry: EventEmitter<any> = new EventEmitter();
+
+ statusOptions = [
+ {index: 0, value: 'true', title: 'Y'},
+ {index: 1, value: 'false', title: 'N'}
+ ];
+ selectedValue = this.statusOptions[0];
+ separator = {
+ availableOptions:[
+ {value: 'true', name: 'Y'},
+ {value: 'false', name: 'N'}
+ ],
+ selectedOption: {value: 'true', name: 'Y'}
+ }
+
+ activeStatusOptions = [
+ {index: 0, value: 'true', title: 'Y'},
+ {index: 1, value: 'false', title: 'N'}
+ ];
+ activeSelectedValue = this.activeStatusOptions[0];
+
+ separatorStatusOptions = [
+ {index: 0, value: 'true', title: 'Y'},
+ {index: 1, value: 'false', title: 'N'}
+ ];
+ separatorSelectedValue = this.separatorStatusOptions[1];
+
+ active = {
+ availableOptions:[
+ {value: 'true', name: 'Y'},
+ {value: 'false', name: 'N'}
+ ],
+ selectedOption: {value: 'true', name: 'Y'}
+ };
+
+ functionCDselectData = [];
+ parentListSelectData = [];
+ childListSelectData = [];
+
+ constructor(public adminService: AdminService, public activeModal: NgbActiveModal,
+ public ngmodel: NgbModal, public router: Router, public sidebarService: SidebarService,public cookieService:CookieService) { }
+
+ ngOnInit() {
+ if(this.selectedMenu){
+ this.menu = this.selectedMenu;
+ }else{
+ this.menu.menuSetCode='APP';
+ }
+ this.getFunctionCDselectData();
+ this.getParentData();
+ }
+
+ getParentData(){
+ this.showSpinner = true;
+ this.adminService.getParentData()
+ .subscribe( _data => {
+ this.result = _data;
+ if(_data){
+ this.parentListSelectData= _data; // data from server
+ let menuItems = this.parentListSelectData;
+ var heirarchicalMenuItems = [];
+ var children = [];
+ for ( var i=0; i<menuItems.length; i++){
+ for(var j=0; j<menuItems.length; j++){
+ if(menuItems[j][2]==menuItems[i][0])
+ children.push(
+ {
+ menuId: menuItems[j][0],
+ label: menuItems[j][1]
+ }
+ );
+ }
+ if(children.length!=0){
+ heirarchicalMenuItems.push(
+ {
+ menuId: menuItems[i][0],
+ label: menuItems[i][1],
+ children: children.sort(this.sortItems("label"))
+ }
+
+ );
+ }
+ children = [];
+ }
+ heirarchicalMenuItems.sort(this.sortItems("label"));
+ this.childListSelectData = heirarchicalMenuItems;
+ }
+ }, error => {
+ this.showSpinner = false;
+ console.log(error);
+ });
+ }
+
+ sortItems(prop){
+ return function(a, b) {
+ if (a[prop] > b[prop]) {
+ return 1;
+ } else if (a[prop] < b[prop]) {
+ return -1;
+ }
+ return 0;
+ }
+ }
+
+ getParentLabel(parentId, parentListSelectData){
+ var element;
+ element = parentListSelectData[0];
+ for (var i=0; i<parentListSelectData.length; i++){
+ element = parentListSelectData[i];
+ if (element[0] == parentId)
+ return element[1];
+ else "---";
+ }
+ }
+
+ updateFnMenu(){
+ this.showSpinner = true;
+ if( this.menu && this.menu.imageSrc == "" ) this.menu.imageSrc = "N/A";
+ if( this.menu && this.menu.target == "" ) this.menu.target = "N/A";
+ if( this.menu && this.menu.externalUrl == "" ) this.menu.externalUrl = "N/A";
+ if( this.menu && this.menu.queryString == "" ) this.menu.queryString = "N/A";
+ if( this.menu && this.menu.servlet == "" ) this.menu.servlet = "N/A";
+
+ let validationRule = /^\S{3,}$/;
+ let selectedFunction = this.menu.functionCd;
+ var selectedFunctionText = this.menu.functionCd; //selectedFunction.options[selectedFunction.selectedIndex].text;
+
+ if((this.menu.label == null || this.menu.label == "" || (this.menu.label && this.menu.label.trim().length == 0) ) ||
+ this.menu.parentId == null || this.menu.parentId == "" || this.menu.action == null || this.menu.action == "" ||
+ selectedFunctionText == null || selectedFunctionText == "" || this.menu.sortOrder == null || this.menu.sortOrder == "" ||
+ this.menu.menuSetCode == null ||this.menu.menuSetCode == ""){
+
+ this.openConfirmationModal('','Please provide all the mandatory (*) fields inputs !');
+ return;
+ }else{
+ this.menu.parentId=parseFloat(this.menu.parentId);
+ let data ={availableFnMenuItem: this.menu};
+ let postData = JSON.stringify(data);
+ this.adminService.updateFnMenuItem(postData)
+ .subscribe( _data => {
+ this.result = _data;
+ this.passEntry.emit(this.result);
+ this.ngmodel.dismissAll();
+ }, error => {
+ this.showSpinner = false;
+ console.log(error);
+ this.openConfirmationModal("Error",error);
+ });
+ this.getLeftMenuItems();
+ }
+
+ }
+
+ getLeftMenuItems(){
+ let sidebarComponent = new SidebarComponent(this.router, this.sidebarService,this.cookieService);
+ sidebarComponent.ngOnInit();
+ }
+
+ getFunctionCDselectData = function(){
+ this.adminService.getFunctionCdList()
+ .subscribe( _data => {
+ this.result = _data;
+ if(_data){
+ this.functionCDselectData = _data;
+ }
+ }, error => {
+ this.showSpinner = false;
+ console.log(error);
+ this.openConfirmationModal("","Function Code Data not available !");
+ });
+ }
+
+ openConfirmationModal(_title: string, _message: string) {
+ const modalInfoRef = this.ngmodel.open(ConfirmationModalComponent);
+ modalInfoRef.componentInstance.title = _title;
+ modalInfoRef.componentInstance.message = _message;
+ }
+
+}