forked from inventree/InvenTree
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Platform UI - React integration (inventree#5011)
* Add SPA views for react inventree#2789 * split up frontend urls * Add settings for frontend url loading * add new UI scaffold * remove tracking insert * add platform app * ensure static indexes work too * add lingui * add lingui config * add mgmt tasks * add base locales * settings for frontend dev * fix typo * update deps * add pre-commit * add eslint * add testing scaffold * fix paths * remove error - tests trip correctly * merge workflow * cleanup samples * use name inline with other tests * Add real worl frontend tests * setup env * tun migrations first * optimize setup time * setup demo dataset * optimize run setup * add test for class ui * rename * fix typo * and another typo * do install * run migrations first * fix name * cleanup * use other credentials * use other credentials * fix qc * move envs to qc * remove create_site * reduce testing env * fix test * fix test call * allaccess user * add ui plattform check * add better check * remove unneeded env * enable debug * reduce wait time * also build frontend on static * add sort plugin * fix order * run pre-commit fixes * add node min version * Docker container (inventree#129) * Fix allocation check for completing build order (inventree#5199) - Allocation check only applies to untracked line items * docker dev Install required node packages to docker development image * add import order settings * cleanout built ui * remove default arg from build * remove eslint * optimize svg * add build step for plattform UI * fix install command * use alpine commands * do not use cache when creating image --------- Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
- Loading branch information
1 parent
b717011
commit 3e37469
Showing
44 changed files
with
2,817 additions
and
7 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% load spa_helper %} | ||
{% load inventree_extras %} | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>{% inventree_instance_name %}</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
{% spa_bundle %} | ||
</body> | ||
|
||
</html> |
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,36 @@ | ||
"""Template tag to render SPA imports.""" | ||
import json | ||
from logging import getLogger | ||
from pathlib import Path | ||
|
||
from django import template | ||
from django.conf import settings | ||
from django.utils.safestring import mark_safe | ||
|
||
logger = getLogger("gwaesser_backend") | ||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def spa_bundle(): | ||
"""Render SPA bundle.""" | ||
manifest = Path(__file__).parent.parent.joinpath("static/web/manifest.json") | ||
|
||
if not manifest.exists(): | ||
logger.error("Manifest file not found") | ||
return | ||
|
||
manifest_data = json.load(manifest.open()) | ||
index = manifest_data.get("index.html") | ||
|
||
dynmanic_files = index.get("dynamicImports", []) | ||
imports_files = "".join( | ||
[ | ||
f'<script type="module" src="{settings.STATIC_URL}web/{manifest_data[file]["file"]}"></script>' | ||
for file in dynmanic_files | ||
] | ||
) | ||
|
||
return mark_safe( | ||
f"""<script type="module" src="{settings.STATIC_URL}web/{index['file']}"></script>{imports_files}""" | ||
) |
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,26 @@ | ||
"""URLs for web app.""" | ||
from django.conf import settings | ||
from django.shortcuts import redirect | ||
from django.urls import path, re_path | ||
from django.views.decorators.csrf import ensure_csrf_cookie | ||
from django.views.generic import TemplateView | ||
|
||
|
||
class RedirectAssetView(TemplateView): | ||
"""View to redirect to static asset.""" | ||
|
||
def get(self, request, *args, **kwargs): | ||
"""Redirect to static asset.""" | ||
return redirect( | ||
f"{settings.STATIC_URL}web/assets/{kwargs['path']}", permanent=True | ||
) | ||
|
||
|
||
spa_view = ensure_csrf_cookie(TemplateView.as_view(template_name="web/index.html")) | ||
|
||
|
||
urlpatterns = [ | ||
path("assets/<path:path>", RedirectAssetView.as_view()), | ||
re_path(r"^(?P<path>.*)/$", spa_view), | ||
path("", spa_view), | ||
] |
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,8 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-react" | ||
], | ||
"plugins": [ | ||
"macros" | ||
] | ||
} |
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 @@ | ||
/* eslint-env node */ | ||
module.exports = { | ||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint'], | ||
root: true, | ||
}; |
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,29 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# Testing | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ |
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,19 @@ | ||
{ | ||
"locales": ["en", "de", "hu", "pseudo-LOCALE"], | ||
"catalogs": [{ | ||
"path": "src/locales/{locale}/messages", | ||
"include": ["src"], | ||
"exclude": ["**/node_modules/**"] | ||
}], | ||
"format": "po", | ||
"orderBy": "origin", | ||
"sourceLocale": "en", | ||
"pseudoLocale": "pseudo-LOCALE", | ||
"fallbackLocales": { | ||
"default": "en", | ||
"pseudo-LOCALE": "en" | ||
}, | ||
"extractBabelOptions": { | ||
"presets": ["@babel/preset-typescript"] | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"semi": true, | ||
"trailingComma": "none", | ||
"singleQuote": true, | ||
"printWidth": 80, | ||
"importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"], | ||
"importOrderSeparation": true, | ||
"importOrderSortSpecifiers": true | ||
} |
Oops, something went wrong.