1
1
<template >
2
- <p class =" text-h6" >File content</p >
3
- <p >
4
- <b
5
- ><v-icon >mdi-information</v-icon > This content will be written to the file
6
- <code >data.txt</code ></b
7
- >
8
- </p >
9
- <div style =" max-height : 200px ; overflow-y : auto " >
10
- <div :id =" idEditor" style =" width : 100% ; height : 200px " >
11
- {{ text }}
12
- </div >
2
+ <p class =" text-h6" >File content</p >
3
+ <p >
4
+ <b
5
+ ><v-icon >mdi-information</v-icon > This content will be written to the file
6
+ <code >data.txt</code ></b
7
+ >
8
+ </p >
9
+ <div style =" max-height : 200px ; overflow-y : auto " >
10
+ <div :id =" idEditor" style =" width : 100% ; height : 200px " >
11
+ {{ text }}
13
12
</div >
14
-
15
- <p class =" text-h6" >Command</p >
16
- <p >
17
- <b
18
- ><v-icon >mdi-information</v-icon > The file name must always be
19
- <code >data.txt</code ></b
20
- >
21
- </p >
22
- <v-dialog v-model =" dialog" width =" 75%" >
23
- <template v-slot :activator =" { props } " >
24
- <v-btn color =" primary" v-bind =" props" size =" small" class =" mb-4" >
25
- <v-icon >mdi-book</v-icon > Read man
26
- </v-btn >
27
- </template >
28
-
29
- <v-card >
30
- <v-card-text style =" height : 90vh " >
31
- <iframe
32
- src =" /man/gawk.html"
33
- frameborder =" 0"
34
- style =" height : 100% ; width : 100% "
35
- ></iframe >
36
- </v-card-text >
37
- </v-card >
38
- </v-dialog >
39
-
40
- <v-text-field
41
- v-model =" commandInput"
42
- style =" font-family : monospace , monospace !important "
43
- ></v-text-field >
44
- <v-btn class =" mt-4" @click =" runTool" >Run tool </v-btn >
45
- <p class =" text-h6" >Output</p >
46
- <pre :id =" idOutput" >Await run click...</pre >
47
- <v-card color =" info" >
48
- <v-card-text v-if =" noResult" >
49
- <v-icon >mdi-information</v-icon > No result
13
+ </div >
14
+
15
+ <p class =" text-h6" >Command</p >
16
+ <p >
17
+ <b
18
+ ><v-icon >mdi-information</v-icon > The file name must always be
19
+ <code >data.txt</code ></b
20
+ >
21
+ </p >
22
+ <v-dialog v-model =" dialog" width =" 75%" >
23
+ <template v-slot :activator =" { props } " >
24
+ <v-btn color =" primary" v-bind =" props" size =" small" class =" mb-4" >
25
+ <v-icon >mdi-book</v-icon > Read man
26
+ </v-btn >
27
+ </template >
28
+
29
+ <v-card >
30
+ <v-card-text style =" height : 90vh " >
31
+ <iframe
32
+ :src =" manPage"
33
+ frameborder =" 0"
34
+ style =" height : 100% ; width : 100% "
35
+ ></iframe >
50
36
</v-card-text >
51
37
</v-card >
52
- </template >
38
+ </v-dialog >
39
+
40
+ <v-text-field
41
+ v-model =" commandInput"
42
+ style =" font-family : monospace , monospace !important "
43
+ ></v-text-field >
44
+ <v-btn class =" mt-4" @click =" runTool" >Run tool </v-btn >
45
+ <p class =" text-h6" >Output</p >
46
+ <pre :id =" idOutput" >Await run click...</pre >
47
+ <v-card color =" info" >
48
+ <v-card-text v-if =" noResult" >
49
+ <v-icon >mdi-information</v-icon > No result
50
+ </v-card-text >
51
+ </v-card >
52
+ </template >
53
53
54
54
<script >
55
- import Aioli from " @biowasm/aioli" ;
56
- import ace from " ace-builds" ;
57
-
58
- export default {
59
- props: {
60
- text: String ,
61
- command: String ,
62
- },
63
- setup (props ) {
64
- var id = new Date ().valueOf ();
65
- var idEditor = " editorArea" + id;
66
- var idOutput = " output" + id;
67
-
68
- const route = useRoute ();
69
- let tool = route .params .tool ;
70
-
71
- return { idEditor, idOutput, tool };
72
- },
73
- data () {
74
- return {
75
- dialog: false ,
76
- editor: null ,
77
- commandInput: null ,
78
- noResult: false ,
55
+ import Aioli from " @biowasm/aioli" ;
56
+ import ace from " ace-builds" ;
57
+
58
+ export default {
59
+ props: {
60
+ text: String ,
61
+ command: String ,
62
+ },
63
+ setup (props ) {
64
+ var id = new Date ().valueOf ();
65
+ var idEditor = " editorArea" + id;
66
+ var idOutput = " output" + id;
67
+
68
+ const route = useRoute ();
69
+ let tool = route .params .tool ;
70
+
71
+ // Get man page
72
+ const config = useRuntimeConfig ();
73
+ let repo_name = config .public .repo_name ;
74
+ let manPage = " /" + repo_name .split (" /" )[1 ] + " /man/" + tool + " .html" ;
75
+
76
+ return { idEditor, idOutput, tool, manPage };
77
+ },
78
+ data () {
79
+ return {
80
+ dialog: false ,
81
+ editor: null ,
82
+ commandInput: null ,
83
+ noResult: false ,
84
+ };
85
+ },
86
+ mounted () {
87
+ this .commandInput = this .command ;
88
+ this .editor = ace .edit (this .idEditor , {
89
+ tabSize: 4 ,
90
+ // readOnly: this.readOnly,
91
+ autoScrollEditorIntoView: true ,
92
+ maxLines: 50 ,
93
+ minLines: 1 ,
94
+ });
95
+ },
96
+ methods: {
97
+ async runTool () {
98
+ document .getElementById (this .idOutput ).innerHTML = " Loading..." ;
99
+ this .noResult = false ;
100
+
101
+ const CLI = await new Aioli ([" gawk/5.1.0" ]);
102
+
103
+ // Create sample file
104
+ var dataEditor = {
105
+ name: " data.txt" ,
106
+ data: this .editor .getValue (),
79
107
};
108
+ await CLI .mount (dataEditor);
109
+ console .log (this .commandInput );
110
+
111
+ var temp = this .commandInput ;
112
+ temp = temp .replace (this .tool , " " ).trim ();
113
+ var params = this .parseFlags (temp)
114
+ // .map((d) => d.replaceAll('"', ""))
115
+ .map ((d ) => d .replaceAll (" '" , " " ));
116
+ console .log (params);
117
+ const output = await CLI .exec (" gawk" , params);
118
+ if (output == " " ) {
119
+ this .noResult = true ;
120
+ }
121
+ console .log (output);
122
+ document .getElementById (this .idOutput ).innerHTML = output;
80
123
},
81
- mounted () {
82
- this .commandInput = this .command ;
83
- this .editor = ace .edit (this .idEditor , {
84
- tabSize: 4 ,
85
- // readOnly: this.readOnly,
86
- autoScrollEditorIntoView: true ,
87
- maxLines: 50 ,
88
- minLines: 1 ,
89
- });
90
- },
91
- methods: {
92
- async runTool () {
93
- document .getElementById (this .idOutput ).innerHTML = " Loading..." ;
94
- this .noResult = false ;
95
-
96
- const CLI = await new Aioli ([" gawk/5.1.0" ]);
97
-
98
- // Create sample file
99
- var dataEditor = {
100
- name: " data.txt" ,
101
- data: this .editor .getValue (),
102
- };
103
- await CLI .mount (dataEditor);
104
- console .log (this .commandInput );
105
-
106
- var temp = this .commandInput ;
107
- temp = temp .replace (this .tool , " " ).trim ();
108
- var params = this .parseFlags (temp)
109
- // .map((d) => d.replaceAll('"', ""))
110
- .map ((d ) => d .replaceAll (" '" , " " ));
111
- console .log (params);
112
- const output = await CLI .exec (" gawk" , params);
113
- if (output == " " ) {
114
- this .noResult = true ;
115
- }
116
- console .log (output);
117
- document .getElementById (this .idOutput ).innerHTML = output;
118
- },
119
- parseFlags (flags ) {
120
- // Source: https://stackoverflow.com/a/16261693
121
- return flags .match (/ (?:[^ \s '] + | '[^ '] * ')+ / g ) || [];
122
- },
124
+ parseFlags (flags ) {
125
+ // Source: https://stackoverflow.com/a/16261693
126
+ return flags .match (/ (?:[^ \s '] + | '[^ '] * ')+ / g ) || [];
123
127
},
124
- };
125
- </script >
128
+ },
129
+ };
130
+ </script >
126
131
127
132
<style >
128
- </style >
133
+ </style >
0 commit comments