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

Parts DataTable now working with dummy data via API callbacks #69

Merged
merged 1 commit into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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