3535 </div >
3636
3737 <div class =" column is-12" v-if =" toggleForm" >
38- <BackendAdd @forceExport =" e => handleEvents('forceExport', e)" :backends =" backends"
39- @runImport =" e => handleEvents('runImport', e)" @addBackend =" e => handleEvents('addBackend', e)" />
38+ <BackendAdd @backupData =" e => handleEvents('backupData', e)" :backends =" backends"
39+ @forceExport =" e => handleEvents('forceExport', e)"
40+ @addBackend =" e => handleEvents('addBackend', e)" />
4041 </div >
4142 <template v-else >
4243 <div class =" column is-12" v-if =" backends.length<1" >
@@ -188,7 +189,7 @@ import 'assets/css/bulma-switch.css'
188189import moment from ' moment'
189190import request from ' ~/utils/request'
190191import BackendAdd from ' ~/components/BackendAdd'
191- import {ag , copyText , makeConsoleCommand , notification , r , TOOLTIP_DATE_FORMAT } from ' ~/utils/index'
192+ import {ag , copyText , makeConsoleCommand , notification , queue_event , r , TOOLTIP_DATE_FORMAT } from ' ~/utils/index'
192193import {useStorage } from ' @vueuse/core'
193194import Message from ' ~/components/Message'
194195
@@ -206,31 +207,31 @@ const usefulCommands = {
206207 export_now: {
207208 id: 1 ,
208209 title: " Run normal export." ,
209- command: ' state:export -v -s {name}' ,
210+ command: ' state:export -v -u {user} - s {name}' ,
210211 state_key: ' export.enabled' ,
211212 },
212213 import_now: {
213214 id: 2 ,
214215 title: " Run normal import." ,
215- command: ' state:import -v -s {name}' ,
216+ command: ' state:import -v -u {user} - s {name}' ,
216217 state_key: ' import.enabled'
217218 },
218219 force_export: {
219220 id: 3 ,
220221 title: " Force export local play state to this backend." ,
221- command: ' state:export -fi -v -s {name}' ,
222+ command: ' state:export -fi -v -u {user} - s {name}' ,
222223 state_key: ' export.enabled' ,
223224 },
224225 backup_now: {
225226 id: 4 ,
226227 title: " Backup this backend play state." ,
227- command: " state:backup -v -s {name} --file '{date}.manual_{name}.json'" ,
228+ command: " state:backup -v -u {user} - s {name} --file '{date}.manual_{name}.json'" ,
228229 state_key: ' import.enabled' ,
229230 },
230231 metadata_only: {
231232 id: 5 ,
232233 title: " Import this backend metadata." ,
233- command: " state:import -v --metadata-only -s {name}" ,
234+ command: " state:import -v --metadata-only -u {user} - s {name}" ,
234235 state_key: ' import.enabled' ,
235236 },
236237}
@@ -247,7 +248,7 @@ const forwardCommand = async backend => {
247248 date: moment ().format (' YYYYMMDD' ),
248249 }
249250
250- await navigateTo (makeConsoleCommand (r (usefulCommands[index].command , {... backend, ... util})));
251+ await navigateTo (makeConsoleCommand (r (usefulCommands[index].command , {... backend, ... util, user : api_user . value })));
251252}
252253
253254const loadContent = async () => {
@@ -285,18 +286,54 @@ const updateValue = async (backend, key, newValue) => {
285286
286287const handleEvents = async (event , backend ) => {
287288 switch (event ) {
288- case ' forceExport' :
289- notification (' warning' , ' Warning' , ` We are going to sync '${ backend .value .name } ' play state to match the current local database.` , 10000 )
290- await navigateTo (makeConsoleCommand (` state:export -fi -v -s ${ backend .value .name } ` , true ))
289+ case ' backupData' :
290+ try {
291+ const backup_status = await queue_event (' run_console' , {
292+ command: ' state:backup' ,
293+ args: [
294+ ' -v' ,
295+ ' --user' ,
296+ api_user .value ,
297+ ' --select-backend' ,
298+ backend .value .name ,
299+ ' --file' ,
300+ ' {user}.{backend}.{date}.initial_backup.json' ,
301+ ]
302+ })
303+ console .log (backup_status);
304+
305+ notification (' info' , ' Info' , ` We are going to initiate a backup for '${ backend .value .name } ' in little bit.` , 5000 )
306+ } catch (e) {
307+ notification (' error' , ' Error' , ` Failed to queue backup request. ${ e .message } ` )
308+ }
291309 break
292- case ' runImport' :
293- notification (' info' , ' Info' , ` We are going to import '${ backend .value .name } ' play state to the local database.` , 10000 )
294- await navigateTo (makeConsoleCommand (` state:import -v -s ${ backend .value .name } ` , true ))
310+ case ' forceExport' :
311+ try {
312+ const export_status = await queue_event (' run_console' , {
313+ command: ' state:export' ,
314+ args: [
315+ ' -fi' ,
316+ ' -v' ,
317+ ' --user' ,
318+ api_user .value ,
319+ ' --dry-run' ,
320+ ' --select-backend' ,
321+ backend .value .name ,
322+ ]
323+ }, 180 )
324+
325+ console .log (export_status);
326+
327+ notification (' info' , ' Info' , ` Soon we are going to force export the local data to '${ backend .value .name } '.` , 5000 )
328+ } catch (e) {
329+ notification (' error' , ' Error' , ` Failed to queue force export request. ${ e .message } ` )
330+ }
295331 break
296332 case ' addBackend' :
297333 toggleForm .value = false
298334 await loadContent ()
299335 break
300336 }
301337}
338+
302339 </script >
0 commit comments