mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
Feature/restart service (#1554)
* add restart button to service show page and restart rpc api * Feature/restart rpc (#1555) * add restart rpc and status * wire up rpc * add restarting bool Co-authored-by: Aiden McClelland <me@drbonez.dev> * check if service is restarting * filter package when restarting to avoid glitch Co-authored-by: Aiden McClelland <me@drbonez.dev>
This commit is contained in:
@@ -3,6 +3,7 @@ import { NavController } from '@ionic/angular'
|
||||
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
|
||||
import {
|
||||
PackageDataEntry,
|
||||
PackageMainStatus,
|
||||
PackageState,
|
||||
} from 'src/app/services/patch-db/data-model'
|
||||
import {
|
||||
@@ -13,7 +14,7 @@ import {
|
||||
ConnectionFailure,
|
||||
ConnectionService,
|
||||
} from 'src/app/services/connection.service'
|
||||
import { map, startWith } from 'rxjs/operators'
|
||||
import { map, startWith, filter } from 'rxjs/operators'
|
||||
import { ActivatedRoute } from '@angular/router'
|
||||
import { getPkgId } from '@start9labs/shared'
|
||||
|
||||
@@ -32,6 +33,13 @@ export class AppShowPage {
|
||||
private readonly pkgId = getPkgId(this.route)
|
||||
|
||||
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 => {
|
||||
// if package disappears, navigate to list page
|
||||
if (!pkg) {
|
||||
|
||||
@@ -21,6 +21,14 @@
|
||||
<ion-icon slot="start" name="stop-outline"></ion-icon>
|
||||
Stop
|
||||
</ion-button>
|
||||
<ion-button
|
||||
class="action-button"
|
||||
color="warning"
|
||||
(click)="tryRestart()"
|
||||
>
|
||||
<ion-icon slot="start" name="refresh"></ion-icon>
|
||||
Restart
|
||||
</ion-button>
|
||||
</ng-container>
|
||||
|
||||
<ion-button
|
||||
@@ -58,4 +66,4 @@
|
||||
</ion-col>
|
||||
</ion-row>
|
||||
</ion-grid>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
}
|
||||
|
||||
.action-button {
|
||||
margin: 20px 20px 10px 0;
|
||||
margin: 12px 20px 10px 0;
|
||||
min-height: 42px;
|
||||
min-width: 140px;
|
||||
}
|
||||
}
|
||||
@@ -137,8 +137,6 @@ export class AppShowStatusComponent {
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
async tryRestart(): Promise<void> {
|
||||
if (hasCurrentDeps(this.pkg)) {
|
||||
const alert = await this.alertCtrl.create({
|
||||
@@ -165,7 +163,28 @@ export class AppShowStatusComponent {
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> 918a1907... Remove app wiz and dry calls (#1541)
|
||||
async presentAlertRestart(): Promise<void> {
|
||||
const alert = await this.alertCtrl.create({
|
||||
header: 'Confirm',
|
||||
message: 'Are you sure you want to restart this service?',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Cancel',
|
||||
role: 'cancel',
|
||||
},
|
||||
{
|
||||
text: 'Restart',
|
||||
handler: () => {
|
||||
this.restart()
|
||||
},
|
||||
cssClass: 'enter-click',
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
await alert.present()
|
||||
}
|
||||
|
||||
private async start(): Promise<void> {
|
||||
const loader = await this.loadingCtrl.create({
|
||||
message: `Starting...`,
|
||||
@@ -181,8 +200,6 @@ export class AppShowStatusComponent {
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
private async stop(): Promise<void> {
|
||||
const loader = await this.loadingCtrl.create({
|
||||
message: 'Stopping...',
|
||||
@@ -212,8 +229,6 @@ export class AppShowStatusComponent {
|
||||
loader.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> 918a1907... Remove app wiz and dry calls (#1541)
|
||||
private async presentAlertStart(message: string): Promise<boolean> {
|
||||
return new Promise(async resolve => {
|
||||
const alert = await this.alertCtrl.create({
|
||||
|
||||
Reference in New Issue
Block a user