From 76361fb6fb89a13c04afaa04b37feebb1cc9c3d7 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Tue, 21 Apr 2020 16:31:11 +0300 Subject: [PATCH] fix(module-template): fix some bugs in module template --- templates/app/angular/angular.json | 24 ++++++-- templates/module/angular/angular.json | 60 ++++++++++--------- templates/module/angular/package.json | 4 +- .../module/angular/src/app/app.component.ts | 19 +++++- .../angular/src/app/shared/shared.module.ts | 3 - .../src/environments/environment.hmr.ts | 25 -------- .../src/environments/environment.prod.ts | 1 - .../angular/src/environments/environment.ts | 1 - templates/module/angular/src/main.ts | 13 +--- .../appsettings.json | 4 +- .../appsettings.json | 4 +- 11 files changed, 77 insertions(+), 81 deletions(-) delete mode 100644 templates/module/angular/src/environments/environment.hmr.ts diff --git a/templates/app/angular/angular.json b/templates/app/angular/angular.json index e66c47ad63..567b8f95c7 100644 --- a/templates/app/angular/angular.json +++ b/templates/app/angular/angular.json @@ -26,8 +26,12 @@ "extractCss": true, "assets": ["src/favicon.ico", "src/assets"], "styles": [ + { + "input": "node_modules/bootstrap/dist/css/bootstrap.min.css", + "inject": true, + "bundleName": "bootstrap.min" + }, "src/styles.scss", - "node_modules/bootstrap/dist/css/bootstrap.min.css", { "input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css", "inject": false, @@ -98,10 +102,22 @@ "karmaConfig": "karma.conf.js", "assets": ["src/favicon.ico", "src/assets"], "styles": [ + { + "input": "node_modules/bootstrap/dist/css/bootstrap.min.css", + "inject": true, + "bundleName": "bootstrap.min" + }, "src/styles.scss", - "node_modules/bootstrap/dist/css/bootstrap.min.css", - "node_modules/@fortawesome/fontawesome-free/css/all.min.css", - "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css" + { + "input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css", + "inject": false, + "bundleName": "fontawesome-all.min" + }, + { + "input": "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css", + "inject": false, + "bundleName": "fontawesome-v4-shims.min" + } ], "scripts": [] } diff --git a/templates/module/angular/angular.json b/templates/module/angular/angular.json index 1f298b967c..cd9a9ed936 100644 --- a/templates/module/angular/angular.json +++ b/templates/module/angular/angular.json @@ -26,12 +26,22 @@ "extractCss": true, "assets": ["src/favicon.ico", "src/assets"], "styles": [ + { + "input": "node_modules/bootstrap/dist/css/bootstrap.min.css", + "inject": true, + "bundleName": "bootstrap.min" + }, "src/styles.scss", - "node_modules/bootstrap/dist/css/bootstrap.min.css", - "node_modules/font-awesome/css/font-awesome.min.css", - "node_modules/primeng/resources/themes/nova-light/theme.css", - "node_modules/primeicons/primeicons.css", - "node_modules/primeng/resources/primeng.min.css" + { + "input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css", + "inject": false, + "bundleName": "fontawesome-all.min" + }, + { + "input": "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css", + "inject": false, + "bundleName": "fontawesome-v4-shims.min" + } ], "scripts": [] }, @@ -59,14 +69,6 @@ "maximumError": "5mb" } ] - }, - "hmr": { - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.hmr.ts" - } - ] } } }, @@ -78,10 +80,6 @@ "configurations": { "production": { "browserTarget": "myProjectName:build:production" - }, - "hmr": { - "hmr": true, - "browserTarget": "myProjectName:build:hmr" } } }, @@ -100,12 +98,22 @@ "karmaConfig": "karma.conf.js", "assets": ["src/favicon.ico", "src/assets"], "styles": [ + { + "input": "node_modules/bootstrap/dist/css/bootstrap.min.css", + "inject": true, + "bundleName": "bootstrap.min" + }, "src/styles.scss", - "node_modules/bootstrap/dist/css/bootstrap.min.css", - "node_modules/font-awesome/css/font-awesome.min.css", - "node_modules/primeng/resources/themes/nova-light/theme.css", - "node_modules/primeicons/primeicons.css", - "node_modules/primeng/resources/primeng.min.css" + { + "input": "node_modules/@fortawesome/fontawesome-free/css/all.min.css", + "inject": false, + "bundleName": "fontawesome-all.min" + }, + { + "input": "node_modules/@fortawesome/fontawesome-free/css/v4-shims.min.css", + "inject": false, + "bundleName": "fontawesome-v4-shims.min" + } ], "scripts": [] } @@ -159,9 +167,7 @@ "projects/my-project-name/tsconfig.lib.json", "projects/my-project-name/tsconfig.spec.json" ], - "exclude": [ - "**/node_modules/**" - ] + "exclude": ["**/node_modules/**"] } } } @@ -194,9 +200,7 @@ "projects/my-project-name-config/tsconfig.lib.json", "projects/my-project-name-config/tsconfig.spec.json" ], - "exclude": [ - "**/node_modules/**" - ] + "exclude": ["**/node_modules/**"] } } } diff --git a/templates/module/angular/package.json b/templates/module/angular/package.json index 56812cb9ca..435df6136e 100644 --- a/templates/module/angular/package.json +++ b/templates/module/angular/package.json @@ -4,7 +4,7 @@ "scripts": { "ng": "ng", "start": "ng serve", - "start:hmr": "ng serve --configuration hmr", + "start:hmr": "ng serve --open", "build": "ng build my-project-name", "test": "ng test my-project-name", "lint": "ng lint my-project-name", @@ -35,8 +35,6 @@ "@angular/cli": "~8.3.20", "@angular/compiler-cli": "~8.2.14", "@angular/language-service": "~8.2.14", - "@angularclass/hmr": "^2.1.3", - "@ngxs/hmr-plugin": "^3.5.0", "@ngxs/logger-plugin": "^3.5.1", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", diff --git a/templates/module/angular/src/app/app.component.ts b/templates/module/angular/src/app/app.component.ts index bf2a27962a..8187365734 100644 --- a/templates/module/angular/src/app/app.component.ts +++ b/templates/module/angular/src/app/app.component.ts @@ -1,4 +1,6 @@ -import { Component } from '@angular/core'; +import { LazyLoadService, LOADING_STRATEGY } from '@abp/ng.core'; +import { Component, OnInit } from '@angular/core'; +import { forkJoin } from 'rxjs'; @Component({ selector: 'app-root', @@ -7,4 +9,17 @@ import { Component } from '@angular/core'; `, }) -export class AppComponent {} +export class AppComponent implements OnInit { + constructor(private lazyLoadService: LazyLoadService) {} + + ngOnInit() { + forkJoin( + this.lazyLoadService.load( + LOADING_STRATEGY.PrependAnonymousStyleToHead('fontawesome-v4-shims.min.css'), + ), + this.lazyLoadService.load( + LOADING_STRATEGY.PrependAnonymousStyleToHead('fontawesome-all.min.css'), + ), + ).subscribe(); + } +} diff --git a/templates/module/angular/src/app/shared/shared.module.ts b/templates/module/angular/src/app/shared/shared.module.ts index 6c4c9b016c..1f268b4572 100644 --- a/templates/module/angular/src/app/shared/shared.module.ts +++ b/templates/module/angular/src/app/shared/shared.module.ts @@ -3,7 +3,6 @@ import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; import { NgModule } from '@angular/core'; import { ThemeBasicModule } from '@abp/ng.theme.basic'; import { ThemeSharedModule } from '@abp/ng.theme.shared'; -import { TableModule } from 'primeng/table'; import { NgxValidateCoreModule } from '@ngx-validate/core'; @NgModule({ @@ -12,7 +11,6 @@ import { NgxValidateCoreModule } from '@ngx-validate/core'; CoreModule, ThemeSharedModule, ThemeBasicModule, - TableModule, NgbDropdownModule, NgxValidateCoreModule, ], @@ -20,7 +18,6 @@ import { NgxValidateCoreModule } from '@ngx-validate/core'; CoreModule, ThemeSharedModule, ThemeBasicModule, - TableModule, NgbDropdownModule, NgxValidateCoreModule, ], diff --git a/templates/module/angular/src/environments/environment.hmr.ts b/templates/module/angular/src/environments/environment.hmr.ts deleted file mode 100644 index 4c6c9fd343..0000000000 --- a/templates/module/angular/src/environments/environment.hmr.ts +++ /dev/null @@ -1,25 +0,0 @@ -export const environment = { - production: false, - hmr: true, - application: { - name: 'MyProjectName', - logoUrl: '', - }, - oAuthConfig: { - issuer: 'https://localhost:44301', - clientId: 'MyProjectName_ConsoleTestApp', - dummyClientSecret: '1q2w3e*', - scope: 'MyProjectName', - showDebugInformation: true, - oidc: false, - requireHttps: true, - }, - apis: { - default: { - url: 'https://localhost:44300', - }, - }, - localization: { - defaultResourceName: 'MyProjectName', - }, -}; diff --git a/templates/module/angular/src/environments/environment.prod.ts b/templates/module/angular/src/environments/environment.prod.ts index 093c7f6f98..ce43f45c24 100644 --- a/templates/module/angular/src/environments/environment.prod.ts +++ b/templates/module/angular/src/environments/environment.prod.ts @@ -1,6 +1,5 @@ export const environment = { production: true, - hmr: false, application: { name: 'MyProjectName', logoUrl: '', diff --git a/templates/module/angular/src/environments/environment.ts b/templates/module/angular/src/environments/environment.ts index 2fe4e73868..f1c21c40ac 100644 --- a/templates/module/angular/src/environments/environment.ts +++ b/templates/module/angular/src/environments/environment.ts @@ -1,6 +1,5 @@ export const environment = { production: false, - hmr: false, application: { name: 'MyProjectName', logoUrl: '', diff --git a/templates/module/angular/src/main.ts b/templates/module/angular/src/main.ts index bbdf75c32d..d9a2e7e4a5 100644 --- a/templates/module/angular/src/main.ts +++ b/templates/module/angular/src/main.ts @@ -1,20 +1,13 @@ import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; -import { BootstrapModuleFn as Bootstrap, hmr, WebpackModule } from '@ngxs/hmr-plugin'; import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; -declare const module: WebpackModule; - if (environment.production) { enableProdMode(); } -const bootstrap: Bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule); - -if (environment.hmr) { - hmr(module, bootstrap).catch(err => console.error(err)); -} else { - bootstrap().catch(err => console.log(err)); -} +platformBrowserDynamic() + .bootstrapModule(AppModule) + .catch((err) => console.error(err)); diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/appsettings.json b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/appsettings.json index 6dceb9c4b9..6152adf169 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/appsettings.json +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/appsettings.json @@ -3,7 +3,7 @@ "CorsOrigins": "https://*.MyProjectName.com,http://localhost:4200" }, "ConnectionStrings": { - "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName_Main;Trusted_Connection=True;MultipleActiveResultSets=true", + "Default": "Server=localhost;Database=MyProjectName_Main;User Id=sa;password=myPassw0rd;MultipleActiveResultSets=true", "MyProjectName": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName_Module;Trusted_Connection=True;MultipleActiveResultSets=true" }, "Redis": { @@ -12,4 +12,4 @@ "AuthServer": { "Authority": "https://localhost:44301/" } -} \ No newline at end of file +} diff --git a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/appsettings.json b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/appsettings.json index 0386db1e6a..f880341925 100644 --- a/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/appsettings.json +++ b/templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/appsettings.json @@ -5,7 +5,7 @@ }, "AppSelfUrl": "https://localhost:44301/", "ConnectionStrings": { - "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=MyProjectName_Main;Trusted_Connection=True;MultipleActiveResultSets=true" + "Default": "Server=localhost;Database=MyProjectName_Main;User Id=sa;password=myPassw0rd;MultipleActiveResultSets=true" }, "Redis": { "Configuration": "127.0.0.1" @@ -25,4 +25,4 @@ } } } -} \ No newline at end of file +}