Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
fix: shell-ui template
Browse files Browse the repository at this point in the history
  • Loading branch information
JamilOmar committed Feb 27, 2020
1 parent 0609e4e commit 0702ecd
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 21 deletions.
2 changes: 1 addition & 1 deletion templates/ui-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protrac
## Env Vars

For adding env vars , you can use the .env file. For more information check
[Shell CLI README](https://github.com/angular/shell-ui/blob/master/README.md).
[Shell CLI README](https://github.com/angular/shell-ui/blob/master/README.md)..

## Further help

Expand Down
2 changes: 2 additions & 0 deletions templates/ui-package/config/default.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = {
test: process.env.TEST_VAL,
production: false,
services: {
auth: {
authFlowType: 'code',
url: process.env.SERVICES_AUTH_URL,
clientId: process.env.SERVICES_AUTH_CLIENT_ID,
tenant: process.env.SERVICES_AUTH_TENANT
Expand Down
4 changes: 2 additions & 2 deletions templates/ui-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"@angular/router": "~8.2.11",
"@labshare/ls-font": "^1.0.0",
"@labshare/ngx-core-components": "^1.0.7",
"@labshare/ngx-core-services": "^1.11.0",
"@labshare/shell-ui": "file:../../../LabShare/shell-ui/labshare-shell-ui-1.12.1.tgz",
"@labshare/ngx-core-services": "^2.0.0",
"@labshare/shell-ui": "^2.0.0",
"@ng-bootstrap/ng-bootstrap": "^5.2.2",
"@ngx-formly/bootstrap": "^5.5.11",
"@ngx-formly/core": "^5.5.11",
Expand Down
6 changes: 1 addition & 5 deletions templates/ui-package/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ import {filter} from 'rxjs/operators';
styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
constructor(private authService: AuthService, private router: Router, private eventService: EventService) {
this.authService.configure().subscribe(done => {
this.authService.onAuthCallback();
});
}
constructor(private router: Router, private eventService: EventService) {}
title = '<%= appNameSlug %>';
ngOnInit(): void {
this.eventService
Expand Down
23 changes: 16 additions & 7 deletions templates/ui-package/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {BrowserModule} from '@angular/platform-browser';
import {NgModule, APP_INITIALIZER} from '@angular/core';
import {HttpClientModule, HttpClient, HTTP_INTERCEPTORS} from '@angular/common/http';
import {HttpClient} from '@angular/common/http';
import {UsersRouting} from './app-routing.module';
import {NgxCoreComponentsModule} from '@labshare/ngx-core-components';
import {CenterHeaderComponent} from './center-header/center-header.component';
Expand All @@ -18,21 +18,26 @@ import {
NgxCoreServicesModule,
AuthService,
ConfigService,
initializerFromUrl,
AuthInterceptor
initializeFromAppConf,
AppType,
EventService
} from '@labshare/ngx-core-services';
// this editor should be removed for a real project
import {LoggingComponent} from './logging/logging.component';
import {AuthComponent} from './auth/auth.component';
import {Router} from '@angular/router';

const customThemes = [labshare];

// Export Angular 8 feature module
// app initializer for Auth
// app initializer
function initialize(http: HttpClient, config: ConfigService, auth: AuthService): () => Promise<any> {
return async () => {
return initializerFromUrl(http, config, auth);
if (APP_TYPE === AppType.Site) {
return initializeFromAppConf(http, config, auth);
} else {
return auth.configure().toPromise();
}
};
}
@NgModule({
Expand All @@ -46,7 +51,7 @@ function initialize(http: HttpClient, config: ConfigService, auth: AuthService):
],
imports: [
BrowserModule,
NgxCoreServicesModule.forRoot(APP_CONF),
NgxCoreServicesModule.forRoot({appConf: APP_CONF, appType: APP_TYPE, appBuildVersion: APP_BUILD_VERSION}),
NgxCoreComponentsModule.forRoot(customThemes),
CommonModule,
UsersRouting,
Expand All @@ -66,4 +71,8 @@ function initialize(http: HttpClient, config: ConfigService, auth: AuthService):
],
bootstrap: [AppComponent]
})
export class AppModule {}
export class AppModule {
constructor(private authService: AuthService, private router: Router, private eventService: EventService) {
this.authService.onAuthCallback();
}
}
4 changes: 4 additions & 0 deletions templates/ui-package/src/app/auth/auth.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export class AuthComponent implements OnInit {
module.exports = {
services: {
logging: {
// for apps with no signup page you need to enable
silentRenew :true,
// for changing auth flows - implicit is the default one
authFlowType : 'code',
url: process.env.SERVICES_LOG_URL,
application: process.env.SERVICES_LOG_APP,
environment: process.env.SERVICES_LOG_ENV,
Expand Down
9 changes: 8 additions & 1 deletion templates/ui-package/src/app/forms/forms.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {ReactiveFormsModule} from '@angular/forms';
import {FormlyModule} from '@ngx-formly/core';
import {NgxJsonViewerModule} from 'ngx-json-viewer';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {FormlyBootstrapModule} from '@ngx-formly/bootstrap';

describe('FormsComponent', () => {
let component: FormsComponent;
Expand All @@ -13,7 +14,13 @@ describe('FormsComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [FormsComponent],
imports: [HttpClientTestingModule, ReactiveFormsModule, FormlyModule.forRoot(), NgxJsonViewerModule]
imports: [
HttpClientTestingModule,
ReactiveFormsModule,
FormlyModule.forRoot(),
NgxJsonViewerModule,
FormlyBootstrapModule
]
}).compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Component, OnInit} from '@angular/core';
styleUrls: ['./version.component.scss']
})
export class VersionComponent implements OnInit {
message = PROJECT_BUILD_VERSION;
message = APP_BUILD_VERSION;
constructor() {}

ngOnInit() {}
Expand Down
6 changes: 3 additions & 3 deletions templates/ui-package/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
// app configuration injected from shell-ui
declare var APP_CONF: any;
// project build version injected from shell-ui
declare var PROJECT_BUILD_VERSION: any;
// env var to indicate if the project is built with prod mod
declare var ENABLE_PROD_MODE: true;
declare var APP_BUILD_VERSION: string;
// project app type injected from shell-ui
declare var APP_TYPE: any;
2 changes: 1 addition & 1 deletion templates/ui-package/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {environment} from './environments/environment';
// remove this for real apps
import 'prismjs';

if (environment.production) {
if (APP_CONF.production) {
enableProdMode();
}

Expand Down

0 comments on commit 0702ecd

Please sign in to comment.