Skip to content

Commit

Permalink
chore(app-launcher): various fixes for fabric8-ui
Browse files Browse the repository at this point in the history
- Added missing HelperService export
- Renamed incorrect runtime platform property to pipelinePlatform
- Fixed missing semi-colons
- Fixed ts-lint errors with spacing and indentation
  • Loading branch information
dlabrecq authored and AdamJ committed Feb 20, 2018
1 parent 677b090 commit 6f83f36
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ export class ReleaseStrategyCreateappStepComponent extends LauncherStep implemen
this.subscriptions.push(this.pipelineService.getPipelines().subscribe((result) => {
// needs to filter out associated pipelines from list of pipelines
let selPipelines: any[] = [];
let selectionWiz: Selection = this.launcherComponent.currentSelection;
let selection: Selection = this.launcherComponent.currentSelection;
selPipelines = result.filter(item => {
return item.platform === selectionWiz.platform;
return item.platform === selection.platform;
})

this._pipelines = this.allPipelines = selPipelines;
Expand Down
2 changes: 1 addition & 1 deletion src/app/launcher/launcher.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class LauncherComponent implements AfterViewInit, OnInit {
? this._summary.dependencyCheck.projectVersion : undefined,
runtimeId: (this._summary.runtime !== undefined) ? this._summary.runtime.id : undefined,
runtimeVersion: (this._summary.runtime !== undefined) ? this._summary.runtime.version : undefined,
platform: (this._summary.runtime !== undefined) ? this._summary.runtime.platform : 'maven',
platform: (this._summary.runtime !== undefined) ? this._summary.runtime.pipelinePlatform : 'maven',
spacePath: (this._summary.dependencyCheck !== undefined) ? this._summary.dependencyCheck.spacePath : undefined,
targetEnvironment: this._summary.targetEnvironment
} as Selection;
Expand Down
4 changes: 4 additions & 0 deletions src/app/launcher/launcher.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,7 @@ export { PipelineService } from './service/pipeline.service';
export { ProjectProgressService } from './service/project-progress.service';
export { ProjectSummaryService } from './service/project-summary.service';
export { TargetEnvironmentService } from './service/target-environment.service';


// Utility Service
export { HelperService } from './service/helper.service';
9 changes: 2 additions & 7 deletions src/app/launcher/model/runtime.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ export class Runtime {
name: string;
}; // Menu selection
url?: string;
projectVersion: string;
platform: string;
}

export class Missions {
id: string;
versions: any[];
projectVersion?: string;
pipelinePlatform?: string;
}
4 changes: 2 additions & 2 deletions src/app/launcher/model/selection.model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class Selection {
groupId: string;
groupId?: string;
missionId?: string;
pipelineId?: string;
projectName?: string;
Expand All @@ -9,7 +9,7 @@ export class Selection {
id: string;
name: string;
};
platform: string;
platform?: string;
spacePath?: string;
targetEnvironment?: string;
}
11 changes: 6 additions & 5 deletions src/demo/service/demo-mission-runtime.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Injectable, Inject } from '@angular/core';
import { Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import { Headers, Http, RequestOptions, Response } from '@angular/http';
import { Observable } from 'rxjs';

import { MissionRuntimeService } from '../../app/launcher/launcher.module';
import { Mission } from '../../app/launcher/launcher.module';
import { Runtime } from '../../app/launcher/launcher.module';
Expand All @@ -11,8 +12,8 @@ import { TokenProvider } from '../../app/service/token-provider';
@Injectable()
export class DemoMissionRuntimeService implements MissionRuntimeService {

//TODO: remove the hardcodes
private END_POINT: string = ''
// TODO: remove the hardcodes
private END_POINT: string = '';
private API_BASE: string = 'booster-catalog/';
private ORIGIN: string = '';

Expand All @@ -34,7 +35,7 @@ export class DemoMissionRuntimeService implements MissionRuntimeService {
headers.append('Authorization', 'Bearer ' + token);
return new RequestOptions({
headers: headers
})
});
}));
}

Expand Down
91 changes: 45 additions & 46 deletions src/demo/service/demo-pipeline.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,53 @@ import { TokenProvider } from '../../app/service/token-provider';
@Injectable()
export class DemoPipelineService implements PipelineService {

//TODO: remove the hardcodes
private END_POINT: string = '';
private API_BASE: string = 'services/jenkins/pipelines';
private ORIGIN: string = '';

constructor(
private http: Http,
private helperService: HelperService,
private tokenProvider: TokenProvider
) {
if (this.helperService) {
this.END_POINT = this.helperService.getBackendUrl();
this.ORIGIN = this.helperService.getOrigin();
}
}
// TODO: remove the hardcodes
private END_POINT: string = '';
private API_BASE: string = 'services/jenkins/pipelines';
private ORIGIN: string = '';

private get options(): Observable<RequestOptions> {
let headers = new Headers();
headers.append('X-App', this.ORIGIN);
return Observable.fromPromise(this.tokenProvider.token.then((token) => {
headers.append('Authorization', 'Bearer ' + token);
return new RequestOptions({
headers: headers
})
}));
constructor(
private http: Http,
private helperService: HelperService,
private tokenProvider: TokenProvider
) {
if (this.helperService) {
this.END_POINT = this.helperService.getBackendUrl();
this.ORIGIN = this.helperService.getOrigin();
}

getPipelines(): Observable<Pipeline[]> {
let runtimeEndPoint: string = this.END_POINT + this.API_BASE;
return this.options.flatMap((option) => {
return this.http.get(runtimeEndPoint, option)
.map(response => response.json() as Pipeline[])
.catch(this.handleError);
}

private get options(): Observable<RequestOptions> {
let headers = new Headers();
headers.append('X-App', this.ORIGIN);
return Observable.fromPromise(this.tokenProvider.token.then((token) => {
headers.append('Authorization', 'Bearer ' + token);
return new RequestOptions({
headers: headers
});
}

private handleError(error: Response | any) {
// In a real world app, we might use a remote logging infrastructure
let errMsg: string;
if (error instanceof Response) {
const body = error.json() || '';
const err = body.error || JSON.stringify(body);
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else {
errMsg = error.message ? error.message : error.toString();
}
console.error(errMsg);
return Observable.throw(errMsg);
}
}));
}

getPipelines(): Observable<Pipeline[]> {
let runtimeEndPoint: string = this.END_POINT + this.API_BASE;
return this.options.flatMap((option) => {
return this.http.get(runtimeEndPoint, option)
.map(response => response.json() as Pipeline[])
.catch(this.handleError);
});
}

private handleError(error: Response | any) {
// In a real world app, we might use a remote logging infrastructure
let errMsg: string;
if (error instanceof Response) {
const body = error.json() || '';
const err = body.error || JSON.stringify(body);
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else {
errMsg = error.message ? error.message : error.toString();
}
console.error(errMsg);
return Observable.throw(errMsg);
}
}

0 comments on commit 6f83f36

Please sign in to comment.