mirror of
https://github.com/netinvent/npbackup.git
synced 2025-11-08 05:04:45 +08:00
Merge branch 'main' of https://github.com/netinvent/npbackup
This commit is contained in:
commit
85d401a4fe
5 changed files with 62 additions and 5 deletions
|
|
@ -7,7 +7,7 @@ __intname__ = "npbackup.gui.main"
|
||||||
__author__ = "Orsiris de Jong"
|
__author__ = "Orsiris de Jong"
|
||||||
__copyright__ = "Copyright (C) 2022-2023 NetInvent"
|
__copyright__ = "Copyright (C) 2022-2023 NetInvent"
|
||||||
__license__ = "GPL-3.0-only"
|
__license__ = "GPL-3.0-only"
|
||||||
__build__ = "2023032001"
|
__build__ = "2023082801"
|
||||||
|
|
||||||
|
|
||||||
from typing import List, Optional, Tuple
|
from typing import List, Optional, Tuple
|
||||||
|
|
@ -245,6 +245,13 @@ def _make_treedata_from_json(ls_result: List[dict]) -> sg.TreeData:
|
||||||
return treedata
|
return treedata
|
||||||
|
|
||||||
|
|
||||||
|
@threaded
|
||||||
|
def _delete_backup(config: dict, snapshot_id: str) -> Future:
|
||||||
|
runner = NPBackupRunner(config_dict=config)
|
||||||
|
result = runner.forget(snapshot=snapshot_id)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
@threaded
|
@threaded
|
||||||
def _ls_window(config: dict, snapshot_id: str) -> Future:
|
def _ls_window(config: dict, snapshot_id: str) -> Future:
|
||||||
runner = NPBackupRunner(config_dict=config)
|
runner = NPBackupRunner(config_dict=config)
|
||||||
|
|
@ -287,6 +294,36 @@ def _ls_window(config: dict, snapshot_id: str) -> Future:
|
||||||
return backup_content, result
|
return backup_content, result
|
||||||
|
|
||||||
|
|
||||||
|
def delete_backup(config: dict, snapshot: str) -> bool:
|
||||||
|
snapshot_id = re.match(r".*\[ID (.*)\].*", snapshot).group(1)
|
||||||
|
# We get a thread result, hence pylint will complain the thread isn't a tuple
|
||||||
|
# pylint: disable=E1101 (no-member)
|
||||||
|
thread = _delete_backup(config, snapshot_id)
|
||||||
|
|
||||||
|
while not thread.done() and not thread.cancelled():
|
||||||
|
sg.PopupAnimated(
|
||||||
|
LOADER_ANIMATION,
|
||||||
|
message="{}. {}".format(
|
||||||
|
_t("main_gui.execute_operation"),
|
||||||
|
_t("main_gui.this_will_take_a_while"),
|
||||||
|
),
|
||||||
|
time_between_frames=50,
|
||||||
|
background_color=GUI_LOADER_COLOR,
|
||||||
|
text_color=GUI_LOADER_TEXT_COLOR,
|
||||||
|
)
|
||||||
|
sg.PopupAnimated(None)
|
||||||
|
result = thread.result()
|
||||||
|
if not result:
|
||||||
|
sg.PopupError(_t("main_gui.delete_failed"), keep_on_top=True)
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
sg.Popup(
|
||||||
|
"{} {} {}".format(
|
||||||
|
snapshot, _t("generic.deleted"), _t("generic.successfully")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def ls_window(config: dict, snapshot: str) -> bool:
|
def ls_window(config: dict, snapshot: str) -> bool:
|
||||||
snapshot_id = re.match(r".*\[ID (.*)\].*", snapshot).group(1)
|
snapshot_id = re.match(r".*\[ID (.*)\].*", snapshot).group(1)
|
||||||
# We get a thread result, hence pylint will complain the thread isn't a tuple
|
# We get a thread result, hence pylint will complain the thread isn't a tuple
|
||||||
|
|
@ -521,6 +558,7 @@ def main_gui(config_dict: dict, config_file: str, version_string: str):
|
||||||
[
|
[
|
||||||
sg.Button(_t("main_gui.launch_backup"), key="launch-backup"),
|
sg.Button(_t("main_gui.launch_backup"), key="launch-backup"),
|
||||||
sg.Button(_t("main_gui.see_content"), key="see-content"),
|
sg.Button(_t("main_gui.see_content"), key="see-content"),
|
||||||
|
sg.Button(_t("generic.delete"), key="delete"),
|
||||||
sg.Button(_t("generic.configure"), key="configure"),
|
sg.Button(_t("generic.configure"), key="configure"),
|
||||||
sg.Button(_t("generic.about"), key="about"),
|
sg.Button(_t("generic.about"), key="about"),
|
||||||
sg.Button(_t("generic.quit"), key="exit"),
|
sg.Button(_t("generic.quit"), key="exit"),
|
||||||
|
|
@ -614,6 +652,13 @@ def main_gui(config_dict: dict, config_file: str, version_string: str):
|
||||||
sg.Popup(_t("main_gui.select_backup"), keep_on_top=True)
|
sg.Popup(_t("main_gui.select_backup"), keep_on_top=True)
|
||||||
continue
|
continue
|
||||||
ls_window(config_dict, snapshot=values["snapshot-list"][0])
|
ls_window(config_dict, snapshot=values["snapshot-list"][0])
|
||||||
|
if event == "delete":
|
||||||
|
if not values["snapshot-list"]:
|
||||||
|
sg.Popup(_t("main_gui.select_backup"), keep_on_top=True)
|
||||||
|
continue
|
||||||
|
delete_backup(config_dict, snapshot=values["snapshot-list"][0])
|
||||||
|
# Make sure we trigger a GUI refresh after deletions
|
||||||
|
event = "state-button"
|
||||||
if event == "configure":
|
if event == "configure":
|
||||||
config_dict = config_gui(config_dict, config_file)
|
config_dict = config_gui(config_dict, config_file)
|
||||||
# Make sure we trigger a GUI refresh when configuration is changed
|
# Make sure we trigger a GUI refresh when configuration is changed
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,10 @@ en:
|
||||||
is_uptodate: Program Up to date
|
is_uptodate: Program Up to date
|
||||||
|
|
||||||
succes: Succes
|
succes: Succes
|
||||||
|
successfully: successfully
|
||||||
failure: Failure
|
failure: Failure
|
||||||
|
|
||||||
scheduled_task: Scheduled task
|
scheduled_task: Scheduled task
|
||||||
|
|
||||||
|
delete: Delete
|
||||||
|
deleted: deleted
|
||||||
|
|
@ -38,6 +38,10 @@ fr:
|
||||||
is_uptodate: Logiciel à jour
|
is_uptodate: Logiciel à jour
|
||||||
|
|
||||||
succes: Succès
|
succes: Succès
|
||||||
|
successfully: avec succès
|
||||||
failure: Echec
|
failure: Echec
|
||||||
|
|
||||||
scheduled_task: Tâche planifiée
|
scheduled_task: Tâche planifiée
|
||||||
|
|
||||||
|
delete: Supprimer
|
||||||
|
deleted: éffacé
|
||||||
|
|
@ -29,4 +29,6 @@ en:
|
||||||
run_as: run as
|
run_as: run as
|
||||||
identified_by: identified by
|
identified_by: identified by
|
||||||
unknown_repo: Repo format unknown
|
unknown_repo: Repo format unknown
|
||||||
repository_not_configured: Repository not configured
|
repository_not_configured: Repository not configured
|
||||||
|
execute_operation: Executing operation
|
||||||
|
delete failed: Deletion failed. Please check the logs
|
||||||
|
|
@ -29,4 +29,6 @@ fr:
|
||||||
run_as: faite en tant que
|
run_as: faite en tant que
|
||||||
identified_by: identifiée en tant que
|
identified_by: identifiée en tant que
|
||||||
unknown_repo: Format de dépot inconnu
|
unknown_repo: Format de dépot inconnu
|
||||||
repository_not_configured: Dépot non configuré
|
repository_not_configured: Dépot non configuré
|
||||||
|
execute_operation: Opération en cours
|
||||||
|
delete_failed: Suppression impossible. Veuillez vérifier les journaux
|
||||||
Loading…
Add table
Reference in a new issue