@@ -5,12 +5,15 @@ import { storeToRefs } from "pinia";
5
5
const $api = inject (" $api" );
6
6
7
7
onMounted (async () => {});
8
+
8
9
</script >
9
10
10
11
<script >
11
12
import { toast } from " bulma-toast" ;
12
13
import { useCoreStore } from " @/stores/coreStore" ;
13
14
import { mapState } from " pinia" ;
15
+ import { loadCommand , setCommand } from ' @/../../manx/static/js/terminal.js'
16
+
14
17
export default {
15
18
inject: [" $api" ],
16
19
data () {
@@ -37,9 +40,9 @@ export default {
37
40
},
38
41
}
39
42
},
40
- created () {
43
+ mounted () {
41
44
this .initPage ();
42
- },
45
+ },
43
46
computed: {
44
47
... mapState (useCoreStore, [" mainConfig" ]),
45
48
},
@@ -50,47 +53,18 @@ export default {
50
53
},
51
54
methods: {
52
55
async initPage () {
53
- let termScript = document .createElement (" script" );
54
- termScript .setAttribute (
55
- " src" ,
56
- " /manx/js/terminal.js"
57
- );
58
- termScript .setAttribute (
59
- " type" ,
60
- " module"
61
- );
62
- if (! import .meta.env.PROD) {
63
- termScript .setAttribute (
64
- "src ",
65
- "http :// localhost:8888/manx/js/terminal.js"
66
- );
67
- }
68
- document .head .appendChild (termScript);
69
- this .$api .get (" /plugin/manx/sessions" ).then ((sessions ) => {
70
- this .sessions = sessions .data .sessions ;
71
- }).catch ((error ) => {
72
- toast ({message: " Error loading sessions" , type: " is-danger" , dismissible: true , pauseOnHover: true , duration: 2000 })
73
- console .error (error);
74
- });
56
+ loadCommand (this .$api );
57
+
58
+ this .refreshManx ();
75
59
setInterval (async () => {
76
- if (! document .querySelector (' .xterm-cursor-layer' ) && window .loadManxTerm ) {
77
- window .loadManxTerm ();
78
- }
79
60
this .refreshManx ();
80
61
}, " 3000" );
81
- // while (this.$refs.header) {
82
- // if (!document.querySelector('.xterm-cursor-layer') && window.loadManxTerm) {
83
- // window.loadManxTerm();
84
- // }
85
- // await sleep(3000);
86
- // this.refreshManx();
87
- // }
88
62
},
89
63
90
64
refreshManx () {
91
- this .$api .post (' /plugin/manx/sessions' ).then ((sessions ) => {
65
+ this .$api .get (' /plugin/manx/sessions' ).then ((sessions ) => {
92
66
// Join new manx agents in array, and assign default platform and executors if DNE
93
- sessions = sessions .data ;
67
+ sessions = sessions .data . sessions ;
94
68
this .sessions = this .sessions .concat (sessions .map ((s ) => ({ ... s, platform: s .platform || this .DEFAULT_PLATFORM , executors: s .executors || [this .DEFAULT_EXECUTORS ] })).filter ((s ) => ! this .sessionIDs .includes (s .id )));
95
69
}).catch ((error ) => {
96
70
toast ({message: " Error refreshing manx" , type: " is-danger" , dismissible: true , pauseOnHover: true , duration: 2000 })
@@ -117,7 +91,7 @@ export default {
117
91
});
118
92
}
119
93
};
120
- this .$api .post (" /api/rest " , { paw: this .selectedSessionID .info }).then ((res ) => {
94
+ this .$api .post (" /plugin/manx/ability " , { paw: this .selectedSession .info }).then ((res ) => {
121
95
getUniqueAbilities (this , res .data );
122
96
}).catch ((error ) => {
123
97
toast ({message: " Error getting tactics" , type: " is-danger" , dismissible: true , pauseOnHover: true , duration: 2000 })
@@ -148,10 +122,9 @@ export default {
148
122
getProcedure () {
149
123
const getCommands = (self , data ) => {
150
124
if (data && data .length > 0 ) {
151
- data = JSON .parse (data);
152
125
data .forEach ((ability ) => {
153
126
const executor = ability .executors .find ((e ) => e .platform === self .selectedSession .platform && e .name === self .selectedSession .executors [0 ]);
154
- self . terminalCommand = executor ? executor .command : ' ' ;
127
+ setCommand ( executor ? executor .command : ' ' ) ;
155
128
});
156
129
} else {
157
130
toast ({message: " No ability available for this agents platform and executor combination" , type: " is-warning" , dismissible: true , pauseOnHover: true , duration: 2000 })
0 commit comments