Fix/misc UI (#1622)

* show available marketplace updates in menu

* complete feature

* delete unused class

* update tsmatches to remove console log

* fix merge conflict

* change config header font size

* fix new options emission for config elements

* delete unecessary import

* add custom modal for service marketplace conflict action

* cleanup

* remove unecessary imports

* pr cleanup of unused imports and classes

Co-authored-by: Matt Hill <matthewonthemoon@gmail.com>
This commit is contained in:
Lucy C
2022-07-06 17:10:22 -06:00
committed by GitHub
parent b0a55593c1
commit 449968bc4e
13 changed files with 168 additions and 38 deletions

View File

@@ -26,6 +26,9 @@ import { pauseFor } from '@start9labs/shared'
import { v4 } from 'uuid'
const Mustache = require('mustache')
interface Config {
[key: string]: any
}
@Component({
selector: 'form-object',
templateUrl: './form-object.component.html',
@@ -35,8 +38,8 @@ export class FormObjectComponent {
@Input() objectSpec: ConfigSpec
@Input() formGroup: FormGroup
@Input() unionSpec?: ValueSpecUnion
@Input() current?: { [key: string]: any }
@Input() original?: { [key: string]: any }
@Input() current?: Config
@Input() original?: Config
@Output() onInputChange = new EventEmitter<void>()
@Output() onExpand = new EventEmitter<void>()
@Output() hasNewOptions = new EventEmitter<void>()
@@ -85,9 +88,16 @@ export class FormObjectComponent {
}
})
if (Object.values(this.original || {}).some(v => v === undefined)) {
this.hasNewOptions.emit()
}
// setTimeout hack to avoid ExpressionChangedAfterItHasBeenCheckedError
setTimeout(() => {
if (this.original) {
Object.keys(this.current || {}).forEach(key => {
if ((this.original as Config)[key] === undefined) {
this.hasNewOptions.emit()
}
})
}
}, 10)
}
getEnumListDisplay(arr: string[], spec: ListValueSpecOf<'enum'>): string {

View File

@@ -0,0 +1,39 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-button (click)="dismiss()">
<ion-icon name="close"></ion-icon>
</ion-button>
</ion-buttons>
<ion-title>{{ title }}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ng-container>
<div class="center text-center">
<div class="card">
<h4>This service was installed from:</h4>
<p class="courier-new color-success-shade">{{ packageMarketplace }}</p>
<h4>But you are currently connected to:</h4>
<p class="courier-new color-primary-shade">{{ currentMarketplace }}</p>
</div>
<br />
<div>
<p>To switch marketplaces visit your</p>
<ion-button
color="success"
routerLink="embassy/marketplaces"
(click)="dismiss()"
>Marketplace Settings</ion-button
>
<p>or you can</p>
<ion-button
[routerLink]="['marketplace/', pkgId]"
click="dismiss()"
(click)="dismiss()"
>Continue to {{ currentMarketplace }}</ion-button
>
</div>
</div>
</ng-container>
</ion-content>

View File

@@ -0,0 +1,12 @@
import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { IonicModule } from '@ionic/angular'
import { RouterModule } from '@angular/router'
import { ActionMarketplaceComponent } from './action-marketplace.component'
@NgModule({
declarations: [ActionMarketplaceComponent],
imports: [CommonModule, IonicModule, RouterModule.forChild([])],
exports: [ActionMarketplaceComponent],
})
export class ActionMarketplaceComponentModule {}

View File

@@ -0,0 +1,16 @@
.center {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.text-center {
text-align: center;
}
.card {
background: rgba(53, 56, 62, 0.768);
border-radius: 7px;
padding: 27px;
}

View File

@@ -0,0 +1,20 @@
import { Component, Input } from '@angular/core'
import { ModalController } from '@ionic/angular'
@Component({
selector: 'action-marketplace',
templateUrl: './action-marketplace.component.html',
styleUrls: ['./action-marketplace.component.scss'],
})
export class ActionMarketplaceComponent {
@Input() title: string
@Input() packageMarketplace: string
@Input() currentMarketplace: string
@Input() pkgId: string
constructor(private readonly modalCtrl: ModalController) {}
dismiss() {
this.modalCtrl.dismiss()
}
}

View File

@@ -26,7 +26,7 @@
*ngIf="hasConfig && !pkg.installed?.status?.configured && !configForm.dirty"
class="ion-padding-bottom"
>
<ion-text color="success">
<ion-text class="header-details" color="success">
<span *ngIf="!original; else hasOriginal">
{{ pkg.manifest.title }} has been automatically configured with
recommended defaults. Make whatever changes you want, then click

View File

@@ -5,4 +5,8 @@
// kills the lines
--border-width: 0;
--inner-border-width: 0;
}
.header-details {
font-size: 20px;
}

View File

@@ -5,7 +5,6 @@ import { IonicModule } from '@ionic/angular'
import { RouterModule } from '@angular/router'
import { SharedPipesModule } from '@start9labs/shared'
import { FormsModule } from '@angular/forms'
import { MaskPipeModule } from 'src/app/pipes/mask/mask.module'
@NgModule({
declarations: [GenericInputComponent],

View File

@@ -21,6 +21,7 @@ import { ToButtonsPipe } from './pipes/to-buttons.pipe'
import { ToDependenciesPipe } from './pipes/to-dependencies.pipe'
import { ToStatusPipe } from './pipes/to-status.pipe'
import { ProgressDataPipe } from './pipes/progress-data.pipe'
import { ActionMarketplaceComponentModule } from 'src/app/modals/action-marketplace/action-marketplace.component.module'
const routes: Routes = [
{
@@ -55,6 +56,7 @@ const routes: Routes = [
EmverPipesModule,
LaunchablePipeModule,
UiPipeModule,
ActionMarketplaceComponentModule,
],
})
export class AppShowPageModule {}

View File

@@ -15,6 +15,7 @@ import { ModalService } from 'src/app/services/modal.service'
import { ApiService } from 'src/app/services/api/embassy-api.service'
import { from } from 'rxjs'
import { Marketplace } from '@start9labs/marketplace'
import { ActionMarketplaceComponent } from 'src/app/modals/action-marketplace/action-marketplace.component'
export interface Button {
title: string
description: string
@@ -166,7 +167,11 @@ export class ToButtonsPipe implements PipeTransform {
}
button.action = () =>
this.differentMarketplaceAction(pkgTitle, marketplaceTitle)
this.differentMarketplaceAction(
pkgTitle,
marketplaceTitle,
pkg.manifest.id,
)
button.description = 'Service was installed from a different marketplace'
}
return button
@@ -184,28 +189,28 @@ export class ToButtonsPipe implements PipeTransform {
await alert.present()
}
}
private async differentMarketplaceAction(pkgM: string, currentM: string) {
const alert = await this.alertCtrl.create({
header: 'Marketplace Conflict',
message: `This service was installed from:
<br><br>
<span class="courier-new color-success-shade">${pkgM}</span>
<br><br>but you are currently connected to:<br><br>
<span class="courier-new color-primary-shade">${currentM}</span>
<br><br>
To view the marketplace listing for this service, visit your Marketplace Settings and change marketplaces.`,
buttons: [
{
text: 'Cancel',
role: 'cancel',
},
{
text: 'Go to Settings',
handler: () => this.navCtrl.navigateForward(['embassy/marketplaces']),
cssClass: 'enter-click',
},
],
private async differentMarketplaceAction(
packageMarketplace: string,
currentMarketplace: string,
pkgId: string,
) {
const modal = await this.modalCtrl.create({
component: ActionMarketplaceComponent,
componentProps: {
title: 'Marketplace Conflict',
packageMarketplace,
currentMarketplace,
pkgId,
buttons: [
{
text: 'Cancel',
role: 'cancel',
},
],
},
cssClass: 'medium-modal',
})
await alert.present()
await modal.present()
}
}