login scripts ui cleanup

This commit is contained in:
Eugene Pankov 2019-06-18 23:53:19 +02:00
parent db3b8cc718
commit f279f1a1e5
2 changed files with 16 additions and 49 deletions

View File

@ -118,15 +118,15 @@
ngb-tab(id='scripts') ngb-tab(id='scripts')
ng-template(ngbTabTitle) Login scripts ng-template(ngbTabTitle) Login scripts
ng-template(ngbTabContent) ng-template(ngbTabContent)
table table(*ngIf='connection.scripts.length > 0')
tr tr
th String to expect th String to expect
th String to be sent th String to be sent
th Regex th.pl-2 Regex
th Optional th.pl-2 Optional
th Actions th.pl-2 Actions
tr(*ngFor='let script of connection.scripts') tr(*ngFor='let script of connection.scripts')
td td.pr-2
input.form-control( input.form-control(
type='text', type='text',
[(ngModel)]='script.expect' [(ngModel)]='script.expect'
@ -136,15 +136,15 @@
type='text', type='text',
[(ngModel)]='script.send' [(ngModel)]='script.send'
) )
td td.pl-2
checkbox( checkbox(
[(ngModel)]='script.isRegex', [(ngModel)]='script.isRegex',
) )
td td.pl-2
checkbox( checkbox(
[(ngModel)]='script.optional', [(ngModel)]='script.optional',
) )
td td.pl-2
.input-group.flex-nowrap .input-group.flex-nowrap
button.btn.btn-outline-info.ml-0((click)='moveScriptUp(script)') button.btn.btn-outline-info.ml-0((click)='moveScriptUp(script)')
i.fas.fa-arrow-up i.fas.fa-arrow-up
@ -152,31 +152,10 @@
i.fas.fa-arrow-down i.fas.fa-arrow-down
button.btn.btn-outline-danger.ml-0((click)='deleteScript(script)') button.btn.btn-outline-danger.ml-0((click)='deleteScript(script)')
i.fas.fa-trash i.fas.fa-trash
tr
td button.btn.btn-outline-info.mt-2((click)='addScript()')
input.form-control( i.fas.fa-plus
type='text', span New item
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
.modal-footer .modal-footer
button.btn.btn-outline-primary((click)='save()') Save button.btn.btn-outline-primary((click)='save()') Save

View File

@ -12,7 +12,6 @@ import { ALGORITHMS } from 'ssh2-streams/lib/constants'
}) })
export class EditConnectionModalComponent { export class EditConnectionModalComponent {
connection: SSHConnection connection: SSHConnection
newScript: LoginScript
hasSavedPassword: boolean hasSavedPassword: boolean
supportedAlgorithms: {[id: string]: string[]} = {} supportedAlgorithms: {[id: string]: string[]} = {}
@ -26,8 +25,6 @@ export class EditConnectionModalComponent {
private passwordStorage: PasswordStorageService, private passwordStorage: PasswordStorageService,
private ngbModal: NgbModal, private ngbModal: NgbModal,
) { ) {
this.newScript = { expect: '', send: '' }
for (const k of Object.values(SSHAlgorithmType)) { for (const k of Object.values(SSHAlgorithmType)) {
const supportedAlg = { const supportedAlg = {
[SSHAlgorithmType.KEX]: 'SUPPORTED_KEX', [SSHAlgorithmType.KEX]: 'SUPPORTED_KEX',
@ -49,6 +46,8 @@ export class EditConnectionModalComponent {
async ngOnInit () { async ngOnInit () {
this.hasSavedPassword = !!await this.passwordStorage.loadPassword(this.connection) this.hasSavedPassword = !!await this.passwordStorage.loadPassword(this.connection)
this.connection.algorithms = this.connection.algorithms || {} this.connection.algorithms = this.connection.algorithms || {}
this.connection.scripts = this.connection.scripts || []
for (const k of Object.values(SSHAlgorithmType)) { for (const k of Object.values(SSHAlgorithmType)) {
if (!this.connection.algorithms[k]) { if (!this.connection.algorithms[k]) {
this.connection.algorithms[k] = this.defaultAlgorithms[k] this.connection.algorithms[k] = this.defaultAlgorithms[k]
@ -136,17 +135,6 @@ export class EditConnectionModalComponent {
} }
addScript () { addScript () {
if (!this.connection.scripts) { this.connection.scripts.push({ expect: '', send: '' })
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
} }
} }