diff options
Diffstat (limited to 'src/app/shared')
-rw-r--r-- | src/app/shared/components/navigation/navigation.component.ts | 17 | ||||
-rw-r--r-- | src/app/shared/confirmModal/confirm.component.ts | 23 | ||||
-rw-r--r-- | src/app/shared/pipes/vm-filtering.pipe.ts | 25 | ||||
-rw-r--r-- | src/app/shared/services/cdt.apicall.ts | 51 | ||||
-rw-r--r-- | src/app/shared/services/httpUtil/http-util.service.ts | 9 | ||||
-rw-r--r-- | src/app/shared/services/mapping-editor.service.ts | 57 | ||||
-rw-r--r-- | src/app/shared/services/paramShare.service.ts | 3 | ||||
-rw-r--r-- | src/app/shared/services/procOnSrvSide.service.ts | 343 | ||||
-rw-r--r-- | src/app/shared/services/utilityService/utility.service.ts | 10 | ||||
-rw-r--r-- | src/app/shared/shared.module.ts | 32 |
10 files changed, 506 insertions, 64 deletions
diff --git a/src/app/shared/components/navigation/navigation.component.ts b/src/app/shared/components/navigation/navigation.component.ts index 522b11a..7271bb1 100644 --- a/src/app/shared/components/navigation/navigation.component.ts +++ b/src/app/shared/components/navigation/navigation.component.ts @@ -19,19 +19,19 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ -import { Component, Input, OnInit, OnDestroy } from '@angular/core'; -import { Router } from '@angular/router'; +import {Component, Input, OnInit} from '@angular/core'; +import {Router} from '@angular/router'; +import {EmitterService} from '../../services/emitter.service'; import { Subscription } from 'rxjs/Subscription'; -import { EmitterService } from '../../services/emitter.service'; -@Component({ selector: 'app-navigation', templateUrl: './navigation.component.html', styleUrls: ['./navigation.component.css'] }) -export class NavigationComponent implements OnInit, OnDestroy { + +@Component({selector: 'app-navigation', templateUrl: './navigation.component.html', styleUrls: ['./navigation.component.css']}) +export class NavigationComponent implements OnInit { navigationTabs: Array<Object> = []; //@ViewChild(GoldenConfigurationComponent) goldenConfig: GoldenConfigurationComponent; @Input() id: string; @@ -77,6 +77,11 @@ export class NavigationComponent implements OnInit, OnDestroy { url: 'test', }, { + name: 'Admin', + url: 'admin' + }, + + { name: 'About us', url: 'aboutUs' } diff --git a/src/app/shared/confirmModal/confirm.component.ts b/src/app/shared/confirmModal/confirm.component.ts index 5fbf4b3..7b764e2 100644 --- a/src/app/shared/confirmModal/confirm.component.ts +++ b/src/app/shared/confirmModal/confirm.component.ts @@ -19,7 +19,6 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ import { Component } from '@angular/core'; @@ -28,8 +27,6 @@ import { DialogComponent, DialogService } from 'ng2-bootstrap-modal'; export interface ConfirmModel { title: string; message: string; - cancelButtonText: string; - confirmButtonText: string; } @Component({ @@ -38,15 +35,15 @@ export interface ConfirmModel { <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> - <h4 class="modal-title">{{title}}</h4> - <button type="button" class="close" (click)="cancel()">×</button> + <button type="button" class="close" (click)="close()">×</button> + <h6 class="modal-title">{{title || 'Save all changes for current action to APPC database.'}}</h6> </div> <div class="modal-body"> - <p>{{message}}</p> + <p>{{message || 'Do you want to save the changes?'}}</p> </div> <div class="modal-footer"> - <button type="button" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" (click)="confirm()">{{confirmButtonText}}</button> - <button type="button" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" (click)="cancel()">{{cancelButtonText}}</button> + <button type="button" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" (click)="onCancel()">No</button> + <button type="button" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" (click)="onConfirm()">Yes</button> </div> </div> </div>` @@ -54,22 +51,20 @@ export interface ConfirmModel { export class ConfirmComponent extends DialogComponent<ConfirmModel, boolean> implements ConfirmModel { title: string; message: string; - cancelButtonText: string; - confirmButtonText: string; constructor(dialogService: DialogService) { super(dialogService); } - confirm() { - // we set dialog result as true on click on confirm button, + onConfirm() { + // we set dialog result as true on click on Yes button, // then we can get dialog result from caller code this.result = true; this.close(); } - cancel() { - // we set dialog result as false on click on cancel/close button, + onCancel() { + // we set dialog result as false on click on Yes button, // then we can get dialog result from caller code this.result = false; this.close(); diff --git a/src/app/shared/pipes/vm-filtering.pipe.ts b/src/app/shared/pipes/vm-filtering.pipe.ts index c20397b..eef39cf 100644 --- a/src/app/shared/pipes/vm-filtering.pipe.ts +++ b/src/app/shared/pipes/vm-filtering.pipe.ts @@ -17,21 +17,34 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ -import {Pipe, PipeTransform} from '@angular/core'; +import { Pipe, PipeTransform } from '@angular/core'; -@Pipe({name: 'vmFiltering', pure: false}) +@Pipe({ name: 'vmFiltering', pure: false }) export class VmFilteringPipe implements PipeTransform { - transform(value: any, action: any, templateId): any { - + transform(value: any, action: any, templateId, newVnfc): any { + let filterValue + if(action == 'ConfigScaleOut'){ + filterValue= templateId + } else if(action == 'Configure' || action == 'ConfigModify'){ + filterValue= newVnfc + } if (action == 'ConfigScaleOut') { let x = value.filter(obj => { //return value - return obj['template-id'] == templateId; + return obj['template-id'] == filterValue; }); + + return x; + } else if( action == 'Configure' || action == 'ConfigModify'){ + let x = value.filter(obj => { + //return value + return ( obj['vnfcType-id'] == filterValue || obj['vnfcType-id'] == undefined); + }); + + return x; } else { return value; diff --git a/src/app/shared/services/cdt.apicall.ts b/src/app/shared/services/cdt.apicall.ts new file mode 100644 index 0000000..40a3f60 --- /dev/null +++ b/src/app/shared/services/cdt.apicall.ts @@ -0,0 +1,51 @@ +/* +============LICENSE_START========================================== +=================================================================== +Copyright (C) 2018 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. + +============LICENSE_END============================================ +*/ + + +import {Injectable} from '@angular/core'; +import {NotificationsService} from 'angular2-notifications'; +import { HttpUtilService } from './httpUtil/http-util.service'; +import { environment } from '../../../environments/environment'; + + +@Injectable() +export class APIService { + + constructor(private notificationService: NotificationsService, private httpUtils: HttpUtilService) { + } + + public callGetArtifactsApi(payloadData){ + console.log("APIService: PAYLOAD====>"+JSON.stringify(payloadData)); + return this.httpUtils.post({ + url: environment.getDesigns, + data: payloadData + })/*.subscribe(response => { + if (this.checkResult(response, action, artifactType)) { + //Call the respective response handler. + } + }, + error => this.notificationService.error('Error', this.connectionErrorMessage))*/ + } + + + +} diff --git a/src/app/shared/services/httpUtil/http-util.service.ts b/src/app/shared/services/httpUtil/http-util.service.ts index 43e6d4f..688f3ea 100644 --- a/src/app/shared/services/httpUtil/http-util.service.ts +++ b/src/app/shared/services/httpUtil/http-util.service.ts @@ -28,23 +28,22 @@ import { Http, Response, Headers, RequestOptions } from '@angular/http'; export class HttpUtilService { headers: Headers; options: RequestOptions - private username = require('../../../cdt.application.properties.json').username; - private password = require('../../../cdt.application.properties.json').password; + private username = require('../../../../cdt.application.properties.json').username; + private password = require('../../../../cdt.application.properties.json').password; constructor(private http: Http) { this.headers = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON - this.options = new RequestOptions({headers: this.headers}); // } - get(req) { + return this .http .get(req.url, this.options) .map((res: Response) => res.json()) } - post(req) { this.headers.append('Authorization', 'Basic ' + btoa(this.username + ':' + this.password)); this.options = new RequestOptions({ headers: this.headers }); + return this .http .post(req.url, req.data, this.options) diff --git a/src/app/shared/services/mapping-editor.service.ts b/src/app/shared/services/mapping-editor.service.ts index b9e2b53..cb47687 100644 --- a/src/app/shared/services/mapping-editor.service.ts +++ b/src/app/shared/services/mapping-editor.service.ts @@ -68,11 +68,11 @@ export class MappingEditorService { public latestAction: any; public selectedWord: any; identifier: any; + private selectedVNFCType; private _navItem = {}; private _observer: Observer<any>; private referenceList = []; - newObject: any; - + newObject: any constructor() { this.navChange$ = new Observable(observer => this._observer = observer).share(); @@ -106,12 +106,20 @@ export class MappingEditorService { } selectedObj(data) { this.newObject = data; + } - saveLatestIdentifier(identifier) { this.identifier = identifier; } + setSelectedVNFCType(vnfcType) { + this.selectedVNFCType = vnfcType; + } + + getSelectedVNFCType() { + return this.selectedVNFCType; + } + public getParamContent() { return this.paramContent; } @@ -129,15 +137,15 @@ export class MappingEditorService { } - public initialise(editor: any, editorContent: string, modal: any): void { + public initialise(editor: any, editorContent: string): void { this.editor = editor; this.editor.session = editor.session; this.editor.selection.session.$backMarkers = {}; this.editorContent = editorContent; this.editor.$blockScrolling = Infinity; this.editor.$blockSelectEnabled = false; - this.initialiseCommands(modal); - this.editor.setValue(this.editorContent); + //this.initialiseCommands(modal); + //this.editor.setValue(this.editorContent); this.refreshEditor(); } @@ -198,7 +206,7 @@ export class MappingEditorService { for (var prop in paramJson) { let value: string = paramJson[prop]; if (value) { - var occurances = this.editor.findAll(value, {regExp: false}); + var occurances = this.editor.findAll(value, { regExp: false }); var ranges = this.editor.getSelection().getAllRanges(); if (ranges && occurances && occurances > 0) { @@ -261,8 +269,8 @@ export class MappingEditorService { selectedRange.start.column = selectedRange.start.column - 1; selectedRange.end.column = selectedRange.end.column + 1; if ((this.editor.session.getTextRange(selectedRange).startsWith(' ') - || this.editor.session.getTextRange(selectedRange).startsWith('"') - || this.editor.session.getTextRange(selectedRange).startsWith('>')) + || this.editor.session.getTextRange(selectedRange).startsWith('"') + || this.editor.session.getTextRange(selectedRange).startsWith('>')) && (this.editor.session.getTextRange(selectedRange).endsWith(' ') || this.editor.session.getTextRange(selectedRange).endsWith('"') || this.editor.session.getTextRange(selectedRange).endsWith(',') @@ -313,7 +321,7 @@ export class MappingEditorService { } public autoAnnotateTemplateForParam(): void { - var occurances = this.editor.findAll(this.T_KEY_EXPRESSION, {regExp: true}); + var occurances = this.editor.findAll(this.T_KEY_EXPRESSION, { regExp: true }); var ranges = this.editor.getSelection().getAllRanges(); if (ranges) { for (var r = 0; r < ranges.length; r++) { @@ -362,19 +370,25 @@ export class MappingEditorService { } replaceNamesWithBlankValues() { - var occurances = this.editor.findAll(this.SYNC_T_KEY_EXPRESSION, {regExp: true}); + var occurances = this.editor.findAll(this.SYNC_T_KEY_EXPRESSION, { regExp: true }); var ranges = this.editor.getSelection().getAllRanges(); if (occurances > 0) { if (ranges) { for (var r = 0; r < ranges.length; r++) { let selectedRange: any = ranges[r]; + // console.log("Selected range == " + selectedRange) let selectedWord: string = this.editor.session.getTextRange(selectedRange); let specialKeys = (selectedWord.substring(2, selectedWord.length - 1)).match(this.checkSpecialCharsReg); - if (selectedWord && this.checkAppliedForNamesOnly(selectedRange) && !specialKeys) { + // console.log("Selected word == " + selectedWord.length) + //if (!selectedWord.startsWith('<') || !selectedWord.startsWith('{')) { + if (specialKeys && specialKeys.length) { + } + + else if (selectedWord && this.checkAppliedForNamesOnly(selectedRange) && !specialKeys && this.checkComments(selectedRange)) { let replaceWord: any = this.KEY_START + '' + this.KEY_MID + selectedWord.substring(2, selectedWord.length - 1) + this.KEY_END; this.editor.session.replace(selectedRange, replaceWord); } - + // } } } } @@ -388,7 +402,8 @@ export class MappingEditorService { this.hasErrorCode = false; for (var r = 0; r < ranges.length; r++) { let keyValue: string = this.editor.session.getTextRange(ranges[r]); - if (keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) { + //console.log("keyValues==="+keyValue) + if (this.checkComments(ranges[r]) && keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) { let key: string = keyValue.substring(keyValue.indexOf(this.KEY_MID) + this.KEY_MID_LENGTH, keyValue.indexOf(this.KEY_END)); let value: string = keyValue.substring(this.KEY_START_LENGTH, keyValue.indexOf(this.KEY_MID)); let specialKeys = key.match(this.checkSpecialCharsReg); @@ -398,7 +413,7 @@ export class MappingEditorService { if (this.fromScreen === 'TemplateScreen') { if (key) { paramJson[key] = value; - var obj: any = {'paramName': '', 'paramValue': ''}; + var obj: any = { 'paramName': '', 'paramValue': '' }; obj.paramName = key; obj.paramValue = value; paramData.push(obj); @@ -408,7 +423,7 @@ export class MappingEditorService { else if (this.fromScreen === 'MappingScreen') { if (key) { paramJson[key] = value; - var obj: any = {'paramName': '', 'paramValue': ''}; + var obj: any = { 'paramName': '', 'paramValue': '' }; obj.paramName = key; obj.paramValue = value; @@ -449,13 +464,13 @@ export class MappingEditorService { public refreshMarker(): void { if (this.editor) { this.hasErrorCode = false; - var occurances = this.editor.findAll(this.KEY_EXPRESSION, {regExp: true}); + var occurances = this.editor.findAll(this.KEY_EXPRESSION, { regExp: true }); var ranges = this.editor.getSelection().getAllRanges(); var keysList = []; // Populate missing keys for (var r = 0; r < ranges.length; r++) { let keyValue: string = this.editor.session.getTextRange(ranges[r]); - if (keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) { + if (this.checkComments(ranges[r]) && keyValue && keyValue.startsWith(this.KEY_START) && keyValue.endsWith(this.KEY_END) && keyValue.includes(this.KEY_MID)) { let key: string = keyValue.substring(keyValue.indexOf(this.KEY_MID) + this.KEY_MID_LENGTH, keyValue.indexOf(this.KEY_END)); let value: string = keyValue.substring(this.KEY_START_LENGTH, keyValue.indexOf(this.KEY_MID)); let specialKeys = key.match(this.checkSpecialCharsReg); @@ -508,7 +523,7 @@ export class MappingEditorService { public generateTemplate(templateEditor: any): void { if (templateEditor) { templateEditor.setValue(this.editor.getValue()); - var occurances = templateEditor.findAll(this.KEY_EXPRESSION, {regExp: true}); + var occurances = templateEditor.findAll(this.KEY_EXPRESSION, { regExp: true }); var ranges = templateEditor.getSelection().getAllRanges(); if (ranges) { for (var r = 0; r < ranges.length; r++) { @@ -532,7 +547,7 @@ export class MappingEditorService { public generateParams(paramsEditor: any, paramsKeyValueEditor: any): JSON { if (paramsEditor && paramsKeyValueEditor) { - var occurances = this.editor.findAll(this.KEY_EXPRESSION, {regExp: true}); + var occurances = this.editor.findAll(this.KEY_EXPRESSION, { regExp: true }); var ranges = this.editor.getSelection().getAllRanges(); if (ranges) { let paramsJSON: JSON = JSON.parse('{}'); @@ -593,4 +608,4 @@ export class MappingEditorService { } -} +}
\ No newline at end of file diff --git a/src/app/shared/services/paramShare.service.ts b/src/app/shared/services/paramShare.service.ts index 559b448..fcf065a 100644 --- a/src/app/shared/services/paramShare.service.ts +++ b/src/app/shared/services/paramShare.service.ts @@ -17,7 +17,6 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ @@ -33,6 +32,8 @@ export class ParamShareService { public templateData: {}; public displayData: {}; public paramData = []; + public ansibleServerData : {}; + setData(data) { diff --git a/src/app/shared/services/procOnSrvSide.service.ts b/src/app/shared/services/procOnSrvSide.service.ts new file mode 100644 index 0000000..17666d3 --- /dev/null +++ b/src/app/shared/services/procOnSrvSide.service.ts @@ -0,0 +1,343 @@ +//.. processing document on the server side +import { Injectable } from '@angular/core'; +//import { HttpClient, HttpHeaders } from '@angular/common/http'; +import { Http, Response, Headers, RequestOptions } from '@angular/http'; +import { Observable } from 'rxjs'; +import { NotificationsService } from 'angular2-notifications'; + +import { UtilityService } from '../../shared/services/utilityService/utility.service'; + +//const httpOptionsT = { + // headers: new HttpHeaders({ 'Content-Type': 'text/plain' }) +//}; + +@Injectable( +// { providedIn: 'root' } +) +export class ProcOnSrvSideSvc +{ + clName: string = "ProcOnSrvSideSvc"; + public theUrl: string = "/api/proc_cont"; + public resUrlPfx: string = "/api/get_result"; + public parmsUrlPfx: string = "/api/get_params"; + public taskId: string = ''; + public stringBuf: string; + public responBuf: string; + public procResult: string; + public parmsBuf: string; + public responObj: any; + // private respObs: Observable<string>; + private respObs: Observable<Response>; + private respObsObj: Observable<Object>; + public ppartLen: number = 102400; //.. 102912 is too large payload + // public ppartLen: number = 10240; + public ppartCnt: number = 0; + public p_offset: number = 0; + public interval: any; + cycleCnt: number; + cycleMAX: number = 40; + editorHolder: any; + templSyncer: any; + fHeaders: Headers; + rOptions: RequestOptions; + noptions = { + timeOut: 4000, + showProgressBar: true, + pauseOnHover: true, + clickToClose: true, + maxLength: 250 + }; + prevTstampInt: number = 0; + currTstampInt: number = 0; + notifDelayMsec: number = 1200; + + constructor( + // private http: HttpClient, + private http: Http, + private utilSvc: UtilityService, + private nService: NotificationsService ) + { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": new: start"); + this.fHeaders= new Headers({'Content-Type': 'text/plain'}); + this.rOptions= new RequestOptions({'responseType':0}); + } + + sendToSrv( content: string, editorHolder: any, templSyncer: any ) { + var methName= "sendToSrv"; + this.stringBuf= content; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": start: content length="+ + this.stringBuf.length ); + this.editorHolder= editorHolder; + this.templSyncer= templSyncer; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": emptying editor..."); + this.editorHolder.editor.session.setValue("temp empty"); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": theUrl:["+this.theUrl+"]"); + this.nService.info( "Start processing", + "sending: content length="+this.stringBuf.length, this.noptions ); + this.taskId= ''; + let contLen= this.stringBuf.length; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": content length="+contLen+ + " ppartLen="+this.ppartLen ); + this.ppartCnt= 1+ Math.floor(contLen / this.ppartLen); + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": ppartCnt="+ this.ppartCnt ); + if( this.ppartCnt > 1 ) { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": will send multiple parts..."); + this.nService.info( "Start processing", "will send multiple parts..."); + this.prevTstampInt= Date.now(); + this.p_offset= 0; + let ppart= this.stringBuf.substr( this.p_offset, this.ppartLen ); + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": First part:["+ppart+"]"); + //.. first + this.sendPart( this.theUrl, ppart, 1 ); + } + else { //.. ppartCnt == 1 + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": will send all-in-1"); + this.nService.info( "Start processing", + "will send all-in-1 part", this.noptions); + this.prevTstampInt= Date.now(); + //.. single + var sUrl= this.theUrl+"?part=1of1"; + this.sendPart( sUrl, this.stringBuf, 1 ); + }; + } + + sendPart( postUrl: string, contPart: string, partNum: number ) { + var methName= "sendPart"; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": start: Url:["+postUrl+"]"); + this.currTstampInt= Date.now(); + let ntDiff= this.currTstampInt - this.prevTstampInt; + if( this.utilSvc.getTracelvl() > 1 ) + console.log( this.clName+": "+methName+ + ": prevTstampInt="+this.prevTstampInt+ + " currTstampInt="+this.currTstampInt+" the diff="+ntDiff ); + if( ntDiff > this.notifDelayMsec ) { + if( this.utilSvc.getTracelvl() > 1 ) + console.log(this.clName+": "+methName+": notif.delay's long enough."); + this.prevTstampInt= this.currTstampInt; + this.nService.info( "Transferring file", + " part Number="+partNum, this.noptions ); + }; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": part length="+ contPart.length ); + this.respObs= + this.http.post( postUrl, contPart, this.rOptions ); + // this.http.post<string>( postUrl, contPart, httpOptionsT ); + // this.respObs.subscribe( (respo: string) => { + this.respObs.subscribe( (respo: Response) => { + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": got response:["+respo+"]"); + if( this.utilSvc.getTracelvl() > 1 ) + console.log( this.clName+": "+methName+": json:["+ + JSON.stringify(respo)+"]"); + this.responBuf= respo.text(); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": responBuf:["+this.responBuf+"]"); + if( this.taskId.length < 1 ) { + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+ + ": taskId is empty -get it from response"); + let respObj= JSON.parse(this.responBuf); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": respObj.taskId:["+ + respObj.taskId+"]"); + if( respObj.taskId == null || respObj.taskId.length == 0 ) { + let errMsg= this.clName+": "+methName+ + ": Error: failed to get taskId from the server response !"; + console.log( errMsg ); + this.nService.error( "Transferring file", errMsg, this.noptions ); + return; + } + else { //.. extracted respObj.taskId + this.taskId= respObj.taskId; + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": obtained new taskId:["+ + this.taskId+"]"); + this.nService.info( "Transferring file", + "current taskId:["+this.taskId+"]", this.noptions); + }; + }; + let tpercent= (100.0*partNum/this.ppartCnt).toFixed(); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+ + ": part#="+partNum+" transfer percent="+tpercent ); + this.currTstampInt= Date.now(); + let ntDiff= this.currTstampInt - this.prevTstampInt; + if( this.utilSvc.getTracelvl() > 1 ) + console.log( this.clName+": "+methName+ + ": prevTstampInt="+this.prevTstampInt+ + " currTstampInt="+this.currTstampInt+" the diff="+ntDiff ); + if( ntDiff > this.notifDelayMsec ) { + if( this.utilSvc.getTracelvl() > 1 ) + console.log(this.clName+": "+methName+": notif.delay long enough."); + this.prevTstampInt= this.currTstampInt; + this.nService.info( "Transferring file", + " progress: "+tpercent+" %", this.noptions ); + //" part Number="+partNum+" vs part Count="+this.ppartCnt, this.noptions ); + }; + if( partNum < this.ppartCnt ) { + // this.nService.info( methName,"need to send more parts..."); + let partN= partNum + 1; + this.p_offset= this.p_offset + this.ppartLen; + var ppart= ''; + if( partN < this.ppartCnt ) { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+ + ": next part is not the last: partN="+partN ); + ppart= this.stringBuf.substr( this.p_offset, this.ppartLen ); + } + else { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+ ": next part is the last."); + ppart= this.stringBuf.substr( this.p_offset ); + }; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": next part:["+ppart+"]"); + let nUrl= + this.theUrl+"?taskId="+this.taskId+"&part="+partN+"of"+this.ppartCnt; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": next Url:["+nUrl+"]"); + this.sendPart( nUrl, ppart, partN ); + } + else { //.. partNum == this.ppartCnt + this.nService.info( "Transferring file", + "all "+this.ppartCnt+ " parts are sent - check processing...", + this.noptions); + var progrUrl= "/api/get_progress?taskId="+this.taskId; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(this.clName+": "+methName+": progrUrl:["+progrUrl+"]"); + this.showProcProgr( progrUrl ); + }; + }, + error => { + console.log( this.clName+": "+methName+ + ": got Error:["+JSON.stringify(error)+']'); + this.responBuf= JSON.stringify(error); + this.nService.error( "Transferring file", + " Error:["+this.responBuf+"]", this.noptions); + }); + } + + showProcProgr( proUrl: string ) { + var methName= "showProcProgr"; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(methName+": start: proUrl:["+proUrl+"]"); + this.cycleCnt= 0; + this.interval = setInterval( () => { + if( this.utilSvc.getTracelvl() > 1 ) + console.log(methName+": call getProcProgr"); + this.getProcProgr( proUrl ); + }, 2500 ); + } + + getProcProgr( proUrl: string ) { + var methName= "getProcProgr"; + if( this.utilSvc.getTracelvl() > 0 ) + console.log( methName+": getProcProgr: start: proUrl:["+proUrl+"]"); + this.cycleCnt++; + if( this.utilSvc.getTracelvl() > 0 ) + console.log( methName+": cycleCnt="+this.cycleCnt ); + this.nService.info( "Processing", + "Requesting server status...", this.noptions); + // this.respObsObj= + // this.http.get( proUrl ); + this.respObs= + this.http.get( proUrl ); + // this.respObs.subscribe( (respo: string) => { + //this.respObsObj.subscribe( (respo) => { + this.respObs.subscribe( (respo: Response) => { + if( this.utilSvc.getTracelvl() > 0 ) + console.log( methName+": response:["+JSON.stringify(respo)+"]"); + this.responBuf= respo.text(); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( methName+": responBuf:["+this.responBuf+"]"); + let respObj= JSON.parse(this.responBuf); + // this.responObj= respo; //.. Object + if( respObj.percentage != undefined && + respObj.percentage != null ) + { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(methName+": got percentage:["+respObj.percentage+"]"); + if( respObj.percentage >= 100.0 ) { + if( this.utilSvc.getTracelvl() > 0 ) + console.log(methName+": percentage == 100 !"); + this.nService.info( "Processing completed", + "The server finished: 100% !", this.noptions); + clearInterval( this.interval ); + if( this.utilSvc.getTracelvl() > 0 ) + console.log(methName+": getting the processing result..."); + this.getProcResult(); + } + }; + if( this.utilSvc.getTracelvl() > 0 ) + console.log(methName+": cycleCnt="+this.cycleCnt+ + " vs MAX="+this.cycleMAX ); + if( this.cycleCnt > this.cycleMAX ) { + this.nService.error( "Processing", + "Too many status requests - stop !",this.noptions ); + clearInterval( this.interval ); + } + }, + error => { + console.log( this.clName+": "+methName+": got Error:["+ + JSON.stringify(error)+']'); + this.responObj= error; //.. as Object + this.nService.error( "Processing"," Error:["+ + JSON.stringify(error)+']', this.noptions ); + clearInterval( this.interval ); + }); + } + + getProcResult() { + var methName= "getProcResult"; + let resUrl= this.resUrlPfx+"?taskId="+this.taskId; + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": start: resUrl:["+resUrl+"]"); + this.respObs= + this.http.get( resUrl, this.rOptions ); + // this.http.get( resUrl, {responseType: 'text'} ); + // this.respObs.subscribe( (respo: string) => { + this.respObs.subscribe( (respo: Response) => { + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": got response:["+respo+"]"); + if( this.utilSvc.getTracelvl() > 1 ) + console.log( this.clName+": "+methName+": json:["+ + JSON.stringify(respo)+"]"); + this.responBuf= respo.text(); + if( this.utilSvc.getTracelvl() > 1 ) + console.log( this.clName+": "+methName+": responBuf:["+this.responBuf+"]"); + if( this.utilSvc.getTracelvl() == 0 ) { + let respoBg= this.responBuf.substr(0, 300); + console.log(this.clName+": "+methName+": response Begin:["+respoBg+"...]"); + }; + this.procResult= this.responBuf; + this.nService.info( "Processing completed", + "the result length="+this.procResult.length, this.noptions ); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+ + ": setting response to the editor..."); + this.editorHolder.editor.session.setValue( this.procResult ); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": calling syncTemplate ..."); + this.templSyncer.syncTemplate('1'); + if( this.utilSvc.getTracelvl() > 0 ) + console.log( this.clName+": "+methName+": finished."); + }, + error => { + console.log( this.clName+": "+methName+": subscribe Error:["+ + JSON.stringify(error)+']'); + this.procResult= JSON.stringify(error); + this.nService.error( "Getting Processing result", + " Error:["+JSON.stringify(error)+']', this.noptions); + }); + } +} diff --git a/src/app/shared/services/utilityService/utility.service.ts b/src/app/shared/services/utilityService/utility.service.ts index 8a9f945..6b29a2e 100644 --- a/src/app/shared/services/utilityService/utility.service.ts +++ b/src/app/shared/services/utilityService/utility.service.ts @@ -18,7 +18,6 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ @@ -73,6 +72,15 @@ export class UtilityService { return artifactData.replace(/"/g, '\\"'); } + // get current date in "mm/dd/yyyy" + getDate() { + let toDay = new Date(); + return (toDay.getMonth()+1) +"/"+ toDay.getDate() +"/"+ toDay.getFullYear(); + } + + + + public checkResult(result: any) { if (result.output.status.code == appConstants.errorCode["401"]) { diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 8959587..c911082 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -17,7 +17,6 @@ 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. -ECOMP is a trademark and service mark of AT&T Intellectual Property. ============LICENSE_END============================================ */ @@ -43,31 +42,44 @@ import {NotificationService} from './services/notification.service'; import {ParamShareService} from './services/paramShare.service'; import {TidyTableModule} from './modules/tidy-table/tidy-table.module'; import {UtilityService} from './services/utilityService/utility.service'; -import {VmFilteringPipe} from '../pipes/vm-filtering.pipe'; +import {ProcOnSrvSideSvc} from './services/procOnSrvSide.service'; + import {SimpleNotificationsModule} from 'angular2-notifications'; import { NgProgressModule } from 'ngx-progressbar'; import {FormsModule} from '@angular/forms'; +import { VmFilteringPipe } from './pipes/vm-filtering.pipe'; +import {APIService} from './services/cdt.apicall' + @NgModule({ imports: [ FormsModule, - CommonModule, HttpModule, RouterModule, TidyTableModule, NgProgressModule, NgbModule, SimpleNotificationsModule.forRoot()], + CommonModule, HttpModule, RouterModule, TidyTableModule, + // HttpClient, HttpHeaders, + NgProgressModule, NgbModule, SimpleNotificationsModule.forRoot()], declarations: [VmFilteringPipe, - HelpComponent, - HeaderComponent, NavigationComponent, LogoutComponent, Collapse, Dropdown, DropdownNotClosableZone, DropdownOpen, DropDownToggleDirective + HeaderComponent, NavigationComponent, LogoutComponent, Collapse, + Dropdown, DropdownNotClosableZone, DropdownOpen, DropDownToggleDirective ], - exports: [VmFilteringPipe, NgProgressModule, NgbModule, HelpComponent, DropDownToggleDirective, HeaderComponent, NavigationComponent, LogoutComponent, TidyTableModule, Collapse, Dropdown, DropdownNotClosableZone, DropdownOpen] + exports: [ + VmFilteringPipe, NgProgressModule, NgbModule, HelpComponent, + DropDownToggleDirective, HeaderComponent, NavigationComponent, + LogoutComponent, TidyTableModule, Collapse, Dropdown, + DropdownNotClosableZone, DropdownOpen + ] }) export class SharedModule { static forRoot(): ModuleWithProviders { return { ngModule: SharedModule, - providers: [HttpUtilService, EmitterService, NotificationService, - UtilityService, - ParamShareService, MappingEditorService] + providers: [ + HttpUtilService, EmitterService, NotificationService, + UtilityService,APIService, ProcOnSrvSideSvc, + ParamShareService, MappingEditorService + ] }; } -}
\ No newline at end of file +} |