Merge branch 'breakout_status_and_bkup_btn'
This commit is contained in:
commit
4ce99e89a4
|
@ -91,164 +91,192 @@ proc rsyncThread(list: RoutineListState) {.thread.} =
|
||||||
list.redrawFromThread()
|
list.redrawFromThread()
|
||||||
|
|
||||||
method view(list: RoutineListState): Widget =
|
method view(list: RoutineListState): Widget =
|
||||||
result = gui:
|
result = gui:
|
||||||
ScrolledWindow:
|
Box:
|
||||||
|
orient = OrientY
|
||||||
Box:
|
Box:
|
||||||
orient = OrientY
|
orient = OrientY
|
||||||
if list.routineModel.routineSeq().len() > 0:
|
ScrolledWindow:
|
||||||
ListBox:
|
Box:
|
||||||
for it, routine in list.routineModel.routineSeq():
|
orient = OrientY
|
||||||
Box:
|
if list.routineModel.routineSeq().len() > 0:
|
||||||
orient = OrientY
|
ListBox:
|
||||||
margin = 6
|
for it, routine in list.routineModel.routineSeq():
|
||||||
spacing = 6
|
|
||||||
Box:
|
|
||||||
orient = OrientX
|
|
||||||
margin = 6
|
|
||||||
spacing = 6
|
|
||||||
Switch {.expand: false, vAlign: AlignCenter.}:
|
|
||||||
state = sequtils.any(list.selected, proc (id: RoutineId): bool = id == routine.id)
|
|
||||||
tooltip = "Enable/Disable this Routine for the current Bkup run."
|
|
||||||
proc changed(state: bool) =
|
|
||||||
if state == true:
|
|
||||||
list.selected.add(routine.id)
|
|
||||||
else:
|
|
||||||
let index = list.selected.find(routine.id)
|
|
||||||
if index != -1:
|
|
||||||
list.selected.delete(index)
|
|
||||||
Label:
|
|
||||||
text = "<span size=\"large\">" & routine.name & "</span>"
|
|
||||||
xAlign = 0
|
|
||||||
useMarkup = true
|
|
||||||
# Edit Button
|
|
||||||
Button {.expand: false.}:
|
|
||||||
#icon = "entity-edit"
|
|
||||||
icon = "entity-edit-dark-theme"
|
|
||||||
tooltip = "Edit this Routine."
|
|
||||||
proc clicked() =
|
|
||||||
## Opens the EditRoutineDialog for updating the existing routine
|
|
||||||
let (res, state) = list.app.open: gui:
|
|
||||||
EditRoutineDialog:
|
|
||||||
routine = routine
|
|
||||||
mode = EditRoutineUpdate
|
|
||||||
if res.kind == DialogAccept:
|
|
||||||
# The "Update" button was clicked
|
|
||||||
list.routineModel.update(EditRoutineDialogState(state).routine)
|
|
||||||
list.selected = selectedPreload()
|
|
||||||
# Delete Button
|
|
||||||
Button {.expand: false.}:
|
|
||||||
icon = "user-trash-symbolic"
|
|
||||||
tooltip = "Delete this Routine. Warning: will not ask you to confirm."
|
|
||||||
proc clicked() =
|
|
||||||
list.routineModel.delete(routine.id)
|
|
||||||
list.selected = selectedPreload()
|
|
||||||
if routine.id in list.selected:
|
|
||||||
Box:
|
Box:
|
||||||
orient = OrientY
|
orient = OrientY
|
||||||
margin = 6
|
margin = 6
|
||||||
spacing = 6
|
spacing = 6
|
||||||
Label:
|
Box:
|
||||||
text = "<span color=\"#6fffa3\">Sources:</span>"
|
orient = OrientX
|
||||||
xAlign = 0
|
margin = 6
|
||||||
useMarkup = true
|
spacing = 6
|
||||||
#routineSeq returns an empty string when no sources exist.
|
Switch {.expand: false, vAlign: AlignCenter.}:
|
||||||
if routine.sources.len != 0:
|
state = sequtils.any(list.selected, proc (id: RoutineId): bool = id == routine.id)
|
||||||
for it, routineSource in routine.sources:
|
tooltip = "Enable/Disable this Routine for the current Bkup run."
|
||||||
Box:
|
proc changed(state: bool) =
|
||||||
orient = OrientX
|
if state == true:
|
||||||
spacing = 6
|
list.selected.add(routine.id)
|
||||||
margin = 6
|
else:
|
||||||
Label:
|
let index = list.selected.find(routine.id)
|
||||||
text = routineSource
|
if index != -1:
|
||||||
xAlign = 0
|
list.selected.delete(index)
|
||||||
else:
|
Label:
|
||||||
|
text = "<span size=\"large\">" & routine.name & "</span>"
|
||||||
|
xAlign = 0
|
||||||
|
useMarkup = true
|
||||||
|
# Edit Button
|
||||||
|
Button {.expand: false.}:
|
||||||
|
#icon = "entity-edit"
|
||||||
|
icon = "entity-edit-dark-theme"
|
||||||
|
tooltip = "Edit this Routine."
|
||||||
|
proc clicked() =
|
||||||
|
## Opens the EditRoutineDialog for updating the existing routine
|
||||||
|
let (res, state) = list.app.open: gui:
|
||||||
|
EditRoutineDialog:
|
||||||
|
routine = routine
|
||||||
|
mode = EditRoutineUpdate
|
||||||
|
if res.kind == DialogAccept:
|
||||||
|
# The "Update" button was clicked
|
||||||
|
list.routineModel.update(EditRoutineDialogState(state).routine)
|
||||||
|
list.selected = selectedPreload()
|
||||||
|
# Delete Button
|
||||||
|
Button {.expand: false.}:
|
||||||
|
icon = "user-trash-symbolic"
|
||||||
|
tooltip = "Delete this Routine. Warning: will not ask you to confirm."
|
||||||
|
proc clicked() =
|
||||||
|
list.routineModel.delete(routine.id)
|
||||||
|
list.selected = selectedPreload()
|
||||||
|
if routine.id in list.selected:
|
||||||
Box:
|
Box:
|
||||||
orient = OrientX
|
orient = OrientY
|
||||||
spacing = 6
|
|
||||||
margin = 6
|
margin = 6
|
||||||
|
spacing = 6
|
||||||
Label:
|
Label:
|
||||||
text = "<span color=\"#ff6b6b\">Routine will be ignored. Source required.</span>"
|
text = "<span color=\"#6fffa3\">Sources:</span>"
|
||||||
xAlign = 0
|
xAlign = 0
|
||||||
useMarkup = true
|
useMarkup = true
|
||||||
Label:
|
#routineSeq returns an empty string when no sources exist.
|
||||||
text = "<span color=\"#6fffa3\">Destinations:</span>"
|
if routine.sources.len != 0:
|
||||||
xAlign = 0
|
for it, routineSource in routine.sources:
|
||||||
useMarkup = true
|
Box:
|
||||||
#routineSeq returns an empty string when no destinations exist.
|
orient = OrientX
|
||||||
if routine.destinations.len != 0:
|
spacing = 6
|
||||||
for it, routineDestination in routine.destinations:
|
margin = 6
|
||||||
Box:
|
Label:
|
||||||
orient = OrientX
|
text = routineSource
|
||||||
spacing = 6
|
xAlign = 0
|
||||||
margin = 6
|
else:
|
||||||
Label:
|
Box:
|
||||||
text = routineDestination
|
orient = OrientX
|
||||||
xAlign = 0
|
spacing = 6
|
||||||
else:
|
margin = 6
|
||||||
Box:
|
Label:
|
||||||
orient = OrientX
|
text = "<span color=\"#ff6b6b\">Routine will be ignored. Source required.</span>"
|
||||||
spacing = 6
|
xAlign = 0
|
||||||
margin = 6
|
useMarkup = true
|
||||||
Label:
|
Label:
|
||||||
text = "<span color=\"#ff6b6b\">Routine will be ignored. Destination required.</span>"
|
text = "<span color=\"#6fffa3\">Destinations:</span>"
|
||||||
xAlign = 0
|
xAlign = 0
|
||||||
useMarkup = true
|
useMarkup = true
|
||||||
Box {.expand: false.}:
|
#routineSeq returns an empty string when no destinations exist.
|
||||||
orient = OrientX
|
if routine.destinations.len != 0:
|
||||||
spacing = 6
|
for it, routineDestination in routine.destinations:
|
||||||
margin = 6
|
Box:
|
||||||
Label {.expand: false.}:
|
orient = OrientX
|
||||||
text = "<span size=\"large\">Status: </span>"
|
spacing = 6
|
||||||
xAlign = 0
|
margin = 6
|
||||||
useMarkup = true
|
Label:
|
||||||
Label:
|
text = routineDestination
|
||||||
if list.runStatus != "":
|
xAlign = 0
|
||||||
text = list.runStatus
|
else:
|
||||||
else:
|
Box:
|
||||||
text = "<span color=\"#6AC9FF\" size=\"large\">Waiting patiently...</span>"
|
orient = OrientX
|
||||||
xAlign = 0
|
spacing = 6
|
||||||
margin = 6
|
margin = 6
|
||||||
useMarkup = true
|
Label:
|
||||||
# Run Button
|
text = "<span color=\"#ff6b6b\">Routine will be ignored. Destination required.</span>"
|
||||||
Button {.expand: false.}:
|
xAlign = 0
|
||||||
Box:
|
useMarkup = true
|
||||||
orient = OrientX
|
else:
|
||||||
spacing = 6
|
Box {.expand: false.}:
|
||||||
|
orient = OrientY
|
||||||
margin = 6
|
margin = 6
|
||||||
Icon:
|
spacing = 12
|
||||||
name = "media-floppy"
|
Label:
|
||||||
pixelSize = 40
|
text = "<span size=\"large\">You don't have any Bkup Routines!!! 🙂</span>"
|
||||||
margin = 4
|
xAlign = 0
|
||||||
Label {.expand: false.}:
|
useMarkup = true
|
||||||
text = "<span size=\"large\">Run Bkup!</span>"
|
Label:
|
||||||
xAlign = 0
|
text = "<span size=\"large\">Please click on the + Routine button above to create your first Routine.</span>"
|
||||||
useMarkup = true
|
xAlign = 0
|
||||||
proc clicked() =
|
useMarkup = true
|
||||||
#check that every source and destination exists for each routine or don't run bkup and show err status.
|
|
||||||
#locations not found will be logged. see routine.nim
|
if list.routineModel.routineSeq().len() > 0:
|
||||||
var allLocationsExist: seq[bool]
|
Box {.expand: false.}:
|
||||||
for routine in list.routineModel.routineSeq():
|
orient = OrientY
|
||||||
if routine.id in list.selected:
|
|
||||||
if locationsExist(routine) == true:
|
|
||||||
allLocationsExist.add(true)
|
|
||||||
else:
|
|
||||||
allLocationsExist.add(false)
|
|
||||||
if false in allLocationsExist:
|
|
||||||
#show error status.
|
|
||||||
list.runStatus = "<span color=\"#ff6b6b\" size=\"large\">Missing Source(s)/Destination(s) in selected Routine(s).</span>"
|
|
||||||
else:
|
|
||||||
createThread(thread, rsyncThread, list)
|
|
||||||
else:
|
|
||||||
Box {.expand: false.}:
|
Box {.expand: false.}:
|
||||||
orient = OrientY
|
orient = OrientY
|
||||||
margin = 6
|
Box {.expand: false.}:
|
||||||
spacing = 12
|
orient = OrientX
|
||||||
Label:
|
spacing = 6
|
||||||
text = "<span size=\"large\">You don't have any Bkup Routines!!! 🙂</span>"
|
margin = 6
|
||||||
xAlign = 0
|
Label {.expand: false.}:
|
||||||
useMarkup = true
|
text = "<span size=\"large\">Status: </span>"
|
||||||
Label:
|
xAlign = 0
|
||||||
text = "<span size=\"large\">Please click on the + Routine button above to create your first Routine.</span>"
|
useMarkup = true
|
||||||
xAlign = 0
|
Label:
|
||||||
useMarkup = true
|
if list.runStatus != "":
|
||||||
|
text = list.runStatus
|
||||||
|
else:
|
||||||
|
text = "<span color=\"#6AC9FF\" size=\"large\">Waiting patiently...</span>"
|
||||||
|
xAlign = 0
|
||||||
|
margin = 6
|
||||||
|
useMarkup = true
|
||||||
|
# Run Button
|
||||||
|
Button {.expand: false.}:
|
||||||
|
Box:
|
||||||
|
orient = OrientX
|
||||||
|
spacing = 6
|
||||||
|
margin = 6
|
||||||
|
Icon:
|
||||||
|
name = "media-floppy"
|
||||||
|
pixelSize = 40
|
||||||
|
margin = 4
|
||||||
|
Label {.expand: false.}:
|
||||||
|
text = "<span size=\"large\">Run Bkup!</span>"
|
||||||
|
xAlign = 0
|
||||||
|
useMarkup = true
|
||||||
|
proc clicked() =
|
||||||
|
#check that every source and destination exists for each routine or don't run bkup and show err status.
|
||||||
|
#locations not found will be logged. see routine.nim
|
||||||
|
var allLocationsExist: seq[bool]
|
||||||
|
for routine in list.routineModel.routineSeq():
|
||||||
|
if routine.id in list.selected:
|
||||||
|
if locationsExist(routine) == true:
|
||||||
|
allLocationsExist.add(true)
|
||||||
|
else:
|
||||||
|
allLocationsExist.add(false)
|
||||||
|
if false in allLocationsExist:
|
||||||
|
#show error status.
|
||||||
|
list.runStatus = "<span color=\"#ff6b6b\" size=\"large\">Missing Source(s)/Destination(s) in selected Routine(s).</span>"
|
||||||
|
else:
|
||||||
|
createThread(thread, rsyncThread, list)
|
||||||
|
|
||||||
|
#[if not list.routineModel.routineSeq().len() > 0:
|
||||||
|
Box:
|
||||||
|
orient = OrientX
|
||||||
|
spacing = 6
|
||||||
|
margin = 6
|
||||||
|
Box {.expand: false.}:
|
||||||
|
orient = OrientY
|
||||||
|
margin = 6
|
||||||
|
spacing = 12
|
||||||
|
Label:
|
||||||
|
text = "<span size=\"large\">You don't have any Bkup Routines!!! 🙂</span>"
|
||||||
|
xAlign = 0
|
||||||
|
useMarkup = true
|
||||||
|
Label:
|
||||||
|
text = "<span size=\"large\">Please click on the + Routine button above to create your first Routine.</span>"
|
||||||
|
xAlign = 0
|
||||||
|
useMarkup = true]#
|
||||||
export RoutineList
|
export RoutineList
|
||||||
|
|
Loading…
Reference in New Issue