forked from Support/sp-hydra-veil-gui
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
from core.models.orm_calls.application_version_calls import get_all_supported_apps
|
|
from core.errors.logger import logger
|
|
|
|
from pathlib import Path
|
|
|
|
def get_list_of_apps() -> list:
|
|
database_object = get_all_supported_apps()
|
|
|
|
if not database_object.valid:
|
|
logger.error(f"Critical Database error with fetching all supported apps. {database_object.error_type} with {database_object.message}")
|
|
return None
|
|
|
|
list_of_data = list(database_object.data)
|
|
return list_of_data
|
|
|
|
def get_app_display_data(button_path: str) -> dict:
|
|
all_apps = get_list_of_apps()
|
|
|
|
display_dto = {}
|
|
|
|
for each_app in all_apps:
|
|
app_id = each_app.id
|
|
app_name = each_app.application_code
|
|
version = each_app.version_number
|
|
button_image_path = f"{app_name}_button.png"
|
|
|
|
full_image_path = Path(button_path, button_image_path)
|
|
default_path = Path(button_path, "default_location_button.png")
|
|
|
|
data = {
|
|
'path': default_path,
|
|
'name': app_name,
|
|
'second_line': version,
|
|
'existing_icon': full_image_path
|
|
}
|
|
|
|
display_dto[app_id] = data
|
|
|
|
return display_dto
|
|
|
|
|
|
|