diff --git a/frontend/angular.json b/frontend/angular.json index 72f331d..36c3eb7 100644 --- a/frontend/angular.json +++ b/frontend/angular.json @@ -43,7 +43,7 @@ { "type": "anyComponentStyle", "maximumWarning": "2kb", - "maximumError": "4kb" + "maximumError": "6kb" } ], "fileReplacements": [ diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 6cfed54..3d9e0de 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -20,7 +20,6 @@ "@angular/platform-browser-dynamic": "^16.0.0", "@angular/router": "^16.0.0", "@syncfusion/ej2-angular-gantt": "^26.2.4", - "@syncfusion/ej2-material-theme": "^26.2.4", "jquery": "^3.6.1", "moment": "^2.29.4", "rxjs": "^7.8.0", @@ -5111,12 +5110,6 @@ "@syncfusion/ej2-popups": "~26.2.5" } }, - "node_modules/@syncfusion/ej2-material-theme": { - "version": "26.2.7", - "resolved": "https://registry.npmjs.org/@syncfusion/ej2-material-theme/-/ej2-material-theme-26.2.7.tgz", - "integrity": "sha512-UeUBuUmAfiTr5UUJwlpbhTf0gDZDTbp1qpayhu3BeZeT9YThju0PkZW95cYxgzOfmdn06SVUxbFqOjIWL7IWbg==", - "license": "SEE LICENSE IN license" - }, "node_modules/@syncfusion/ej2-navigations": { "version": "26.2.7", "resolved": "https://registry.npmjs.org/@syncfusion/ej2-navigations/-/ej2-navigations-26.2.7.tgz", diff --git a/frontend/package.json b/frontend/package.json index 09ce0bc..96c6516 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,11 +3,12 @@ "version": "0.0.0", "scripts": { "ng": "ng", - "start": "ng serve", + "start": "npm run generate-env && ng serve", "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test", - "compodoc": "npx compodoc -p tsconfig.doc.json" + "compodoc": "npx compodoc -p tsconfig.doc.json", + "generate-env": "npx ts-node -O \"{\\\"module\\\":\\\"commonjs\\\"}\" -e \"const fs = require('fs'); const path = require('path'); const { environment } = require(path.join(process.cwd(), './src/environments/', (process.argv[1] || 'environment.ts'))); fs.writeFileSync(path.join(process.cwd(), './src/assets/environment.json'), JSON.stringify(environment));\"" }, "private": true, "dependencies": { diff --git a/frontend/src/app/app.config.ts b/frontend/src/app/app.config.ts new file mode 100644 index 0000000..4acd95b --- /dev/null +++ b/frontend/src/app/app.config.ts @@ -0,0 +1,4 @@ +import { InjectionToken } from '@angular/core' +import { AppConfig } from 'src/environments/models/environment.model' + +export let APP_CONFIG = new InjectionToken('APP_CONFIG') \ No newline at end of file diff --git a/frontend/src/app/data.service.ts b/frontend/src/app/data.service.ts index fdbd943..fed0a7a 100644 --- a/frontend/src/app/data.service.ts +++ b/frontend/src/app/data.service.ts @@ -1,10 +1,12 @@ import { JsonPipe } from '@angular/common'; import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; +import { Inject, Injectable } from '@angular/core'; import { ResourceFields } from '@syncfusion/ej2-angular-gantt'; import { LanguageService } from './language.service'; import { ErrorService } from './error.service'; import { Location } from '@angular/common'; +import { AppConfig } from 'src/environments/models/environment.model'; +import { APP_CONFIG } from './app.config'; interface Preset { id: string; @@ -36,7 +38,8 @@ export class DataService { private totalSize: number = null; private user: string = null; public userSupportGroup: string; - public authUrl = 'https://itsm-dev-neu-rsso.asfinag.at/rsso/start?bypass-auth=true&tenant=itsm-dev-neu&goto=https://itsm-dev-neu.asfinag.at/arsys/calendar'; + //public authUrl = 'https://itsm-dev-neu-rsso.asfinag.at/rsso/start?bypass-auth=true&tenant=itsm-dev-neu&goto=https://itsm-dev-neu.asfinag.at/arsys/calendar'; + private config: AppConfig; //public selectedLanguage: string = 'DE'; @@ -45,7 +48,7 @@ export class DataService { * @param languageService injection of the languageService * @param http representation of the HttpClient */ - constructor(public languageService: LanguageService, private http: HttpClient, public errorService: ErrorService, private location: Location) { + constructor(@Inject(APP_CONFIG) config: AppConfig, public languageService: LanguageService, private http: HttpClient, public errorService: ErrorService, private location: Location) { this.getUser().then((res: any )=>{ this.user = res.userId; }); @@ -66,10 +69,12 @@ export class DataService { this.userSupportGroup = res.name; console.log(this.userSupportGroup); }); + + this.config=config; } public redirectToAuthUrl() { - window.location.href = this.authUrl; + window.location.href = this.config.rssoUrl; } /** @@ -164,7 +169,7 @@ export class DataService { public async getUser(){ const promise = new Promise(resolve=>{ let res : any; - this.http.get('http://localhost:8080/api/getUser') + this.http.get(this.config.backendUrl+'/getUser') .subscribe((response: any)=>{ res = response; resolve(res); @@ -184,7 +189,7 @@ export class DataService { public async initPresets(){ const promise = new Promise(resolve=>{ let res = {presets: [], selectedPreset: '', userPreferences: {}, presetGroups: []}; - this.http.get('http://localhost:8080/api/initPresets') + this.http.get(this.config.backendUrl+'/initPresets') .subscribe((response: any)=>{ console.log(response); if(response.status == 500){ @@ -276,7 +281,7 @@ export class DataService { let strigifiedResource = JSON.stringify(serializableResource); let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource; console.log(resJson); - this.http.post('http://localhost:8080/api/selectPreset', resJson).subscribe((response:any)=>{ + this.http.post(this.config.backendUrl+'/selectPreset', resJson).subscribe((response:any)=>{ resolve(response); console.log(response); },(error:any)=>{ @@ -296,7 +301,7 @@ export class DataService { let strigifiedResource = JSON.stringify(serializableResource); let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource; console.log(resJson); - this.http.post('http://localhost:8080/api/savePreset', resJson).subscribe((response:any)=>{ + this.http.post(this.config.backendUrl+'/savePreset', resJson).subscribe((response:any)=>{ resolve(response); console.log(response); },(error:any)=>{ @@ -316,7 +321,7 @@ export class DataService { let serializableResource = {id: preset.id, definition: JSON.stringify(preset.definition)}; let strigifiedResource = JSON.stringify(serializableResource); let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource; - this.http.post('http://localhost:8080/api/updatePreset', resJson).subscribe((response:any)=>{ + this.http.post(this.config.backendUrl+'/updatePreset', resJson).subscribe((response:any)=>{ resolve(response); },(error:any)=>{ resolve(error); @@ -334,7 +339,7 @@ export class DataService { let serializableResource = {id: preset.id, newName: preset.name}; let strigifiedResource = JSON.stringify(serializableResource); let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource; - this.http.post('http://localhost:8080/api/renamePreset', resJson).subscribe((response:any)=>{ + this.http.post(this.config.backendUrl+'/renamePreset', resJson).subscribe((response:any)=>{ resolve(response); },(error:any)=>{ resolve(error); @@ -352,7 +357,7 @@ export class DataService { let serializableResource = {id: preset.id}; let strigifiedResource = JSON.stringify(serializableResource); let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource; - this.http.post('http://localhost:8080/api/deletePreset', resJson).subscribe((response:any)=>{ + this.http.post(this.config.backendUrl+'/deletePreset', resJson).subscribe((response:any)=>{ resolve(response); },(error:any)=>{ resolve(error); @@ -371,7 +376,7 @@ export class DataService { let strigifiedResource = JSON.stringify(serializableResource); let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource; console.log(resJson); - this.http.post('http://localhost:8080/api/editUserPreferences', resJson).subscribe((response:any)=>{ + this.http.post(this.config.backendUrl+'/editUserPreferences', resJson).subscribe((response:any)=>{ resolve(response); },(error:any)=>{ resolve(error); @@ -387,7 +392,7 @@ export class DataService { public async fetchStates(){ const promise = new Promise(resolve=>{ let res : any[] = []; - this.http.get('http://localhost:8080/api/getStates') + this.http.get(this.config.backendUrl+'/getStates') .subscribe((response: any)=>{ console.log("###\n"); console.log(response); @@ -411,7 +416,7 @@ export class DataService { public async fetchSupportGroups(){ const promise = new Promise(resolve=>{ let res : any[] = []; - this.http.get('http://localhost:8080/api/getSupportGroups') + this.http.get(this.config.backendUrl+'/getSupportGroups') .subscribe((response: any)=>{ response.forEach(supportGroup => { res.push(supportGroup) @@ -433,7 +438,7 @@ export class DataService { public async fetchContracts(){ const promise = new Promise(resolve=>{ let res : any[] = []; - this.http.get('http://localhost:8080/api/getContracts') + this.http.get(this.config.backendUrl+'/getContracts') .subscribe((response: any)=>{ response.forEach(contract => { res.push(contract) @@ -451,7 +456,7 @@ export class DataService { // public async fetchPaketTypes(){ // const promise = new Promise(resolve=>{ // let res : any[] = []; - // this.http.get('http://localhost:8080/api/getPackageTypes') + // this.http.get(this.config.backendUrl+'/getPackageTypes') // .subscribe((response: any)=>{ // response.forEach(paketType => { // res.push(paketType) @@ -469,7 +474,7 @@ export class DataService { public async fetchUserSupportGroup(){ const promise = new Promise(resolve=>{ let res : any = {}; - this.http.get('http://localhost:8080/api/getUserSupportGroup') + this.http.get(this.config.backendUrl+'/getUserSupportGroup') .subscribe((response: any)=>{ this.userSupportGroup = res.name; res = response; @@ -495,7 +500,7 @@ export class DataService { let stringyfiedData = JSON.stringify(obj); let dataJson = JSON.parse(stringyfiedData) as typeof stringyfiedData; let res : any[] = []; - this.http.post('http://localhost:8080/api/fetchPlanTimes', dataJson) + this.http.post(this.config.backendUrl+'/fetchPlanTimes', dataJson) .subscribe((response: any[])=>{ response.forEach(week => { res.push(week); @@ -518,7 +523,7 @@ export class DataService { let dataJson = JSON.parse(stringyfiedData) as typeof stringyfiedData; // console.log(dataJson); let res : any[] = []; - this.http.post('http://localhost:8080/api/getImplementer', dataJson) + this.http.post(this.config.backendUrl+'/getImplementer', dataJson) .subscribe((response: any)=>{ response.members.forEach(implementer => { res.push(implementer) @@ -538,7 +543,7 @@ export class DataService { let serializableResource = { resourceId: change.resourceId, d2: change.tasks[1].StartDate, changeNr: change.changeNr, state: change.state}; let strigifiedResource = JSON.stringify(serializableResource); let resJson = JSON.parse(strigifiedResource) as typeof strigifiedResource; - this.http.post('http://localhost:8080/api/updateChange', resJson).subscribe((response:any)=>{ + this.http.post(this.config.backendUrl+'/updateChange', resJson).subscribe((response:any)=>{ resolve(response); },(error:any)=>{ resolve(error); @@ -558,7 +563,7 @@ export class DataService { let stringyfiedData = JSON.stringify(obj); let dataJson = JSON.parse(stringyfiedData) as typeof stringyfiedData; // console.log(dataJson); - this.http.post('http://localhost:8080/api/updateState', dataJson).subscribe((response:any)=>{ + this.http.post(this.config.backendUrl+'/updateState', dataJson).subscribe((response:any)=>{ resolve(response); },(error:any)=>{ resolve(error); @@ -580,7 +585,7 @@ export class DataService { let stringyfiedData = JSON.stringify(obj); let dataJson = JSON.parse(stringyfiedData) as typeof stringyfiedData; // console.log(dataJson); - this.http.post('http://localhost:8080/api/updateImplementer', dataJson).subscribe((response:any)=>{ + this.http.post(this.config.backendUrl+'/updateImplementer', dataJson).subscribe((response:any)=>{ resolve(response); },(error:any)=>{ console.log(error); @@ -602,7 +607,7 @@ export class DataService { let stringyfiedData = JSON.stringify(obj); let dataJson = JSON.parse(stringyfiedData) as typeof stringyfiedData; console.log(dataJson); - this.http.post('http://localhost:8080/api/updateApproval', dataJson).subscribe((response:any)=>{ + this.http.post(this.config.backendUrl+'/updateApproval', dataJson).subscribe((response:any)=>{ resolve(response); },(error:any)=>{ resolve(error); @@ -627,7 +632,7 @@ export class DataService { let first : boolean = true; let res : any[] = []; console.log(dataJson); - this.http.post('http://localhost:8080/api/getChanges', dataJson) + this.http.post(this.config.backendUrl+'/getChanges', dataJson) .subscribe((response:any)=>{ console.log("ALL CHANGES ##############\n",response); this.totalSize = response.totalSize; diff --git a/frontend/src/assets/environment.json b/frontend/src/assets/environment.json new file mode 100644 index 0000000..a062946 --- /dev/null +++ b/frontend/src/assets/environment.json @@ -0,0 +1 @@ +{"production":false,"rssoUrl":"http://orf.at","backendUrl":"http://localhost:8080/api"} \ No newline at end of file diff --git a/frontend/src/environments/environment.container.ts b/frontend/src/environments/environment.container.ts new file mode 100644 index 0000000..0d28b0b --- /dev/null +++ b/frontend/src/environments/environment.container.ts @@ -0,0 +1,7 @@ +import { AppConfig } from './models/environment.model'; + +export const environment: AppConfig = { + production: true, + rssoUrl: "RSSO_URL", + backendUrl: "BACKEND_API_URL" +}; diff --git a/frontend/src/environments/environment.prod.ts b/frontend/src/environments/environment.prod.ts deleted file mode 100644 index 3612073..0000000 --- a/frontend/src/environments/environment.prod.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const environment = { - production: true -}; diff --git a/frontend/src/environments/environment.ts b/frontend/src/environments/environment.ts index f56ff47..5413891 100644 --- a/frontend/src/environments/environment.ts +++ b/frontend/src/environments/environment.ts @@ -1,16 +1,9 @@ -// This file can be replaced during build by using the `fileReplacements` array. -// `ng build` replaces `environment.ts` with `environment.prod.ts`. -// The list of file replacements can be found in `angular.json`. -export const environment = { - production: false -}; -/* - * For easier debugging in development mode, you can import the following file - * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. - * - * This import should be commented out in production mode because it will have a negative impact - * on performance if an error is thrown. - */ -// import 'zone.js/plugins/zone-error'; // Included with Angular CLI. +import { AppConfig } from './models/environment.model'; + +export const environment: AppConfig = { + production: false, + rssoUrl: "#", + backendUrl: "http://localhost:8080/api" +}; \ No newline at end of file diff --git a/frontend/src/environments/models/environment.model.ts b/frontend/src/environments/models/environment.model.ts new file mode 100644 index 0000000..32164a6 --- /dev/null +++ b/frontend/src/environments/models/environment.model.ts @@ -0,0 +1,5 @@ +export interface AppConfig { + production: boolean; + rssoUrl: string; + backendUrl: string; +} \ No newline at end of file diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 8419948..7702fe5 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -1,14 +1,24 @@ import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; -import {registerLicense} from '@syncfusion/ej2-base' +import { registerLicense } from '@syncfusion/ej2-base' import { AppModule } from './app/app.module'; -import { environment } from './environments/environment'; +import { AppComponent } from './app/app.component'; +import { APP_CONFIG } from './app/app.config'; + registerLicense("Ngo9BigBOggjHTQxAR8/V1NCaF5cXmZCf1FpRmJGdld5fUVHYVZUTXxaS00DNHVRdkdnWXdedXRcQmJeVUZzV0Y="); -if (environment.production) { - enableProdMode(); -} -platformBrowserDynamic().bootstrapModule(AppModule) - .catch(err => console.error(err)); +fetch('/assets/environment.json') + .then((response) => response.json()) + .then((config) => { + if (config.production) { + enableProdMode() + } + + platformBrowserDynamic([{ provide: APP_CONFIG, useValue: config }]).bootstrapModule(AppModule) + .catch(err => console.error(err)); + }) + +//bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err)); +