This repository has been archived by the owner on Nov 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,622 additions
and
5 deletions.
There are no files selected for viewing
Empty file.
3 changes: 3 additions & 0 deletions
3
ui/projects/beetle-lib/src/core/about-dialog/about-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<pfng-about-modal [config]="aboutConfig" | ||
(onCancel)="close()"> | ||
</pfng-about-modal> |
41 changes: 41 additions & 0 deletions
41
ui/projects/beetle-lib/src/core/about-dialog/about-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { async, ComponentFixture, TestBed } from "@angular/core/testing"; | ||
import { HttpModule } from "@angular/http"; | ||
import { About } from "../about-dialog/about.model"; | ||
import { AboutService } from "../about-dialog/about.service"; | ||
import { MockAboutService } from "../about-dialog/mock-about.service"; | ||
import { AppSettingsService } from "../app-settings.service"; | ||
import { LoggerService } from "../logger.service"; | ||
import { MockAppSettingsService } from "../mock-app-settings.service"; | ||
import { ModalModule } from "patternfly-ng"; | ||
import { AboutDialogComponent } from "./about-dialog.component"; | ||
|
||
describe("AboutDialogComponent", () => { | ||
let component: AboutDialogComponent; | ||
let fixture: ComponentFixture<AboutDialogComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ AboutDialogComponent ], | ||
imports: [ HttpModule, ModalModule ], | ||
providers: [ | ||
AboutService, | ||
{ provide: AppSettingsService, useClass: MockAppSettingsService }, | ||
LoggerService ] | ||
}) | ||
.compileComponents().then(() => { | ||
// nothing to do | ||
}); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(AboutDialogComponent); | ||
component = fixture.componentInstance; | ||
component.info = About.create( MockAboutService.json ); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it("should be created", () => { | ||
console.log("========== [AboutDialogComponent] should be created"); | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
103 changes: 103 additions & 0 deletions
103
ui/projects/beetle-lib/src/core/about-dialog/about-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file 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. | ||
*/ | ||
|
||
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from "@angular/core"; | ||
import { AboutService } from "../about-dialog/about.service"; | ||
import { LoggerService } from "../logger.service"; | ||
import { AboutEvent } from "../about-dialog/about-event"; | ||
import { About } from "../about-dialog/about.model"; | ||
import { AboutModalConfig } from "patternfly-ng/modal"; | ||
|
||
@Component({ | ||
encapsulation: ViewEncapsulation.None, | ||
selector: "app-about-dialog", | ||
templateUrl: "./about-dialog.component.html", | ||
styleUrls: ["./about-dialog.component.css"] | ||
}) | ||
export class AboutDialogComponent implements OnInit { | ||
|
||
/** | ||
* The Event is emitted when modal is closed | ||
*/ | ||
@Output( "onCancel" ) public onCancel = new EventEmitter(); | ||
|
||
/** | ||
* The about information. | ||
*/ | ||
@Input() public info: About; | ||
|
||
public aboutConfig: AboutModalConfig; | ||
private aboutService: AboutService; | ||
private logger: LoggerService; | ||
|
||
/** | ||
* The default contructor | ||
*/ | ||
constructor(logger: LoggerService, | ||
aboutService: AboutService) { | ||
this.aboutService = aboutService; | ||
this.logger = logger; | ||
} | ||
|
||
public ngOnInit(): void { | ||
|
||
const self = this; | ||
|
||
this.aboutService.getAboutInformation().subscribe( | ||
( result ) => { | ||
this.aboutConfig = { | ||
additionalInfo: result.appDescription, | ||
copyright: result.copyright, | ||
logoImageAlt: this.appImageAlt, | ||
logoImageSrc: this.appImageSrc, | ||
title: result.appTitle, | ||
productInfo: [ | ||
{ name: "Version", value: result.appVersion }, | ||
{ name: "Server Name", value: "Localhost_update_me" }, | ||
{ name: "User Name", value: "admin_update_me" }, | ||
{ name: "User Role", value: "Administrator_update_me" }] | ||
} as AboutModalConfig; | ||
}, | ||
( error ) => { | ||
self.logger.error( error, "Error getting about information."); | ||
} | ||
); | ||
} | ||
|
||
public get appImageAlt(): string { | ||
return "Beetle Studio image"; | ||
} | ||
|
||
public get appImageSrc(): string { | ||
return "assets/teiid-lizard-gradient-bgd.png"; | ||
} | ||
|
||
public close(): void { | ||
this.onCancel.emit( { | ||
close: true | ||
} as AboutEvent ); | ||
} | ||
|
||
public get logoImageAlt(): string { | ||
return "Red Hat Logo image"; | ||
} | ||
|
||
public get logoImageSrc(): string { | ||
return "assets/redhat-iot.png"; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
ui/projects/beetle-lib/src/core/about-dialog/about-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file 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. | ||
*/ | ||
|
||
export class AboutEvent { | ||
|
||
/** | ||
* Flag indicating Modal is open | ||
*/ | ||
public close?: boolean; | ||
|
||
} |
91 changes: 91 additions & 0 deletions
91
ui/projects/beetle-lib/src/core/about-dialog/about.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file 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. | ||
*/ | ||
|
||
export class About { | ||
|
||
// Here is the JSON returned from REST: | ||
// | ||
// { | ||
// "Information": { | ||
// "App Name": "vdb-builder", | ||
// "App Title": "Vdb Builder", | ||
// "copyright": "2017-1018", | ||
// "App Description": "A tool that allows creating, editing and managing dynamic VDBs and their contents", | ||
// "App Version": "0.0.4-SNAPSHOT", | ||
// "Repository Workspace": "komodoLocalWorkspace", | ||
// "Repository Configuration": "vfs:/dirLocation/komodo-core-0.0.4-SNAPSHOT.jar/org/komodo/repository/local-repository-config.json", | ||
// "Repository Vdb Total": "1" | ||
// } | ||
// } | ||
|
||
private Information: {}; | ||
|
||
public static create( json: object = {} ): About { | ||
const about = new About(); | ||
about.setValues( json ); | ||
return about; | ||
} | ||
|
||
public get appDescription(): string { | ||
if ( this.Information && this.Information[ "App Description" ] != null ) { | ||
return this.Information[ "App Description" ]; | ||
} | ||
|
||
return "App description not found"; | ||
} | ||
|
||
public get appName(): string { | ||
if ( this.Information && this.Information[ "App Name" ] ) { | ||
return this.Information[ "App Name" ]; | ||
} | ||
|
||
return "App name not found"; | ||
} | ||
|
||
public get appTitle(): string { | ||
if ( this.Information && this.Information[ "App Title" ] ) { | ||
return this.Information[ "App Title" ]; | ||
} | ||
|
||
return "App title not found"; | ||
} | ||
|
||
public get appVersion(): string { | ||
if ( this.Information && this.Information[ "App Version" ] ) { | ||
return this.Information[ "App Version" ]; | ||
} | ||
|
||
return "App version not found"; | ||
} | ||
|
||
public get copyright(): string { | ||
if ( this.Information && this.Information[ "App Copyright" ] ) { | ||
return this.Information[ "App Copyright" ]; | ||
} | ||
|
||
return "2017-2018 Red Hat, Inc."; | ||
} | ||
|
||
/** | ||
* Set all object values using the supplied JSON. | ||
* @param {Object} values | ||
*/ | ||
public setValues( values: object = {} ): void { | ||
Object.assign( this, values ); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
ui/projects/beetle-lib/src/core/about-dialog/about.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { inject, TestBed } from "@angular/core/testing"; | ||
import { HttpModule } from "@angular/http"; | ||
import { AboutService } from "../about-dialog/about.service"; | ||
import { AppSettingsService } from "../app-settings.service"; | ||
import { LoggerService } from "../logger.service"; | ||
import { MockAppSettingsService } from "../mock-app-settings.service"; | ||
|
||
describe("AboutService", () => { | ||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ HttpModule ], | ||
providers: [ | ||
AboutService, | ||
{ provide: AppSettingsService, useClass: MockAppSettingsService }, | ||
LoggerService ] | ||
}); | ||
}); | ||
|
||
it("should be created", | ||
inject([ AboutService, AppSettingsService, LoggerService ], | ||
( service: AboutService ) => { | ||
console.log("========== [AboutService] should be created"); | ||
expect( service ).toBeTruthy(); | ||
})); | ||
}); |
49 changes: 49 additions & 0 deletions
49
ui/projects/beetle-lib/src/core/about-dialog/about.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* @license | ||
* Copyright 2017 JBoss Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file 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. | ||
*/ | ||
|
||
import { Injectable } from "@angular/core"; | ||
import { Http } from "@angular/http"; | ||
import { About } from "./about.model"; | ||
import { ApiService } from "../api.service"; | ||
import { AppSettingsService } from "../app-settings.service"; | ||
import { LoggerService } from "../logger.service"; | ||
import { environment } from "../../../environments/environment"; | ||
import { Observable } from "rxjs/Observable"; | ||
|
||
@Injectable() | ||
export class AboutService extends ApiService { | ||
|
||
private static readonly aboutUrl = environment.komodoServiceUrl + "/about"; | ||
|
||
private http: Http; | ||
|
||
constructor( http: Http, | ||
appSettings: AppSettingsService, | ||
logger: LoggerService ) { | ||
super( appSettings, logger ); | ||
this.http = http; | ||
} | ||
|
||
public getAboutInformation(): Observable<any> { | ||
return this.http.get( AboutService.aboutUrl, this.getAuthRequestOptions() ) | ||
.map( ( response ) => { | ||
const aboutInfo = response.json(); | ||
return About.create( aboutInfo ); | ||
} ) | ||
.catch( ( error ) => this.handleError( error ) ); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
ui/projects/beetle-lib/src/core/about-dialog/mock-about.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { Http } from "@angular/http"; | ||
import { About } from "../about-dialog/about.model"; | ||
import { AboutService } from "../about-dialog/about.service"; | ||
import { AppSettingsService } from "../app-settings.service"; | ||
import { LoggerService } from "../logger.service"; | ||
import { Observable } from "rxjs/Observable"; | ||
import "rxjs/add/observable/of"; | ||
|
||
@Injectable() | ||
export class MockAboutService extends AboutService { | ||
|
||
public static readonly json = { | ||
"Information": { | ||
"App Name": "vdb-builder", | ||
"App Title": "Vdb Builder", | ||
"App Description": "A tool that allows creating, editing and managing dynamic VDBs and their contents", | ||
"App Version": "0.0.4-SNAPSHOT" | ||
} | ||
}; | ||
|
||
constructor( http: Http, | ||
appSettings: AppSettingsService, | ||
logger: LoggerService ) { | ||
super( http, appSettings, logger ); | ||
} | ||
|
||
public getAboutInformation(): Observable< About > { | ||
const about = About.create( MockAboutService.json ); | ||
return Observable.of( about ); | ||
} | ||
|
||
} |
Oops, something went wrong.