mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-04 22:39:46 +00:00
Multiple (#1823)
* display preference for suto check and better messaging on properties page * improve logs by a lot * clean up * fix searchbar and url in marketplace
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
<ion-grid>
|
<ion-grid>
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col sizeSm="8" offset-sm="2">
|
<ion-col sizeSm="8" offset-sm="2" sizeLg="6" offset-lg="3">
|
||||||
<ion-toolbar color="transparent">
|
<ion-toolbar color="transparent" class="ion-text-left">
|
||||||
<ion-searchbar
|
<ion-searchbar
|
||||||
enterkeyhint="search"
|
|
||||||
color="dark"
|
color="dark"
|
||||||
debounce="250"
|
debounce="250"
|
||||||
[ngModel]="query"
|
[ngModel]="query"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
>
|
>
|
||||||
<ion-infinite-scroll
|
<ion-infinite-scroll
|
||||||
id="scroller"
|
id="scroller"
|
||||||
*ngIf="!loading && needInfinite"
|
[disabled]="!needInfinite"
|
||||||
position="top"
|
position="top"
|
||||||
threshold="1000"
|
threshold="1000"
|
||||||
(ionInfinite)="doInfinite($event)"
|
(ionInfinite)="doInfinite($event)"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Component, Input, ViewChild } from '@angular/core'
|
import { Component, Input, ViewChild } from '@angular/core'
|
||||||
import { IonContent, LoadingController } from '@ionic/angular'
|
import { IonContent, LoadingController } from '@ionic/angular'
|
||||||
import { map, takeUntil, timer } from 'rxjs'
|
import { bufferTime, takeUntil, tap } from 'rxjs'
|
||||||
import { WebSocketSubjectConfig } from 'rxjs/webSocket'
|
import { WebSocketSubjectConfig } from 'rxjs/webSocket'
|
||||||
import {
|
import {
|
||||||
LogsRes,
|
LogsRes,
|
||||||
@@ -42,13 +42,12 @@ export class LogsComponent {
|
|||||||
@Input() title!: string
|
@Input() title!: string
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
needInfinite = true
|
needInfinite = false
|
||||||
startCursor?: string
|
startCursor?: string
|
||||||
isOnBottom = true
|
isOnBottom = true
|
||||||
autoScroll = true
|
autoScroll = true
|
||||||
websocketFail = false
|
websocketFail = false
|
||||||
limit = 400
|
limit = 400
|
||||||
toProcess: Log[] = []
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly errToast: ErrorToastService,
|
private readonly errToast: ErrorToastService,
|
||||||
@@ -71,18 +70,27 @@ export class LogsComponent {
|
|||||||
openObserver: {
|
openObserver: {
|
||||||
next: () => {
|
next: () => {
|
||||||
this.websocketFail = false
|
this.websocketFail = false
|
||||||
this.processJob()
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let totalLogs = 0
|
||||||
|
|
||||||
this.api
|
this.api
|
||||||
.openLogsWebsocket$(config)
|
.openLogsWebsocket$(config)
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(
|
||||||
|
tap(_ => {
|
||||||
|
totalLogs++
|
||||||
|
if (totalLogs === this.limit) this.needInfinite = true
|
||||||
|
}),
|
||||||
|
bufferTime(500),
|
||||||
|
tap(msgs => {
|
||||||
|
this.loading = false
|
||||||
|
this.processRes({ entries: msgs })
|
||||||
|
}),
|
||||||
|
takeUntil(this.destroy$),
|
||||||
|
)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: msg => {
|
|
||||||
this.toProcess.push(msg)
|
|
||||||
},
|
|
||||||
error: () => {
|
error: () => {
|
||||||
this.websocketFail = true
|
this.websocketFail = true
|
||||||
if (this.isOnBottom) this.scrollToBottom()
|
if (this.isOnBottom) this.scrollToBottom()
|
||||||
@@ -151,19 +159,6 @@ export class LogsComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private processJob() {
|
|
||||||
timer(100, 500)
|
|
||||||
.pipe(
|
|
||||||
map((_, index) => index),
|
|
||||||
takeUntil(this.destroy$),
|
|
||||||
)
|
|
||||||
.subscribe(index => {
|
|
||||||
this.processRes({ entries: this.toProcess })
|
|
||||||
this.toProcess = []
|
|
||||||
if (index === 0) this.loading = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
private processRes(res: LogsRes) {
|
private processRes(res: LogsRes) {
|
||||||
const { entries, 'start-cursor': startCursor } = res
|
const { entries, 'start-cursor': startCursor } = res
|
||||||
|
|
||||||
@@ -176,7 +171,7 @@ export class LogsComponent {
|
|||||||
|
|
||||||
newLogs.innerHTML = this.convertToAnsi(entries)
|
newLogs.innerHTML = this.convertToAnsi(entries)
|
||||||
|
|
||||||
// if respone contains startCursor, it means we are scrolling backwards
|
// if response contains a startCursor, it means we are scrolling backwards
|
||||||
if (startCursor) {
|
if (startCursor) {
|
||||||
this.startCursor = startCursor
|
this.startCursor = startCursor
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,11 @@
|
|||||||
|
|
||||||
<ng-template #loaded>
|
<ng-template #loaded>
|
||||||
<!-- not running -->
|
<!-- not running -->
|
||||||
<ion-item *ngIf="notRunning$ | async" class="ion-margin-bottom">
|
<ion-item *ngIf="stopped$ | async" class="ion-margin-bottom">
|
||||||
<ion-label>
|
<ion-label>
|
||||||
<p>
|
<p>
|
||||||
<ion-text color="warning"
|
<ion-text color="warning"
|
||||||
>Service not running. Information on this page could be
|
>Service is stopped. Information on this page could be
|
||||||
inaccurate.</ion-text
|
inaccurate.</ion-text
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ export class AppPropertiesPage {
|
|||||||
properties: PackageProperties = {}
|
properties: PackageProperties = {}
|
||||||
unmasked: { [key: string]: boolean } = {}
|
unmasked: { [key: string]: boolean } = {}
|
||||||
|
|
||||||
notRunning$ = this.patch
|
stopped$ = this.patch
|
||||||
.watch$('package-data', this.pkgId, 'installed', 'status', 'main', 'status')
|
.watch$('package-data', this.pkgId, 'installed', 'status', 'main', 'status')
|
||||||
.pipe(map(status => status !== PackageMainStatus.Running))
|
.pipe(map(status => status === PackageMainStatus.Stopped))
|
||||||
|
|
||||||
@ViewChild(IonBackButtonDelegate, { static: false })
|
@ViewChild(IonBackButtonDelegate, { static: false })
|
||||||
backButton?: IonBackButtonDelegate
|
backButton?: IonBackButtonDelegate
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col size="12">
|
<ion-col size="12">
|
||||||
<h1 class="heading montserrat ion-text-center">{{ details.name }}</h1>
|
<h1 class="heading montserrat ion-text-center">{{ details.name }}</h1>
|
||||||
<p style="margin-top: 0">{{ details.url }}</p>
|
|
||||||
<marketplace-search [(query)]="query"></marketplace-search>
|
<marketplace-search [(query)]="query"></marketplace-search>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
|
|||||||
@@ -17,12 +17,14 @@
|
|||||||
|
|
||||||
<ion-item-divider>Marketplace</ion-item-divider>
|
<ion-item-divider>Marketplace</ion-item-divider>
|
||||||
<ion-item
|
<ion-item
|
||||||
*ngIf="autoCheck$ | async as auto"
|
*ngIf="ui$ | async as ui"
|
||||||
button
|
button
|
||||||
(click)="serverConfig.presentAlert('auto-check-updates', auto)"
|
(click)="serverConfig.presentAlert('auto-check-updates', ui['auto-check-updates'])"
|
||||||
>
|
>
|
||||||
<ion-label>Auto Check for Updates</ion-label>
|
<ion-label>Auto Check for Updates</ion-label>
|
||||||
<ion-note slot="end"> {{ auto ? 'Enabled' : 'Disabled' }} </ion-note>
|
<ion-note slot="end">
|
||||||
|
{{ ui['auto-check-updates'] ? 'Enabled' : 'Disabled' }}
|
||||||
|
</ion-note>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ion-item-group>
|
</ion-item-group>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { DataModel } from 'src/app/services/patch-db/data-model'
|
|||||||
export class PreferencesPage {
|
export class PreferencesPage {
|
||||||
clicks = 0
|
clicks = 0
|
||||||
|
|
||||||
readonly autoCheck$ = this.patch.watch$('ui', 'auto-check-updates')
|
readonly ui$ = this.patch.watch$('ui')
|
||||||
readonly server$ = this.patch.watch$('server-info')
|
readonly server$ = this.patch.watch$('server-info')
|
||||||
readonly name$ = this.serverNameService.name$
|
readonly name$ = this.serverNameService.name$
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export class MockApiService extends ApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
openLogsWebsocket$(config: WebSocketSubjectConfig<Log>): Observable<Log> {
|
openLogsWebsocket$(config: WebSocketSubjectConfig<Log>): Observable<Log> {
|
||||||
return interval(100).pipe(
|
return interval(50).pipe(
|
||||||
map((_, index) => {
|
map((_, index) => {
|
||||||
// mock fire open observer
|
// mock fire open observer
|
||||||
if (index === 0) config.openObserver?.next(new Event(''))
|
if (index === 0) config.openObserver?.next(new Event(''))
|
||||||
|
|||||||
Reference in New Issue
Block a user