Skip to content

Commit

Permalink
add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
auumgn committed Oct 26, 2023
1 parent c434bd4 commit 20de98c
Show file tree
Hide file tree
Showing 37 changed files with 752 additions and 502 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/angular-prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions ui/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"ignorePatterns": ["projects/**/*"],
"overrides": [
{
"files": [
"*.ts"
],
"files": ["*.ts"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
Expand All @@ -34,9 +30,7 @@
}
},
{
"files": [
"*.html"
],
"files": ["*.html"],
"extends": [
"plugin:@angular-eslint/template/recommended",
"plugin:@angular-eslint/template/accessibility"
Expand Down
28 changes: 6 additions & 22 deletions ui/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -96,32 +90,22 @@
"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"]
}
}
}
}
},
"cli": {
"analytics": false,
"schematicCollections": [
"@angular-eslint/schematics"
]
"schematicCollections": ["@angular-eslint/schematics"]
}
}
33 changes: 15 additions & 18 deletions ui/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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,
});
};
22 changes: 22 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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"
}
}
}
12 changes: 6 additions & 6 deletions ui/src/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"bracketSpacing": true,
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 80
}
"bracketSpacing": true,
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 80
}
24 changes: 9 additions & 15 deletions ui/src/app/account/account.module.ts
Original file line number Diff line number Diff line change
@@ -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 {}
19 changes: 9 additions & 10 deletions ui/src/app/account/account.route.ts
Original file line number Diff line number Diff line change
@@ -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
}
];

{
path: 'login',
component: LoginComponent,
},
]
58 changes: 33 additions & 25 deletions ui/src/app/account/auth.guard.ts
Original file line number Diff line number Diff line change
@@ -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> | boolean => {
const authorities = route.data['authorities']

export const AuthGuard = (route: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | 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;
}
}));
})
)
}
2 changes: 1 addition & 1 deletion ui/src/app/account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
export * from './login/login.component'
Loading

0 comments on commit 20de98c

Please sign in to comment.