From f279f1a1e570eff770bd3d363950d73d0309c077 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Tue, 18 Jun 2019 23:53:19 +0200 Subject: [PATCH] login scripts ui cleanup --- .../editConnectionModal.component.pug | 47 +++++-------------- .../editConnectionModal.component.ts | 18 ++----- 2 files changed, 16 insertions(+), 49 deletions(-) diff --git a/terminus-ssh/src/components/editConnectionModal.component.pug b/terminus-ssh/src/components/editConnectionModal.component.pug index 0a257706..24a51cf4 100644 --- a/terminus-ssh/src/components/editConnectionModal.component.pug +++ b/terminus-ssh/src/components/editConnectionModal.component.pug @@ -118,15 +118,15 @@ ngb-tab(id='scripts') ng-template(ngbTabTitle) Login scripts ng-template(ngbTabContent) - table + table(*ngIf='connection.scripts.length > 0') tr th String to expect th String to be sent - th Regex - th Optional - th Actions + th.pl-2 Regex + th.pl-2 Optional + th.pl-2 Actions tr(*ngFor='let script of connection.scripts') - td + td.pr-2 input.form-control( type='text', [(ngModel)]='script.expect' @@ -136,15 +136,15 @@ type='text', [(ngModel)]='script.send' ) - td + td.pl-2 checkbox( [(ngModel)]='script.isRegex', ) - td + td.pl-2 checkbox( [(ngModel)]='script.optional', ) - td + td.pl-2 .input-group.flex-nowrap button.btn.btn-outline-info.ml-0((click)='moveScriptUp(script)') i.fas.fa-arrow-up @@ -152,32 +152,11 @@ i.fas.fa-arrow-down button.btn.btn-outline-danger.ml-0((click)='deleteScript(script)') i.fas.fa-trash - tr - td - input.form-control( - type='text', - placeholder='Enter a string to expect', - [(ngModel)]='newScript.expect' - ) - td - input.form-control( - type='text', - placeholder='Enter a string to be sent', - [(ngModel)]='newScript.send' - ) - td - checkbox( - [(ngModel)]='newScript.isRegex', - ) - td - checkbox( - [(ngModel)]='newScript.optional', - ) - td - .input-group.flex-nowrap - button.btn.btn-outline-info.ml-0((click)='addScript()') - i.fas.fa-check - + + button.btn.btn-outline-info.mt-2((click)='addScript()') + i.fas.fa-plus + span New item + .modal-footer button.btn.btn-outline-primary((click)='save()') Save button.btn.btn-outline-danger((click)='cancel()') Cancel diff --git a/terminus-ssh/src/components/editConnectionModal.component.ts b/terminus-ssh/src/components/editConnectionModal.component.ts index 4621760b..ff250548 100644 --- a/terminus-ssh/src/components/editConnectionModal.component.ts +++ b/terminus-ssh/src/components/editConnectionModal.component.ts @@ -12,7 +12,6 @@ import { ALGORITHMS } from 'ssh2-streams/lib/constants' }) export class EditConnectionModalComponent { connection: SSHConnection - newScript: LoginScript hasSavedPassword: boolean supportedAlgorithms: {[id: string]: string[]} = {} @@ -26,8 +25,6 @@ export class EditConnectionModalComponent { private passwordStorage: PasswordStorageService, private ngbModal: NgbModal, ) { - this.newScript = { expect: '', send: '' } - for (const k of Object.values(SSHAlgorithmType)) { const supportedAlg = { [SSHAlgorithmType.KEX]: 'SUPPORTED_KEX', @@ -49,6 +46,8 @@ export class EditConnectionModalComponent { async ngOnInit () { this.hasSavedPassword = !!await this.passwordStorage.loadPassword(this.connection) this.connection.algorithms = this.connection.algorithms || {} + this.connection.scripts = this.connection.scripts || [] + for (const k of Object.values(SSHAlgorithmType)) { if (!this.connection.algorithms[k]) { this.connection.algorithms[k] = this.defaultAlgorithms[k] @@ -136,17 +135,6 @@ export class EditConnectionModalComponent { } addScript () { - if (!this.connection.scripts) { - this.connection.scripts = [] - } - this.connection.scripts.push({ ...this.newScript }) - this.clearScript() - } - - clearScript () { - this.newScript.expect = '' - this.newScript.send = '' - this.newScript.isRegex = false - this.newScript.optional = false + this.connection.scripts.push({ expect: '', send: '' }) } }