Переглянути джерело

fix styling and make PWA - wip - check licensing of assets

Pi 1 рік тому
батько
коміт
18ce1dc4a1

+ 14 - 9
app/rest/query_to_xml.py

@@ -6,7 +6,8 @@
 from bottle import request, template, FormsDict
 from pandas import DataFrame
 from psycopg import Cursor
-from psycopg.sql import SQL, Literal
+from psycopg.sql import SQL, Literal, Identifier
+from typing import List
 
 from ..data.filter import get_filter
 from ..data.util import get_where_include_exclude
@@ -15,7 +16,7 @@ from .form import get_form
 from . import BOOLEAN, PARAMS
 
 
-def get_product_rollup_statement(filters) -> SQL:
+def get_product_rollup_statement(filters, orderby: List[str]) -> SQL:
     _map = { k: k[0] for k in ('product', 'category', 'group') }
     where = [ get_where_include_exclude(
         _map[k], "name", list(include), list(exclude)
@@ -33,12 +34,16 @@ JOIN categories c ON p.category_id = c.id
 JOIN groups g ON c.group_id = g.id
 WHERE {where}
 GROUP BY ROLLUP (g.name, c.name, p.name)
-""").format(where=SQL("\nAND").join(where))
+ORDER BY {orderby}
+""").format(
+        where=SQL("\nAND").join(where),
+        orderby=SQL(", ").join(map(Identifier,orderby)),
+    )
 
 
-def get_inner_query(query: FormsDict) -> SQL:
+def get_inner_query(query: FormsDict, orderby: List[str]) -> SQL:
     filters = get_filter(query, allow=('group', 'category', 'product'))
-    inner = get_product_rollup_statement(filters)
+    inner = get_product_rollup_statement(filters, orderby)
     return inner
 
 
@@ -57,7 +62,7 @@ def get_xml(cur: Cursor, sql: str):
 
 
 def get_products(cur: Cursor, query: FormsDict):
-    inner = get_inner_query(query)
+    inner = get_inner_query(query, ['product', 'category', 'group'])
     form = render_form(cur, inner, query)
     sql = SQL("""
 SELECT
@@ -73,11 +78,11 @@ WHERE q.product IS NOT NULL OR q.group IS NULL
 
 
 def get_categories(cur: Cursor, query: FormsDict):
-    inner = get_inner_query(query)
+    inner = get_inner_query(query, ['category', 'group'])
     form = render_form(cur, inner, query)
     sql = SQL("""
 SELECT
-    "Products" "Product",
+    "Products",
     COALESCE("category", "Categories"||'') "Category",
     COALESCE("group", "Groups"||'') "Group"
 FROM ({inner}) q
@@ -88,7 +93,7 @@ WHERE q.product IS NULL AND (q.category IS NOT NULL OR q.group IS NULL)
 
 
 def get_groups(cur: Cursor, query: FormsDict):
-    inner = get_inner_query(query)
+    inner = get_inner_query(query, ['group',])
     form = render_form(cur, inner, query)
     sql = SQL("""
 SELECT

Різницю між файлами не показано, бо вона завелика
+ 72 - 0
app/rest/static/favicon.svg


Різницю між файлами не показано, бо вона завелика
+ 306 - 0
app/rest/static/favicon_square.svg


+ 22 - 0
app/rest/static/manifest.json

@@ -0,0 +1,22 @@
+{
+  "id": "/grocery",
+  "name": "Grocery Manager Web Application",
+  "short_name": "Grocery",
+  "description": "View trending price data and tracked product info",
+  "start_url": "/grocery/trend",
+  "theme_color": "firebrick",
+  "background_color": "black",
+  "display": "standalone",
+  "icons": [
+    {
+      "src": "/grocery/static/favicon.svg",
+      "sizes": "any",
+      "purpose": "any"
+    },
+    {
+      "src": "/grocery/static/favicon_square.svg",
+      "sizes": "any",
+      "purpose": "any"
+    }
+  ]
+}

+ 9 - 3
app/rest/templates/trend.tpl

@@ -9,6 +9,7 @@
     <link rel="stylesheet" href="https://shandan.one/css/grids-responsive-min.css"/>
     <link rel="stylesheet" href="https://shandan.one/css/responsive-visibility-collapse.css"/>
     <link rel="stylesheet" href="/grocery/static/cloud-gears.css"/>
+    <link rel="manifest" href="/grocery/static/manifest.json"/>
     <style>
 html {
   --scrollbarBG: #333333;
@@ -25,8 +26,13 @@ body {
 }
 .loader-container {
   position: absolute;
-  left: 45vw;
-  top: 45vh;
+  left: 50vw;
+  top: 50vh;
+  margin-top: -5.5em;
+  margin-left: -87.5px;
+  padding-bottom: 2em;
+  height: 9em;
+  width: 175px;
 }
 .loader-container:has(+ .done) {
   display: none;
@@ -58,4 +64,4 @@ div.progress:has(+ .done) label:after {
 {{!form}}
 {{!svg}}
     </body>
-</html>
+</html>

Деякі файли не було показано, через те що забагато файлів було змінено