0.3.0 refactor

ui: adds overlay layer to patch-db-client

ui: getting towards mocks

ui: cleans up factory init

ui: nice type hack

ui: live api for patch

ui: api service source + http

starts up

ui: api source + http

ui: rework patchdb config, pass stashTimeout into patchDbModel

wires in temp patching into api service

ui: example of wiring patchdbmodel into page

begin integration

remove unnecessary method

linting

first data rendering

rework app initialization

http source working for ssh delete call

temp patches working

entire Embassy tab complete

not in kansas anymore

ripping, saving progress

progress for API request response types and endoint defs

Update data-model.ts

shambles, but in a good way

progress

big progress

progress

installed list working

big progress

progress

progress

begin marketplace redesign

Update api-types.ts

Update api-types.ts

marketplace improvements

cosmetic

dependencies and recommendations

begin nym auth approach

install wizard

restore flow and donations
This commit is contained in:
Aaron Greenspan
2021-02-16 13:45:09 -07:00
committed by Aiden McClelland
parent fd685ae32c
commit 594d93eb3b
238 changed files with 15137 additions and 21331 deletions

View File

@@ -1,36 +1,41 @@
import { Injectable } from '@angular/core'
import { CanActivate, Router, CanActivateChild } from '@angular/router'
import { tap } from 'rxjs/operators'
import { AuthState, AuthService } from '../services/auth.service'
@Injectable({
providedIn: 'root',
})
export class AuthGuard implements CanActivate, CanActivateChild {
authState: AuthState
constructor (
private readonly authService: AuthService,
private readonly router: Router,
) { }
) {
this.authService.watch$()
.pipe(
tap(auth => this.authState = auth),
).subscribe()
}
canActivate (): boolean {
return this.runCheck()
return this.runAuthCheck()
}
canActivateChild (): boolean {
return this.runCheck()
return this.runAuthCheck()
}
private runCheck (): boolean {
const state = this.authService.peek()
switch (state){
case AuthState.VERIFIED: return true
case AuthState.UNVERIFIED: return this.toAuthenticate()
case AuthState.INITIALIZING: return this.toAuthenticate()
private runAuthCheck (): boolean {
switch (this.authState){
case AuthState.VERIFIED:
return true
case AuthState.UNVERIFIED:
// @TODO could initializing cause a loop?
case AuthState.INITIALIZING:
this.router.navigate(['/auth'], { replaceUrl: true })
return false
}
}
private toAuthenticate () {
this.router.navigate(['/authenticate'], { replaceUrl: true })
return false
}
}

View File

@@ -1,26 +0,0 @@
import { Injectable, Directive } from '@angular/core'
import { CanDeactivate } from '@angular/router'
import { HostListener } from '@angular/core'
@Directive()
export abstract class PageCanDeactivate {
abstract canDeactivate (): boolean
@HostListener('window:beforeunload', ['$event'])
unloadNotification (e: any) {
console.log(e)
if (!this.canDeactivate()) {
e.returnValue = true
}
}
}
@Injectable({
providedIn: 'root',
})
export class CanDeactivateGuard implements CanDeactivate<PageCanDeactivate> {
canDeactivate (page: PageCanDeactivate): boolean {
return page.canDeactivate() || confirm('You have unsaved changes. Are you sure you want to leave the page?')
}
}

View File

@@ -0,0 +1,39 @@
import { Injectable } from '@angular/core'
import { CanActivate, Router, CanActivateChild } from '@angular/router'
import { tap } from 'rxjs/operators'
import { ServerStatus } from '../models/patch-db/data-model'
import { PatchDbModel } from '../models/patch-db/patch-db-model'
@Injectable({
providedIn: 'root',
})
export class MaintenanceGuard implements CanActivate, CanActivateChild {
serverStatus: ServerStatus
constructor (
private readonly router: Router,
private readonly patch: PatchDbModel,
) {
this.patch.watch$('server-info', 'status')
.pipe(
tap(status => this.serverStatus = status),
).subscribe()
}
canActivate (): boolean {
return this.runServerStatusCheck()
}
canActivateChild (): boolean {
return this.runServerStatusCheck()
}
private runServerStatusCheck (): boolean {
if ([ServerStatus.Updating, ServerStatus.BackingUp].includes(this.serverStatus)) {
this.router.navigate(['/maintenance'], { replaceUrl: true })
return false
} else {
return true
}
}
}

View File

@@ -1,25 +1,34 @@
import { Injectable } from '@angular/core'
import { CanActivate, Router } from '@angular/router'
import { tap } from 'rxjs/operators'
import { AuthService, AuthState } from '../services/auth.service'
@Injectable({
providedIn: 'root',
})
export class UnauthGuard implements CanActivate {
authState: AuthState
constructor (
private readonly authService: AuthService,
private readonly router: Router,
) { }
) {
this.authService.watch$()
.pipe(
tap(auth => this.authState = auth),
).subscribe()
}
canActivate (): boolean {
const state = this.authService.peek()
switch (state){
switch (this.authState){
case AuthState.VERIFIED: {
this.router.navigateByUrl('')
return false
}
case AuthState.UNVERIFIED: return true
case AuthState.INITIALIZING: return true
case AuthState.UNVERIFIED:
case AuthState.INITIALIZING:
return true
}
}
}

View File

@@ -0,0 +1,31 @@
import { Injectable } from '@angular/core'
import { CanActivate, Router } from '@angular/router'
import { tap } from 'rxjs/operators'
import { ServerStatus } from '../models/patch-db/data-model'
import { PatchDbModel } from '../models/patch-db/patch-db-model'
@Injectable({
providedIn: 'root',
})
export class UnmaintenanceGuard implements CanActivate {
serverStatus: ServerStatus
constructor (
private readonly router: Router,
private readonly patch: PatchDbModel,
) {
this.patch.watch$('server-info', 'status')
.pipe(
tap(status => this.serverStatus = status),
).subscribe()
}
canActivate (): boolean {
if (![ServerStatus.Updating, ServerStatus.BackingUp].includes(this.serverStatus)) {
this.router.navigate([''], { replaceUrl: true })
return false
} else {
return true
}
}
}