diff --git a/.github/workflows/angular-prettier.yml b/.github/workflows/angular-prettier.yml index 6148de764..0e6592790 100644 --- a/.github/workflows/angular-prettier.yml +++ b/.github/workflows/angular-prettier.yml @@ -19,7 +19,7 @@ jobs: run: npm ci - name: Run prettier working-directory: ui - run: npm run prettier:format + run: npm run prettier - name: add and commit any files that have changed id: add_and_commit uses: EndBug/add-and-commit@c8bfb4ff65642c4c54445500822f6e7da558994a diff --git a/ui/.eslintrc.json b/ui/.eslintrc.json index db226e9d7..1d6e2c032 100644 --- a/ui/.eslintrc.json +++ b/ui/.eslintrc.json @@ -1,13 +1,9 @@ { "root": true, - "ignorePatterns": [ - "projects/**/*" - ], + "ignorePatterns": ["projects/**/*"], "overrides": [ { - "files": [ - "*.ts" - ], + "files": ["*.ts"], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended", @@ -34,9 +30,7 @@ } }, { - "files": [ - "*.html" - ], + "files": ["*.html"], "extends": [ "plugin:@angular-eslint/template/recommended", "plugin:@angular-eslint/template/accessibility" diff --git a/ui/angular.json b/ui/angular.json index bbc0313f1..f3ade9fbd 100644 --- a/ui/angular.json +++ b/ui/angular.json @@ -23,14 +23,8 @@ "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.app.json", "inlineStyleLanguage": "scss", - "assets": [ - "src/favicon.ico", - "src/assets", - "src/content/images" - ], - "styles": [ - "src/content/scss/global.scss" - ], + "assets": ["src/favicon.ico", "src/assets", "src/content/images"], + "styles": ["src/content/scss/global.scss"], "scripts": [] }, "configurations": { @@ -96,23 +90,15 @@ "tsConfig": "tsconfig.spec.json", "karmaConfig": "karma.conf.js", "inlineStyleLanguage": "scss", - "assets": [ - "src/favicon.ico", - "src/assets" - ], - "styles": [ - "src/content/scss/global.scss" - ], + "assets": ["src/favicon.ico", "src/assets"], + "styles": ["src/content/scss/global.scss"], "scripts": [] } }, "lint": { "builder": "@angular-eslint/builder:lint", "options": { - "lintFilePatterns": [ - "src/**/*.ts", - "src/**/*.html" - ] + "lintFilePatterns": ["src/**/*.ts", "src/**/*.html"] } } } @@ -120,8 +106,6 @@ }, "cli": { "analytics": false, - "schematicCollections": [ - "@angular-eslint/schematics" - ] + "schematicCollections": ["@angular-eslint/schematics"] } } diff --git a/ui/karma.conf.js b/ui/karma.conf.js index e4f96d35d..089680626 100644 --- a/ui/karma.conf.js +++ b/ui/karma.conf.js @@ -3,14 +3,14 @@ module.exports = function (config) { config.set({ - basePath: '', - frameworks: ['jasmine', '@angular-devkit/build-angular'], + basePath: "", + frameworks: ["jasmine", "@angular-devkit/build-angular"], plugins: [ - require('karma-jasmine'), - require('karma-chrome-launcher'), - require('karma-jasmine-html-reporter'), - require('karma-coverage'), - require('@angular-devkit/build-angular/plugins/karma') + require("karma-jasmine"), + require("karma-chrome-launcher"), + require("karma-jasmine-html-reporter"), + require("karma-coverage"), + require("@angular-devkit/build-angular/plugins/karma"), ], client: { jasmine: { @@ -19,26 +19,23 @@ module.exports = function (config) { // for example, you can disable the random execution with `random: false` // or set a specific seed with `seed: 4321` }, - clearContext: false // leave Jasmine Spec Runner output visible in browser + clearContext: false, // leave Jasmine Spec Runner output visible in browser }, jasmineHtmlReporter: { - suppressAll: true // removes the duplicated traces + suppressAll: true, // removes the duplicated traces }, coverageReporter: { - dir: require('path').join(__dirname, './coverage/gateway'), - subdir: '.', - reporters: [ - { type: 'html' }, - { type: 'text-summary' } - ] + dir: require("path").join(__dirname, "./coverage/gateway"), + subdir: ".", + reporters: [{ type: "html" }, { type: "text-summary" }], }, - reporters: ['progress', 'kjhtml'], + reporters: ["progress", "kjhtml"], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, - browsers: ['ChromeHeadless'], + browsers: ["ChromeHeadless"], singleRun: true, - restartOnFileChange: true + restartOnFileChange: true, }); }; diff --git a/ui/package-lock.json b/ui/package-lock.json index 8904bac84..1c09167b3 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -47,6 +47,7 @@ "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.0.0", + "prettier": "^3.0.3", "typescript": "~4.9.5" } }, @@ -12461,6 +12462,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", + "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", @@ -24411,6 +24427,12 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, + "prettier": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.0.3.tgz", + "integrity": "sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==", + "dev": true + }, "pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", diff --git a/ui/package.json b/ui/package.json index c59b42b56..c216350f9 100644 --- a/ui/package.json +++ b/ui/package.json @@ -8,7 +8,8 @@ "build": "ng build --base-href ./", "watch": "ng build --base-href ./ --watch --configuration development", "test": "ng test", - "lint": "ng lint" + "lint": "ng lint", + "prettier": "npx prettier --write ." }, "private": true, "dependencies": { @@ -51,6 +52,7 @@ "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.0.0", + "prettier": "^3.0.3", "typescript": "~4.9.5" } -} \ No newline at end of file +} diff --git a/ui/src/.prettierrc b/ui/src/.prettierrc index 47f998fcd..b8db160ba 100644 --- a/ui/src/.prettierrc +++ b/ui/src/.prettierrc @@ -1,7 +1,7 @@ { - "bracketSpacing": true, - "semi": false, - "singleQuote": true, - "trailingComma": "es5", - "printWidth": 80 - } \ No newline at end of file + "bracketSpacing": true, + "semi": false, + "singleQuote": true, + "trailingComma": "es5", + "printWidth": 80 +} diff --git a/ui/src/app/account/account.module.ts b/ui/src/app/account/account.module.ts index ca7072ff5..c06b2283e 100644 --- a/ui/src/app/account/account.module.ts +++ b/ui/src/app/account/account.module.ts @@ -1,18 +1,12 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { LoginComponent } from './login/login.component'; -import { RouterModule, Routes } from '@angular/router'; -import { ReactiveFormsModule } from '@angular/forms'; -import { routes } from './account.route'; +import { NgModule } from '@angular/core' +import { CommonModule } from '@angular/common' +import { LoginComponent } from './login/login.component' +import { RouterModule, Routes } from '@angular/router' +import { ReactiveFormsModule } from '@angular/forms' +import { routes } from './account.route' @NgModule({ - declarations: [ - LoginComponent - ], - imports: [ - CommonModule, - ReactiveFormsModule, - RouterModule.forChild(routes) - ] + declarations: [LoginComponent], + imports: [CommonModule, ReactiveFormsModule, RouterModule.forChild(routes)], }) -export class AccountModule { } +export class AccountModule {} diff --git a/ui/src/app/account/account.route.ts b/ui/src/app/account/account.route.ts index 2c8af5aeb..17978d8b7 100644 --- a/ui/src/app/account/account.route.ts +++ b/ui/src/app/account/account.route.ts @@ -1,12 +1,11 @@ -import { Routes } from "@angular/router"; -import { LoginComponent } from "./login/login.component"; -import { AuthGuard } from "./auth.guard"; -import { HomeComponent } from "../home/home.component"; +import { Routes } from '@angular/router' +import { LoginComponent } from './login/login.component' +import { AuthGuard } from './auth.guard' +import { HomeComponent } from '../home/home.component' export const routes: Routes = [ - { - path: 'login', - component: LoginComponent - } - ]; - \ No newline at end of file + { + path: 'login', + component: LoginComponent, + }, +] diff --git a/ui/src/app/account/auth.guard.ts b/ui/src/app/account/auth.guard.ts index af27a4c6b..dbacf7568 100644 --- a/ui/src/app/account/auth.guard.ts +++ b/ui/src/app/account/auth.guard.ts @@ -1,34 +1,42 @@ -import { inject } from '@angular/core'; -import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router'; +import { inject } from '@angular/core' +import { + ActivatedRouteSnapshot, + Router, + RouterStateSnapshot, +} from '@angular/router' +import { StateStorageService } from './service/state-storage.service' +import { AccountService } from './service/account.service' +import { Observable, filter, map, take } from 'rxjs' -import { StateStorageService } from './service/state-storage.service'; -import { AccountService } from './service/account.service'; -import { Observable, filter, map, take } from 'rxjs'; +export const AuthGuard = ( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot +): Observable | boolean => { + const authorities = route.data['authorities'] -export const AuthGuard = (route: ActivatedRouteSnapshot, - state: RouterStateSnapshot): Observable | boolean => { - const authorities = route.data['authorities']; - - const router = inject(Router); - const accountService = inject(AccountService); + const router = inject(Router) + const accountService = inject(AccountService) const stateStorageService = inject(StateStorageService) - return accountService.getAccountData().pipe(filter(account => account !== undefined),map(account => { - console.log(authorities, account); + return accountService.getAccountData().pipe( + filter((account) => account !== undefined), + map((account) => { + console.log(authorities, account) - if (account) { - const hasAnyAuthority = accountService.hasAnyAuthority(authorities); - if (hasAnyAuthority) { - return true; + if (account) { + const hasAnyAuthority = accountService.hasAnyAuthority(authorities) + if (hasAnyAuthority) { + return true + } else { + router.navigate(['accessdenied']) + return false + } } else { - router.navigate(['accessdenied']); - return false; + router.navigate(['/login']) + stateStorageService.storeUrl(state.url) + return false } - } else { - router.navigate(['/login']); - stateStorageService.storeUrl(state.url); - return false; - } - })); + }) + ) } diff --git a/ui/src/app/account/index.ts b/ui/src/app/account/index.ts index 469eed4c1..fcd1e286f 100644 --- a/ui/src/app/account/index.ts +++ b/ui/src/app/account/index.ts @@ -2,4 +2,4 @@ export * from './service/account.service' export * from './service/login.service' export * from './service/auth-jwt.service' export * from './service/state-storage.service' -export * from './login/login.component' \ No newline at end of file +export * from './login/login.component' diff --git a/ui/src/app/account/login/login.component.html b/ui/src/app/account/login/login.component.html index 822e7ed86..ebf27f665 100644 --- a/ui/src/app/account/login/login.component.html +++ b/ui/src/app/account/login/login.component.html @@ -1,40 +1,99 @@