fix bugs with config and clean up dev options (#1558)

* fix bugs with config and clean up dev options

* dont down down arrow in logs prematurely

* change config error border to match error text red color

* change restart button color

* fix error when sideloading and update copy

* adds back in param cloning as this bug creeped up again

* make restarting text match button color

* fix version comparision for updates category

Co-authored-by: Matt Hill <matthill@Matt-M1.local>
Co-authored-by: Lucy Cifferello <12953208+elvece@users.noreply.github.com>
This commit is contained in:
Matt Hill
2022-06-22 18:26:10 -06:00
committed by GitHub
parent 53ca9b0420
commit d431fac7de
19 changed files with 128 additions and 80 deletions

View File

@@ -3,6 +3,7 @@ import Fuse from 'fuse.js'
import { MarketplacePkg } from '../types/marketplace-pkg' import { MarketplacePkg } from '../types/marketplace-pkg'
import { MarketplaceManifest } from '../types/marketplace-manifest' import { MarketplaceManifest } from '../types/marketplace-manifest'
import { Emver } from '@start9labs/shared'
const defaultOps = { const defaultOps = {
isCaseSensitive: false, isCaseSensitive: false,
@@ -29,6 +30,8 @@ const defaultOps = {
name: 'filterPackages', name: 'filterPackages',
}) })
export class FilterPackagesPipe implements PipeTransform { export class FilterPackagesPipe implements PipeTransform {
constructor(private readonly emver: Emver) {}
transform( transform(
packages: MarketplacePkg[] | null, packages: MarketplacePkg[] | null,
query: string, query: string,
@@ -49,7 +52,10 @@ export class FilterPackagesPipe implements PipeTransform {
return packages.filter( return packages.filter(
({ manifest }) => ({ manifest }) =>
local[manifest.id] && local[manifest.id] &&
manifest.version !== local[manifest.id].manifest.version, this.emver.compare(
manifest.version,
local[manifest.id].manifest.version,
) === 1,
) )
} }

View File

@@ -31,6 +31,7 @@ export class EmverComparesPipe implements PipeTransform {
} }
} }
} }
// left compared to right - if 1, version on left is higher; if 0, values the same; if -1, version on left is lower
type SemverResult = 0 | 1 | -1 | 'comparison-impossible' type SemverResult = 0 | 1 | -1 | 'comparison-impossible'
@Pipe({ @Pipe({

View File

@@ -1,4 +1,4 @@
<div [hidden]="!control.dirty && !control.touched" class="validation-error"> <div [hidden]="!control.dirty && !control.touched" class="error-message">
<!-- primitive --> <!-- primitive -->
<p *ngIf="control.hasError('required')">{{ spec.name }} is required</p> <p *ngIf="control.hasError('required')">{{ spec.name }} is required</p>

View File

@@ -1,24 +1,12 @@
<ion-button <ion-button
*ngIf="data.spec.description" *ngIf="data.spec.description"
class="slot-start" class="slot-start"
style="--padding-start: 0; --padding-end: 7px"
fill="clear" fill="clear"
(click)="presentAlertDescription()" (click)="presentAlertDescription()"
> >
<ion-icon name="help-circle-outline" slot="icon-only" size="small"></ion-icon> <ion-icon name="help-circle-outline" slot="icon-only" size="small"></ion-icon>
</ion-button> </ion-button>
<!-- this is a button for css purposes only -->
<ion-button
*ngIf="data.invalid"
class="slot-start"
fill="clear"
size="small"
color="danger"
>
<ion-icon name="warning-outline"></ion-icon>
</ion-button>
<span>{{ data.spec.name }}</span> <span>{{ data.spec.name }}</span>
<ion-text color="success" *ngIf="data.new">&nbsp;(New)</ion-text> <ion-text color="success" *ngIf="data.new">&nbsp;(New)</ion-text>

View File

@@ -47,7 +47,10 @@
<!-- string or number --> <!-- string or number -->
<ng-container *ngIf="spec.type === 'string' || spec.type === 'number'"> <ng-container *ngIf="spec.type === 'string' || spec.type === 'number'">
<!-- label --> <!-- label -->
<h4 class="input-label"> <h4
class="input-label"
[class.validation-error]="formGroup.get(entry.key)?.errors"
>
<form-label <form-label
[data]="{ [data]="{
spec: spec, spec: spec,
@@ -98,6 +101,12 @@
>{{ spec.units }}</ion-note >{{ spec.units }}</ion-note
> >
</ion-item> </ion-item>
<form-error
*ngIf="formGroup.get(entry.key)?.errors"
[control]="$any(formGroup.get(entry.key))"
[spec]="spec"
>
</form-error>
</ng-container> </ng-container>
<!-- boolean or enum --> <!-- boolean or enum -->
<ion-item <ion-item
@@ -164,6 +173,8 @@
<ion-item-divider <ion-item-divider
(click)="toggleExpandObject(entry.key)" (click)="toggleExpandObject(entry.key)"
style="cursor: pointer" style="cursor: pointer"
[class.error-border]="entry.value.invalid"
[class.validation-error]="entry.value.invalid"
> >
<form-label <form-label
[data]="{ [data]="{
@@ -217,7 +228,10 @@
[formArrayName]="entry.key" [formArrayName]="entry.key"
> >
<!-- label --> <!-- label -->
<ion-item-divider> <ion-item-divider
[class.error-border]="entry.value.invalid"
[class.validation-error]="entry.value.invalid"
>
<form-label <form-label
[data]="{ [data]="{
spec: spec, spec: spec,
@@ -226,8 +240,9 @@
}" }"
></form-label> ></form-label>
<ion-button <ion-button
strong
fill="clear" fill="clear"
color="primary" color="dark"
slot="end" slot="end"
(click)="addListItemWrapper(entry.key, spec)" (click)="addListItemWrapper(entry.key, spec)"
> >
@@ -235,6 +250,12 @@
Add Add
</ion-button> </ion-button>
</ion-item-divider> </ion-item-divider>
<form-error
*ngIf="formGroup.get(entry.key)?.errors"
[control]="$any(formGroup.get(entry.key))"
[spec]="spec"
>
</form-error>
<!-- body --> <!-- body -->
<div class="nested-wrapper"> <div class="nested-wrapper">
<div <div
@@ -249,7 +270,11 @@
*ngIf="spec.subtype === 'object' || spec.subtype === 'union'" *ngIf="spec.subtype === 'object' || spec.subtype === 'union'"
> >
<!-- nested label --> <!-- nested label -->
<ion-item button (click)="toggleExpandListObject(entry.key, i)"> <ion-item
button
(click)="toggleExpandListObject(entry.key, i)"
[class.error-border]="abstractControl.invalid"
>
<form-label <form-label
[data]="{ [data]="{
spec: $any({ spec: $any({
@@ -258,8 +283,7 @@
'Entry ' + (i + 1) 'Entry ' + (i + 1)
}), }),
new: false, new: false,
edited: abstractControl.dirty, edited: abstractControl.dirty
invalid: abstractControl.invalid
}" }"
></form-label> ></form-label>
<ion-icon <ion-icon
@@ -275,7 +299,7 @@
</ion-item> </ion-item>
<!-- nested body --> <!-- nested body -->
<div <div
class="ion-padding-start" style="padding-left: 24px"
[id]="getElementId(entry.key, i)" [id]="getElementId(entry.key, i)"
[ngStyle]="{ [ngStyle]="{
'max-height': objectListDisplay[entry.key][i].height, 'max-height': objectListDisplay[entry.key][i].height,
@@ -332,6 +356,7 @@
> >
</ion-input> </ion-input>
<ion-button <ion-button
strong
slot="end" slot="end"
color="danger" color="danger"
(click)="presentAlertDelete(entry.key, i)" (click)="presentAlertDelete(entry.key, i)"
@@ -359,6 +384,7 @@
<!-- label --> <!-- label -->
<p class="input-label"> <p class="input-label">
<form-label <form-label
[class.validation-error]="entry.value.invalid"
[data]="{ [data]="{
spec: spec, spec: spec,
new: original?.[entry.key] === undefined, new: original?.[entry.key] === undefined,
@@ -380,14 +406,14 @@
<ion-icon slot="icon-only" name="chevron-down"></ion-icon> <ion-icon slot="icon-only" name="chevron-down"></ion-icon>
</ion-button> </ion-button>
</ion-item> </ion-item>
<form-error
*ngIf="formGroup.get(entry.key)?.errors"
[control]="$any(formGroup.get(entry.key))"
[spec]="spec"
>
</form-error>
</ng-container> </ng-container>
</ng-container> </ng-container>
<form-error
*ngIf="formGroup.get(entry.key)?.errors"
[control]="$any(formGroup.get(entry.key))"
[spec]="spec"
>
</form-error>
</div> </div>
</div> </div>
</ion-item-group> </ion-item-group>

View File

@@ -1,6 +1,13 @@
.slot-start { .slot-start {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
--padding-start: 0;
--padding-end: 7px;
}
.error-border {
border-color: var(--ion-color-danger-shade);
--border-color: var(--ion-color-danger-shade);
} }
ion-input { ion-input {
@@ -17,11 +24,16 @@ ion-item-divider {
} }
.nested-wrapper { .nested-wrapper {
padding: 0 0 24px 24px; padding: 0 0 16px 24px;
} }
.validation-error { .validation-error {
opacity: 1;
}
.error-message {
p { p {
margin-bottom: 4px;
font-size: small; font-size: small;
color: var(--ion-color-danger); color: var(--ion-color-danger);
} }

View File

@@ -168,7 +168,7 @@ export class FormObjectComponent {
] ]
this.objectListDisplay[key].push({ this.objectListDisplay[key].push({
height: '0px', height: '0px',
expanded: true, expanded: false,
displayAs: displayAs ? Mustache.render(displayAs, newItem.value) : '', displayAs: displayAs ? Mustache.render(displayAs, newItem.value) : '',
}) })
} }
@@ -372,7 +372,6 @@ interface HeaderData {
edited: boolean edited: boolean
new: boolean new: boolean
newOptions?: boolean newOptions?: boolean
invalid?: boolean
} }
@Component({ @Component({

View File

@@ -1,19 +1,30 @@
<ion-content <ion-content
[scrollEvents]="true" [scrollEvents]="true"
(ionScroll)="scrollEvent()" (ionScroll)="scrollEvent()"
style="height: 100%;" style="height: 100%"
class="ion-padding" class="ion-padding"
> >
<ion-infinite-scroll id="scroller" *ngIf="!loading && needInfinite" position="top" threshold="0" (ionInfinite)="loadData($event)"> <ion-infinite-scroll
<ion-infinite-scroll-content loadingSpinner="lines"></ion-infinite-scroll-content> id="scroller"
*ngIf="!loading && needInfinite"
position="top"
threshold="0"
(ionInfinite)="loadData($event)"
>
<ion-infinite-scroll-content
loadingSpinner="lines"
></ion-infinite-scroll-content>
</ion-infinite-scroll> </ion-infinite-scroll>
<text-spinner *ngIf="loading" text="Loading Logs"></text-spinner> <text-spinner *ngIf="loading" text="Loading Logs"></text-spinner>
<div id="container"> <div id="container">
<div id="template" style="white-space: pre-line; font-family: monospace;"></div> <div
id="template"
style="white-space: pre-line; font-family: monospace"
></div>
</div> </div>
<div id="button-div" *ngIf="!loading" style="width: 100%; text-align: center;"> <div id="button-div" *ngIf="!loading" style="width: 100%; text-align: center">
<ion-button *ngIf="!loadingMore" (click)="loadMore()" strong color="dark"> <ion-button *ngIf="!loadingMore" (click)="loadMore()" strong color="dark">
Load More Load More
<ion-icon slot="end" name="refresh"></ion-icon> <ion-icon slot="end" name="refresh"></ion-icon>
@@ -22,18 +33,29 @@
</div> </div>
<div <div
*ngIf="!loading"
[ngStyle]="{ [ngStyle]="{
'position': 'fixed', 'position': 'fixed',
'bottom': '50px', 'bottom': '36px',
'right': isOnBottom ? '-52px' : '30px', 'right': isOnBottom ? '-52px' : '36px',
'background-color': 'var(--ion-color-medium)', 'background-color': 'var(--ion-color-medium)',
'border-radius': '100%', 'border-radius': '100%',
'transition': 'right 0.4s ease-out' 'transition': 'right 0.4s ease-out'
}" }"
> >
<ion-button style="width: 50px; height: 50px; --padding-start: 0px; --padding-end: 0px; --border-radius: 100%;" color="dark" (click)="scrollToBottom()" strong> <ion-button
style="
width: 50px;
height: 50px;
--padding-start: 0px;
--padding-end: 0px;
--border-radius: 100%;
"
color="dark"
(click)="scrollToBottom()"
strong
>
<ion-icon name="chevron-down"></ion-icon> <ion-icon name="chevron-down"></ion-icon>
</ion-button> </ion-button>
</div> </div>
</ion-content> </ion-content>

View File

@@ -14,7 +14,6 @@ import {
isObject, isObject,
} from '@start9labs/shared' } from '@start9labs/shared'
import { DependentInfo } from 'src/app/types/dependent-info' import { DependentInfo } from 'src/app/types/dependent-info'
import { WizardDefs } from 'src/app/components/app-wizard/wizard-defs'
import { ConfigSpec } from 'src/app/pkg-config/config-types' import { ConfigSpec } from 'src/app/pkg-config/config-types'
import { PackageDataEntry } from 'src/app/services/patch-db/data-model' import { PackageDataEntry } from 'src/app/services/patch-db/data-model'
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
@@ -134,7 +133,7 @@ export class AppConfigPage {
if (this.configForm.invalid) { if (this.configForm.invalid) {
document document
.getElementsByClassName('validation-error')[0] .getElementsByClassName('validation-error')[0]
?.parentElement?.parentElement?.scrollIntoView({ behavior: 'smooth' }) ?.scrollIntoView({ behavior: 'smooth' })
return return
} }

View File

@@ -50,7 +50,7 @@ export class GenericFormPage {
this.formGroup.markAllAsTouched() this.formGroup.markAllAsTouched()
document document
.getElementsByClassName('validation-error')[0] .getElementsByClassName('validation-error')[0]
?.parentElement?.parentElement?.scrollIntoView({ behavior: 'smooth' }) ?.scrollIntoView({ behavior: 'smooth' })
return return
} }

View File

@@ -33,13 +33,6 @@ export class AppShowPage {
private readonly pkgId = getPkgId(this.route) private readonly pkgId = getPkgId(this.route)
readonly pkg$ = this.patch.watch$('package-data', this.pkgId).pipe( readonly pkg$ = this.patch.watch$('package-data', this.pkgId).pipe(
filter(
(p: PackageDataEntry) =>
!(
p.installed?.status.main.status === PackageMainStatus.Starting &&
p.installed?.status.main.restarting
),
),
map(pkg => { map(pkg => {
// if package disappears, navigate to list page // if package disappears, navigate to list page
if (!pkg) { if (!pkg) {
@@ -49,6 +42,15 @@ export class AppShowPage {
return { ...pkg } return { ...pkg }
}), }),
startWith(this.patch.getData()['package-data'][this.pkgId]), startWith(this.patch.getData()['package-data'][this.pkgId]),
filter(
(p: PackageDataEntry | undefined) =>
// will be undefined when sideloading
p !== undefined &&
!(
p.installed?.status.main.status === PackageMainStatus.Starting &&
p.installed?.status.main.restarting
),
),
) )
readonly connectionFailure$ = this.connectionService readonly connectionFailure$ = this.connectionService
@@ -60,7 +62,7 @@ export class AppShowPage {
private readonly navCtrl: NavController, private readonly navCtrl: NavController,
private readonly patch: PatchDbService, private readonly patch: PatchDbService,
private readonly connectionService: ConnectionService, private readonly connectionService: ConnectionService,
) {} ) { }
isInstalled( isInstalled(
{ state }: PackageDataEntry, { state }: PackageDataEntry,

View File

@@ -23,7 +23,7 @@
</ion-button> </ion-button>
<ion-button <ion-button
class="action-button" class="action-button"
color="warning" color="tertiary"
(click)="tryRestart()" (click)="tryRestart()"
> >
<ion-icon slot="start" name="refresh"></ion-icon> <ion-icon slot="start" name="refresh"></ion-icon>

View File

@@ -11,7 +11,11 @@
</ion-header> </ion-header>
<ion-content> <ion-content>
<ion-item button (click)="openBasicInfoModal()"> <ion-item
*ngIf="projectData$ | async as projectData"
button
(click)="openBasicInfoModal(projectData)"
>
<ion-icon slot="start" name="information-circle-outline"></ion-icon> <ion-icon slot="start" name="information-circle-outline"></ion-icon>
<ion-label> <ion-label>
<h2>Basic Info</h2> <h2>Basic Info</h2>

View File

@@ -6,10 +6,8 @@ import { BasicInfo, getBasicInfoSpec } from './form-info'
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
import { ApiService } from 'src/app/services/api/embassy-api.service' import { ApiService } from 'src/app/services/api/embassy-api.service'
import { ErrorToastService, DestroyService } from '@start9labs/shared' import { ErrorToastService, DestroyService } from '@start9labs/shared'
import { takeUntil } from 'rxjs/operators'
import { DevProjectData } from 'src/app/services/patch-db/data-model'
import { getProjectId } from 'src/app/util/get-project-id' import { getProjectId } from 'src/app/util/get-project-id'
import * as yaml from 'js-yaml' import { DevProjectData } from 'src/app/services/patch-db/data-model'
@Component({ @Component({
selector: 'developer-menu', selector: 'developer-menu',
@@ -19,7 +17,7 @@ import * as yaml from 'js-yaml'
}) })
export class DeveloperMenuPage { export class DeveloperMenuPage {
readonly projectId = getProjectId(this.route) readonly projectId = getProjectId(this.route)
projectData: DevProjectData projectData$ = this.patch.watch$('ui', 'dev', this.projectId)
constructor( constructor(
private readonly route: ActivatedRoute, private readonly route: ActivatedRoute,
@@ -27,29 +25,19 @@ export class DeveloperMenuPage {
private readonly loadingCtrl: LoadingController, private readonly loadingCtrl: LoadingController,
private readonly api: ApiService, private readonly api: ApiService,
private readonly errToast: ErrorToastService, private readonly errToast: ErrorToastService,
private readonly destroy$: DestroyService, private readonly patch: PatchDbService,
private readonly patchDb: PatchDbService, ) { }
) {}
get name(): string { get name(): string {
return this.patchDb.getData().ui?.dev?.[this.projectId]?.name || '' return this.patch.getData().ui?.dev?.[this.projectId]?.name || ''
} }
ngOnInit() { async openBasicInfoModal(data: DevProjectData) {
this.patchDb
.watch$('ui', 'dev', this.projectId)
.pipe(takeUntil(this.destroy$))
.subscribe(pd => {
this.projectData = pd
})
}
async openBasicInfoModal() {
const modal = await this.modalCtrl.create({ const modal = await this.modalCtrl.create({
component: GenericFormPage, component: GenericFormPage,
componentProps: { componentProps: {
title: 'Basic Info', title: 'Basic Info',
spec: getBasicInfoSpec(this.projectData), spec: getBasicInfoSpec(data),
buttons: [ buttons: [
{ {
text: 'Save', text: 'Save',

View File

@@ -44,7 +44,7 @@ export function getBasicInfoSpec(devData: DevProjectData): ConfigSpec {
}, },
'service-version-number': { 'service-version-number': {
type: 'string', type: 'string',
name: 'Service Version Number', name: 'Service Version',
description: description:
'Service version - accepts up to four digits, where the last confirms to revisions necessary for EmbassyOS - see documentation: https://github.com/Start9Labs/emver-rs. This value will change with each release of the service', 'Service version - accepts up to four digits, where the last confirms to revisions necessary for EmbassyOS - see documentation: https://github.com/Start9Labs/emver-rs. This value will change with each release of the service',
placeholder: 'e.g. 0.1.2.3', placeholder: 'e.g. 0.1.2.3',

View File

@@ -327,8 +327,8 @@ export class ServerShowPage {
disabled: of(false), disabled: of(false),
}, },
{ {
title: 'Manually Install A Service', title: 'Sideload Service',
description: `Install a service by drag and drop`, description: `Manually install any service package`,
icon: 'push-outline', icon: 'push-outline',
action: () => action: () =>
this.navCtrl.navigateForward(['sideload'], { this.navCtrl.navigateForward(['sideload'], {

View File

@@ -3,7 +3,7 @@
<ion-buttons slot="start"> <ion-buttons slot="start">
<ion-back-button defaultHref="embassy"></ion-back-button> <ion-back-button defaultHref="embassy"></ion-back-button>
</ion-buttons> </ion-buttons>
<ion-title>Manually Install A Service</ion-title> <ion-title>Sideload Service</ion-title>
</ion-toolbar> </ion-toolbar>
</ion-header> </ion-header>
@@ -21,7 +21,7 @@
color="dark" color="dark"
style="font-size: 42px" style="font-size: 42px"
></ion-icon> ></ion-icon>
<h4>To install a service manually, upload the s9pk here</h4> <h4>Manually upload a service package</h4>
<p *ngIf="onTor"> <p *ngIf="onTor">
<ion-text color="success" <ion-text color="success"
>Tip: switch to LAN for faster uploads.</ion-text >Tip: switch to LAN for faster uploads.</ion-text

View File

@@ -187,11 +187,12 @@ export class MarketplaceService extends AbstractMarketplaceService {
url: string, url: string,
eosVersionCompat: string, eosVersionCompat: string,
): Promise<RR.GetMarketplacePackagesRes> { ): Promise<RR.GetMarketplacePackagesRes> {
let clonedParams = { ...params }
if (params.query) delete params.category if (params.query) delete params.category
if (params.ids) params.ids = JSON.stringify(params.ids) if (clonedParams.ids) clonedParams.ids = JSON.stringify(clonedParams.ids)
const qp: RR.GetMarketplacePackagesReq = { const qp: RR.GetMarketplacePackagesReq = {
...params, ...clonedParams,
'eos-version-compat': eosVersionCompat, 'eos-version-compat': eosVersionCompat,
} }

View File

@@ -144,7 +144,7 @@ export const PrimaryRendering: Record<string, StatusRendering> = {
}, },
[PrimaryStatus.Restarting]: { [PrimaryStatus.Restarting]: {
display: 'Restarting', display: 'Restarting',
color: 'warning', color: 'tertiary',
showDots: true, showDots: true,
}, },
[PrimaryStatus.Stopped]: { [PrimaryStatus.Stopped]: {