diff --git a/web/package-lock.json b/web/package-lock.json index 826feb6315..7646941274 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "startos-ui", - "version": "0.3.6-alpha.6", + "version": "0.3.6-alpha.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "startos-ui", - "version": "0.3.6-alpha.6", + "version": "0.3.6-alpha.8", "license": "MIT", "dependencies": { "@angular/animations": "^14.1.0", diff --git a/web/projects/ui/src/app/modals/backup-select/backup-select.page.ts b/web/projects/ui/src/app/modals/backup-select/backup-select.page.ts index 2b6934c39c..32770af76a 100644 --- a/web/projects/ui/src/app/modals/backup-select/backup-select.page.ts +++ b/web/projects/ui/src/app/modals/backup-select/backup-select.page.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core' import { ModalController } from '@ionic/angular' -import { map, take } from 'rxjs/operators' +import { map } from 'rxjs/operators' import { DataModel } from 'src/app/services/patch-db/data-model' import { PatchDB } from 'patch-db-client' import { firstValueFrom } from 'rxjs' @@ -13,7 +13,7 @@ import { getManifest } from 'src/app/util/get-package-data' }) export class BackupSelectPage { hasSelection = false - selectAll = false + selectAll = true pkgs: { id: string title: string diff --git a/web/projects/ui/src/app/pages/diagnostic-routes/home/home.page.html b/web/projects/ui/src/app/pages/diagnostic-routes/home/home.page.html index 69a58a3aa6..7605d2a8e2 100644 --- a/web/projects/ui/src/app/pages/diagnostic-routes/home/home.page.html +++ b/web/projects/ui/src/app/pages/diagnostic-routes/home/home.page.html @@ -1,12 +1,10 @@
-

- StartOS - Diagnostic Mode -

+
+

StartOS - Diagnostic Mode

+

StartOS version: {{ config.version }}

+

Logs + + Download + + diff --git a/web/projects/ui/src/app/pages/diagnostic-routes/logs/logs.page.ts b/web/projects/ui/src/app/pages/diagnostic-routes/logs/logs.page.ts index 1a6cf6a4f3..d8e6b22532 100644 --- a/web/projects/ui/src/app/pages/diagnostic-routes/logs/logs.page.ts +++ b/web/projects/ui/src/app/pages/diagnostic-routes/logs/logs.page.ts @@ -1,6 +1,12 @@ import { Component, ViewChild } from '@angular/core' import { IonContent } from '@ionic/angular' -import { ErrorService, toLocalIsoString } from '@start9labs/shared' +import { + DownloadHTMLService, + ErrorService, + LoadingService, + Log, + toLocalIsoString, +} from '@start9labs/shared' import { ApiService } from 'src/app/services/api/embassy-api.service' var Convert = require('ansi-to-html') @@ -24,6 +30,8 @@ export class LogsPage { constructor( private readonly api: ApiService, private readonly errorService: ErrorService, + private readonly loader: LoadingService, + private readonly downloadHtml: DownloadHTMLService, ) {} async ngOnInit() { @@ -47,6 +55,30 @@ export class LogsPage { e.target.complete() } + async download() { + const loader = this.loader.open('Processing 10,000 logs...').subscribe() + + try { + const { entries } = await this.api.diagnosticGetLogs({ + before: true, + limit: 10000, + }) + + const styles = { + 'background-color': '#222428', + color: '#e0e0e0', + 'font-family': 'monospace', + } + const html = this.convertToAnsi(entries) + + this.downloadHtml.download('diagnostic-logs.html', html, styles) + } catch (e: any) { + this.errorService.handleError(e) + } finally { + loader.unsubscribe() + } + } + private async getLogs() { try { const { startCursor, entries } = await this.api.diagnosticGetLogs({ @@ -92,4 +124,15 @@ export class LogsPage { this.errorService.handleError(e) } } + + private convertToAnsi(entries: Log[]) { + return entries + .map( + entry => + `${toLocalIsoString( + new Date(entry.timestamp), + )}  ${convert.toHtml(entry.message)}`, + ) + .join('
') + } }