Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.0 #221

Merged
merged 21 commits into from
Apr 30, 2024
Merged

1.1.0 #221

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c702d4c
prevent crashes caused by leading spaces and parts without parameters
T0jan Mar 11, 2024
958feff
Merge pull request #219 from T0jan/main
eeintech Mar 28, 2024
b39924e
Update SnapEDA test part number
eeintech Mar 28, 2024
23eab93
Update Github action worflow to include main branch for testing APIs …
eeintech Apr 2, 2024
a21ee1a
Start work on upgrading flet version, current bug: freezes when switc…
eeintech Apr 17, 2024
53fc866
Rebuilding views create more issues, still losing page pointer in vie…
Apr 19, 2024
7dd51d3
Navigation and routing seem stable, still a few tweaks needed
Apr 19, 2024
8ce6d6b
Resolve conflict with 1.0.x branch
Apr 19, 2024
96771e9
Merge branch '1.0.x' into update_flet_version
eeintech Apr 19, 2024
1f161f4
Add fix for UI error, update inventree version
eeintech Apr 27, 2024
8717d6d
Merge branch 'update_flet_version' of github.com:sparkmicro/Ki-nTree …
eeintech Apr 27, 2024
b3d5b57
Merge pull request #224 from sparkmicro/update_flet_version
eeintech Apr 27, 2024
dc3ad77
Bump dev version, update README
eeintech Apr 27, 2024
1ff38ac
Update pip requirements
eeintech Apr 27, 2024
2b31539
Downgrade inventree package for testing
eeintech Apr 27, 2024
3d10d18
Real fix for reset view
eeintech Apr 27, 2024
74250c5
Changes from #223, with exception catching for control error
eeintech Apr 27, 2024
5554b83
Retry inventree 0.13.3
eeintech Apr 27, 2024
28bbafa
try specific InvenTree version
T0jan Apr 29, 2024
c45ac61
Merge pull request #226 from sparkmicro/update_flet_version
T0jan Apr 29, 2024
46dbb1f
branch instead of version
T0jan Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/test_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ jobs:
- name: Install dependencies
run: |
sudo apt install sqlite3
pip install -U invoke coveralls
pip install -U pip invoke coveralls
- name: InvenTree setup
run: |
git clone https://github.com/inventree/InvenTree/
mkdir InvenTree/static
cp tests/files/inventree_default_db.sqlite3 InvenTree/
cd InvenTree/ && git switch stable && invoke install && invoke migrate && cd -
cd InvenTree/ && git switch 0.14.x && invoke install && invoke migrate && cd -
- name: Ki-nTree setup
run: |
invoke install
Expand All @@ -93,7 +93,7 @@ jobs:
export len_log=$(cat gui.log | wc -l)
[[ ${len_log} -eq 0 ]] && true || false
- name: Setup Digi-Key token
if: github.event.pull_request.head.repo.full_name == 'sparkmicro/Ki-nTree'
if: ${{ github.ref == 'refs/heads/main' || github.event.pull_request.head.repo.full_name == 'sparkmicro/Ki-nTree' }}
run: |
git clone https://[email protected]/eeintech/digikey-token.git
cd digikey-token/
Expand All @@ -108,7 +108,7 @@ jobs:
echo -e "Digi-Key Token: $dk_token\n"
cd ..
- name: Run tests
if: github.event.pull_request.head.repo.full_name == 'sparkmicro/Ki-nTree'
if: ${{ github.ref == 'refs/heads/main' || github.event.pull_request.head.repo.full_name == 'sparkmicro/Ki-nTree' }}
run: |
invoke test -e 1
env:
Expand All @@ -119,7 +119,7 @@ jobs:
run: |
invoke test -e 0
- name: Coveralls
if: github.event.pull_request.head.repo.full_name == 'sparkmicro/Ki-nTree'
if: ${{ github.ref == 'refs/heads/main' || github.event.pull_request.head.repo.full_name == 'sparkmicro/Ki-nTree' }}
run: |
coveralls --version
coveralls --service=github
Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Note that each time you enable the "Add" permission to an object, InvenTree auto
d. It is also possible to sync the prices in InvenTree with the latest supplier prices. For this enable "Upload Pricing Data to InvenTree"
6. If your InvenTree server requires a IPN in a specific pattern make sure to adjust "Settings > InvenTree > Internal Part Number" to match it or adjust the servers pattern to the one yo set in Ki-nTree

