mirror of
https://github.com/netinvent/npbackup.git
synced 2025-11-10 06:01:39 +08:00
GUI: Fix object creation
This commit is contained in:
parent
4be4386951
commit
b2ccdf0190
1 changed files with 11 additions and 8 deletions
|
|
@ -172,7 +172,7 @@ def config_gui(full_config: dict, config_file: str):
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
full_config.s(
|
full_config.s(
|
||||||
f"groups.{object_name}",
|
f"{object_type}.{object_name}",
|
||||||
configuration.get_default_group_config(),
|
configuration.get_default_group_config(),
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
@ -199,7 +199,8 @@ def config_gui(full_config: dict, config_file: str):
|
||||||
if not object_name or not object_type:
|
if not object_name or not object_type:
|
||||||
object = object_list[0]
|
object = object_list[0]
|
||||||
else:
|
else:
|
||||||
object = f"{object_type.capitalize()}: {object_name}"
|
# We need to remove the "s" and the end if we want our comobox name to be usable later
|
||||||
|
object = f"{object_type.rstrip('s').capitalize()}: {object_name}"
|
||||||
|
|
||||||
window["-OBJECT-SELECT-"].Update(values=object_list)
|
window["-OBJECT-SELECT-"].Update(values=object_list)
|
||||||
window["-OBJECT-SELECT-"].Update(value=object)
|
window["-OBJECT-SELECT-"].Update(value=object)
|
||||||
|
|
@ -209,7 +210,6 @@ def config_gui(full_config: dict, config_file: str):
|
||||||
Extracts selected object from combobox
|
Extracts selected object from combobox
|
||||||
Returns object type and name
|
Returns object type and name
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if combo_value.startswith("Repo: "):
|
if combo_value.startswith("Repo: "):
|
||||||
object_type = "repos"
|
object_type = "repos"
|
||||||
object_name = combo_value[len("Repo: ") :]
|
object_name = combo_value[len("Repo: ") :]
|
||||||
|
|
@ -219,6 +219,8 @@ def config_gui(full_config: dict, config_file: str):
|
||||||
else:
|
else:
|
||||||
object_type = None
|
object_type = None
|
||||||
object_name = None
|
object_name = None
|
||||||
|
logger.error(f"Could not obtain object_type and object_name from {combo_value}")
|
||||||
|
|
||||||
return object_type, object_name
|
return object_type, object_name
|
||||||
|
|
||||||
def update_gui_values(key, value, inherited, object_type, unencrypted):
|
def update_gui_values(key, value, inherited, object_type, unencrypted):
|
||||||
|
|
@ -480,7 +482,6 @@ def config_gui(full_config: dict, config_file: str):
|
||||||
encrypted_env_variables_tree = sg.TreeData()
|
encrypted_env_variables_tree = sg.TreeData()
|
||||||
|
|
||||||
object_type, object_name = get_object_from_combo(object_name)
|
object_type, object_name = get_object_from_combo(object_name)
|
||||||
|
|
||||||
if object_type == "repos":
|
if object_type == "repos":
|
||||||
object_config, config_inheritance = configuration.get_repo_config(
|
object_config, config_inheritance = configuration.get_repo_config(
|
||||||
full_config, object_name, eval_variables=False
|
full_config, object_name, eval_variables=False
|
||||||
|
|
@ -507,6 +508,7 @@ def config_gui(full_config: dict, config_file: str):
|
||||||
else:
|
else:
|
||||||
object_config = None
|
object_config = None
|
||||||
config_inheritance = None
|
config_inheritance = None
|
||||||
|
logger.error(f"Bogus object {object_type}.{object_name}")
|
||||||
|
|
||||||
# Now let's iter over the whole config object and update keys accordingly
|
# Now let's iter over the whole config object and update keys accordingly
|
||||||
iter_over_config(
|
iter_over_config(
|
||||||
|
|
@ -665,7 +667,7 @@ def config_gui(full_config: dict, config_file: str):
|
||||||
"repo_opts.upload_speed",
|
"repo_opts.upload_speed",
|
||||||
"repo_opts.download_speed",
|
"repo_opts.download_speed",
|
||||||
):
|
):
|
||||||
if (
|
if full_config.g(inheritance_key) is not None and value is not None and (
|
||||||
BytesConverter(full_config.g(inheritance_key)).bytes
|
BytesConverter(full_config.g(inheritance_key)).bytes
|
||||||
== BytesConverter(value).bytes
|
== BytesConverter(value).bytes
|
||||||
):
|
):
|
||||||
|
|
@ -714,7 +716,6 @@ def config_gui(full_config: dict, config_file: str):
|
||||||
"""
|
"""
|
||||||
Sets repo wide repo_uri / password / permissions
|
Sets repo wide repo_uri / password / permissions
|
||||||
"""
|
"""
|
||||||
object_type, object_name = get_object_from_combo(object_name)
|
|
||||||
if object_type == "groups":
|
if object_type == "groups":
|
||||||
sg.PopupError(_t("config_gui.permissions_only_for_repos"), keep_on_top=True)
|
sg.PopupError(_t("config_gui.permissions_only_for_repos"), keep_on_top=True)
|
||||||
return full_config
|
return full_config
|
||||||
|
|
@ -2015,6 +2016,8 @@ Google Cloud storage: GOOGLE_PROJECT_ID GOOGLE_APPLICATION_CREDENTIALS\n\
|
||||||
if event == "-OBJECT-CREATE-":
|
if event == "-OBJECT-CREATE-":
|
||||||
full_config, object_name, object_type = create_object(full_config)
|
full_config, object_name, object_type = create_object(full_config)
|
||||||
update_object_selector(object_name, object_type)
|
update_object_selector(object_name, object_type)
|
||||||
|
current_object_type = object_type
|
||||||
|
current_object_name = object_name
|
||||||
continue
|
continue
|
||||||
if event == "--SET-PERMISSIONS--":
|
if event == "--SET-PERMISSIONS--":
|
||||||
manager_password = configuration.get_manager_password(
|
manager_password = configuration.get_manager_password(
|
||||||
|
|
@ -2027,8 +2030,8 @@ Google Cloud storage: GOOGLE_PROJECT_ID GOOGLE_APPLICATION_CREDENTIALS\n\
|
||||||
)
|
)
|
||||||
full_config = set_permissions(
|
full_config = set_permissions(
|
||||||
full_config,
|
full_config,
|
||||||
object_type=object_type,
|
object_type=current_object_type,
|
||||||
object_name=values["-OBJECT-SELECT-"],
|
object_name=current_object_name,
|
||||||
)
|
)
|
||||||
update_object_gui(full_config, values["-OBJECT-SELECT-"])
|
update_object_gui(full_config, values["-OBJECT-SELECT-"])
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue