mirror of
https://github.com/netinvent/npbackup.git
synced 2024-09-21 07:16:16 +08:00
UX improvements
This commit is contained in:
parent
bb6b293138
commit
adcba0bc5f
|
@ -538,6 +538,12 @@ def _main_gui(viewer_mode: bool):
|
||||||
"""
|
"""
|
||||||
if default:
|
if default:
|
||||||
config_file = Path(f"{CURRENT_DIR}/npbackup.conf")
|
config_file = Path(f"{CURRENT_DIR}/npbackup.conf")
|
||||||
|
if default:
|
||||||
|
full_config = npbackup.configuration.load_config(config_file)
|
||||||
|
if not config_file.exists():
|
||||||
|
config_file = None
|
||||||
|
if not full_config:
|
||||||
|
return full_config, config_file
|
||||||
else:
|
else:
|
||||||
config_file = None
|
config_file = None
|
||||||
|
|
||||||
|
@ -561,8 +567,8 @@ def _main_gui(viewer_mode: bool):
|
||||||
return full_config, config_file
|
return full_config, config_file
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
def get_config():
|
def get_config(default: bool = False):
|
||||||
full_config, config_file = get_config_file()
|
full_config, config_file = get_config_file(default=default)
|
||||||
if full_config and config_file:
|
if full_config and config_file:
|
||||||
repo_config, config_inheritance = npbackup.configuration.get_repo_config(
|
repo_config, config_inheritance = npbackup.configuration.get_repo_config(
|
||||||
full_config
|
full_config
|
||||||
|
@ -595,7 +601,7 @@ def _main_gui(viewer_mode: bool):
|
||||||
backend_type,
|
backend_type,
|
||||||
repo_uri,
|
repo_uri,
|
||||||
repo_list,
|
repo_list,
|
||||||
) = get_config()
|
) = get_config(default=True)
|
||||||
else:
|
else:
|
||||||
# Let's try to read standard restic repository env variables
|
# Let's try to read standard restic repository env variables
|
||||||
viewer_repo_uri = os.environ.get("RESTIC_REPOSITORY", None)
|
viewer_repo_uri = os.environ.get("RESTIC_REPOSITORY", None)
|
||||||
|
@ -644,6 +650,10 @@ def _main_gui(viewer_mode: bool):
|
||||||
vertical_alignment="top",
|
vertical_alignment="top",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
sg.Text(_t("main_gui.no_config"), font=("Arial", 14), text_color="red", key="-NO-CONFIG-", visible=False)
|
||||||
|
] if not viewer_mode
|
||||||
|
else [],
|
||||||
[
|
[
|
||||||
sg.Text(_t("main_gui.backup_list_to")),
|
sg.Text(_t("main_gui.backup_list_to")),
|
||||||
sg.Combo(
|
sg.Combo(
|
||||||
|
@ -664,6 +674,7 @@ def _main_gui(viewer_mode: bool):
|
||||||
justification="left",
|
justification="left",
|
||||||
key="snapshot-list",
|
key="snapshot-list",
|
||||||
select_mode="extended",
|
select_mode="extended",
|
||||||
|
size=(None, 10)
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@ -725,7 +736,9 @@ def _main_gui(viewer_mode: bool):
|
||||||
window["snapshot-list"].expand(True, True)
|
window["snapshot-list"].expand(True, True)
|
||||||
window.set_title(f"{SHORT_PRODUCT_NAME} - {config_file}")
|
window.set_title(f"{SHORT_PRODUCT_NAME} - {config_file}")
|
||||||
|
|
||||||
window.read(timeout=1)
|
window.read(timeout=0.01)
|
||||||
|
if not config_file and not full_config and not viewer_mode:
|
||||||
|
window["-NO-CONFIG-"].Update(visible=True)
|
||||||
if repo_config:
|
if repo_config:
|
||||||
try:
|
try:
|
||||||
current_state, backup_tz, snapshot_list = get_gui_data(repo_config)
|
current_state, backup_tz, snapshot_list = get_gui_data(repo_config)
|
||||||
|
@ -812,6 +825,10 @@ def _main_gui(viewer_mode: bool):
|
||||||
repo_list,
|
repo_list,
|
||||||
) = get_config()
|
) = get_config()
|
||||||
window.set_title(f"{SHORT_PRODUCT_NAME} - {config_file}")
|
window.set_title(f"{SHORT_PRODUCT_NAME} - {config_file}")
|
||||||
|
if not viewer_mode and not config_file and not full_config:
|
||||||
|
window["-NO-CONFIG-"].Update(visible=True)
|
||||||
|
elif not viewer_mode:
|
||||||
|
window["-NO-CONFIG-"].Update(visible=False)
|
||||||
event = "--STATE-BUTTON--"
|
event = "--STATE-BUTTON--"
|
||||||
if event == _t("generic.destination"):
|
if event == _t("generic.destination"):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -41,7 +41,7 @@ en:
|
||||||
new_config: New config
|
new_config: New config
|
||||||
load_config: Load configuration
|
load_config: Load configuration
|
||||||
config_error: Configuration error
|
config_error: Configuration error
|
||||||
no_config: Please load a configuration before proceeding
|
no_config: Please load / create a configuration before proceeding
|
||||||
|
|
||||||
# logs
|
# logs
|
||||||
last_messages: Last messages
|
last_messages: Last messages
|
||||||
|
|
|
@ -41,7 +41,7 @@ fr:
|
||||||
new_config: Nouvelle configuration
|
new_config: Nouvelle configuration
|
||||||
load_config: Charger configuration
|
load_config: Charger configuration
|
||||||
config_error: Erreur de configuration
|
config_error: Erreur de configuration
|
||||||
no_config: Veuillez charger une configuration avant de procéder
|
no_config: Veuillez charger / créer une configuration avant de procéder
|
||||||
|
|
||||||
# logs
|
# logs
|
||||||
last_messages: Last messages
|
last_messages: Last messages
|
||||||
|
|
Loading…
Reference in a new issue