Merge branch 'update_selected'

master
itwrx 1 year ago
commit e1f26ec966
  1. 30
      views/routine_list.nim

@ -4,7 +4,7 @@ EZ-Bkup is released under the General Public License 3.0.
See COPYING or <https://www.gnu.org/licenses/> for details.]# See COPYING or <https://www.gnu.org/licenses/> for details.]#
import owlkettle import owlkettle
import std/osproc, std/os, std/logging import osproc, os, logging, sequtils
import edit_routine_dialog import edit_routine_dialog
import "../models/routine", "../shared" import "../models/routine", "../shared"
@ -13,14 +13,9 @@ viewable RoutineList:
runStatus: string runStatus: string
selected: seq[RoutineId] selected: seq[RoutineId]
# hey, hook.
hooks: hooks:
# yes, you, the build hook.
build: build:
# i love you. :) state.selected = selectedPreload()
state.selected = selectedPreload()
proc changed(state: bool)
var thread: Thread[RoutineListState] var thread: Thread[RoutineListState]
@ -50,15 +45,15 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
routineRuncount += 1 routineRuncount += 1
for source in routine.sources: for source in routine.sources:
for destination in routine.destinations: for destination in routine.destinations:
#try without requiring superuser privs by default. #try without requiring superuser privs by default.
#rsyncRunCmd = "rsync -aq " & source & " " & destination #rsyncRunCmd = "rsync -aq " & source & " " & destination
#quote sources and destinations to handle possible spaces. #quote sources and destinations to handle possible spaces.
rsyncRunCmd = "rsync -aq " & "'" & source & "'" & " " & "'" & destination & "'" rsyncRunCmd = "rsync -aq " & "'" & source & "'" & " " & "'" & destination & "'"
rsyncRun = execCmdEx(rsyncRunCmd) rsyncRun = execCmdEx(rsyncRunCmd)
if rsyncRun.exitCode != 0: if rsyncRun.exitCode != 0:
#handle permission denied error. #handle permission denied error.
if rsyncRun.exitCode == 23: if rsyncRun.exitCode == 23:
rsyncRun.exitCode = 0 rsyncRun.exitCode = 0
#rsyncRunCmd = "pkexec rsync -aq " & source & " " & destination #rsyncRunCmd = "pkexec rsync -aq " & source & " " & destination
#quote sources and destinations to handle possible spaces. #quote sources and destinations to handle possible spaces.
rsyncRunCmd = "pkexec rsync -aq " & "'" & source & "'" & " " & "'" & destination & "'" rsyncRunCmd = "pkexec rsync -aq " & "'" & source & "'" & " " & "'" & destination & "'"
@ -115,19 +110,16 @@ method view(list: RoutineListState): Widget =
orient = OrientX orient = OrientX
margin = 6 margin = 6
spacing = 6 spacing = 6
Switch {.expand: false, vAlign: AlignCenter.}: Switch {.expand: false, vAlign: AlignCenter.}:
state = routine.selByDef state = sequtils.any(list.selected, proc (id: RoutineId): bool = id == routine.id)
tooltip = "Enable/Disable this Routine for the current Bkup run." tooltip = "Enable/Disable this Routine for the current Bkup run."
proc changed(state: bool) = proc changed(state: bool) =
if state == true: if state == true:
list.selected.add(routine.id) list.selected.add(routine.id)
else: else:
let index = list.selected.find(routine.id) let index = list.selected.find(routine.id)
if index != -1: if index != -1:
list.selected.delete(index) list.selected.delete(index)
if not list.changed.isNil:
list.changed.callback(true)
Label: Label:
text = "<span size=\"large\">" & routine.name & "</span>" text = "<span size=\"large\">" & routine.name & "</span>"
xAlign = 0 xAlign = 0
@ -145,13 +137,15 @@ method view(list: RoutineListState): Widget =
mode = EditRoutineUpdate mode = EditRoutineUpdate
if res.kind == DialogAccept: if res.kind == DialogAccept:
# The "Update" button was clicked # The "Update" button was clicked
list.routineModel.update(EditRoutineDialogState(state).routine) list.routineModel.update(EditRoutineDialogState(state).routine)
list.selected = selectedPreload()
# Delete Button # Delete Button
Button {.expand: false.}: Button {.expand: false.}:
icon = "user-trash-symbolic" icon = "user-trash-symbolic"
tooltip = "Delete this Routine. Warning: will not ask you to confirm." tooltip = "Delete this Routine. Warning: will not ask you to confirm."
proc clicked() = proc clicked() =
list.routineModel.delete(routine.id) list.routineModel.delete(routine.id)
list.selected = selectedPreload()
if routine.id in list.selected: if routine.id in list.selected:
Box: Box:
orient = OrientY orient = OrientY

Loading…
Cancel
Save