> Note: All URLs should start with "http://" if they do not have a valid SSL certificate.

#### Get Digi-Key API token
<details>
Expand Down Expand Up @@ -204,12 +205,14 @@ Refer to [this file](https://github.com/sparkmicro/Ki-nTree/blob/main/kintree/co

Ki-nTree currently supports APIs for the following electronics suppliers: Digi-Key, Mouser, Element14, TME and LCSC.

1. In the main window, enter the part number and select the supplier in drop-down list, then click "CREATE". It will start by fetching part data using the supplier's API
1. In the main window, enter the part number and select the supplier in drop-down list, then click the "Submit" button (arrow). It will start by fetching part data using the supplier's API
2. In the case Digi-Key has been selected and the API token is not found or expired, a browser window will pop-up. To get a new token: [follow those steps](#get-digi-key-api-token)
3. Once the part data has been successfully fetched from the supplier's API, you will be prompted to add/confirm/edit the part information, followed by the `Category` and `Subcategory` to use for this part (Ki-nTree tries to match them automatically)
4. Then, you will be prompted with selecting the KiCad symbol library, the template and the footprint library to use for this part
5. It will take some time to complete the part creation in InvenTree and/or KiCad, once it finishes you'll be notified of the result
6. Finally, if the part was created or found in InvenTree, your browser will automatically open a new tab with the part information
3. Once the part data has been successfully fetched from the supplier's API, you can review the part information in the different fields and edit them, if needed.
4. Then, go to the Inventree tabl to pick the `Category` and `Subcategory` to use for this part
5. If you desire to add this part to KiCad, click the KiCad tab and select the KiCad symbol library, the template and the footprint library to use for this part
6. Finally, go to the Create tab and launch the part creation. It will take some time to complete the process in InvenTree and/or KiCad, once it finishes you'll be notified of the result

If the part was created or found in InvenTree, and if you have selected this option in the settings, your browser will automatically open and navigate to the new Inventree part page.

#### Kicad Templates

Expand Down Expand Up @@ -244,7 +247,7 @@ git clone https://github.com/sparkmicro/Ki-nTree
poetry install
Installing dependencies from lock file
...
Installing the current project: kintree (1.0.99)
Installing the current project: kintree (1.1.99)
```
> Note: the version is not accurate (placeholder only)

Expand All @@ -263,11 +266,11 @@ $ python -m kintree_gui
1. Make sure you followed the previous installation steps, then run:
``` bash
$ poetry build
Building kintree (1.0.99)
Building kintree (1.1.99)
- Building sdist
- Built kintree-1.0.99.tar.gz
- Built kintree-1.1.99.tar.gz
- Building wheel
- Built kintree-1.0.99-py3-none-any.whl
- Built kintree-1.1.99-py3-none-any.whl
```
2. Exit the virtual environment (`Ctrl + D` on Linux; you can also close the
terminal and reopen it in the same folder).
Expand All @@ -276,7 +279,7 @@ Building kintree (1.0.99)
step. For example:

```bash
pip install dist/kintree-1.0.99-py3-none-any.whl
pip install dist/kintree-1.1.99-py3-none-any.whl
```

3. You can now start Ki-nTree by typing `kintree` in the terminal, provided
Expand Down
6 changes: 4 additions & 2 deletions kintree/database/inventree_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ def translate_form_to_inventree(part_info: dict, category_tree: list, is_custom=
inventree_part['pricing'] = part_info.get('pricing', {})
inventree_part['currency'] = part_info.get('currency', 'USD')

parameters = part_info.get('parameters', {})

# Load parameters map
if category_tree:
parameter_map = config_interface.load_category_parameters(
Expand All @@ -335,7 +337,7 @@ def translate_form_to_inventree(part_info: dict, category_tree: list, is_custom=
parameter_value = part_tools.clean_parameter_value(
category=category_tree[0],
name=supplier_param,
value=part_info['parameters'][supplier_param],
value=parameters[supplier_param],
)
inventree_part['parameters'][inventree_param] = parameter_value
except KeyError:
Expand All @@ -354,7 +356,7 @@ def translate_form_to_inventree(part_info: dict, category_tree: list, is_custom=

# Check for extra parameters which weren't mapped
parameters_unmapped = []
for search_param in part_info['parameters'].keys():
for search_param in parameters.keys():
if search_param not in parameter_map.keys():
parameters_unmapped.append(search_param)

Expand Down
28 changes: 12 additions & 16 deletions kintree/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,23 @@ def kintree_gui(page: ft.Page):
'''Ki-nTree GUI'''
# Init
init_gui(page)
# Views
# Create main views
part_view = PartSearchView(page)
inventree_view = InventreeView(page)
kicad_view = KicadView(page)
create_view = CreateView(page)
# Settings
# Create settings views
user_settings_view = UserSettingsView(page)
supplier_settings_view = SupplierSettingsView(page)
inventree_settings_view = InvenTreeSettingsView(page)
kicad_settings_view = KiCadSettingsView(page)

# Routing
def route_change(route):
# print(f'\n--> Routing to {route.route}')
if '/main' in page.route:
if '/main' in page.route or page.route == '/':
page.views.clear()
if 'part' in page.route:
if 'part' in page.route or page.route == '/':
page.views.append(part_view)
if 'inventree' in page.route:
page.views.append(inventree_view)
Expand All @@ -71,22 +72,19 @@ def route_change(route):
elif '/settings' in page.route:
if '/settings' in page.views[-1].route:
page.views.pop()
if page.route == user_settings_view.route:
if 'user' in page.route:
page.views.append(user_settings_view)
elif page.route == supplier_settings_view.route:
elif 'supplier' in page.route:
page.views.append(supplier_settings_view)
elif page.route == inventree_settings_view.route:
elif 'inventree' in page.route:
page.views.append(inventree_settings_view)
elif page.route == kicad_settings_view.route:
elif 'kicad' in page.route:
page.views.append(kicad_settings_view)
else:
page.views.append(user_settings_view)
else:
page.views.append(part_view)

page.update()

def view_pop(e):
def view_pop(view):
'''Pop setting view'''
page.views.pop()
top_view = page.views[-1]
Expand All @@ -101,10 +99,8 @@ def view_pop(e):
update_page=True,
timeout=0.3,
)
if 'part' in top_view.route:
part_view.partial_update()
elif 'inventree' in top_view.route:
inventree_view.partial_update()
if '/main/part' in top_view.route or '/main/inventree' in top_view.route:
top_view.partial_update()

page.on_route_change = route_change
page.on_view_pop = view_pop
Expand Down
25 changes: 12 additions & 13 deletions kintree/gui/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ def update_theme(page: ft.Page, mode='light', transition=False, compact=True):
class CommonView(ft.View):
'''Common view to all GUI views'''

page = None
_page = None
navigation_rail = None
NAV_BAR_INDEX = None
title = None
column = None
fields = None
Expand All @@ -90,7 +89,7 @@ class CommonView(ft.View):

def __init__(self, page: ft.Page, appbar: ft.AppBar, navigation_rail: ft.NavigationRail):
# Store page pointer
self.page = page
self._page = page

# Init view
super().__init__(route=self.route, appbar=appbar)
Expand All @@ -103,7 +102,7 @@ def build_column(self):
# Empty column (to be set inside the children views)
self.column = ft.Column()

def _build(self):
def build(self):
# Build column
if not self.column:
self.build_column()
Expand Down Expand Up @@ -164,15 +163,15 @@ def show_dialog(
if snackbar:
self.build_snackbar(d_type, message)
if isinstance(self.dialog, ft.SnackBar):
self.page.snack_bar = self.dialog
self.page.snack_bar.open = True
self._page.snack_bar = self.dialog
self._page.snack_bar.open = True
elif isinstance(self.dialog, ft.Banner):
self.page.banner = self.dialog
self.page.banner.open = open
self._page.banner = self.dialog
self._page.banner.open = open
elif isinstance(self.dialog, ft.AlertDialog):
self.page.dialog = self.dialog
self.page.dialog.open = open
self.page.update()
self._page.dialog = self.dialog
self._page.dialog.open = open
self._page.update()


class SwitchWithRefs(ft.Switch):
Expand Down Expand Up @@ -433,7 +432,7 @@ def header_click(self, e):
self.shevron.rotate = pi / 2 if self.shevron.rotate == 0 else 0
self.update()

def _build(self):
def build(self):
title_row = ft.Row()
if self.icon is not None:
title_row.controls.append(self.icon)
Expand Down Expand Up @@ -476,7 +475,7 @@ def __init__(
def item_click(self, _):
pass

def _build(self):
def build(self):
row = ft.Row()
if self.icon is not None:
row.controls.append(self.icon)
Expand Down
Loading
Loading