aboutsummaryrefslogtreecommitdiffstats
path: root/src/app/shared/services
diff options
context:
space:
mode:
authorasgar <ma926a@us.att.com>2019-03-01 15:32:47 +0530
committerTakamune Cho <takamune.cho@att.com>2019-03-04 19:52:20 +0000
commit611c9da62c2e266f9facd97dc9f340ce311060a3 (patch)
treee471d6c851cefd46ed83380c6e41d20f54fe2666 /src/app/shared/services
parent9ccb0353f1c59bd7d49ff17c54e5d00c0960ea82 (diff)
multiple asible servers support
multiple asible servers support for CDT Issue-ID: APPC-1510 Change-Id: Id1b1b02274487cfbf6f108a57211a192924a6b08 Signed-off-by: Mohamed Asgar Samiulla <ma926a@us.att.com>
Diffstat (limited to 'src/app/shared/services')
-rw-r--r--src/app/shared/services/cdt.apicall.ts52
-rw-r--r--src/app/shared/services/httpUtil/http-util.service.ts9
-rw-r--r--src/app/shared/services/mapping-editor.service.ts57
-rw-r--r--src/app/shared/services/procOnSrvSide.service.ts343
4 files changed, 435 insertions, 26 deletions
diff --git a/src/app/shared/services/cdt.apicall.ts b/src/app/shared/services/cdt.apicall.ts
new file mode 100644
index 0000000..9d7fbc2
--- /dev/null
+++ b/src/app/shared/services/cdt.apicall.ts
@@ -0,0 +1,52 @@
+/*
+============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.
+
+ECOMP is a trademark and service mark of AT&T Intellectual Property.
+============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/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);
+ });
+ }
+}