Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
elvisisking committed Mar 21, 2018
1 parent 5f0cb20 commit 6565865
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 20 deletions.
26 changes: 25 additions & 1 deletion ngapp/src/app/connections/connections.module.ts
Expand Up @@ -34,6 +34,10 @@ import { SharedModule } from "@shared/shared.module";
import { PatternFlyNgModule } from "patternfly-ng";
import { ConnectionTypeCardComponent } from "./connection-type-cards/connection-type-card/connection-type-card.component";
import { ConnectionTypeCardsComponent } from "./connection-type-cards/connection-type-cards.component";
import { AppSettingsService } from "@core/app-settings.service";
import { Http } from "@angular/http";
import { environment } from "@environments/environment";
import { MockConnectionService } from "@connections/shared/mock-connection.service";

@NgModule({
imports: [
Expand All @@ -59,10 +63,30 @@ import { ConnectionTypeCardsComponent } from "./connection-type-cards/connection
ConnectionTypeCardComponent
],
providers: [
ConnectionService,
{
provide: ConnectionService,
useFactory: connectionServiceFactory,
deps: [ Http, AppSettingsService, LoggerService ],
multi: false
},
LoggerService
],
exports: [
]
})
export class ConnectionsModule { }

/**
* A factory that produces the appropriate instande of the service based on current environment settings.
*
* @param {Http} http the HTTP service
* @param {AppSettingsService} appSettings the app settings service
* @param {LoggerService} logger the logger
* @returns {ConnectionService} the requested service
*/
export function connectionServiceFactory( http: Http,
appSettings: AppSettingsService,
logger: LoggerService ): ConnectionService {
return environment.production || !environment.uiDevMode ? new ConnectionService( http, appSettings, logger )
: new MockConnectionService( http, appSettings, logger );
}
24 changes: 22 additions & 2 deletions ngapp/src/app/core/core.module.ts
Expand Up @@ -17,15 +17,17 @@

import { CommonModule } from "@angular/common";
import { NgModule, Optional, SkipSelf } from "@angular/core";
import { HttpModule } from "@angular/http";
import { Http, HttpModule } from "@angular/http";
import { RouterModule } from "@angular/router";
import { AboutDialogComponent } from "@core/about-dialog/about-dialog.component";
import { AboutService } from "@core/about-dialog/about.service";
import { AppSettingsService } from "@core/app-settings.service";
import { BreadcrumbComponent } from "@core/breadcrumbs/breadcrumb/breadcrumb.component";
import { BreadcrumbsComponent } from "@core/breadcrumbs/breadcrumbs.component";
import { LoggerService } from "@core/logger.service";
import { MockAppSettingsService } from "@core/mock-app-settings.service";
import { VerticalNavComponent } from "@core/vertical-nav/vertical-nav.component";
import { environment } from "@environments/environment";
import { ModalModule } from "ngx-bootstrap/modal";
import { BsModalService } from "ngx-bootstrap/modal";
import { PatternFlyNgModule } from "patternfly-ng";
Expand All @@ -51,7 +53,12 @@ import { PatternFlyNgModule } from "patternfly-ng";
],
providers: [
AboutService,
AppSettingsService,
{
provide: AppSettingsService,
useFactory: appSettingsServiceFactory,
deps: [ Http, LoggerService ],
multi: false
},
LoggerService,
BsModalService
]
Expand All @@ -65,3 +72,16 @@ export class CoreModule {
}

}

/**
* A factory that produces the appropriate instande of the service based on current environment settings.
*
* @param {Http} http the HTTP service
* @param {LoggerService} logger the logger
* @returns {AppSettingsService} the requested service
*/
export function appSettingsServiceFactory( http: Http,
logger: LoggerService ): AppSettingsService {
return environment.production || !environment.uiDevMode ? new AppSettingsService( http, logger )
: new MockAppSettingsService( http, logger );
}
86 changes: 83 additions & 3 deletions ngapp/src/app/dataservices/dataservices.module.ts
Expand Up @@ -18,7 +18,9 @@
import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { Http } from "@angular/http";
import { RouterModule } from "@angular/router";
import { AppSettingsService } from "@core/app-settings.service";
import { CoreModule } from "@core/core.module";
import { LoggerService } from "@core/logger.service";
import { DataservicesCardsComponent } from "@dataservices/dataservices-cards/dataservices-cards.component";
Expand All @@ -28,9 +30,13 @@ import { ViewsContentComponent } from "@dataservices/dataservices-list/views-con
import { DataservicesRoutingModule } from "@dataservices/dataservices-routing.module";
import { DataservicesComponent } from "@dataservices/dataservices.component";
import { DataserviceService } from "@dataservices/shared/dataservice.service";
import { MockDataserviceService } from "@dataservices/shared/mock-dataservice.service";
import { MockNotifierService } from "@dataservices/shared/mock-notifier.service";
import { MockVdbService } from "@dataservices/shared/mock-vdb.service";
import { NotifierService } from "@dataservices/shared/notifier.service";
import { VdbService } from "@dataservices/shared/vdb.service";
import { WizardService } from "@dataservices/shared/wizard.service";
import { environment } from "@environments/environment";
import { SharedModule } from "@shared/shared.module";
import { CodemirrorModule } from "ng2-codemirror";
import { PatternFlyNgModule } from "patternfly-ng";
Expand Down Expand Up @@ -71,13 +77,87 @@ import { TestDataserviceComponent } from "./test-dataservice/test-dataservice.co
DataserviceCardComponent
],
providers: [
DataserviceService,
VdbService,
{
provide: DataserviceService,
useFactory: dataserviceServiceFactory,
deps: [ Http, VdbService, AppSettingsService, NotifierService, LoggerService ],
multi: false
},
{
provide: NotifierService,
useFactory: notifierServiceFactory,
multi: false
},
{
provide: VdbService,
useFactory: vdbServiceFactory,
deps: [ Http, AppSettingsService, NotifierService, LoggerService ],
multi: false
},
LoggerService,
NotifierService,
WizardService
],
exports: [
]
})
export class DataservicesModule { }

