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

@@ -5,6 +5,7 @@ import { RouterModule, Routes } from '@angular/router'
import { NotificationsPage } from './notifications.page'
import { PwaBackComponentModule } from 'src/app/components/pwa-back-button/pwa-back.component.module'
import { BadgeMenuComponentModule } from 'src/app/components/badge-menu-button/badge-menu.component.module'
import { SharingModule } from 'src/app/modules/sharing.module'
const routes: Routes = [
{
@@ -20,6 +21,7 @@ const routes: Routes = [
RouterModule.forChild(routes),
PwaBackComponentModule,
BadgeMenuComponentModule,
SharingModule,
],
declarations: [NotificationsPage],
})

View File

@@ -36,15 +36,19 @@
<ion-item *ngFor="let not of notifications; let i = index">
<ion-label class="ion-text-wrap">
<h2>
<ion-text [color]="getColor(not)"><b>{{ not.title }}</b></ion-text>
<ion-text [color]="not | notificationColor"><b>{{ not.title }}</b></ion-text>
</h2>
<h2 class="notification-message">
{{ not.message }}
<a *ngIf="not.code === 1" style="text-decoration: none;" (click)="viewBackupReport(not)">
View Report
</a>
</h2>
<h2 class="notification-message">{{ not.message }}</h2>
<p>{{ not.createdAt | date: 'short' }}</p>
<p>
<a style="text-decoration: none;"
[routerLink]="['/services', 'installed', not.appId]">{{ not.appId }}</a>
<span> - </span>
Code: {{ not.code }}
{{ not['created-at'] | date: 'short' }}
<a *ngIf="not['package-id'] as pkgId" style="text-decoration: none;" [routerLink]="['/services', 'installed', not['package-id']]">
- {{ not['package-id'] }}
</a>
</p>
</ion-label>
<ion-button slot="end" fill="clear" (click)="remove(not.id, i)">

View File

@@ -1,8 +1,9 @@
import { Component } from '@angular/core'
import { ServerModel, S9Notification } from 'src/app/models/server-model'
import { ApiService } from 'src/app/services/api/api.service'
import { pauseFor } from 'src/app/util/misc.util'
import { LoaderService } from 'src/app/services/loader.service'
import { ServerNotification, ServerNotifications } from 'src/app/services/api/api-types'
import { AlertController } from '@ionic/angular'
@Component({
selector: 'notifications',
templateUrl: 'notifications.page.html',
@@ -11,33 +12,25 @@ import { LoaderService } from 'src/app/services/loader.service'
export class NotificationsPage {
error = ''
loading = true
notifications: S9Notification[] = []
notifications: ServerNotifications = []
page = 1
needInfinite = false
readonly perPage = 20
constructor (
private readonly serverModel: ServerModel,
private readonly apiService: ApiService,
private readonly loader: LoaderService,
private readonly alertCtrl: AlertController,
) { }
async ngOnInit () {
const [notifications] = await Promise.all([
this.getNotifications(),
pauseFor(600),
])
this.notifications = notifications
this.serverModel.update({ badge: 0 })
this.notifications = await this.getNotifications()
this.loading = false
}
async doRefresh (e: any) {
this.page = 1
await Promise.all([
this.getNotifications(),
pauseFor(600),
])
this.notifications = await this.getNotifications(),
e.target.complete()
}
@@ -47,10 +40,10 @@ export class NotificationsPage {
e.target.complete()
}
async getNotifications (): Promise<S9Notification[]> {
let notifications: S9Notification[] = []
async getNotifications (): Promise<ServerNotifications> {
let notifications: ServerNotifications = []
try {
notifications = await this.apiService.getNotifications(this.page, this.perPage)
notifications = await this.apiService.getNotifications({ page: this.page, 'per-page': this.perPage })
this.needInfinite = notifications.length >= this.perPage
this.page++
this.error = ''
@@ -62,29 +55,13 @@ export class NotificationsPage {
}
}
getColor (notification: S9Notification): string {
const char = notification.code.charAt(0)
switch (char) {
case '0':
return 'primary'
case '1':
return 'success'
case '2':
return 'warning'
case '3':
return 'danger'
default:
return ''
}
}
async remove (notificationId: string, index: number): Promise<void> {
async remove (id: string, index: number): Promise<void> {
this.loader.of({
message: 'Deleting...',
spinner: 'lines',
cssClass: 'loader',
}).displayDuringP(
this.apiService.deleteNotification(notificationId).then(() => {
this.apiService.deleteNotification({ id }).then(() => {
this.notifications.splice(index, 1)
this.error = ''
}),
@@ -93,5 +70,45 @@ export class NotificationsPage {
this.error = e.message
})
}
async viewBackupReport (notification: ServerNotification<1>) {
const data = notification.data
const embassyFailed = !!data.server.error
const packagesFailed = Object.entries(data.packages).some(([_, val]) => val.error)
let message: string
if (embassyFailed || packagesFailed) {
message = 'There was an issue backing up one or more items. Click "Retry" to retry ONLY the items that failed.'
} else {
message = 'All items were successfully backed up'
}
const buttons: any[] = [ // why can't I import AlertButton?
{
text: 'Dismiss',
role: 'cancel',
},
]
if (embassyFailed || packagesFailed) {
buttons.push({
text: 'Retry',
handler: () => {
console.log('retry backup')
},
})
}
const alert = await this.alertCtrl.create({
header: 'Backup Report',
message,
buttons,
})
await alert.present()
}
}