-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start of datatable api start of data table implementation in templates
- Loading branch information
1 parent
d656a03
commit 370e039
Showing
21 changed files
with
1,219 additions
and
907 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,3 +73,6 @@ maker_hub/static/cache_manifest.json | |
!.vscode/launch.json | ||
|
||
site/* | ||
app/coverage.xml | ||
coverage.xml | ||
htmlcov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import fastapi | ||
from fastapi.param_functions import Depends | ||
|
||
from app.schema.datatable import FormRequest | ||
from app.services import part_service | ||
|
||
api = fastapi.APIRouter() | ||
|
||
|
||
@api.post("/api/part/table") | ||
def table_datasource(request: FormRequest = Depends): | ||
"""Parts Datatable Source | ||
Returns: | ||
[TableResponse]: [DataTable Ajax Response] | ||
""" | ||
|
||
draw = request.draw | ||
|
||
# search_str = request.query_params["search[value]"] | ||
# is_regex = bool(request.query_params["search[regex]"]) | ||
# start = int(request.query_params["start"]) | ||
# limit = int(request.query_params["length"]) | ||
data = part_service.latest_parts(limit=30) | ||
return { | ||
"draw": draw, | ||
"recordsTotal": 100, | ||
"recordsFiltered": 100, | ||
"data": data, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from typing import List | ||
|
||
from fastapi import Form | ||
from pydantic import BaseModel | ||
|
||
|
||
class Search(BaseModel): | ||
value: str = "" | ||
regex: bool = False | ||
|
||
|
||
class Order(BaseModel): | ||
column: int = 1 | ||
dir: str = "asc" | ||
|
||
|
||
class Column(BaseModel): | ||
name: str = "" | ||
data: str = "" | ||
searchable: bool = True | ||
orderable: bool = True | ||
search: Search | ||
|
||
|
||
class DataTableBase(BaseModel): | ||
draw: int | ||
|
||
|
||
class TableRequest(DataTableBase): | ||
start: int | ||
length: int | ||
search: Search | ||
order: Order | ||
columns: List[Column] = [] | ||
|
||
|
||
class TableResponse(DataTableBase): | ||
recordsTotal: int | ||
recordsFiltered: int | ||
data: list | ||
error: str | ||
|
||
|
||
class FormRequest(BaseModel): | ||
draw: int | ||
start: int | ||
length: int | ||
|
||
def __init__( | ||
self, draw: str = Form(...), start: int = Form(...), length: int = Form(...) | ||
): | ||
super().__init__(draw, start, length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.