Revision 61123
Added by Konstantinos Triantafyllou over 3 years ago
modules/uoa-monitor-portal/branches/angular-11/monitor/angular.json | ||
---|---|---|
35 | 35 |
"build": { |
36 | 36 |
"builder": "@angular-devkit/build-angular:browser", |
37 | 37 |
"options": { |
38 |
"outputPath": "dist/monitor", |
|
38 |
"aot": true, |
|
39 |
"outputPath": "dist/monitor/browser", |
|
39 | 40 |
"index": "src/index.html", |
40 | 41 |
"main": "src/main.ts", |
41 | 42 |
"polyfills": "src/polyfills.ts", |
... | ... | |
79 | 80 |
"type": "initial", |
80 | 81 |
"maximumWarning": "2mb", |
81 | 82 |
"maximumError": "5mb" |
83 |
}, |
|
84 |
{ |
|
85 |
"type": "anyComponentStyle", |
|
86 |
"maximumWarning": "6kb" |
|
82 | 87 |
} |
83 | 88 |
] |
84 | 89 |
} |
... | ... | |
129 | 134 |
"**/node_modules/**" |
130 | 135 |
] |
131 | 136 |
} |
137 |
}, |
|
138 |
"server": { |
|
139 |
"builder": "@angular-devkit/build-angular:server", |
|
140 |
"options": { |
|
141 |
"outputPath": "dist/monitor/server", |
|
142 |
"main": "server.ts", |
|
143 |
"tsConfig": "src/tsconfig.server.json" |
|
144 |
}, |
|
145 |
"configurations": { |
|
146 |
"production": { |
|
147 |
"outputHashing": "media", |
|
148 |
"fileReplacements": [ |
|
149 |
{ |
|
150 |
"replace": "src/environments/environment.ts", |
|
151 |
"with": "src/environments/environment.prod.ts" |
|
152 |
} |
|
153 |
], |
|
154 |
"sourceMap": false, |
|
155 |
"optimization": true |
|
156 |
} |
|
157 |
} |
|
158 |
}, |
|
159 |
"serve-ssr": { |
|
160 |
"builder": "@nguniversal/builders:ssr-dev-server", |
|
161 |
"options": { |
|
162 |
"browserTarget": "monitor:build", |
|
163 |
"serverTarget": "monitor:server" |
|
164 |
}, |
|
165 |
"configurations": { |
|
166 |
"production": { |
|
167 |
"browserTarget": "monitor:build:production", |
|
168 |
"serverTarget": "monitor:server:production" |
|
169 |
} |
|
170 |
} |
|
171 |
}, |
|
172 |
"prerender": { |
|
173 |
"builder": "@nguniversal/builders:prerender", |
|
174 |
"options": { |
|
175 |
"browserTarget": "monitor:build:production", |
|
176 |
"serverTarget": "monitor:server:production", |
|
177 |
"routes": [ |
|
178 |
"/" |
|
179 |
] |
|
180 |
}, |
|
181 |
"configurations": { |
|
182 |
"production": {} |
|
183 |
} |
|
132 | 184 |
} |
133 | 185 |
} |
134 | 186 |
}, |
modules/uoa-monitor-portal/branches/angular-11/monitor/package.json | ||
---|---|---|
6 | 6 |
"start": " ng serve --port 4500 --disable-host-check --host 0.0.0.0", |
7 | 7 |
"build": "ng build", |
8 | 8 |
"test": "ng test", |
9 |
"e2e": "ng e2e" |
|
9 |
"e2e": "ng e2e", |
|
10 |
"dev:ssr": "ng run monitor:serve-ssr", |
|
11 |
"serve:ssr": "node dist/monitor/server/main.js", |
|
12 |
"build:ssr": "ng build --prod && ng run monitor:server:production", |
|
13 |
"prerender": "ng run monitor:prerender" |
|
10 | 14 |
}, |
11 | 15 |
"private": true, |
12 | 16 |
"dependencies": { |
13 |
"@angular/cdk": "^8.2.3", |
|
14 |
"@angular/animations": "~8.2.14", |
|
15 |
"@angular/common": "~8.2.14", |
|
16 |
"@angular/compiler": "~8.2.14", |
|
17 |
"@angular/core": "~8.2.14", |
|
18 |
"@angular/material": "^8.2.3", |
|
19 |
"@angular/forms": "~8.2.14", |
|
20 |
"@angular/platform-browser": "~8.2.14", |
|
21 |
"@angular/platform-browser-dynamic": "~8.2.14", |
|
22 |
"@angular/router": "~8.2.14", |
|
17 |
"@angular/animations": "~9.1.13", |
|
18 |
"@angular/cdk": "^9.2.4", |
|
19 |
"@angular/common": "~9.1.13", |
|
20 |
"@angular/compiler": "~9.1.13", |
|
21 |
"@angular/core": "~9.1.13", |
|
22 |
"@angular/forms": "~9.1.13", |
|
23 |
"@angular/localize": "^9.1.13", |
|
24 |
"@angular/material": "^9.2.4", |
|
25 |
"@angular/platform-browser": "~9.1.13", |
|
26 |
"@angular/platform-browser-dynamic": "~9.1.13", |
|
27 |
"@angular/platform-server": "~9.1.13", |
|
28 |
"@angular/router": "~9.1.13", |
|
29 |
"@nguniversal/express-engine": "^9.1.1", |
|
23 | 30 |
"clipboard": "^1.5.16", |
24 | 31 |
"core-js": "^2.5.4", |
25 | 32 |
"express": "^4.15.2", |
26 | 33 |
"jquery": "^3.4.1", |
34 |
"ng-recaptcha": "^5.0.0", |
|
35 |
"rxjs": "^6.5.1", |
|
27 | 36 |
"ts-md5": "^1.2.0", |
28 |
"rxjs": "^6.5.1", |
|
29 |
"ng-recaptcha": "^5.0.0", |
|
30 |
"zone.js": "~0.9.1" |
|
37 |
"tslib": "^1.10.0", |
|
38 |
"zone.js": "~0.10.2" |
|
31 | 39 |
}, |
32 | 40 |
"devDependencies": { |
33 |
"@angular-devkit/build-angular": "~0.803.29", |
|
34 |
"@angular/cli": "~8.3.29", |
|
35 |
"@angular/compiler-cli": "~8.2.14", |
|
36 |
"@angular/language-service": "~8.2.14", |
|
41 |
"@angular-devkit/build-angular": "~0.901.15", |
|
42 |
"@angular/cli": "~9.1.15", |
|
43 |
"@angular/compiler-cli": "~9.1.13", |
|
44 |
"@angular/language-service": "~9.1.13", |
|
45 |
"@nguniversal/builders": "^9.1.1", |
|
37 | 46 |
"@types/express": "^4.17.0", |
38 | 47 |
"@types/compression": "^1.7.0", |
39 |
"@types/node": "~8.9.4",
|
|
48 |
"@types/node": "^12.11.1",
|
|
40 | 49 |
"@types/jasmine": "~2.8.8", |
41 | 50 |
"@types/jasminewd2": "~2.0.3", |
42 |
"codelyzer": "^5.0.1",
|
|
51 |
"codelyzer": "^5.1.2",
|
|
43 | 52 |
"jasmine-core": "~2.99.1", |
44 | 53 |
"jasmine-spec-reporter": "~4.2.1", |
45 | 54 |
"karma": "~4.0.0", |
... | ... | |
49 | 58 |
"karma-jasmine-html-reporter": "^0.2.2", |
50 | 59 |
"protractor": "~5.4.0", |
51 | 60 |
"ts-node": "~7.0.0", |
52 |
"typescript": "~3.5.3"
|
|
61 |
"typescript": "~3.8.3"
|
|
53 | 62 |
} |
54 | 63 |
} |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/app/shared/shared.module.ts | ||
---|---|---|
37 | 37 |
] |
38 | 38 |
}) |
39 | 39 |
export class SharedModule { |
40 |
static forRoot(): ModuleWithProviders { |
|
40 |
static forRoot(): ModuleWithProviders<SharedModule> {
|
|
41 | 41 |
return { |
42 | 42 |
ngModule: SharedModule, |
43 | 43 |
}; |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/app/home/home.component.ts | ||
---|---|---|
78 | 78 |
|
79 | 79 |
public state = 1; |
80 | 80 |
private timeouts: any[] = []; |
81 |
@ViewChild('AlertModal', { static: false }) modal;
|
|
81 |
@ViewChild('AlertModal') modal; |
|
82 | 82 |
public directLink: boolean = true; |
83 | 83 |
private user: User; |
84 | 84 |
visibilityIcon: Map<Visibility, string> = new Map<Visibility, string> ([ |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/app/app.module.ts | ||
---|---|---|
31 | 31 |
BottomModule, |
32 | 32 |
CookieLawModule, |
33 | 33 |
BrowserTransferStateModule, |
34 |
BrowserModule, |
|
34 |
BrowserModule.withServerTransition({ appId: 'monitor' }),
|
|
35 | 35 |
AppRoutingModule, |
36 | 36 |
Schema2jsonldModule |
37 | 37 |
], |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/app/contact/contact.component.ts | ||
---|---|---|
34 | 34 |
'Non-profit', 'Industry', 'Other' |
35 | 35 |
]; |
36 | 36 |
public contactForm: FormGroup; |
37 |
@ViewChild('AlertModal', { static: false }) modal;
|
|
37 |
@ViewChild('AlertModal') modal; |
|
38 | 38 |
|
39 | 39 |
constructor(private route: ActivatedRoute, |
40 | 40 |
private _router: Router, |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/app/contact/contact.module.ts | ||
---|---|---|
18 | 18 |
@NgModule({ |
19 | 19 |
imports: [ |
20 | 20 |
ContactRoutingModule, CommonModule, RouterModule, |
21 |
AlertModalModule, RecaptchaModule.forRoot(), HelperModule,
|
|
21 |
AlertModalModule, RecaptchaModule, HelperModule, |
|
22 | 22 |
Schema2jsonldModule, SEOServiceModule, ContactUsModule |
23 | 23 |
], |
24 | 24 |
declarations: [ |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/app/app-routing.module.ts | ||
---|---|---|
35 | 35 |
]; |
36 | 36 |
|
37 | 37 |
@NgModule({ |
38 |
imports: [RouterModule.forRoot(routes)], |
|
38 |
imports: [RouterModule.forRoot(routes, { |
|
39 |
onSameUrlNavigation: "reload" |
|
40 |
})], |
|
39 | 41 |
exports: [RouterModule] |
40 | 42 |
}) |
41 | 43 |
export class AppRoutingModule { |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/app/app.server.module.ts | ||
---|---|---|
1 |
import { NgModule } from '@angular/core'; |
|
2 |
import {ServerModule, ServerTransferStateModule} from '@angular/platform-server'; |
|
3 |
|
|
4 |
import { AppModule } from './app.module'; |
|
5 |
import { AppComponent } from './app.component'; |
|
6 |
|
|
7 |
@NgModule({ |
|
8 |
imports: [ |
|
9 |
AppModule, |
|
10 |
ServerModule, |
|
11 |
ServerTransferStateModule |
|
12 |
], |
|
13 |
bootstrap: [AppComponent], |
|
14 |
}) |
|
15 |
export class AppServerModule {} |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/tsconfig.server.json | ||
---|---|---|
1 |
{ |
|
2 |
"extends": "./tsconfig.app.json", |
|
3 |
"compilerOptions": { |
|
4 |
"outDir": "../out-tsc/app-server", |
|
5 |
"module": "commonjs", |
|
6 |
"types": [ |
|
7 |
"node" |
|
8 |
] |
|
9 |
}, |
|
10 |
"files": [ |
|
11 |
"src/main.server.ts", |
|
12 |
"server.ts" |
|
13 |
], |
|
14 |
"angularCompilerOptions": { |
|
15 |
"entryModule": "./app/app.server.module#AppServerModule" |
|
16 |
} |
|
17 |
} |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/polyfills.ts | ||
---|---|---|
1 |
/*************************************************************************************************** |
|
2 |
* Load `$localize` onto the global scope - used if i18n tags appear in Angular templates. |
|
3 |
*/ |
|
4 |
import '@angular/localize/init'; |
|
1 | 5 |
/** |
2 | 6 |
* This file includes polyfills needed by Angular and is loaded before the app. |
3 | 7 |
* You can add your own extra polyfills to this file. |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/tsconfig.app.json | ||
---|---|---|
4 | 4 |
"outDir": "../out-tsc/app", |
5 | 5 |
"types": [] |
6 | 6 |
}, |
7 |
"exclude": [ |
|
8 |
"test.ts", |
|
9 |
"**/*.spec.ts" |
|
7 |
"files": [ |
|
8 |
"main.ts", |
|
9 |
"polyfills.ts" |
|
10 |
], |
|
11 |
"include": [ |
|
12 |
"src/**/*.d.ts" |
|
10 | 13 |
] |
11 | 14 |
} |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/main.ts | ||
---|---|---|
8 | 8 |
enableProdMode(); |
9 | 9 |
} |
10 | 10 |
|
11 |
platformBrowserDynamic().bootstrapModule(AppModule) |
|
11 |
document.addEventListener('DOMContentLoaded', () => { |
|
12 |
platformBrowserDynamic().bootstrapModule(AppModule) |
|
12 | 13 |
.catch(err => console.error(err)); |
14 |
}); |
modules/uoa-monitor-portal/branches/angular-11/monitor/src/main.server.ts | ||
---|---|---|
1 |
/*************************************************************************************************** |
|
2 |
* Load `$localize` onto the global scope - used if i18n tags appear in Angular templates. |
|
3 |
*/ |
|
4 |
import '@angular/localize/init'; |
|
5 |
|
|
6 |
import {enableProdMode} from '@angular/core'; |
|
7 |
|
|
8 |
import {properties} from './environments/environment'; |
|
9 |
|
|
10 |
if (properties.environment !== "development") { |
|
11 |
enableProdMode(); |
|
12 |
} |
|
13 |
|
|
14 |
export {AppServerModule} from './app/app.server.module'; |
|
15 |
export {renderModule, renderModuleFactory} from '@angular/platform-server'; |
modules/uoa-monitor-portal/branches/angular-11/monitor/server.ts | ||
---|---|---|
1 |
import 'zone.js/dist/zone-node'; |
|
2 |
|
|
3 |
import { ngExpressEngine } from '@nguniversal/express-engine'; |
|
4 |
import * as express from 'express'; |
|
5 |
import * as compression from 'compression'; |
|
6 |
import { join } from 'path'; |
|
7 |
|
|
8 |
import { AppServerModule } from './src/main.server'; |
|
9 |
import { APP_BASE_HREF } from '@angular/common'; |
|
10 |
import { existsSync } from 'fs'; |
|
11 |
import {REQUEST, RESPONSE} from "./src/app/openaireLibrary/utils/tokens"; |
|
12 |
|
|
13 |
// The Express app is exported so that it can be used by serverless Functions. |
|
14 |
export function app() { |
|
15 |
const server = express(); |
|
16 |
server.use(compression()); |
|
17 |
const distFolder = join(process.cwd(), 'dist/monitor/browser'); |
|
18 |
const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index'; |
|
19 |
|
|
20 |
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine) |
|
21 |
server.engine('html', ngExpressEngine({ |
|
22 |
bootstrap: AppServerModule, |
|
23 |
})); |
|
24 |
|
|
25 |
server.set('view engine', 'html'); |
|
26 |
server.set('views', distFolder); |
|
27 |
|
|
28 |
// Example Express Rest API endpoints |
|
29 |
// server.get('/api/**', (req, res) => { }); |
|
30 |
// Serve static files from /browser |
|
31 |
server.get('*.*', express.static(distFolder, { |
|
32 |
maxAge: '1y' |
|
33 |
})); |
|
34 |
|
|
35 |
// All regular routes use the Universal engine |
|
36 |
server.get('*', (req, res) => { |
|
37 |
res.render(indexHtml, { |
|
38 |
req, providers: [ |
|
39 |
{ |
|
40 |
provide: APP_BASE_HREF, |
|
41 |
useValue: req.baseUrl |
|
42 |
}, |
|
43 |
{ |
|
44 |
provide: REQUEST, useValue: (req) |
|
45 |
}, |
|
46 |
{ |
|
47 |
provide: RESPONSE, useValue: (res) |
|
48 |
} |
|
49 |
] |
|
50 |
} |
|
51 |
); |
|
52 |
}); |
|
53 |
|
|
54 |
return server; |
|
55 |
} |
|
56 |
|
|
57 |
function run() { |
|
58 |
const port = process.env.PORT || 4000; |
|
59 |
|
|
60 |
// Start up the Node server |
|
61 |
const server = app(); |
|
62 |
server.listen(port, () => { |
|
63 |
console.log(`Node Express server listening on http://localhost:${port}`); |
|
64 |
}); |
|
65 |
} |
|
66 |
|
|
67 |
// Webpack will replace 'require' with '__webpack_require__' |
|
68 |
// '__non_webpack_require__' is a proxy to Node 'require' |
|
69 |
// The below code is to ensure that the server is run only when not requiring the bundle. |
|
70 |
declare const __non_webpack_require__: NodeRequire; |
|
71 |
const mainModule = __non_webpack_require__.main; |
|
72 |
const moduleFilename = mainModule && mainModule.filename || ''; |
|
73 |
if (moduleFilename === __filename || moduleFilename.includes('iisnode')) { |
|
74 |
run(); |
|
75 |
} |
|
76 |
|
|
77 |
export * from './src/main.server'; |
Also available in: Unified diff
[Monitor | Angular 11]: Update to angular 9. Add server side