diff --git a/src/app/_directives/index.ts b/src/app/_directives/index.ts deleted file mode 100644 index acdd4fe..0000000 --- a/src/app/_directives/index.ts +++ /dev/null @@ -1 +0,0 @@ -// export * from 'password-toggle.directive'; diff --git a/src/app/_directives/password-toggle.directive.spec.ts b/src/app/_directives/password-toggle.directive.spec.ts deleted file mode 100644 index dab2c6e..0000000 --- a/src/app/_directives/password-toggle.directive.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { PasswordToggleDirective } from './password-toggle.directive'; - -describe('PasswordToggleDirective', () => { - it('should create an instance', () => { - const directive = new PasswordToggleDirective(); - expect(directive).toBeTruthy(); - }); -}); diff --git a/src/app/_directives/password-toggle.directive.ts b/src/app/_directives/password-toggle.directive.ts deleted file mode 100644 index 37e2f6f..0000000 --- a/src/app/_directives/password-toggle.directive.ts +++ /dev/null @@ -1,36 +0,0 @@ -import {Directive, ElementRef, Input, Renderer2} from '@angular/core'; - -@Directive({ - selector: '[appPasswordToggle]' -}) -export class PasswordToggleDirective { - @Input() - id: string; - iconId: string; - - constructor( - private elementRef: ElementRef, - private renderer: Renderer2, - ) { - this.renderer.listen(this.elementRef.nativeElement, 'click', () => { - this.togglePasswordVisibility(); - }); - } - - togglePasswordVisibility(): void { - const password = document.getElementById(this.id); - const icon = document.getElementById(this.iconId); - // @ts-ignore - if (password.type === 'password') { - // @ts-ignore - password.type = 'text'; - icon.classList.remove('fa-eye'); - icon.classList.add('fa-eye-slash'); - } else { - // @ts-ignore - password.type = 'password'; - icon.classList.remove('fa-eye-slash'); - icon.classList.add('fa-eye'); - } - } -} diff --git a/src/app/_guards/auth.guard.spec.ts b/src/app/_guards/auth.guard.spec.ts index 68889d2..5a64c10 100644 --- a/src/app/_guards/auth.guard.spec.ts +++ b/src/app/_guards/auth.guard.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; -import { AuthGuard } from './auth.guard'; +import { AuthGuard } from '@app/_guards/auth.guard'; describe('AuthGuard', () => { let guard: AuthGuard; diff --git a/src/app/_guards/index.ts b/src/app/_guards/index.ts index f033f4e..563181d 100644 --- a/src/app/_guards/index.ts +++ b/src/app/_guards/index.ts @@ -1,2 +1,2 @@ -export * from './auth.guard'; -export * from './role.guard'; +export * from '@app/_guards/auth.guard'; +export * from '@app/_guards/role.guard'; diff --git a/src/app/_guards/role.guard.spec.ts b/src/app/_guards/role.guard.spec.ts index 5b6db9f..af8dc36 100644 --- a/src/app/_guards/role.guard.spec.ts +++ b/src/app/_guards/role.guard.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; -import { RoleGuard } from './role.guard'; +import { RoleGuard } from '@app/_guards/role.guard'; describe('RoleGuard', () => { let guard: RoleGuard; diff --git a/src/app/_helpers/custom-error-state-matcher.spec.ts b/src/app/_helpers/custom-error-state-matcher.spec.ts index 7a3b76c..2395c25 100644 --- a/src/app/_helpers/custom-error-state-matcher.spec.ts +++ b/src/app/_helpers/custom-error-state-matcher.spec.ts @@ -1,4 +1,4 @@ -import { CustomErrorStateMatcher } from './custom-error-state-matcher'; +import { CustomErrorStateMatcher } from '@app/_helpers/custom-error-state-matcher'; describe('CustomErrorStateMatcher', () => { it('should create an instance', () => { diff --git a/src/app/_helpers/custom.validator.spec.ts b/src/app/_helpers/custom.validator.spec.ts index 565ab9c..fcddcc1 100644 --- a/src/app/_helpers/custom.validator.spec.ts +++ b/src/app/_helpers/custom.validator.spec.ts @@ -1,7 +1,7 @@ -import { Custom.Validator } from './custom.validator'; +import { CustomValidator } from '@app/_helpers/custom.validator'; describe('Custom.Validator', () => { it('should create an instance', () => { - expect(new Custom.Validator()).toBeTruthy(); + expect(new CustomValidator()).toBeTruthy(); }); }); diff --git a/src/app/_helpers/error.interceptor.spec.ts b/src/app/_helpers/error.interceptor.spec.ts index 4d083ad..42c01bc 100644 --- a/src/app/_helpers/error.interceptor.spec.ts +++ b/src/app/_helpers/error.interceptor.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; -import { ErrorInterceptor } from './error.interceptor'; +import { ErrorInterceptor } from '@app/_helpers/error.interceptor'; describe('ErrorInterceptor', () => { beforeEach(() => TestBed.configureTestingModule({ diff --git a/src/app/_helpers/index.ts b/src/app/_helpers/index.ts index 1c31d75..de40a7a 100644 --- a/src/app/_helpers/index.ts +++ b/src/app/_helpers/index.ts @@ -1,4 +1,5 @@ -export * from './custom.validator'; -export * from './error.interceptor'; -export * from './custom-error-state-matcher'; -export * from './unsafe-key-store'; +export * from '@app/_helpers/custom.validator'; +export * from '@app/_helpers/error.interceptor'; +export * from '@app/_helpers/custom-error-state-matcher'; +export * from '@app/_helpers/unsafe-key-store'; +export * from '@app/_helpers/pgp-key-store'; diff --git a/src/app/_helpers/unsafe-key-store.spec.ts b/src/app/_helpers/unsafe-key-store.spec.ts index 56785ce..012ff6d 100644 --- a/src/app/_helpers/unsafe-key-store.spec.ts +++ b/src/app/_helpers/unsafe-key-store.spec.ts @@ -1,4 +1,4 @@ -import { UnsafeKeyStore } from './unsafe-key-store'; +import { UnsafeKeyStore } from '@app/_helpers/unsafe-key-store'; describe('UnsafeKeyStore', () => { it('should create an instance', () => { diff --git a/src/app/_helpers/unsafe-key-store.ts b/src/app/_helpers/unsafe-key-store.ts index 590389e..b9ef572 100644 --- a/src/app/_helpers/unsafe-key-store.ts +++ b/src/app/_helpers/unsafe-key-store.ts @@ -1,5 +1,5 @@ -// import * as openpgp from '../../assets/js/openpgp.min.js'; -const openpgp = require('../../assets/js/openpgp.min.js'); +// import * as openpgp from '@src/assets/js/openpgp.min.js'; +const openpgp = require('@src/assets/js/openpgp.min.js'); export function UnsafeKeyStore(): void { this.key = undefined; diff --git a/src/app/_services/auth.service.spec.ts b/src/app/_services/auth.service.spec.ts index f1251ca..9351d3f 100644 --- a/src/app/_services/auth.service.spec.ts +++ b/src/app/_services/auth.service.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; -import { AuthService } from './auth.service'; +import { AuthService } from '@app/_services/auth.service'; describe('AuthService', () => { let service: AuthService; diff --git a/src/app/_services/index.ts b/src/app/_services/index.ts index 2a719d1..a2aa76c 100644 --- a/src/app/_services/index.ts +++ b/src/app/_services/index.ts @@ -1 +1 @@ -export * from './auth.service'; +export * from '@app/_services/auth.service'; diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index f3b3992..699b88c 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -2,7 +2,7 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; const routes: Routes = [ - { path: 'auth', loadChildren: () => import('./auth/auth.module').then(m => m.AuthModule) }, + { path: 'auth', loadChildren: () => import('@app/auth/auth.module').then(m => m.AuthModule) }, { path: '**', redirectTo: 'auth', pathMatch: 'full' } ]; diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index e0e7941..a82f639 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,6 +1,6 @@ import { TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; -import { AppComponent } from './app.component'; +import { AppComponent } from '@app/app.component'; describe('AppComponent', () => { beforeEach(async () => { diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2c120a8..b69e3bf 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,5 @@ import { Component } from '@angular/core'; +import {AuthService} from '@app/_services'; @Component({ selector: 'app-root', @@ -7,4 +8,8 @@ import { Component } from '@angular/core'; }) export class AppComponent { title = 'cic-staff-client'; + + constructor(private authService: AuthService) { + this.authService.getPublicKeys().then(); + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index a76cdcb..4dc5070 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,22 +1,23 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; -import { AppRoutingModule } from './app-routing.module'; -import { AppComponent } from './app.component'; -import { PasswordToggleDirective } from './_directives/password-toggle.directive'; +import { AppRoutingModule } from '@app/app-routing.module'; +import { AppComponent } from '@app/app.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import {HttpClientModule} from '@angular/common/http'; +import {MutablePgpKeyStore} from '@app/_helpers'; @NgModule({ declarations: [ AppComponent, - PasswordToggleDirective ], imports: [ BrowserModule, AppRoutingModule, - BrowserAnimationsModule + BrowserAnimationsModule, + HttpClientModule ], - providers: [], + providers: [MutablePgpKeyStore], bootstrap: [AppComponent] }) export class AppModule { } diff --git a/src/app/auth/_directives/index.ts b/src/app/auth/_directives/index.ts index acdd4fe..e69de29 100644 --- a/src/app/auth/_directives/index.ts +++ b/src/app/auth/_directives/index.ts @@ -1 +0,0 @@ -// export * from 'password-toggle.directive'; diff --git a/src/app/auth/_directives/password-toggle.directive.spec.ts b/src/app/auth/_directives/password-toggle.directive.spec.ts index dab2c6e..1e4aacf 100644 --- a/src/app/auth/_directives/password-toggle.directive.spec.ts +++ b/src/app/auth/_directives/password-toggle.directive.spec.ts @@ -1,8 +1,12 @@ -import { PasswordToggleDirective } from './password-toggle.directive'; +import { PasswordToggleDirective } from '@app/auth/_directives/password-toggle.directive'; +import {ElementRef, Renderer2} from '@angular/core'; + +let elementRef: ElementRef; +let renderer: Renderer2; describe('PasswordToggleDirective', () => { it('should create an instance', () => { - const directive = new PasswordToggleDirective(); + const directive = new PasswordToggleDirective(elementRef, renderer); expect(directive).toBeTruthy(); }); }); diff --git a/src/app/auth/auth-routing.module.ts b/src/app/auth/auth-routing.module.ts index 7c042f9..153532f 100644 --- a/src/app/auth/auth-routing.module.ts +++ b/src/app/auth/auth-routing.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; -import { AuthComponent } from './auth.component'; +import { AuthComponent } from '@app/auth/auth.component'; const routes: Routes = [ { path: '', component: AuthComponent }, diff --git a/src/app/auth/auth.component.spec.ts b/src/app/auth/auth.component.spec.ts index 2e9ddd9..5009717 100644 --- a/src/app/auth/auth.component.spec.ts +++ b/src/app/auth/auth.component.spec.ts @@ -1,6 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { AuthComponent } from './auth.component'; +import { AuthComponent } from '@app/auth/auth.component'; describe('AuthComponent', () => { let component: AuthComponent; diff --git a/src/app/auth/auth.component.ts b/src/app/auth/auth.component.ts index 843f028..4f5f305 100644 --- a/src/app/auth/auth.component.ts +++ b/src/app/auth/auth.component.ts @@ -1,7 +1,7 @@ import {AfterViewInit, Component, OnInit} from '@angular/core'; import {FormBuilder, FormGroup, Validators} from '@angular/forms'; -import {CustomErrorStateMatcher, CustomValidator} from '../_helpers'; -import {AuthService} from '../_services'; +import {CustomErrorStateMatcher} from '@app/_helpers'; +import {AuthService} from '@app/_services'; @Component({ selector: 'app-auth', diff --git a/src/app/auth/auth.module.ts b/src/app/auth/auth.module.ts index 6843d31..d8347a1 100644 --- a/src/app/auth/auth.module.ts +++ b/src/app/auth/auth.module.ts @@ -1,20 +1,20 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { AuthRoutingModule } from './auth-routing.module'; -import { AuthComponent } from './auth.component'; +import { AuthRoutingModule } from '@app/auth/auth-routing.module'; +import { AuthComponent } from '@app/auth/auth.component'; import {ReactiveFormsModule} from '@angular/forms'; -import {PasswordToggleDirective} from './_directives/password-toggle.directive'; +import {PasswordToggleDirective} from '@app/auth/_directives/password-toggle.directive'; import {MatCardModule} from '@angular/material/card'; import {MatSelectModule} from '@angular/material/select'; import {MatInputModule} from '@angular/material/input'; import {MatButtonModule} from '@angular/material/button'; import {MatRippleModule} from '@angular/material/core'; -// import {PasswordToggleDirective} from '../_directives/password-toggle.directive'; +import {AddPublicKeysComponent} from '@app/auth/add-public-keys/add-public-keys.component'; @NgModule({ - declarations: [AuthComponent, PasswordToggleDirective], + declarations: [AuthComponent, PasswordToggleDirective, AddPublicKeysComponent], imports: [ CommonModule, AuthRoutingModule, @@ -24,7 +24,6 @@ import {MatRippleModule} from '@angular/material/core'; MatInputModule, MatButtonModule, MatRippleModule, - // PasswordToggleDirective ] }) export class AuthModule { } diff --git a/src/assets/js/hoba-pgp.js b/src/assets/js/hoba-pgp.js index 0c36aa5..adc7743 100644 --- a/src/assets/js/hoba-pgp.js +++ b/src/assets/js/hoba-pgp.js @@ -1,4 +1,4 @@ -import {hobaResult, hobaToSign} from "./hoba.js"; +import {hobaResult, hobaToSign} from "@src/assets/js/hoba.js"; const alg = '969'; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 3612073..19aa674 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,3 +1,5 @@ export const environment = { - production: true + production: true, + cicMetaUrl: 'http://localhost:63380', + publicKeysUrl: 'http://localhost:8000' }; diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 7b4f817..5a9d56f 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -3,7 +3,9 @@ // The list of file replacements can be found in `angular.json`. export const environment = { - production: false + production: false, + cicMetaUrl: 'http://localhost:63380', + publicKeysUrl: 'http://localhost:8000' }; /* diff --git a/src/index.html b/src/index.html index 78f0d12..5f86e7f 100644 --- a/src/index.html +++ b/src/index.html @@ -2,7 +2,7 @@ - CicStaffClient + CICADA @@ -13,7 +13,7 @@ - + diff --git a/tsconfig.json b/tsconfig.json index f69f654..5c38007 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,10 @@ "compileOnSave": false, "compilerOptions": { "baseUrl": "./", + "paths": { + "@src/*": ["src/*"], + "@app/*": ["src/app/*"] + }, "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false,