Add support for absolute path import shortcuts.

This commit is contained in:
Spencer Ofwiti 2021-02-14 19:02:35 +03:00
parent 81c6b05a42
commit c0381a170e
29 changed files with 60 additions and 88 deletions

View File

@ -1 +0,0 @@
// export * from 'password-toggle.directive';

View File

@ -1,8 +0,0 @@
import { PasswordToggleDirective } from './password-toggle.directive';
describe('PasswordToggleDirective', () => {
it('should create an instance', () => {
const directive = new PasswordToggleDirective();
expect(directive).toBeTruthy();
});
});

View File

@ -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');
}
}
}

View File

@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { AuthGuard } from './auth.guard'; import { AuthGuard } from '@app/_guards/auth.guard';
describe('AuthGuard', () => { describe('AuthGuard', () => {
let guard: AuthGuard; let guard: AuthGuard;

View File

@ -1,2 +1,2 @@
export * from './auth.guard'; export * from '@app/_guards/auth.guard';
export * from './role.guard'; export * from '@app/_guards/role.guard';

View File

@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { RoleGuard } from './role.guard'; import { RoleGuard } from '@app/_guards/role.guard';
describe('RoleGuard', () => { describe('RoleGuard', () => {
let guard: RoleGuard; let guard: RoleGuard;

View File

@ -1,4 +1,4 @@
import { CustomErrorStateMatcher } from './custom-error-state-matcher'; import { CustomErrorStateMatcher } from '@app/_helpers/custom-error-state-matcher';
describe('CustomErrorStateMatcher', () => { describe('CustomErrorStateMatcher', () => {
it('should create an instance', () => { it('should create an instance', () => {

View File

@ -1,7 +1,7 @@
import { Custom.Validator } from './custom.validator'; import { CustomValidator } from '@app/_helpers/custom.validator';
describe('Custom.Validator', () => { describe('Custom.Validator', () => {
it('should create an instance', () => { it('should create an instance', () => {
expect(new Custom.Validator()).toBeTruthy(); expect(new CustomValidator()).toBeTruthy();
}); });
}); });

View File

@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { ErrorInterceptor } from './error.interceptor'; import { ErrorInterceptor } from '@app/_helpers/error.interceptor';
describe('ErrorInterceptor', () => { describe('ErrorInterceptor', () => {
beforeEach(() => TestBed.configureTestingModule({ beforeEach(() => TestBed.configureTestingModule({

View File

@ -1,4 +1,5 @@
export * from './custom.validator'; export * from '@app/_helpers/custom.validator';
export * from './error.interceptor'; export * from '@app/_helpers/error.interceptor';
export * from './custom-error-state-matcher'; export * from '@app/_helpers/custom-error-state-matcher';
export * from './unsafe-key-store'; export * from '@app/_helpers/unsafe-key-store';
export * from '@app/_helpers/pgp-key-store';

View File

@ -1,4 +1,4 @@
import { UnsafeKeyStore } from './unsafe-key-store'; import { UnsafeKeyStore } from '@app/_helpers/unsafe-key-store';
describe('UnsafeKeyStore', () => { describe('UnsafeKeyStore', () => {
it('should create an instance', () => { it('should create an instance', () => {

View File

@ -1,5 +1,5 @@
// import * as openpgp from '../../assets/js/openpgp.min.js'; // import * as openpgp from '@src/assets/js/openpgp.min.js';
const openpgp = require('../../assets/js/openpgp.min.js'); const openpgp = require('@src/assets/js/openpgp.min.js');
export function UnsafeKeyStore(): void { export function UnsafeKeyStore(): void {
this.key = undefined; this.key = undefined;

View File

@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { AuthService } from './auth.service'; import { AuthService } from '@app/_services/auth.service';
describe('AuthService', () => { describe('AuthService', () => {
let service: AuthService; let service: AuthService;

View File

@ -1 +1 @@
export * from './auth.service'; export * from '@app/_services/auth.service';

View File

@ -2,7 +2,7 @@ import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [ 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' } { path: '**', redirectTo: 'auth', pathMatch: 'full' }
]; ];

View File

@ -1,6 +1,6 @@
import { TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component'; import { AppComponent } from '@app/app.component';
describe('AppComponent', () => { describe('AppComponent', () => {
beforeEach(async () => { beforeEach(async () => {

View File

@ -1,4 +1,5 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import {AuthService} from '@app/_services';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -7,4 +8,8 @@ import { Component } from '@angular/core';
}) })
export class AppComponent { export class AppComponent {
title = 'cic-staff-client'; title = 'cic-staff-client';
constructor(private authService: AuthService) {
this.authService.getPublicKeys().then();
}
} }

View File

@ -1,22 +1,23 @@
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from '@app/app-routing.module';
import { AppComponent } from './app.component'; import { AppComponent } from '@app/app.component';
import { PasswordToggleDirective } from './_directives/password-toggle.directive';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {HttpClientModule} from '@angular/common/http';
import {MutablePgpKeyStore} from '@app/_helpers';
@NgModule({ @NgModule({
declarations: [ declarations: [
AppComponent, AppComponent,
PasswordToggleDirective
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
AppRoutingModule, AppRoutingModule,
BrowserAnimationsModule BrowserAnimationsModule,
HttpClientModule
], ],
providers: [], providers: [MutablePgpKeyStore],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { } export class AppModule { }

View File

@ -1 +0,0 @@
// export * from 'password-toggle.directive';

View File

@ -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', () => { describe('PasswordToggleDirective', () => {
it('should create an instance', () => { it('should create an instance', () => {
const directive = new PasswordToggleDirective(); const directive = new PasswordToggleDirective(elementRef, renderer);
expect(directive).toBeTruthy(); expect(directive).toBeTruthy();
}); });
}); });

View File

@ -1,7 +1,7 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
import { AuthComponent } from './auth.component'; import { AuthComponent } from '@app/auth/auth.component';
const routes: Routes = [ const routes: Routes = [
{ path: '', component: AuthComponent }, { path: '', component: AuthComponent },

View File

@ -1,6 +1,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuthComponent } from './auth.component'; import { AuthComponent } from '@app/auth/auth.component';
describe('AuthComponent', () => { describe('AuthComponent', () => {
let component: AuthComponent; let component: AuthComponent;

View File

@ -1,7 +1,7 @@
import {AfterViewInit, Component, OnInit} from '@angular/core'; import {AfterViewInit, Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms'; import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {CustomErrorStateMatcher, CustomValidator} from '../_helpers'; import {CustomErrorStateMatcher} from '@app/_helpers';
import {AuthService} from '../_services'; import {AuthService} from '@app/_services';
@Component({ @Component({
selector: 'app-auth', selector: 'app-auth',

View File

@ -1,20 +1,20 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { AuthRoutingModule } from './auth-routing.module'; import { AuthRoutingModule } from '@app/auth/auth-routing.module';
import { AuthComponent } from './auth.component'; import { AuthComponent } from '@app/auth/auth.component';
import {ReactiveFormsModule} from '@angular/forms'; 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 {MatCardModule} from '@angular/material/card';
import {MatSelectModule} from '@angular/material/select'; import {MatSelectModule} from '@angular/material/select';
import {MatInputModule} from '@angular/material/input'; import {MatInputModule} from '@angular/material/input';
import {MatButtonModule} from '@angular/material/button'; import {MatButtonModule} from '@angular/material/button';
import {MatRippleModule} from '@angular/material/core'; 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({ @NgModule({
declarations: [AuthComponent, PasswordToggleDirective], declarations: [AuthComponent, PasswordToggleDirective, AddPublicKeysComponent],
imports: [ imports: [
CommonModule, CommonModule,
AuthRoutingModule, AuthRoutingModule,
@ -24,7 +24,6 @@ import {MatRippleModule} from '@angular/material/core';
MatInputModule, MatInputModule,
MatButtonModule, MatButtonModule,
MatRippleModule, MatRippleModule,
// PasswordToggleDirective
] ]
}) })
export class AuthModule { } export class AuthModule { }

View File

@ -1,4 +1,4 @@
import {hobaResult, hobaToSign} from "./hoba.js"; import {hobaResult, hobaToSign} from "@src/assets/js/hoba.js";
const alg = '969'; const alg = '969';

View File

@ -1,3 +1,5 @@
export const environment = { export const environment = {
production: true production: true,
cicMetaUrl: 'http://localhost:63380',
publicKeysUrl: 'http://localhost:8000'
}; };

View File

@ -3,7 +3,9 @@
// The list of file replacements can be found in `angular.json`. // The list of file replacements can be found in `angular.json`.
export const environment = { export const environment = {
production: false production: false,
cicMetaUrl: 'http://localhost:63380',
publicKeysUrl: 'http://localhost:8000'
}; };
/* /*

View File

@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>CicStaffClient</title> <title>CICADA</title>
<base href="/"> <base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">
@ -13,7 +13,7 @@
</head> </head>
<body class="mat-typography"> <body class="mat-typography">
<app-root></app-root> <app-root></app-root>
<script async src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script async src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script> <script async src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script async src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s" crossorigin="anonymous"></script> <script async src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s" crossorigin="anonymous"></script>
</body> </body>

View File

@ -3,6 +3,10 @@
"compileOnSave": false, "compileOnSave": false,
"compilerOptions": { "compilerOptions": {
"baseUrl": "./", "baseUrl": "./",
"paths": {
"@src/*": ["src/*"],
"@app/*": ["src/app/*"]
},
"outDir": "./dist/out-tsc", "outDir": "./dist/out-tsc",
"sourceMap": true, "sourceMap": true,
"declaration": false, "declaration": false,