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

Commit

Permalink
fix(shared): removes shared from demo app as env are not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
invincibleJai committed Sep 10, 2018
1 parent c19a6ee commit 7f41414
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 216 deletions.
Expand Up @@ -16,13 +16,6 @@ import { ComponentSnippetComponent } from './component-snippet/component-snippet
import { ProgressMeterModule } from '../../utils/progress-meter/progress-meter.module';
import { ComponentFeedbackModule } from '../../utils/component-feedback/component-feedback.module';

import { witApiUrlProvider } from '../../../../../../../src/app/shared/wit-api.provider';
import { ApiLocatorService } from '../../../../../../../src/app/shared/api-locator.service';
import { authApiUrlProvider } from '../../../../../../../src/app/shared/auth-api.provider';
import { ssoApiUrlProvider } from '../../../../../../../src/app/shared/sso-api.provider';
import { realmProvider } from '../../../../../../../src/app/shared/realm-token.provider';
import { MockAuthenticationService } from '../../../../../../../src/app/shared/mock-auth.service';

import {
MRecommendationInformation,
MComponentInformation,
Expand Down Expand Up @@ -106,13 +99,13 @@ describe ('ComponentInformationComponent', () => {
],
providers: [
Contexts,
witApiUrlProvider,
ApiLocatorService,
authApiUrlProvider,
ssoApiUrlProvider,
realmProvider,
// witApiUrlProvider,
// ApiLocatorService,
// authApiUrlProvider,
// ssoApiUrlProvider,
// realmProvider,
{
provide: AuthenticationService, useClass: MockAuthenticationService
provide: AuthenticationService, useValue: {}
},
{
provide: AddWorkFlowService,
Expand Down
Expand Up @@ -5,22 +5,19 @@ import {
} from '../models/stack-report.model';
import { PipelineInsightsService } from './pipeline-insights.service';
import { Injectable } from '@angular/core';
// import 'rxjs/add/operator/map';
// import { TimerObservable } from 'rxjs/observable/TimerObservable';
import { timeInterval, pluck, take} from 'rxjs/operators';
import { of } from 'rxjs';
import { takeWhile, catchError } from 'rxjs/operators';

import { timer } from 'rxjs';

@Component({
selector: 'pipleine-insights-details',
providers: [PipelineInsightsService],
// encapsulation: ViewEncapsulation.None,
styleUrls: ['./pipeline-insights.component.less'],
templateUrl: './pipeline-insights.component.html'
})
@Injectable()
export class PipelineInsightsComponent implements OnInit, OnChanges {
// @Input() gatewayConfig: any;

@Input() stack: string;
@Input() buildNumber;
@Input() appName;
Expand All @@ -37,7 +34,6 @@ export class PipelineInsightsComponent implements OnInit, OnChanges {
public flag = false;
public flag1 = false;
public interval = 7000;
// public alive: boolean = true;

constructor(private pipelineInsightsService: PipelineInsightsService) { }

Expand All @@ -50,13 +46,13 @@ export class PipelineInsightsComponent implements OnInit, OnChanges {
return;
}
this.stackUrl = this.url;
let observable: any = this .pipelineInsightsService
const observable: any = this.pipelineInsightsService
.getStackAnalyses(this.url);

timer(0, this.interval).pipe(
timeInterval(),
pluck('interval'),
take(3))
timer(0, this.interval)
.pipe(
takeWhile(() => alive),
catchError(error => of(`error: ${error}`)))
.subscribe(() => {
if (subs) {
subs.unsubscribe();
Expand All @@ -65,14 +61,14 @@ export class PipelineInsightsComponent implements OnInit, OnChanges {
if (data && (!data.hasOwnProperty('error') && Object.keys(data).length !== 0) && (data.statusCode === 200 || data.statusCode === 202)) {
alive = false;
subs.unsubscribe();
let response: Array<ResultInformationModel> = data.result;
const response: Array<ResultInformationModel> = data.result;
if (response.length > 0) {
for (let i = 0; i < data.result.length; ++i) {
let c = data.result[i];
const 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];
const d = c.user_stack_info.analyzed_dependencies[j];
if (d.security && d.security.length > 0) {
this.flag = true;
break;
Expand Down Expand Up @@ -114,9 +110,6 @@ export class PipelineInsightsComponent implements OnInit, OnChanges {
}
});
}



}


Expand Down
Expand Up @@ -2,7 +2,7 @@ import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';


import { PipelineInsightsService } from './pipeline-insights.service';
import { GlobalConstants } from '../constants/constants.service';
import { PipelineInsightsComponent } from './pipeline-insights.component';

Expand All @@ -17,7 +17,7 @@ import { PipelineInsightsComponent } from './pipeline-insights.component';
exports: [
PipelineInsightsComponent
],
providers: [ GlobalConstants ],
providers: [ GlobalConstants, PipelineInsightsService ],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class PipelineInsightsModule {
Expand Down
Expand Up @@ -15,15 +15,15 @@ export class PipelineInsightsService {
private http: HttpClient,
private auth: AuthenticationService
) {
if (this.auth.getToken() !== null) {
this.headers.set('Authorization', 'Bearer ' + this.auth.getToken());
if (this.auth && this.auth.getToken && this.auth.getToken() !== null) {
this.headers = this.headers.set('Authorization', 'Bearer ' + this.auth.getToken());
}
}

getStackAnalyses(url: string, params?: any): Observable<StackReportModel> {
const options: any = { headers: this.headers, observe: 'response' };
if (params && params['access_token']) {
this.headers.set('Authorization', 'Bearer ' + params['access_token']);
this.headers = this.headers.set('Authorization', 'Bearer ' + params['access_token']);
}
return this.http.get<StackReportModel>(url, options)
.pipe(map(this.extractData),
Expand Down
Expand Up @@ -35,7 +35,7 @@ export class StackAnalysesService {
private http: HttpClient,
private auth: AuthenticationService
) {
if (this.auth && this.auth.getToken() !== null) {
if (this.auth && this.auth.getToken && this.auth.getToken() !== null) {
this.headers = this.headers.set('Authorization', 'Bearer ' + this.auth.getToken());
}
}
Expand Down
Expand Up @@ -23,7 +23,7 @@ export class AddWorkFlowService {
private auth: AuthenticationService,
private context: Contexts
) {
if (this.auth.getToken && this.auth.getToken() !== null) {
if (this.auth && this.auth.getToken && this.auth.getToken() !== null) {
this.headers = this.headers.set('Authorization', 'Bearer ' + this.auth.getToken());
}
this.setMetaInformation();
Expand Down
Expand Up @@ -16,13 +16,6 @@ import { Broadcaster } from 'ngx-base';
import { Contexts } from 'ngx-fabric8-wit';
import { AuthenticationService, AUTH_API_URL, SSO_API_URL } from 'ngx-login-client';

import { witApiUrlProvider } from '../../../../../../src/app/shared/wit-api.provider';
import { ApiLocatorService } from '../../../../../../src/app/shared/api-locator.service';
import { authApiUrlProvider } from '../../../../../../src/app/shared/auth-api.provider';
import { ssoApiUrlProvider } from '../../../../../../src/app/shared/sso-api.provider';
import { realmProvider } from '../../../../../../src/app/shared/realm-token.provider';
import { MockAuthenticationService } from '../../../../../../src/app/shared/mock-auth.service';

/** Stack Report Revamp - Latest */
import { ReportSummaryModule } from '../report-summary/report-summary.module';
import { CardDetailsModule } from '../card-details/card-details.module';
Expand Down Expand Up @@ -57,13 +50,13 @@ describe ('StackDetailsComponent', () => {
],
providers: [
Broadcaster,
ApiLocatorService,
witApiUrlProvider,
authApiUrlProvider,
ssoApiUrlProvider,
realmProvider,
// ApiLocatorService,
// witApiUrlProvider,
// authApiUrlProvider,
// ssoApiUrlProvider,
// realmProvider,
{
provide: AuthenticationService, useClass: MockAuthenticationService
provide: AuthenticationService, useValue: {}
},
Contexts,
CommonService,
Expand Down
Expand Up @@ -5,7 +5,6 @@ import { ChartModule } from '../utils/chart/chart.module';
import { StackDetailsModule } from '../stack-details/stack-details.module';
import { StackAnalysesService } from '../stack-analyses.service';
import { AuthenticationService } from 'ngx-login-client';
import { MockAuthenticationService } from '../../../../../../src/app/shared/mock-auth.service';
import { ReportSummaryModule } from '../report-summary/report-summary.module';
import { CommonService } from '../utils/common.service';

Expand All @@ -24,7 +23,7 @@ describe ('StackReportInShortComponent', () => {
providers: [
StackAnalysesService,
{
provide: AuthenticationService, useClass: MockAuthenticationService
provide: AuthenticationService, useValue: {}
},
CommonService
],
Expand Down
Expand Up @@ -3,7 +3,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpClientModule } from '@angular/common/http';

import { AuthenticationService } from 'ngx-login-client';
import { MockAuthenticationService } from '../../../../../../../src/app/shared/mock-auth.service';
import { ComponentFeedbackService } from './component-feedback.service';

import { ComponentFeedbackComponent } from './component-feedback.component';
Expand All @@ -24,7 +23,7 @@ describe('ComponentFeedbackComponent', () => {
],
providers: [
{
provide: AuthenticationService, useClass: MockAuthenticationService
provide: AuthenticationService, useValue: {}
},
ComponentFeedbackService
]
Expand Down
Expand Up @@ -16,7 +16,7 @@ export class ComponentFeedbackService {
private http: HttpClient,
private auth: AuthenticationService
) {
if (this.auth.getToken() !== null) {
if (this.auth && this.auth.getToken && this.auth.getToken() !== null) {
this.headers.set('Authorization', 'Bearer ' + this.auth.getToken());
}
}
Expand Down
22 changes: 4 additions & 18 deletions src/app/app.module.ts
Expand Up @@ -3,24 +3,15 @@ import { BrowserModule } from '@angular/platform-browser';
import { HttpClient, HttpClientModule } from '@angular/common/http';

import { Broadcaster } from 'ngx-base';
import { Contexts, WIT_API_URL } from 'ngx-fabric8-wit';
import { AuthenticationService, AUTH_API_URL, SSO_API_URL } from 'ngx-login-client';
import { Contexts } from 'ngx-fabric8-wit';
import { AuthenticationService } from 'ngx-login-client';

import { AppComponent } from './app.component';
import { FormsModule } from '@angular/forms';

import { witApiUrlProvider } from './shared/wit-api.provider';
import { ApiLocatorService } from './shared/api-locator.service';
import { authApiUrlProvider } from './shared/auth-api.provider';
import { ssoApiUrlProvider } from './shared/sso-api.provider';
import { realmProvider } from './shared/realm-token.provider';
import { MockAuthenticationService } from './shared/mock-auth.service';

// Imports stackdetailsmodule
import { StackDetailsModule } from '../../projects/fabric8-stack-analysis-ui/src/lib/stack/stack-details/stack-details.module';
import { StackReportInShortModule } from '../../projects/fabric8-stack-analysis-ui/src/lib/stack/stack-report-inshort/stack-report-inshort.module';
// import { StackDetailsModule } from './stack/stack-details/stack-details.module';
// import { StackReportInShortModule } from './stack/stack-report-inshort/stack-report-inshort.module';

import { AppRoutingModule } from './app.routing';

Expand All @@ -41,17 +32,12 @@ import { ComponentFeedbackService } from '../../projects/fabric8-stack-analysis-
declarations: [ AppComponent ],
providers: [
Broadcaster,
ApiLocatorService,
CommonService,
witApiUrlProvider,
authApiUrlProvider,
ssoApiUrlProvider,
realmProvider,
{
provide: AuthenticationService, useClass: MockAuthenticationService
provide: AuthenticationService, useValue: {}
},
{ provide: StackAnalysesService, useClass: StackAnalysesService, deps: [HttpClient, AuthenticationService]},
{ provide: AddWorkFlowService, useClass: AddWorkFlowService, deps: [HttpClient, AuthenticationService, WIT_API_URL, Contexts]},
{ provide: AddWorkFlowService, useClass: AddWorkFlowService, deps: [HttpClient, AuthenticationService]},
{ provide: ComponentFeedbackService, useClass: ComponentFeedbackService, deps: [HttpClient, AuthenticationService]},
Contexts
],
Expand Down
74 changes: 0 additions & 74 deletions src/app/shared/api-locator.service.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/app/shared/auth-api.provider.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/app/shared/mock-auth.service.ts

This file was deleted.

0 comments on commit 7f41414

Please sign in to comment.