-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui - init work on interfacing templates with UI
- Loading branch information
1 parent
eb42706
commit deabfe6
Showing
10 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from json import loads | ||
from glob import glob | ||
from os import sep | ||
from os.path import join | ||
|
||
def get_ui_templates(): | ||
ui_templates = [] | ||
for template_file in glob(join(sep, "usr", "share", "bunkerweb", "templates", "*.json")): | ||
try: | ||
ui_template = {} | ||
with open(template_file, "r") as f: | ||
bw_template = loads(f.read()) | ||
ui_template = { | ||
"name": bw_template["name"], | ||
"description": bw_template["description"] | ||
} | ||
ui_template["steps"] = [] | ||
for bw_step in bw_template["steps"]: | ||
ui_step = {} | ||
ui_step["name"] = bw_step["name"] | ||
ui_step["description"] = bw_step["description"] | ||
ui_step["settings"] = [] | ||
for setting, value in bw_step["settings"].items(): | ||
ui_setting = { | ||
"setting_id": setting, | ||
"value": value | ||
} | ||
ui_step["settings"].append(ui_setting) | ||
ui_template["steps"].append(ui_step) | ||
ui_templates.append(ui_template) | ||
except Exception as e: | ||
# print(e) | ||
# TODO: log | ||
pass | ||
# print(ui_templates, flush=True) | ||
return ui_templates |