From db940340d9c10c5a36fc46957d694fc99c0ef1b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D1=81=D0=B8=D0=BB=D1=8C=20=D0=A1=D0=B2=D1=96?= =?UTF-8?q?=D0=B4=D1=80=D1=96=D0=BA?= Date: Wed, 14 Jun 2023 10:17:39 +0300 Subject: [PATCH] add get menu-items api ver. --- __pycache__/main.cpython-310.pyc | Bin 719 -> 690 bytes __pycache__/routes.cpython-310.pyc | Bin 411 -> 411 bytes .../k2test/__pycache__/__init__.cpython-310.pyc | Bin 169 -> 169 bytes .../k2test/__pycache__/__init__.cpython-310.pyc | Bin 176 -> 176 bytes .../k2test/__pycache__/views.cpython-310.pyc | Bin 1985 -> 1985 bytes components/menu.yml | 18 +++++- db/database.db | Bin 36864 -> 36864 bytes k2/__pycache__/k2inst.cpython-310.pyc | Bin 12849 -> 12906 bytes k2/k2inst.py | 62 ++++++++++++++------- main.py | 2 - 10 files changed, 57 insertions(+), 25 deletions(-) diff --git a/__pycache__/main.cpython-310.pyc b/__pycache__/main.cpython-310.pyc index a84e1e37b8c402a75b3fcfb5cc5c94981eb9f0bb..85190c691f8b66792896b4355938e232a09552a2 100644 GIT binary patch delta 96 zcmX@lx`~xHpO=@50SJ=gJ5zEd^2#!qzOI$ScdZX`*(!Oe*^Vp@j^L3@HpL967=v45=I`oY_o8 z;i;TiA`_3zWfYy9!gyLkFg>*-J~uV5G(I&aH7_-QYz1Th diff --git a/components/k2test/__pycache__/__init__.cpython-310.pyc b/components/k2test/__pycache__/__init__.cpython-310.pyc index 3e7b35c0af5ee2ec856cfc98c7f181452dd5a911..cf3befada6989b6d432e763b259f837cabc4661f 100644 GIT binary patch delta 19 ZcmZ3 zL8@`KQAuiXiJ_i>nUR5!v95ucuAzy7fw`5TnUx_>)WXEf&~$R0uGr=c`i2g2_zm0q IKc7(n0K8EpM*si- delta 134 zcmZozz|^pSX@V3J)7^6`nIQJ3ITB-Syhu^{%~sJKK%lO`4>oX@e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is|}HIjd_5SqkW%YECy8YE01;_w}F_1LLgnnfbQ3GxfmNH-W{9bYvoMhDu$P#~PJYPW#8~k}HBzKqb;vr9+i2Bd*W|MaRfG?E;h+i*sB& z*ZXOwVai=?z9gZOU`sEQ<&^A`UVPLSQ`KCXm`b&YZ2#fdK{`as^8ZzkZqOh-8km2e z;!0f1_r)7;^*;*f-^!+r%ce9lKaE@N^3r_4nlF^{A0>t z+;Sva4Ke%*z;DF') def show_components(component_id): - response = requests.get('http://127.0.0.1:8001/api/components') + response = requests.get(f'{k2.update_domain}api/components') json_data = response.json() selected_component = next((component for component in json_data if component['id'] == component_id), None) return render_template('component-info.html', selected_component=selected_component) @@ -159,7 +164,7 @@ def install_components_git(component_id): # Шлях до головної папки проекту project_folder = 'components' #component = Component.get_repository_by_id(component_id) - response = requests.get('http://127.0.0.1:8001/api/components') + response = requests.get(f'{k2.update_domain}api/components') json_data = response.json() selected_component = next((component for component in json_data if component['id'] == component_id), None) # Назва репозиторія @@ -224,7 +229,7 @@ def install_component_from_archive(component_id): # Шлях до головної папки проекту project_folder = 'components' # Отримати відповідну компоненту зі списку компонент - response = requests.get('http://127.0.0.1:8001/api/components') + response = requests.get(f'{k2.update_domain}api/components') json_data = response.json() selected_component = next((component for component in json_data if component['id'] == component_id), None) if selected_component is None: @@ -286,21 +291,21 @@ def install_component_from_archive(component_id): component.installed = True db.session.commit() - # add menu items - file_path_input = f"components/{selected_component['name']}/menu_items.yml" - if os.path.exists(file_path_input): - with open(file_path_input, 'r', encoding='utf-8') as file: - data = yaml.safe_load(file) - else: - data = { - 'url': {'name': 'error'}, - 'icon': 'error', - 'title': f"{selected_component['name']}--error", - 'category': 'error', - } - - file_path = 'components/menu.yml' - append_to_yaml_file(file_path, data) + # add menu items yml + #file_path_input = f"components/{selected_component['name']}/menu_items.yml" + #if os.path.exists(file_path_input): + # with open(file_path_input, 'r', encoding='utf-8') as file: + # data = yaml.safe_load(file) + #else: + # data = { + # 'url': {'name': 'error'}, + # 'icon': 'error', + # 'title': f"{selected_component['name']}--error", + # 'category': 'error', + # } + + #file_path = 'components/menu.yml' + #append_to_yaml_file(file_path, data) #add language folders k2.search_babel_translation_directories() @@ -314,6 +319,24 @@ def install_component_from_archive(component_id): @components_bp.route('/install-requirments/', methods=['GET']) def install_requirments(selected_component_name): + #menu items api + response = requests.get(f"{k2.domain}{selected_component_name}/menu-items") + if response.status_code == 200: + data = response.json() + print(data) + else: + data = [{ + 'url': {'name': 'error'}, + 'icon': 'error', + 'title': f"{selected_component_name}--error", + 'category': 'error', + }] + + file_path = 'components/menu.yml' + append_to_yaml_file(file_path, data) + k2.get_menu_elenents() + + #install requirements requirements_file = os.path.join('components', selected_component_name, "requirements.txt") if os.path.isfile(requirements_file): pip_command = f"{k2.venv_bin_path}/python -m pip install -r {requirements_file}" @@ -322,7 +345,6 @@ def install_requirments(selected_component_name): \n \n please wait installing requirments components... ''' - @components_bp.route('/install-requirments-components') def install_requirements_components(): # Откриття файлу requirements_components.txt diff --git a/main.py b/main.py index 61f0ec5..e79ea8b 100644 --- a/main.py +++ b/main.py @@ -19,8 +19,6 @@ app.config['BABEL_TRANSLATION_DIRECTORIES'] = k2.babel_translation_directories babel = Babel(app) babel.init_app(app, locale_selector=k2.get_locale) -#menu -k2.get_menu_elenents() # flask routing from routes import * -- 1.9.1