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')
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

View File

@ -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: '' })
}
}