/**
* A factory that produces the appropriate instance of the service based on current environment settings.
*
* @param {Http} http the HTTP service
* @param {VdbService} vdbService the VDB service
* @param {AppSettingsService} appSettings the app settings service
* @param {NotifierService} notifierService the notifier service
* @param {LoggerService} logger the logger
* @returns {DataserviceService} the requested service
*/
export function dataserviceServiceFactory( http: Http,
vdbService: VdbService,
appSettings: AppSettingsService,
notifierService: NotifierService,
logger: LoggerService ): DataserviceService {
return environment.production || !environment.uiDevMode ? new DataserviceService( http,
vdbService,
appSettings,
notifierService,
logger )
: new MockDataserviceService( http,
vdbService,
appSettings,
notifierService,
logger );
}

/**
* A factory that produces the appropriate instance of the service based on current environment settings.
*
* @returns {NotifierService} the requested service
*/
export function notifierServiceFactory(): NotifierService {
return environment.production || !environment.uiDevMode ? new NotifierService()
: new MockNotifierService();
}

/**
* A factory that produces the appropriate instance of the service based on current environment settings.
*
* @param {Http} http the HTTP service
* @param {AppSettingsService} appSettings the app settings service
* @param {NotifierService} notifierService the notifier service
* @param {LoggerService} logger the logger
* @returns {VdbService} the requested service
*/
export function vdbServiceFactory( http: Http,
appSettings: AppSettingsService,
notifierService: NotifierService,
logger: LoggerService ): VdbService {
return environment.production || !environment.uiDevMode ? new VdbService( http,
appSettings,
notifierService,
logger )
: new MockVdbService( http,
appSettings,
notifierService,
logger );
}
26 changes: 13 additions & 13 deletions ngapp/src/app/dataservices/shared/mock-dataservice.service.ts
Expand Up @@ -106,20 +106,20 @@ export class MockDataserviceService extends DataserviceService {
return tables;
}

/**
* Updates the current Dataservice states - triggers update to be broadcast to interested components
*/
public updateDataserviceStates(): void {
// Nothing to do
}
// /**
// * Updates the current Dataservice states - triggers update to be broadcast to interested components
// */
// public updateDataserviceStates(): void {
// // Nothing to do
// }

/**
* Polls the server and sends Dataservice state updates at the specified interval
* @param {number} pollIntervalSec the interval (sec) between polling attempts
*/
public pollDataserviceStatus(pollIntervalSec: number): void {
// Nothing to do
}
// /**
// * Polls the server and sends Dataservice state updates at the specified interval
// * @param {number} pollIntervalSec the interval (sec) between polling attempts
// */
// public pollDataserviceStatus(pollIntervalSec: number): void {
// // Nothing to do
// }

/**
* Query a Dataservice via the komodo rest interface
Expand Down
11 changes: 11 additions & 0 deletions ngapp/src/app/dataservices/shared/mock-notifier.service.ts
@@ -0,0 +1,11 @@
import { Injectable } from "@angular/core";
import { NotifierService } from "@dataservices/shared/notifier.service";

@Injectable()
export class MockNotifierService extends NotifierService {

constructor() {
super();
}

}
12 changes: 12 additions & 0 deletions ngapp/src/app/dataservices/shared/mock-vdb.service.ts
Expand Up @@ -48,8 +48,19 @@ export class MockVdbService extends VdbService {
constructor(http: Http, appSettings: AppSettingsService, notifierService: NotifierService, logger: LoggerService ) {
super(http, appSettings, notifierService, logger);
this.vdb1.setId("serv1");
this.vdbStatus1.setName( "serv1" );
this.vdbStatus1.setLoading( false );
this.vdbStatus1.setActive( true );

this.vdb2.setId("serv2");
this.vdbStatus2.setName("serv2");
this.vdbStatus2.setLoading( false );
this.vdbStatus2.setActive( true );

this.vdb3.setId("serv3");
this.vdbStatus3.setName("serv2");
this.vdbStatus3.setLoading( false );
this.vdbStatus3.setActive( true );
}

/**
Expand All @@ -65,6 +76,7 @@ export class MockVdbService extends VdbService {
* @returns {Observable<Vdb[]>}
*/
public getTeiidVdbStatuses(): Observable<VdbStatus[]> {
super.getTeiidVdbStatuses();
return Observable.of(this.statuses);
}

Expand Down
5 changes: 4 additions & 1 deletion ngapp/src/environments/environment.ts
Expand Up @@ -56,6 +56,9 @@ export const environment = {
komodoTeiidUrl: komodoUrlPrefix + komodoEngine + "/" + komodoRestVersion + "/metadata",

// REST URL - Komodo service
komodoServiceUrl: komodoUrlPrefix + komodoEngine + "/" + komodoRestVersion + "/service"
komodoServiceUrl: komodoUrlPrefix + komodoEngine + "/" + komodoRestVersion + "/service",

// Indicates if in UI development mode where OpenShift will not be used.
uiDevMode: true

};

0 comments on commit 6565865

Please sign in to comment.