Skip to content

Commit

Permalink
Parts DataTable now working with dummy data via API callbacks
Browse files Browse the repository at this point in the history
fixing test actions (+2 squashed commits)
Squashed commits:
[4bb5a7c] Fixes failing tests on action as poetry not installing pytest
[e211c5c] Parts DataTable now working with dummy data via API callbacks

fixed broken reports page (+12 squashed commits)
Squashed commits:
[06da556] updated dependencies due to dependabot updates

added PRs to changelog
[9adc02c] Bump pyjwt from 1.7.1 to 2.1.0

Bumps [pyjwt](https://github.com/jpadilla/pyjwt) from 1.7.1 to 2.1.0.
- [Release notes](https://github.com/jpadilla/pyjwt/releases)
- [Changelog](https://github.com/jpadilla/pyjwt/blob/master/CHANGELOG.rst)
- [Commits](jpadilla/pyjwt@1.7.1...2.1.0)

Signed-off-by: dependabot[bot] <support@github.com>
[3018fbf] Bump fastapi from 0.63.0 to 0.64.0

Bumps [fastapi](https://github.com/tiangolo/fastapi) from 0.63.0 to 0.64.0.
- [Release notes](https://github.com/tiangolo/fastapi/releases)
- [Commits](tiangolo/fastapi@0.63.0...0.64.0)

Signed-off-by: dependabot[bot] <support@github.com>
[c6fc277] Bump aiofiles from 0.6.0 to 0.7.0

Bumps [aiofiles](https://github.com/Tinche/aiofiles) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/Tinche/aiofiles/releases)
- [Commits](Tinche/aiofiles@v0.6.0...v0.7.0)

Signed-off-by: dependabot[bot] <support@github.com>
[ce0422a] Bump pytest-asyncio from 0.14.0 to 0.15.1

Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.14.0 to 0.15.1.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](pytest-dev/pytest-asyncio@v0.14.0...v0.15.1)

Signed-off-by: dependabot[bot] <support@github.com>
[a332e5f] Bump python-slugify from 4.0.1 to 5.0.2

Bumps [python-slugify](https://github.com/un33k/python-slugify) from 4.0.1 to 5.0.2.
- [Release notes](https://github.com/un33k/python-slugify/releases)
- [Changelog](https://github.com/un33k/python-slugify/blob/master/CHANGELOG.md)
- [Commits](un33k/python-slugify@4.0.1...5.0.2)

Signed-off-by: dependabot[bot] <support@github.com>
[20775f2] Bump abatilo/actions-poetry from 2.1.0 to 2.1.2

Bumps [abatilo/actions-poetry](https://github.com/abatilo/actions-poetry) from 2.1.0 to 2.1.2.
- [Release notes](https://github.com/abatilo/actions-poetry/releases)
- [Changelog](https://github.com/abatilo/actions-poetry/blob/master/.releaserc)
- [Commits](abatilo/actions-poetry@v2.1.0...v2.1.2)

Signed-off-by: dependabot[bot] <support@github.com>
[ee0a378] Bump mindsers/changelog-reader-action from 1 to 2

Bumps [mindsers/changelog-reader-action](https://github.com/mindsers/changelog-reader-action) from 1 to 2.
- [Release notes](https://github.com/mindsers/changelog-reader-action/releases)
- [Changelog](https://github.com/mindsers/changelog-reader-action/blob/master/CHANGELOG.md)
- [Commits](mindsers/changelog-reader-action@v1...v2)

Signed-off-by: dependabot[bot] <support@github.com>
[95450f6] Update Changelog for PR
[bdb7a8b] Bump heinrichreimer/github-changelog-generator-action from 2.1.1 to 2.2

Bumps [heinrichreimer/github-changelog-generator-action](https://github.com/heinrichreimer/github-changelog-generator-action) from 2.1.1 to 2.2.
- [Release notes](https://github.com/heinrichreimer/github-changelog-generator-action/releases)
- [Commits](heinrichreimer/action-github-changelog-generator@v2.1.1...v2.2)

Signed-off-by: dependabot[bot] <support@github.com>
[91dd042] parts datatable api now working with dummy data and made async
[370e039] basic service tests

start of datatable api
start of data table implementation in templates
  • Loading branch information
madeinoz67 committed May 24, 2021
1 parent d656a03 commit 861fd71
Show file tree
Hide file tree
Showing 39 changed files with 1,369 additions and 971 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ jobs:
- name: Install Python dependencies
run: |
pip install poetry
poetry install --no-dev
poetry install
- name: Run Test
run: |
poetry run pytest --no-cov
# - name: Install Node dependencies
# run: npm install
# - run: cp .env.example .env
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
with:
ref: master
- name: Update Changelog
uses: heinrichreimer/github-changelog-generator-action@v2.1.1
uses: heinrichreimer/github-changelog-generator-action@v2.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
issues: true
issuesWoLabels: true
pullRequests: false
prWoLabels: false
pullRequests: true
prWoLabels: true
unreleased: true
addSections: '{"documentation":{"prefix":"**Documentation:**","labels":["documentation"]}}'
- uses: stefanzweifel/git-auto-commit-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}

- name: Python Poetry Action
uses: abatilo/actions-poetry@v2.1.0
uses: abatilo/actions-poetry@v2.1.2
with:
poetry-version: ${{ env.POETRY_VERSION }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
ref: master
- name: Update Changelog
uses: heinrichreimer/github-changelog-generator-action@v2.1.1
uses: heinrichreimer/github-changelog-generator-action@v2.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
issues: true
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:

- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v1
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ env.CURRENT_VERSION }}
path: ./CHANGELOG.md
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@ maker_hub/static/cache_manifest.json
!.vscode/launch.json

site/*
app/coverage.xml
coverage.xml
htmlcov
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Add pages site \(docs\) link to README [\#51](https://github.com/madeinoz67/maker-hub/issues/51)

**Closed issues:**

- Update About page with new Repo [\#59](https://github.com/madeinoz67/maker-hub/issues/59)

## [v2021.0.0-dev1](https://github.com/madeinoz67/maker-hub/tree/v2021.0.0-dev1) (2021-05-22)

**Implemented enhancements:**
Expand Down
11 changes: 11 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.9"
File renamed without changes.
24 changes: 24 additions & 0 deletions app/api/part_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import fastapi

from app.schema.datatable import DataTableRequest, DataTableResponse
from app.services import part_service

api = fastapi.APIRouter()


@api.post("/api/part/datatable")
async def table_datasource(request: DataTableRequest) -> DataTableResponse:
"""Parts Datatable Source
Returns:
[TableResponse]: [DataTable Ajax Response]
"""

draw = request.draw

data = await part_service.get_latest_parts(
start=request.start, limit=request.length
)
return DataTableResponse(
draw=draw, recordsTotal=100, recordsFiltered=100, data=data
)
14 changes: 12 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import fastapi
import fastapi_chameleon
import uvicorn

from starlette.staticfiles import StaticFiles
from dotenv import load_dotenv

Expand All @@ -11,8 +11,13 @@
from app.views import storage
from app.views import reports

from app.api import part_api

app = fastapi.FastAPI()
app = fastapi.FastAPI(
title="Maker Hub",
description="Personal Hub for makers: Manage Parts, projects, ideas, documentation, parts and footprints etc",
version="2021.0.0-dev1",
)


def main():
Expand All @@ -37,6 +42,11 @@ def configure_routes():
static_folder = os.path.join(folder, "static")
static_folder = os.path.abspath(static_folder)
app.mount("/static", StaticFiles(directory=static_folder), name="static")

# API endpoints
app.include_router(part_api.api)

# Webpages
app.include_router(home.router)
app.include_router(parts.router)
app.include_router(projects.router)
Expand Down
Empty file added app/schema/__init__.py
Empty file.
75 changes: 75 additions & 0 deletions app/schema/datatable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from typing import List, Optional

from pydantic import BaseModel

from app.schema.part import Part


class Search(BaseModel):
value: str = ""
regex: bool = False


class Order(BaseModel):
column: int
dir: str = "asc"


class Column(BaseModel):
name: str
data: str
searchable: bool = True
orderable: bool = True
search: Search


class DataTableBase(BaseModel):
draw: int


class DataTableRequest(DataTableBase):
start: int
length: int
search: Search
order: List[Order]
columns: List[Column]


class DataTableResponse(DataTableBase):
recordsTotal: int
recordsFiltered: int
data: List[Part] = []
error: Optional[str] = None


# Example DataTable generated Query
# {
# "draw": 1,
# "columns": [
# {
# "data": "id",
# "name": "",
# "searchable": false,
# "orderable": false,
# "search": {"value": "", "regex": false},
# },
# {
# "data": "name",
# "name": "",
# "searchable": true,
# "orderable": true,
# "search": {"value": "", "regex": false},
# },
# {
# "data": "description",
# "name": "",
# "searchable": true,
# "orderable": true,
# "search": {"value": "", "regex": false},
# },
# ],
# "order": [{"column": 1, "dir": "asc"}],
# "start": 0,
# "length": 100,
# "search": {"value": "", "regex": false},
# }
7 changes: 7 additions & 0 deletions app/schema/part.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from pydantic import BaseModel


class Part(BaseModel):
id: str
name: str
description: str
Loading

0 comments on commit 861fd71

Please sign in to comment.