Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
fix(console): removes console log and caches the response from the pr…
Browse files Browse the repository at this point in the history
…evious calls if any
  • Loading branch information
arunkumars08 authored and invincibleJai committed May 3, 2018
1 parent 8e8eec8 commit 742c58f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 37 deletions.
80 changes: 44 additions & 36 deletions src/app/stack/pipeline-insights/pipeline-insights.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit, OnChanges, ViewChild, ViewEncapsulation } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, OnChanges, Output, SimpleChanges, ViewChild, ViewEncapsulation } from '@angular/core';
import { Observable } from 'rxjs/Observable';

import { getStackReportModel } from '../utils/stack-api-utils';
Expand Down Expand Up @@ -29,16 +29,18 @@ export class PipelineInsightsComponent implements OnInit, OnChanges {
@Input() component;
@Input() url: string;

@Output() onStackResponse: EventEmitter<StackReportModel> = new EventEmitter<StackReportModel>();

@ViewChild('stackModule') modalStackModule: any;

public cve_Info: string;
public stackUrl: string;
public flag: boolean = false;
public flag1: boolean = false;
public interval : number = 7000;
public interval: number = 7000;
// public alive: boolean = true;

constructor(private PipelineInsightsService: PipelineInsightsService,
constructor(private pipelineInsightsService: PipelineInsightsService,
private http: Http) { }


Expand All @@ -47,14 +49,17 @@ export class PipelineInsightsComponent implements OnInit, OnChanges {
let subs = null;
let alive: boolean = true;
let counter: number = 0;
if(this.url && this.url !== '') {
if (this.url && this.url !== '') {
if (this.stackUrl === this.url) {
return;
}
this.stackUrl = this.url;
let observable: any = this.PipelineInsightsService
.getStackAnalyses(this.url);
let observable: any = this .pipelineInsightsService
.getStackAnalyses(this.url);

TimerObservable.create(0, this.interval)
TimerObservable.create(0, this.interval)
.takeWhile(() => alive)
.subscribe(()=>{
.subscribe(() => {
if (subs) {
subs.unsubscribe();
}
Expand All @@ -65,57 +70,58 @@ export class PipelineInsightsComponent implements OnInit, OnChanges {
console.log(data);
console.log("Status :" + typeof data.statusCode);
let response: Array<ResultInformationModel> = data.result;
if (response.length> 0) {
if (response.length > 0) {
for (let i = 0; i < data.result.length; ++i) {
let c = data.result[i];
if (c.user_stack_info) {
if (c.user_stack_info.analyzed_dependencies) {
for (let j = 0; j < c.user_stack_info.analyzed_dependencies.length; ++j) {
let d = c.user_stack_info.analyzed_dependencies[j];
if (d.security && d.security.length > 0) {
this.flag = true;
break;
let c = data.result[i];
if (c.user_stack_info) {
if (c.user_stack_info.analyzed_dependencies) {
for (let j = 0; j < c.user_stack_info.analyzed_dependencies.length; ++j) {
let d = c.user_stack_info.analyzed_dependencies[j];
if (d.security && d.security.length > 0) {
this.flag = true;
break;
}
}
}
}

}

}
for (let i = 0; i < data.result.length; ++i) {
let c = data.result[i];
if (c.user_stack_info) {
if (c.user_stack_info.license_analysis) {console.log("liscense"+c.user_stack_info.license_analysis.length);
let d = c.user_stack_info.license_analysis.status;
console.log("d value"+d);
if (d=="ComponentConflict") {
for (let i = 0; i < data.result.length; ++i) {
let c = data.result[i];
if (c.user_stack_info) {
if (c.user_stack_info.license_analysis) {
let d = c.user_stack_info.license_analysis.status;
console.log("d value" + d);
if (d == "ComponentConflict") {
this.flag1 = true;
break;
}
if (d=="StackConflict") {
if (d == "StackConflict") {
this.flag1 = true;
break;
}
}
}

}

}
}
}
if(data.statusCode !== 200 && data.statusCode !== 202) {
if (data.statusCode !== 200 && data.statusCode !== 202) {
alive = false;
subs.unsubscribe();
this.onStackResponse.emit(data);
console.log("Status :" + data.statusCode);
}
}, error => {
}, error => {
alive = false;
});
if (counter ++ > 5) {
if (counter++ > 3) {
alive = false;
}
})
}



}

Expand All @@ -125,8 +131,10 @@ export class PipelineInsightsComponent implements OnInit, OnChanges {
this.geturl();
}

ngOnChanges(): void {
this.geturl();
ngOnChanges(changes: SimpleChanges): void {
if (changes && changes['url'] && changes['url']['currentValue'] !== changes['url']['previousValue']) {
this.geturl();
}
}


Expand Down
2 changes: 1 addition & 1 deletion src/app/stack/stack-details/stack-details.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="stack-report">
<a [ngClass]="{'stack-reports-btn': true, 'pipeline-case': showF}" (click)="showStackModal($event)">{{displayName}}</a>
<pipleine-insights-details (click)="showStackModal($event)" *ngIf="stack && showF" [url]="stack"></pipleine-insights-details>
<pipleine-insights-details (onStackResponse)="stackResponse = $event" (click)="showStackModal($event)" *ngIf="stack && showF" [url]="stack"></pipleine-insights-details>
<modal #stackModule title="Stack report for {{appName}}, Build #{{buildNumber}}" modalClass="modal-lg modal-fullscreen modal-width-class" (onClose)="handleModalClose();" (onOpen)="init();">
<modal-content>
<div *ngIf="!error">
Expand Down

0 comments on commit 742c58f

Please sign in to comment.