80
80
:rules =" param.required ? [ val => val && val.length > 0 || $t('requiredField') ] : [] "
81
81
:hint =" `${param.required ? $t('requiredParam') : $t('optionalParam') } | ${param.type} | ${param.hint ? param.hint[language] || param.hint['default'] : ''}`"
82
82
:type =" paramType[param.type][1]"
83
- @keyup .enter = " $event.target.nextElementSibling.focus() "
83
+ @keydown .enter.prevent
84
84
filled
85
85
clearable
86
86
lazy-rules
297
297
no-backdrop-dismiss
298
298
>
299
299
<q-card class =" full-width" >
300
- <q-form autofocus >
300
+ <q-form
301
+ autofocus
302
+ @submit =" executeCommand"
303
+ >
301
304
<q-card-section >
302
305
<div class =" text-h6" >
303
306
<q-icon
330
333
<q-btn
331
334
v-close-popup
332
335
:label =" $t('launch')"
333
- @click =" executeCommand"
334
336
flat
335
337
type =" submit"
336
338
/>
@@ -432,6 +434,7 @@ import { exportFile } from 'quasar'
432
434
import { mapGetters } from ' vuex'
433
435
import { QMarkdown } from ' @quasar/quasar-ui-qmarkdown'
434
436
import Prism from ' vue-prismjs'
437
+ import _ from ' lodash'
435
438
import ' src/assets/prism_tomorrowlight.css'
436
439
const childProcess = require (' child_process' )
437
440
@@ -471,7 +474,7 @@ export default {
471
474
returnParamsPaginate: 1 , // In multiple selection workflows allows parameters for each selection
472
475
resultCommand: ' ' , // Command ready to be executed, that is variables replaced for user set parameters
473
476
results: {}, // Command result object displayed in Results Dialog
474
- resultsSelected: { ' 0 ' : [] } , // Array of selected objects from Results Dialog
477
+ resultsSelected: [[]] , // Array of selected objects from Results Dialog
475
478
resultsFilter: ' ' , // Filter for results table
476
479
externalHelpFile: ' ' , // Holds Help text loaded from external source
477
480
displayCommandDiag: false , // Visibility state for command dialog
@@ -502,7 +505,7 @@ export default {
502
505
}
503
506
},
504
507
computed: {
505
- ... mapGetters (' lazystore' , [' getLanguage' , ' getSearch' , ' getScriptsArray' , ' getDefinitions' , ' getCommandMaximized' , ' getAlwaysConfirm' ]),
508
+ ... mapGetters (' lazystore' , [' getLanguage' , ' getSearch' , ' getScriptsArray' , ' getDefinitions' , ' getCommandMaximized' , ' getAlwaysConfirm' , ' getHistoryLength ' , ' getHistory ' ]),
506
509
language : function () {
507
510
return this .getLanguage
508
511
},
@@ -526,6 +529,18 @@ export default {
526
529
alwaysConfirm : function () {
527
530
return this .getAlwaysConfirm
528
531
},
532
+ historyLength : function () {
533
+ return this .getHistoryLength
534
+ },
535
+ history: {
536
+ get () {
537
+ return this .getHistory
538
+ },
539
+ set (val) {
540
+ let history = _ .cloneDeep (val)
541
+ this .$store .dispatch (' lazystore/setHistory' , history)
542
+ }
543
+ },
529
544
resultsColumns: {
530
545
get () {
531
546
let columns = [
@@ -662,7 +677,7 @@ export default {
662
677
this .returnParams = {} // User defined parameters from Command Dialog
663
678
this .returnParamsPaginate = 1 // In multiple selection workflows allows parameters for each selection
664
679
this .results = {} // Command result object displayed in Results Dialog
665
- this .resultsSelected = { ' 0 ' : [] } // Array of selected objects from Results Dialog
680
+ this .resultsSelected = [[]] // Array of selected objects from Results Dialog
666
681
this .resultsFilter = ' ' // Filter for results table
667
682
},
668
683
// If user needs to stop PowerShell execution for whatever reason, he can smash Esc to kill process and launch new one.
@@ -807,21 +822,14 @@ export default {
807
822
}
808
823
},
809
824
executeCommand () {
810
- // this.resultsSelected = [] // Clear variable as we do not need it anymore
811
- // TODO: Above move to preexecute command, so user can see it and edit it before running
812
825
this .toggleLoading (true )
813
- // TODO: Save command to history
814
826
this .$pwsh .shell .clear ().then (() => {
815
827
if (this .currentCommand .insidePsSession ) {
816
- // if (this.resultCommand.match(/(\r\n|\n|\r)/gm)) {
817
- // console.log('multiline!')
818
- // }
819
828
this .$pwsh .shell .addCommand (` Invoke-Command -Session $Global:LazyAdminPSSession -ScriptBlock {${ this .resultCommand } }` )
820
829
} else {
821
830
this .$pwsh .shell .addCommand (this .resultCommand )
822
831
}
823
832
this .$pwsh .shell .invoke ().then (output => {
824
- // console.log('Command results: ', output)
825
833
// Code block to handle PowerShell return data
826
834
let data
827
835
let params
@@ -858,6 +866,16 @@ export default {
858
866
output: output .trim ()
859
867
}
860
868
}
869
+ // Save to history
870
+ this .history = {
871
+ currentCommand: this .currentCommand ,
872
+ currentCommandMaster: this .currentCommandMaster ,
873
+ currentWorkflowIndex: this .currentWorkflowIndex ,
874
+ resultCommand: this .resultCommand ,
875
+ returnParams: this .returnParams ,
876
+ returnParamsPaginate: this .returnParamsPaginate ,
877
+ results: this .results
878
+ }
861
879
this .displayResultsDiag = true
862
880
this .toggleLoading ()
863
881
}).catch (error => {
0 commit comments