better messageboxes

This commit is contained in:
Eugene Pankov
2019-01-03 17:20:02 +03:00
parent d5b6a686f8
commit 9faa346699
8 changed files with 84 additions and 15 deletions

View File

@@ -66,8 +66,17 @@ export class EditConnectionModalComponent {
}
}
deleteScript (script: LoginScript) {
if (confirm(`Delete?`)) {
async deleteScript (script: LoginScript) {
if ((await this.electron.showMessageBox(
this.hostApp.getWindow(),
{
type: 'warning',
message: 'Delete this script?',
detail: script.expect,
buttons: ['Keep', 'Delete'],
defaultId: 1,
}
)).response === 1) {
this.connection.scripts = this.connection.scripts.filter(x => x !== script)
}
}

View File

@@ -1,6 +1,6 @@
import { Component } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { ConfigService } from 'terminus-core'
import { ConfigService, ElectronService, HostAppService } from 'terminus-core'
import { SSHConnection, ISSHConnectionGroup } from '../api'
import { EditConnectionModalComponent } from './editConnectionModal.component'
import { PromptModalComponent } from './promptModal.component'
@@ -15,6 +15,8 @@ export class SSHSettingsTabComponent {
constructor (
public config: ConfigService,
private electron: ElectronService,
private hostApp: HostAppService,
private ngbModal: NgbModal,
) {
this.connections = this.config.store.ssh.connections
@@ -49,8 +51,16 @@ export class SSHSettingsTabComponent {
})
}
deleteConnection (connection: SSHConnection) {
if (confirm(`Delete "${connection.name}"?`)) {
async deleteConnection (connection: SSHConnection) {
if ((await this.electron.showMessageBox(
this.hostApp.getWindow(),
{
type: 'warning',
message: `Delete "${connection.name}"?`,
buttons: ['Keep', 'Delete'],
defaultId: 1,
}
)).response === 1) {
this.connections = this.connections.filter(x => x !== connection)
this.config.store.ssh.connections = this.connections
this.config.save()
@@ -73,8 +83,16 @@ export class SSHSettingsTabComponent {
})
}
deleteGroup (group: ISSHConnectionGroup) {
if (confirm(`Delete "${group}"?`)) {
async deleteGroup (group: ISSHConnectionGroup) {
if ((await this.electron.showMessageBox(
this.hostApp.getWindow(),
{
type: 'warning',
message: `Delete "${group}"?`,
buttons: ['Keep', 'Delete'],
defaultId: 1,
}
)).response === 1) {
for (let connection of this.connections.filter(x => x.group === group.name)) {
connection.group = null
}