Settings.vue
4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<template>
<div class="content">
<div class="content-wrapper" :key="$route.fullPath">
<!-- Output Control -->
<v-expansion-panels
class="control-panel"
v-model="panels[0]"
>
<v-expansion-panel>
<v-expansion-panel-header>Output File Control</v-expansion-panel-header>
<v-expansion-panel-content>
<v-text-field
v-model="output"
label="Output Filename"
prepend-icon="mdi-file-delimited-outline"
>
{{ output }}
</v-text-field>
<div class="control-button-wrapper">
<v-btn class="control-button"
small
color="primary"
@click="saveOutputFilename"
>
Save Filename
</v-btn>
</div>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
<v-divider></v-divider>
<!-- Start Filename Control -->
<v-expansion-panels
class="start-filename-panel"
v-model="panels[1]"
>
<v-expansion-panel>
<v-expansion-panel-header>Start Filename Control</v-expansion-panel-header>
<v-expansion-panel-content>
<v-text-field
v-model="startFilename"
label="Start Filename"
prepend-icon="mdi-file-delimited-outline"
>
{{ startFilename }}
</v-text-field>
<div class="control-button-wrapper">
<v-btn class="control-button"
small
color="primary"
@click="saveStartFilename"
>
Save Filename
</v-btn>
</div>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
<v-divider></v-divider>
<!-- Workspace Control -->
<v-expansion-panels
class="control-panel"
v-model="panels[2]"
>
<v-expansion-panel>
<v-expansion-panel-header>Workspace Control</v-expansion-panel-header>
<v-expansion-panel-content>
<span v-if='workspace !== null' class="font-italic font-weight-light">{{ workspace }}</span>
<span v-else class="font-italic font-weight-light">Please open your workspace</span>
<div class="control-button-wrapper">
<v-btn
class="control-button"
id="btn-workspace"
small
color="primary"
@click="openWorkspace"
>
Open Workspace
</v-btn>
</div>
</v-expansion-panel-content>
</v-expansion-panel>
</v-expansion-panels>
<v-snackbar
v-model="snackbar.isOpened"
:timeout="4000"
>
{{ snackbar.text }}
<v-btn
color="blue"
text
@click="snackbar.isOpened = false"
>
Close
</v-btn>
</v-snackbar>
</div>
</div>
</template>
<script>
export default {
name: 'settings',
data: () => ({
panels: [0, 0, 0],
workspace: null,
output: 'result.csv',
startFilename: '0.png',
snackbar: {
isOpened: false,
text: ''
}
}),
mounted () {
this.getSetting()
},
methods: {
getSetting () {
const remote = require('electron').remote
var _workspace = remote.getGlobal('workspacePath')
if (_workspace !== '') this.workspace = _workspace
else this.workspace = null
var _result = remote.getGlobal('resultFilename')
if (_result !== '') this.output = _result
else {
this.output = 'result.csv'
remote.getGlobal('setResultFilename')(this.output)
}
},
openWorkspace () {
var vm = this
const ipc = require('electron').ipcRenderer
ipc.send('open-file-dialog')
ipc.on('selected-file', function (event, path) {
vm.workspace = `${path}`
})
ipc.on('workspace-load-event', function (event, ok) {
if (ok === true) {
vm.snackbar.text = 'Workspace loaded successfully!'
vm.snackbar.isOpened = true
} else {
vm.snackbar.text = 'Workspace loaded failed!'
vm.snackbar.isOpened = true
}
})
},
saveOutputFilename () {
const remote = require('electron').remote
remote.getGlobal('setResultFilename')(this.output)
},
saveStartFilename () {
const remote = require('electron').remote
remote.getGlobal('setStartFilename')(this.startFilename)
}
}
}
</script>
<style lang="scss" scoped>
@import "@/assets/scss/common.scss";
.control-panel {
margin: 10px 0;
}
.control-button-wrapper {
float: right;
.control-button {
margin-right: 10px;
}
}
</style>