Moved to Angular 20
Moved to Tailwind 4 Moved to Python 3.13 Enabled arm64/v8 Builds
This commit is contained in:
1 parent
86722e3558
commit
44513dd6be
203 files changed
+2942
-5628
No files matched your search
Vendored
+3
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"python.defaultInterpreterPath": "/home/tanshu/.cache/pypoetry/virtualenvs/barker-3ndhMgBR-py3.12/bin/python",
|
||||
"python.defaultInterpreterPath": "/home/tanshu/.cache/pypoetry/virtualenvs/barker-3ndhMgBR-py3.13/bin/python",
|
||||
"files.exclude": {
|
||||
"**/__pycache__": true,
|
||||
"**/.mypy_cache": true,
|
||||
@@ -12,5 +12,6 @@
|
||||
".idea": true,
|
||||
"**/node_modules": true,
|
||||
"**/package-lock.json": true,
|
||||
}
|
||||
},
|
||||
"makefile.configureOnOpen": false
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ RUN \
|
||||
else echo "Lockfile not found." && exit 1; \
|
||||
fi
|
||||
|
||||
FROM python:3.12 AS runner
|
||||
FROM python:3.13 AS runner
|
||||
LABEL maintainer="Amritanshu <docker@tanshu.com>"
|
||||
|
||||
RUN apt-get update && \
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
.PHONY: build-production
|
||||
build-production: ## Build the production docker image.
|
||||
@docker buildx build \
|
||||
--tag barker:latest \
|
||||
--platform linux/amd64,linux/arm64/v8 \
|
||||
--tag registry.tanshu.com/barker:latest \
|
||||
$(if $(TAG),--tag registry.tanshu.com/barker:$(TAG)) \
|
||||
--push \
|
||||
git@git.tanshu.com:tanshu/barker.git
|
||||
@@ -3,7 +3,7 @@
|
||||
repos:
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
# Ruff version.
|
||||
rev: v0.8.3
|
||||
rev: v0.12.1
|
||||
hooks:
|
||||
# Run the linter.
|
||||
- id: ruff
|
||||
|
||||
@@ -42,14 +42,14 @@ def design_cashier_report(report: CashierReport):
|
||||
now = datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)
|
||||
s = f"{report.cashier.name} Checkout By {report.user.name} @ {now:%d-%b-%Y %H:%M}".center(42)
|
||||
s += "\n\r" + "-" * 42
|
||||
s += "\n\r" f"{report.start_date:%d-%b-%Y} To {report.finish_date:%d-%b-%Y}".center(42)
|
||||
s += f"\n\r{report.start_date:%d-%b-%Y} To {report.finish_date:%d-%b-%Y}".center(42)
|
||||
s += "\n\r" + "-" * 42
|
||||
for item in report.amounts:
|
||||
s += f"\n\r{item.name: <21} : {currency_format(item.amount): >16}"
|
||||
s += "\n\r" + "=" * 42
|
||||
s += f"\n\rActive Cashiers : {report.cashiers}"
|
||||
for so, it in report.info.items():
|
||||
s += f"\n\r" f"--- {so} ".ljust(42, "-")
|
||||
s += f"\n\r--- {so} ".ljust(42, "-")
|
||||
for i in it:
|
||||
s += f"\n\r{i.date} {i.bill_id} {i.customer}"
|
||||
s += f"\n\rAmount: {currency_format(i.amount):9}"
|
||||
|
||||
@@ -40,14 +40,18 @@ def design_product_sale_report(report):
|
||||
now = datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)
|
||||
s = f"{report['userName']} @ {now:%d-%b-%Y %H:%M}".center(42)
|
||||
s += "\n\r" + "-" * 42
|
||||
s += "\n\r" f"{report['startDate']} To {report['finishDate']}".center(42)
|
||||
s += f"\n\r{report['startDate']} To {report['finishDate']}".center(42)
|
||||
s += "\n\r" + "-" * 42
|
||||
s += "\n\rUnbilled Sale NC Staff Void"
|
||||
for item in report["amounts"]:
|
||||
s += f"\n\r{item['name']: ^42.42}" f"\n\r" + (f"{item['kot']: >7.2f} " if "kot" in item else " ") + (
|
||||
f"{item['regularBill']: >7.2f} " if "regularBill" in item else " "
|
||||
) + (f"{item['noCharge']: >7.2f} " if "noCharge" in item else " ") + (
|
||||
f"{item['staff']: >7.2f} " if "staff" in item else " "
|
||||
) + (f"{item['void']: >7.2f}" if "void" in item else " ")
|
||||
s += (
|
||||
f"\n\r{item['name']: ^42.42}"
|
||||
f"\n\r"
|
||||
+ (f"{item['kot']: >7.2f} " if "kot" in item else " ")
|
||||
+ (f"{item['regularBill']: >7.2f} " if "regularBill" in item else " ")
|
||||
+ (f"{item['noCharge']: >7.2f} " if "noCharge" in item else " ")
|
||||
+ (f"{item['staff']: >7.2f} " if "staff" in item else " ")
|
||||
+ (f"{item['void']: >7.2f}" if "void" in item else " ")
|
||||
)
|
||||
s += "\n\r" + "=" * 42
|
||||
return s
|
||||
@@ -42,7 +42,7 @@ def design_sale_report(report: SaleReport):
|
||||
now = datetime.now() + timedelta(minutes=settings.TIMEZONE_OFFSET_MINUTES)
|
||||
s = f"{report.user.name} @ {now:%d-%b-%Y %H:%M}".center(42)
|
||||
s += "\n\r" + "-" * 42
|
||||
s += "\n\r" f"{report.start_date:%d-%b-%Y} To {report.finish_date:%d-%b-%Y}".center(42)
|
||||
s += f"\n\r{report.start_date:%d-%b-%Y} To {report.finish_date:%d-%b-%Y}".center(42)
|
||||
s += "\n\r" + "-" * 42
|
||||
for item in report.amounts:
|
||||
s += f"\n\r{item.name: <29.29} {currency_format(item.amount): >12}"
|
||||
|
||||
@@ -146,7 +146,7 @@ def do_save(
|
||||
if round(i.quantity, 2) < 0 and "edit-printed-product" not in user.permissions:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail=f"You are not allowed to delete printed products." f"\n In this case {product.full_name}",
|
||||
detail=f"You are not allowed to delete printed products.\n In this case {product.full_name}",
|
||||
)
|
||||
tax_rate = get_tax(product.sale_category.tax.rate, voucher_type)
|
||||
inv = Inventory(
|
||||
|
||||
@@ -112,8 +112,7 @@ def save(
|
||||
if happy_hour_items_more_than_regular(inventories):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="When product has happy hours\n"
|
||||
"Minimum same number of regular items also needed in the whole bill.",
|
||||
detail="When product has happy hours\nMinimum same number of regular items also needed in the whole bill.",
|
||||
)
|
||||
kot_id = db.execute(select(func.coalesce(func.max(Voucher.kot_id), 0) + 1)).scalar_one()
|
||||
|
||||
|
||||
+18
-18
@@ -5,28 +5,28 @@ description = "Point of Sale for a restaurant"
|
||||
authors = ["tanshu <git@tanshu.com>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.12"
|
||||
uvicorn = {extras = ["standard"], version = "^0.34.0"}
|
||||
fastapi = {extras = ["all"], version = "^0.115.6"}
|
||||
python = "^3.13"
|
||||
uvicorn = {extras = ["standard"], version = "^0.35.0"}
|
||||
fastapi = {extras = ["all"], version = "^0.115.14"}
|
||||
passlib = {extras = ["bcrypt"], version = "^1.7.4"}
|
||||
psycopg = {extras = ["binary", "pool"], version = "^3.2.3"}
|
||||
SQLAlchemy = "^2.0.36"
|
||||
python-multipart = "^0.0.19"
|
||||
psycopg = {extras = ["binary", "pool"], version = "^3.2.9"}
|
||||
SQLAlchemy = "^2.0.41"
|
||||
python-multipart = "^0.0.20"
|
||||
PyJWT = "^2.10.1"
|
||||
alembic = "^1.14.0"
|
||||
alembic = "^1.16.2"
|
||||
itsdangerous = "^2.2.0"
|
||||
python-dotenv = "^1.0.1"
|
||||
pydantic = {extras = ["dotenv"], version = "^2.10.3"}
|
||||
arq = "^0.26.1"
|
||||
aiohttp = "^3.11.10"
|
||||
cryptography = "^44.0.0"
|
||||
python-dotenv = "^1.1.1"
|
||||
pydantic = {extras = ["dotenv"], version = "^2.11.7"}
|
||||
arq = "^0.26.3"
|
||||
aiohttp = "^3.12.13"
|
||||
cryptography = "^45.0.4"
|
||||
gunicorn = "^23.0.0"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
pre-commit = "^4.0.1"
|
||||
mypy = "^1.13.0"
|
||||
ruff = "^0.8.3"
|
||||
bandit = "^1.8.0"
|
||||
pre-commit = "^4.2.0"
|
||||
mypy = "^1.16.1"
|
||||
ruff = "^0.12.1"
|
||||
bandit = "^1.8.5"
|
||||
# safety = "^3.2.0"
|
||||
|
||||
[build-system]
|
||||
@@ -35,8 +35,8 @@ build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 120
|
||||
# Assume Python 3.12.
|
||||
target-version = "py312"
|
||||
# Assume Python 3.13.
|
||||
target-version = "py313"
|
||||
exclude = [
|
||||
".eggs",
|
||||
".git",
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
/node_modules
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
package-lock.json
|
||||
|
||||
# profiling files
|
||||
chrome-profiler-events*.json
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"plugins": {
|
||||
"@tailwindcss/postcss": {}
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,5 @@ module.exports = {
|
||||
semi: true,
|
||||
singleQuote: true,
|
||||
bracketSpacing: true,
|
||||
printWidth: 120
|
||||
printWidth: 120,
|
||||
};
|
||||
+36
-27
@@ -18,7 +18,7 @@
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:application",
|
||||
"builder": "@angular/build:application",
|
||||
"options": {
|
||||
"outputPath": {
|
||||
"base": "../frontend"
|
||||
@@ -26,14 +26,8 @@
|
||||
"index": "src/index.html",
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"inlineStyleLanguage": "sass",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets"
|
||||
],
|
||||
"styles": [
|
||||
"@angular/material/prebuilt-themes/azure-blue.css",
|
||||
"src/styles.sass"
|
||||
],
|
||||
"assets": ["src/favicon.ico", "src/assets"],
|
||||
"styles": ["@angular/material/prebuilt-themes/azure-blue.css", "src/styles.sass"],
|
||||
"scripts": [],
|
||||
"browser": "src/main.ts"
|
||||
},
|
||||
@@ -63,7 +57,7 @@
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"builder": "@angular/build:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "bookie:build:production"
|
||||
@@ -78,43 +72,58 @@
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"builder": "@angular/build:extract-i18n",
|
||||
"options": {
|
||||
"buildTarget": "bookie:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"builder": "@angular/build:karma",
|
||||
"options": {
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"inlineStyleLanguage": "sass",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets"
|
||||
],
|
||||
"styles": [
|
||||
"@angular/material/prebuilt-themes/azure-blue.css",
|
||||
"src/styles.sass"
|
||||
],
|
||||
"assets": ["src/favicon.ico", "src/assets"],
|
||||
"styles": ["@angular/material/prebuilt-themes/azure-blue.css", "src/styles.sass"],
|
||||
"scripts": []
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"builder": "@angular-eslint/builder:lint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.html"
|
||||
]
|
||||
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"schematicCollections": [
|
||||
"@angular-eslint/schematics"
|
||||
],
|
||||
"schematicCollections": ["@angular-eslint/schematics"],
|
||||
"analytics": false
|
||||
},
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"type": "component"
|
||||
},
|
||||
"@schematics/angular:directive": {
|
||||
"type": "directive"
|
||||
},
|
||||
"@schematics/angular:service": {
|
||||
"type": "service"
|
||||
},
|
||||
"@schematics/angular:guard": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:interceptor": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:module": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:pipe": {
|
||||
"typeSeparator": "."
|
||||
},
|
||||
"@schematics/angular:resolver": {
|
||||
"typeSeparator": "."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
const rule = require("./sort-component-imports");
|
||||
|
||||
module.exports = {
|
||||
rules: {
|
||||
"sort-component-imports": rule
|
||||
}
|
||||
};
|
||||
+45
-45
@@ -1,78 +1,78 @@
|
||||
// @ts-check
|
||||
const eslint = require("@eslint/js");
|
||||
const tseslint = require("typescript-eslint");
|
||||
const angular = require("angular-eslint");
|
||||
const eslintConfigPrettier = require("eslint-config-prettier");
|
||||
const pluginImport = require("eslint-plugin-import");
|
||||
const unusedImports = require("eslint-plugin-unused-imports");
|
||||
const sortImports = require("./eslint-plugin-sort-component-imports");
|
||||
const eslint = require('@eslint/js');
|
||||
const tseslint = require('typescript-eslint');
|
||||
const angular = require('angular-eslint');
|
||||
const eslintConfigPrettier = require('eslint-config-prettier');
|
||||
const unusedImports = require('eslint-plugin-unused-imports');
|
||||
const perfectionist = require('eslint-plugin-perfectionist');
|
||||
|
||||
module.exports = tseslint.config(
|
||||
{
|
||||
files: ["**/*.ts"],
|
||||
files: ['**/*.ts'],
|
||||
extends: [
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
...tseslint.configs.stylistic,
|
||||
...angular.configs.tsRecommended,
|
||||
eslintConfigPrettier
|
||||
eslintConfigPrettier,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: './tsconfig.json', // <-- REQUIRED
|
||||
tsconfigRootDir: __dirname,
|
||||
},
|
||||
},
|
||||
|
||||
processor: angular.processInlineTemplates,
|
||||
plugins: {
|
||||
unusedImports: unusedImports,
|
||||
import: pluginImport,
|
||||
sortImports: sortImports,
|
||||
perfectionist: perfectionist,
|
||||
},
|
||||
rules: {
|
||||
"@angular-eslint/directive-selector": [
|
||||
"error",
|
||||
'@angular-eslint/directive-selector': [
|
||||
'error',
|
||||
{
|
||||
type: "attribute",
|
||||
prefix: "app",
|
||||
style: "camelCase",
|
||||
type: 'attribute',
|
||||
prefix: 'app',
|
||||
style: 'camelCase',
|
||||
},
|
||||
],
|
||||
"@angular-eslint/component-selector": [
|
||||
"error",
|
||||
'@angular-eslint/component-selector': [
|
||||
'error',
|
||||
{
|
||||
type: "element",
|
||||
prefix: "app",
|
||||
style: "kebab-case",
|
||||
type: 'element',
|
||||
prefix: 'app',
|
||||
style: 'kebab-case',
|
||||
},
|
||||
],
|
||||
"@/lines-between-class-members": [
|
||||
"error",
|
||||
"always",
|
||||
'@angular-eslint/prefer-inject': 'error',
|
||||
'@/lines-between-class-members': [
|
||||
'error',
|
||||
'always',
|
||||
{
|
||||
"exceptAfterSingleLine": true
|
||||
}
|
||||
exceptAfterSingleLine: true,
|
||||
},
|
||||
],
|
||||
"import/order": [
|
||||
"error",
|
||||
'no-duplicate-imports': 'error',
|
||||
'@typescript-eslint/no-explicit-any': ['error'],
|
||||
'unusedImports/no-unused-imports': 'error',
|
||||
'@typescript-eslint/no-empty-function': 'off',
|
||||
'@typescript-eslint/no-deprecated': 'error',
|
||||
'perfectionist/sort-imports': [
|
||||
'error',
|
||||
{
|
||||
"alphabetize": {
|
||||
"order": "asc",
|
||||
"caseInsensitive": true
|
||||
},
|
||||
"newlines-between": "always"
|
||||
}
|
||||
type: 'natural',
|
||||
order: 'asc',
|
||||
},
|
||||
],
|
||||
"no-duplicate-imports" : "error",
|
||||
"@typescript-eslint/no-explicit-any": [
|
||||
"error"
|
||||
],
|
||||
"unusedImports/no-unused-imports": "error",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"import/no-deprecated": "warn",
|
||||
"sortImports/sort-component-imports": "error",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["**/*.html"],
|
||||
files: ['**/*.html'],
|
||||
extends: [
|
||||
...angular.configs.templateRecommended,
|
||||
// ...angular.configs.templateAccessibility,
|
||||
],
|
||||
rules: {},
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -10,7 +10,7 @@ module.exports = function (config) {
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage'),
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
],
|
||||
client: {
|
||||
jasmine: {
|
||||
@@ -19,18 +19,15 @@ module.exports = function (config) {
|
||||
// for example, you can disable the random execution with `random: false`
|
||||
// or set a specific seed with `seed: 4321`
|
||||
},
|
||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||
clearContext: false, // leave Jasmine Spec Runner output visible in browser
|
||||
},
|
||||
jasmineHtmlReporter: {
|
||||
suppressAll: true // removes the duplicated traces
|
||||
suppressAll: true, // removes the duplicated traces
|
||||
},
|
||||
coverageReporter: {
|
||||
dir: require('path').join(__dirname, './coverage/bookie'),
|
||||
subdir: '.',
|
||||
reporters: [
|
||||
{ type: 'html' },
|
||||
{ type: 'text-summary' }
|
||||
]
|
||||
reporters: [{ type: 'html' }, { type: 'text-summary' }],
|
||||
},
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
@@ -39,6 +36,6 @@ module.exports = function (config) {
|
||||
autoWatch: true,
|
||||
browsers: ['Chrome'],
|
||||
singleRun: false,
|
||||
restartOnFileChange: true
|
||||
restartOnFileChange: true,
|
||||
});
|
||||
};
|
||||
+25
-23
@@ -14,33 +14,35 @@
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^19.0.4",
|
||||
"@angular/cdk": "^19.0.3",
|
||||
"@angular/common": "^19.0.4",
|
||||
"@angular/compiler": "^19.0.4",
|
||||
"@angular/core": "^19.0.4",
|
||||
"@angular/forms": "^19.0.4",
|
||||
"@angular/material": "^19.0.3",
|
||||
"@angular/material-moment-adapter": "^19.0.3",
|
||||
"@angular/platform-browser": "^19.0.4",
|
||||
"@angular/platform-browser-dynamic": "^19.0.4",
|
||||
"@angular/router": "^19.0.4",
|
||||
"@angular/animations": "^20.0.6",
|
||||
"@angular/cdk": "^20.0.4",
|
||||
"@angular/common": "^20.0.6",
|
||||
"@angular/compiler": "^20.0.6",
|
||||
"@angular/core": "^20.0.6",
|
||||
"@angular/forms": "^20.0.6",
|
||||
"@angular/material": "^20.0.4",
|
||||
"@angular/material-moment-adapter": "^20.0.4",
|
||||
"@angular/platform-browser": "^20.0.6",
|
||||
"@angular/platform-browser-dynamic": "^20.0.6",
|
||||
"@angular/router": "^20.0.6",
|
||||
"mathjs": "^14.0.1",
|
||||
"moment": "^2.30.1",
|
||||
"rxjs": "~7.8.0",
|
||||
"tslib": "^2.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^19.0.5",
|
||||
"@angular/cli": "^19.0.5",
|
||||
"@angular/compiler-cli": "^19.0.4",
|
||||
"@angular/language-service": "^19.0.4",
|
||||
"@angular/build": "^20.0.5",
|
||||
"@angular/cli": "^20.0.5",
|
||||
"@angular/compiler-cli": "^20.0.6",
|
||||
"@angular/language-service": "^20.0.6",
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@types/jasmine": "~5.1.4",
|
||||
"angular-eslint": "^19.0.2",
|
||||
"angular-eslint": "^20.1.1",
|
||||
"autoprefixer": "^10.4.19",
|
||||
"eslint": "^9.17.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint": "^9.28.0",
|
||||
"eslint-config-prettier": "^10.1.5",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-perfectionist": "^4.15.0",
|
||||
"eslint-plugin-unused-imports": "^4.1.4",
|
||||
"husky": "^9.1.7",
|
||||
"jasmine-core": "^5.5.0",
|
||||
@@ -49,13 +51,13 @@
|
||||
"karma-coverage": "^2.2.1",
|
||||
"karma-jasmine": "~5.1.0",
|
||||
"karma-jasmine-html-reporter": "~2.1.0",
|
||||
"lint-staged": "^15.2.11",
|
||||
"postcss": "^8.4.27",
|
||||
"lint-staged": "^16.1.2",
|
||||
"postcss": "^8.5.6",
|
||||
"prettier": "^3.4.2",
|
||||
"standard-version": "^9.5.0",
|
||||
"tailwindcss": "^3.4.16",
|
||||
"typescript": "~5.6.3",
|
||||
"typescript-eslint": "^8.0.0"
|
||||
"tailwindcss": "^4.1.11",
|
||||
"typescript": "~5.8.3",
|
||||
"typescript-eslint": "^8.33.1"
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
"secure": false,
|
||||
"logLevel": "debug"
|
||||
},
|
||||
"/token": {
|
||||
"/token": {
|
||||
"target": "http://localhost:9995",
|
||||
"secure": false,
|
||||
"logLevel": "info"
|
||||
},
|
||||
"/refresh": {
|
||||
"/refresh": {
|
||||
"target": "http://localhost:9995",
|
||||
"secure": false,
|
||||
"logLevel": "info"
|
||||
},
|
||||
"/db-image": {
|
||||
"/db-image": {
|
||||
"target": "http://localhost:9995",
|
||||
"secure": false,
|
||||
"logLevel": "info"
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
/**
|
||||
* @fileoverview ESLint rule to enforce sorted imports arrays in Angular @Component decorators.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
docs: {
|
||||
description: "Enforce sorted imports array in Angular @Component decorators",
|
||||
category: "Stylistic Issues",
|
||||
recommended: false,
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [] // no options
|
||||
},
|
||||
|
||||
create(context) {
|
||||
return {
|
||||
Decorator(node) {
|
||||
// Look for @Component decorator
|
||||
if (
|
||||
node.expression &&
|
||||
node.expression.callee &&
|
||||
node.expression.callee.name === "Component" &&
|
||||
node.expression.arguments &&
|
||||
node.expression.arguments.length > 0
|
||||
) {
|
||||
const arg = node.expression.arguments[0];
|
||||
if (arg && arg.type === "ObjectExpression") {
|
||||
// Find the 'imports' property
|
||||
const importsProperty = arg.properties.find(
|
||||
(prop) =>
|
||||
prop.type === "Property" &&
|
||||
((prop.key.type === "Identifier" && prop.key.name === "imports") ||
|
||||
(prop.key.type === "Literal" && prop.key.value === "imports"))
|
||||
);
|
||||
|
||||
if (importsProperty && importsProperty.value.type === "ArrayExpression") {
|
||||
const elements = importsProperty.value.elements;
|
||||
|
||||
// Extract the names from the elements
|
||||
// Assuming elements are simple Identifiers or Literals
|
||||
const elementNames = elements.map((el) => {
|
||||
if (!el) return "";
|
||||
if (el.type === "Identifier") {
|
||||
return el.name;
|
||||
} else if (el.type === "Literal" && typeof el.value === "string") {
|
||||
return el.value;
|
||||
} else {
|
||||
return ""; // Non-standard entry, skip sorting
|
||||
}
|
||||
});
|
||||
|
||||
// Check if sorted
|
||||
const sorted = [...elementNames].sort((a, b) =>
|
||||
a.localeCompare(b, undefined, { sensitivity: "base" })
|
||||
);
|
||||
|
||||
// Compare elementNames and sorted
|
||||
let isSorted = true;
|
||||
for (let i = 0; i < elementNames.length; i++) {
|
||||
if (elementNames[i] !== sorted[i]) {
|
||||
isSorted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isSorted) {
|
||||
// Report and fix
|
||||
context.report({
|
||||
node: importsProperty,
|
||||
message: "The imports array in @Component should be sorted alphabetically.",
|
||||
fix: (fixer) => {
|
||||
// Build a sorted array expression text
|
||||
const sourceCode = context.getSourceCode();
|
||||
const sortedElements = [];
|
||||
for (const name of sorted) {
|
||||
// Attempt to find original element to preserve formatting if possible
|
||||
const originalElement = elements.find((el) => {
|
||||
if (!el) return false;
|
||||
if (el.type === "Identifier" && el.name === name) return true;
|
||||
if (el.type === "Literal" && el.value === name) return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
if (originalElement) {
|
||||
sortedElements.push(sourceCode.getText(originalElement));
|
||||
} else {
|
||||
// fallback: write identifier as is
|
||||
// If it's a string, wrap in quotes
|
||||
const isIdentifier = /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);
|
||||
sortedElements.push(isIdentifier ? name : `'${name}'`);
|
||||
}
|
||||
}
|
||||
|
||||
const arrayText = `[${sortedElements.join(", ")}]`;
|
||||
|
||||
const importsValue = importsProperty.value;
|
||||
return fixer.replaceTextRange(
|
||||
[importsValue.range[0], importsValue.range[1]],
|
||||
arrayText
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -1,12 +1,8 @@
|
||||
import { LayoutModule } from '@angular/cdk/layout';
|
||||
import { provideHttpClient, withInterceptors } from '@angular/common/http';
|
||||
import {
|
||||
ApplicationConfig,
|
||||
LOCALE_ID,
|
||||
importProvidersFrom,
|
||||
provideExperimentalZonelessChangeDetection,
|
||||
} from '@angular/core';
|
||||
import { ApplicationConfig, LOCALE_ID, importProvidersFrom, provideZonelessChangeDetection } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE } from '@angular/material/core';
|
||||
@@ -22,7 +18,6 @@ import { MAT_SNACK_BAR_DEFAULT_OPTIONS, MatSnackBarModule } from '@angular/mater
|
||||
import { MatSortModule } from '@angular/material/sort';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
import { MomentDateAdapter } from '@angular/material-moment-adapter';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { provideAnimations } from '@angular/platform-browser/animations';
|
||||
import { provideRouter, withRouterConfig } from '@angular/router';
|
||||
@@ -68,6 +63,6 @@ export const appConfig: ApplicationConfig = {
|
||||
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
|
||||
{ provide: MAT_DATE_FORMATS, useValue: dateFormat },
|
||||
{ provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: { duration: 3000 } },
|
||||
provideExperimentalZonelessChangeDetection(),
|
||||
provideZonelessChangeDetection(),
|
||||
],
|
||||
};
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { CanActivateFn, Router } from '@angular/router';
|
||||
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
|
||||
import { AuthService } from './auth.service';
|
||||
|
||||
export const authGuard: CanActivateFn = (route, state) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@@ -15,15 +15,15 @@ const JWT_USER = 'JWT_USER';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class AuthService {
|
||||
private http = inject(HttpClient);
|
||||
private cs = inject(CookieService);
|
||||
|
||||
public currentUser: Observable<User | null>;
|
||||
public device: Device;
|
||||
private currentUserSubject: BehaviorSubject<User | null> = new BehaviorSubject<User | null>(null);
|
||||
public isRefreshing = false;
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private cs: CookieService,
|
||||
) {
|
||||
constructor() {
|
||||
this.checkStorage();
|
||||
this.currentUser = this.currentUserSubject.asObservable();
|
||||
const deviceId = this.cs.getCookie('device_id');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -27,6 +27,13 @@ import { AuthService } from '../auth.service';
|
||||
],
|
||||
})
|
||||
export class LoginComponent implements OnInit, AfterViewInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private auth = inject(AuthService);
|
||||
private router = inject(Router);
|
||||
private toaster = inject(ToasterService);
|
||||
private cs = inject(CookieService);
|
||||
private cd = inject(ChangeDetectorRef);
|
||||
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: FormGroup<{
|
||||
username: FormControl<string>;
|
||||
@@ -38,14 +45,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
|
||||
deviceName: string;
|
||||
private returnUrl: string;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private auth: AuthService,
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private cs: CookieService,
|
||||
private cd: ChangeDetectorRef,
|
||||
) {
|
||||
constructor() {
|
||||
this.hide = true;
|
||||
this.unregisteredDevice = false;
|
||||
this.deviceName = '';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
|
||||
import { AuthService } from '../auth.service';
|
||||
|
||||
@@ -8,7 +8,7 @@ import { AuthService } from '../auth.service';
|
||||
standalone: true,
|
||||
})
|
||||
export class LogoutComponent implements OnInit {
|
||||
constructor(private auth: AuthService) {}
|
||||
private auth = inject(AuthService);
|
||||
|
||||
ngOnInit() {
|
||||
this.auth.logout();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -12,7 +12,6 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import moment from 'moment';
|
||||
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { BeerSaleExportHeaderInterface } from './beer-sale-export-header-interface';
|
||||
import { BeerSaleReport } from './beer-sale-report';
|
||||
import { BeerSaleReportDataSource } from './beer-sale-report-datasource';
|
||||
@@ -34,6 +33,10 @@ import { BeerSaleReportDataSource } from './beer-sale-report-datasource';
|
||||
],
|
||||
})
|
||||
export class BeerSaleReportComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toCsv = inject(ToCsvService);
|
||||
|
||||
info: BeerSaleReport = new BeerSaleReport();
|
||||
dataSource: BeerSaleReportDataSource = new BeerSaleReportDataSource(this.info.data);
|
||||
form: FormGroup<{
|
||||
@@ -48,11 +51,7 @@ export class BeerSaleReportComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns: string[] = ['date'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toCsv: ToCsvService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
startDate: new FormControl(new Date(), { nonNullable: true }),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { BeerSaleReportComponent } from './beer-sale-report.component';
|
||||
import { beerSaleReportResolver } from './beer-sale-report.resolver';
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { BeerSaleReport } from './beer-sale-report';
|
||||
|
||||
const url = '/api/beer-sale-report';
|
||||
@@ -14,10 +13,8 @@ const serviceName = 'BeerSaleReportService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BeerSaleReportService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(
|
||||
startDate: string | null,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -13,7 +13,6 @@ import moment from 'moment';
|
||||
|
||||
import { LocalTimePipe } from '../shared/local-time.pipe';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { BillSettlementReport } from './bill-settlement-report';
|
||||
import { BillSettlementReportDataSource } from './bill-settlement-report-datasource';
|
||||
|
||||
@@ -35,6 +34,10 @@ import { BillSettlementReportDataSource } from './bill-settlement-report-datasou
|
||||
],
|
||||
})
|
||||
export class BillSettlementReportComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toCsv = inject(ToCsvService);
|
||||
|
||||
info: BillSettlementReport = new BillSettlementReport();
|
||||
dataSource: BillSettlementReportDataSource = new BillSettlementReportDataSource(this.info.amounts);
|
||||
|
||||
@@ -46,11 +49,7 @@ export class BillSettlementReportComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['date', 'billId', 'amount', 'settlement'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toCsv: ToCsvService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
startDate: new FormControl(new Date(), { nonNullable: true }),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { BillSettlementReportComponent } from './bill-settlement-report.component';
|
||||
import { billSettlementReportResolver } from './bill-settlement-report.resolver';
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { BillSettlementReport } from './bill-settlement-report';
|
||||
|
||||
const url = '/api/bill-settlement-report';
|
||||
@@ -14,10 +13,8 @@ const serviceName = 'BillSettlementReportService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class BillSettlementReportService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(startDate: string | null, finishDate: string | null): Observable<BillSettlementReport> {
|
||||
const options = { params: new HttpParams() };
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { User } from '../core/user';
|
||||
|
||||
import { CashierReportService } from './cashier-report.service';
|
||||
|
||||
export const activeCashiersResolver: ResolveFn<User[]> = (route) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CurrencyPipe } from '@angular/common';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -16,7 +16,6 @@ import moment from 'moment';
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { User } from '../core/user';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { CashierReport } from './cashier-report';
|
||||
import { CashierReportDataSource } from './cashier-report-datasource';
|
||||
import { CashierReportService } from './cashier-report.service';
|
||||
@@ -40,6 +39,12 @@ import { CashierReportService } from './cashier-report.service';
|
||||
],
|
||||
})
|
||||
export class CashierReportComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toCsv = inject(ToCsvService);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(CashierReportService);
|
||||
|
||||
activeCashiers: User[] = [];
|
||||
info: CashierReport = new CashierReport();
|
||||
dataSource: CashierReportDataSource = new CashierReportDataSource(this.info.amounts);
|
||||
@@ -52,13 +57,7 @@ export class CashierReportComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'amount'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toCsv: ToCsvService,
|
||||
private toaster: ToasterService,
|
||||
private ser: CashierReportService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
startDate: new FormControl(new Date(), { nonNullable: true }),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { activeCashiersResolver } from './active-cashiers.resolver';
|
||||
import { CashierReportComponent } from './cashier-report.component';
|
||||
import { cashierReportResolver } from './cashier-report.resolver';
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
import { User } from '../core/user';
|
||||
|
||||
import { CashierReport } from './cashier-report';
|
||||
|
||||
const url = '/api/cashier-report';
|
||||
@@ -15,10 +14,8 @@ const serviceName = 'CashierReportService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CashierReportService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
list(id: string | null, startDate: string | null, finishDate: string | null): Observable<CashierReport> {
|
||||
const listUrl = id === null ? url : `${url}/${id}`;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { User } from '../core/user';
|
||||
|
||||
import { CashierReportDisplayItem } from './cashier-report-display-item';
|
||||
import { CashierReportPrintItem } from './cashier-report-print-item';
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { AuthService } from '../auth/auth.service';
|
||||
import { ConfirmDialogComponent } from '../shared/confirm-dialog/confirm-dialog.component';
|
||||
|
||||
import { ToasterService } from './toaster.service';
|
||||
|
||||
export const authInterceptor: HttpInterceptorFn = (req, next) => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { VoucherType } from '../sales/bills/voucher-type';
|
||||
|
||||
import { ReportingLevel } from './reporting-level';
|
||||
|
||||
export class SettleOption {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ToasterService {
|
||||
constructor(private snackBar: MatSnackBar) {}
|
||||
private snackBar = inject(MatSnackBar);
|
||||
|
||||
show(type: string, msg: string) {
|
||||
this.snackBar.open(msg, type, {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PercentPipe } from '@angular/common';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { FormArray, FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -32,6 +32,12 @@ import { CustomerService } from '../customer.service';
|
||||
],
|
||||
})
|
||||
export class CustomerDetailComponent implements OnInit, AfterViewInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toaster = inject(ToasterService);
|
||||
private dialog = inject(MatDialog);
|
||||
private ser = inject(CustomerService);
|
||||
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
@@ -48,13 +54,7 @@ export class CustomerDetailComponent implements OnInit, AfterViewInit {
|
||||
item: Customer = new Customer();
|
||||
hide: boolean;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private dialog: MatDialog,
|
||||
private ser: CustomerService,
|
||||
) {
|
||||
constructor() {
|
||||
this.hide = true;
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Customer } from '../core/customer';
|
||||
|
||||
import { CustomerService } from './customer.service';
|
||||
|
||||
export const customerListResolver: ResolveFn<Customer[]> = () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PercentPipe } from '@angular/common';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -7,7 +7,6 @@ import { MatTableModule } from '@angular/material/table';
|
||||
import { ActivatedRoute, RouterLink } from '@angular/router';
|
||||
|
||||
import { Customer } from '../../core/customer';
|
||||
|
||||
import { CustomerListDatasource } from './customer-list-datasource';
|
||||
|
||||
@Component({
|
||||
@@ -17,13 +16,13 @@ import { CustomerListDatasource } from './customer-list-datasource';
|
||||
imports: [MatButtonModule, MatCardModule, MatIconModule, MatTableModule, PercentPipe, RouterLink],
|
||||
})
|
||||
export class CustomerListComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
|
||||
dataSource: CustomerListDatasource = new CustomerListDatasource([]);
|
||||
list: Customer[] = [];
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'phone', 'address', 'printInBill', 'discounts'];
|
||||
|
||||
constructor(private route: ActivatedRoute) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: Customer[] };
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Customer } from '../core/customer';
|
||||
|
||||
import { CustomerService } from './customer.service';
|
||||
|
||||
export const customerResolver: ResolveFn<Customer> = (route) => {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { CustomerDetailComponent } from './customer-detail/customer-detail.component';
|
||||
import { CustomerListComponent } from './customer-list/customer-list.component';
|
||||
import { customerListResolver } from './customer-list.resolver';
|
||||
import { CustomerListComponent } from './customer-list/customer-list.component';
|
||||
import { customerResolver } from './customer.resolver';
|
||||
|
||||
export const routes: Routes = [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@@ -16,10 +16,8 @@ const serviceName = 'CustomerService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CustomerService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(id: string | null): Observable<Customer> {
|
||||
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -34,6 +34,12 @@ import { DeviceService } from '../device.service';
|
||||
],
|
||||
})
|
||||
export class DeviceDetailComponent implements OnInit, AfterViewInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private dialog = inject(MatDialog);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(DeviceService);
|
||||
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
@@ -44,13 +50,7 @@ export class DeviceDetailComponent implements OnInit, AfterViewInit {
|
||||
sections: Section[] = [];
|
||||
item: Device = new Device();
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
private ser: DeviceService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl<string>('', { nonNullable: true }),
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Device } from '../core/device';
|
||||
|
||||
import { DeviceService } from './device.service';
|
||||
|
||||
export const deviceListResolver: ResolveFn<Device[]> = () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -7,7 +7,6 @@ import { ActivatedRoute, RouterLink } from '@angular/router';
|
||||
|
||||
import { Device } from '../../core/device';
|
||||
import { LocalTimePipe } from '../../shared/local-time.pipe';
|
||||
|
||||
import { DeviceListDataSource } from './device-list-datasource';
|
||||
|
||||
@Component({
|
||||
@@ -17,13 +16,13 @@ import { DeviceListDataSource } from './device-list-datasource';
|
||||
imports: [LocalTimePipe, MatButtonModule, MatCardModule, MatIconModule, MatTableModule, RouterLink],
|
||||
})
|
||||
export class DeviceListComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
|
||||
list: Device[] = [];
|
||||
dataSource: DeviceListDataSource = new DeviceListDataSource(this.list);
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'section', 'enabled', 'creationDate', 'last'];
|
||||
|
||||
constructor(private route: ActivatedRoute) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: Device[] };
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Device } from '../core/device';
|
||||
|
||||
import { DeviceService } from './device.service';
|
||||
|
||||
export const deviceResolver: ResolveFn<Device> = (route) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@@ -13,10 +13,8 @@ const serviceName = 'DeviceService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DeviceService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(id: string | null): Observable<Device> {
|
||||
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
|
||||
|
||||
@@ -2,10 +2,9 @@ import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
import { sectionListResolver } from '../sections/section-list.resolver';
|
||||
|
||||
import { DeviceDetailComponent } from './device-detail/device-detail.component';
|
||||
import { DeviceListComponent } from './device-list/device-list.component';
|
||||
import { deviceListResolver } from './device-list.resolver';
|
||||
import { DeviceListComponent } from './device-list/device-list.component';
|
||||
import { deviceResolver } from './device.resolver';
|
||||
|
||||
export const routes: Routes = [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CurrencyPipe } from '@angular/common';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -13,7 +13,6 @@ import moment from 'moment';
|
||||
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { DiscountReport } from './discount-report';
|
||||
import { DiscountReportDataSource } from './discount-report-datasource';
|
||||
import { DiscountReportService } from './discount-report.service';
|
||||
@@ -35,6 +34,12 @@ import { DiscountReportService } from './discount-report.service';
|
||||
],
|
||||
})
|
||||
export class DiscountReportComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toCsv = inject(ToCsvService);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(DiscountReportService);
|
||||
|
||||
info: DiscountReport = new DiscountReport();
|
||||
dataSource: DiscountReportDataSource = new DiscountReportDataSource(this.info.amounts);
|
||||
form: FormGroup<{
|
||||
@@ -45,13 +50,7 @@ export class DiscountReportComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'amount'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toCsv: ToCsvService,
|
||||
private toaster: ToasterService,
|
||||
private ser: DiscountReportService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
startDate: new FormControl(new Date(), { nonNullable: true }),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { DiscountReportComponent } from './discount-report.component';
|
||||
import { discountReportResolver } from './discount-report.resolver';
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { DiscountReport } from './discount-report';
|
||||
|
||||
const url = '/api/discount-report';
|
||||
@@ -14,10 +13,8 @@ const serviceName = 'DiscountReportService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class DiscountReportService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(startDate: string | null, finishDate: string | null): Observable<DiscountReport> {
|
||||
const options = { params: new HttpParams() };
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatAutocompleteSelectedEvent, MatAutocompleteModule } from '@angular/material/autocomplete';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
@@ -38,6 +38,13 @@ import { GuestBookService } from '../guest-book.service';
|
||||
],
|
||||
})
|
||||
export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private dialog = inject(MatDialog);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(GuestBookService);
|
||||
private customerService = inject(CustomerService);
|
||||
|
||||
@ViewChild('phone', { static: true }) phoneElement?: ElementRef;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
@@ -53,14 +60,7 @@ export class GuestBookDetailComponent implements OnInit, AfterViewInit {
|
||||
item: GuestBook = new GuestBook();
|
||||
customers: Observable<Customer[]>;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
private ser: GuestBookService,
|
||||
private customerService: CustomerService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl('', { validators: Validators.required, nonNullable: true }),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -17,7 +17,6 @@ import { LocalTimePipe } from '../../shared/local-time.pipe';
|
||||
import { GuestBook } from '../guest-book';
|
||||
import { GuestBookList } from '../guest-book-list';
|
||||
import { GuestBookService } from '../guest-book.service';
|
||||
|
||||
import { GuestBookListDataSource } from './guest-book-list-datasource';
|
||||
|
||||
@Component({
|
||||
@@ -39,6 +38,11 @@ import { GuestBookListDataSource } from './guest-book-list-datasource';
|
||||
],
|
||||
})
|
||||
export class GuestBookListComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(GuestBookService);
|
||||
|
||||
data: BehaviorSubject<GuestBook[]> = new BehaviorSubject<GuestBook[]>([]);
|
||||
dataSource: GuestBookListDataSource = new GuestBookListDataSource(this.data);
|
||||
form: FormGroup<{
|
||||
@@ -48,12 +52,7 @@ export class GuestBookListComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['sno', 'name', 'phone', 'pax', 'date', 'action'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private ser: GuestBookService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
date: new FormControl(new Date(), { nonNullable: true }),
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { GuestBookDetailComponent } from './guest-book-detail/guest-book-detail.component';
|
||||
import { guestBookDetailResolver } from './guest-book-detail.resolver';
|
||||
import { GuestBookListComponent } from './guest-book-list/guest-book-list.component';
|
||||
import { GuestBookDetailComponent } from './guest-book-detail/guest-book-detail.component';
|
||||
import { guestBookListResolver } from './guest-book-list.resolver';
|
||||
import { GuestBookListComponent } from './guest-book-list/guest-book-list.component';
|
||||
|
||||
export const routes: Routes = [
|
||||
{
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { GuestBook } from './guest-book';
|
||||
import { GuestBookList } from './guest-book-list';
|
||||
|
||||
@@ -17,10 +16,8 @@ const serviceName = 'GuestBookService';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class GuestBookService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(id: string | null, type: string): Observable<GuestBook> {
|
||||
const options = { params: new HttpParams().set('t', type) };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -12,7 +12,6 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
|
||||
import { HeaderFooter } from './header-footer';
|
||||
import { HeaderFooterService } from './header-footer.service';
|
||||
|
||||
@@ -32,6 +31,12 @@ import { HeaderFooterService } from './header-footer.service';
|
||||
],
|
||||
})
|
||||
export class HeaderFooterComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toaster = inject(ToasterService);
|
||||
private dialog = inject(MatDialog);
|
||||
private ser = inject(HeaderFooterService);
|
||||
|
||||
@ViewChild('section', { static: true }) sectionElement?: ElementRef;
|
||||
form: FormGroup<{
|
||||
id: FormControl<string>;
|
||||
@@ -41,13 +46,9 @@ export class HeaderFooterComponent implements OnInit {
|
||||
list: HeaderFooter[] = [];
|
||||
id = '';
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private dialog: MatDialog,
|
||||
private ser: HeaderFooterService,
|
||||
) {
|
||||
constructor() {
|
||||
const route = this.route;
|
||||
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
id: new FormControl<string>('', { nonNullable: true }),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { HeaderFooterComponent } from './header-footer.component';
|
||||
import { headerFooterResolver } from './header-footer.resolver';
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { HeaderFooter } from './header-footer';
|
||||
|
||||
const httpOptions = {
|
||||
@@ -17,10 +16,8 @@ const serviceName = 'HeaderFooterService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class HeaderFooterService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
list(): Observable<HeaderFooter[]> {
|
||||
return this.http.get<HeaderFooter[]>(url).pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { RouterLink } from '@angular/router';
|
||||
|
||||
@@ -12,9 +12,11 @@ import { AuthService } from '../auth/auth.service';
|
||||
imports: [MatCardModule, RouterLink],
|
||||
})
|
||||
export class HomeComponent {
|
||||
auth = inject(AuthService);
|
||||
|
||||
version: string;
|
||||
|
||||
constructor(public auth: AuthService) {
|
||||
constructor() {
|
||||
this.version = environment.version;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { MenuCategoryDetailComponent } from './menu-category-detail/menu-category-detail.component';
|
||||
import { MenuCategoryListComponent } from './menu-category-list/menu-category-list.component';
|
||||
import { menuCategoryListResolver } from './menu-category-list.resolver';
|
||||
import { MenuCategoryListComponent } from './menu-category-list/menu-category-list.component';
|
||||
import { menuCategoryResolver } from './menu-category.resolver';
|
||||
|
||||
export const routes: Routes = [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -20,6 +20,12 @@ import { MenuCategoryService } from '../menu-category.service';
|
||||
imports: [MatButtonModule, MatCardModule, MatCheckboxModule, MatFormFieldModule, MatInputModule, ReactiveFormsModule],
|
||||
})
|
||||
export class MenuCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private dialog = inject(MatDialog);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(MenuCategoryService);
|
||||
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
@@ -28,13 +34,7 @@ export class MenuCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
item: MenuCategory = new MenuCategory();
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
private ser: MenuCategoryService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl<string>('', { nonNullable: true }),
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { MenuCategory } from '../core/menu-category';
|
||||
|
||||
import { MenuCategoryService } from './menu-category.service';
|
||||
|
||||
export const menuCategoryListResolver: ResolveFn<MenuCategory[]> = () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CdkDragDrop, moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -10,7 +10,6 @@ import { BehaviorSubject } from 'rxjs';
|
||||
import { MenuCategory } from '../../core/menu-category';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { MenuCategoryService } from '../menu-category.service';
|
||||
|
||||
import { MenuCategoryListDatasource } from './menu-category-list-datasource';
|
||||
|
||||
@Component({
|
||||
@@ -20,6 +19,11 @@ import { MenuCategoryListDatasource } from './menu-category-list-datasource';
|
||||
imports: [DragDropModule, MatButtonModule, MatCardModule, MatIconModule, MatTableModule, RouterLink],
|
||||
})
|
||||
export class MenuCategoryListComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(MenuCategoryService);
|
||||
|
||||
// @ViewChild('table', { static: true }) table?: MatTable<MenuCategory>;
|
||||
list: MenuCategory[] = [];
|
||||
data: BehaviorSubject<MenuCategory[]> = new BehaviorSubject<MenuCategory[]>(this.list);
|
||||
@@ -27,12 +31,7 @@ export class MenuCategoryListComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'isActive', 'isFixture'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private ser: MenuCategoryService,
|
||||
) {
|
||||
constructor() {
|
||||
this.data.subscribe((data: MenuCategory[]) => {
|
||||
this.list = data;
|
||||
});
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { MenuCategory } from '../core/menu-category';
|
||||
|
||||
import { MenuCategoryService } from './menu-category.service';
|
||||
|
||||
export const menuCategoryResolver: ResolveFn<MenuCategory> = (route) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@@ -16,10 +16,8 @@ const serviceName = 'MenuCategoryService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MenuCategoryService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(id: string | null): Observable<MenuCategory> {
|
||||
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DecimalPipe, PercentPipe } from '@angular/common';
|
||||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
|
||||
import { Component, OnInit, ViewChild, ElementRef, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -17,7 +17,6 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
||||
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { MenuEngineeringReport } from './menu-engineering-report';
|
||||
import { MenuEngineeringReportDataSource } from './menu-engineering-report-datasource';
|
||||
import { MenuEngineeringReportService } from './menu-engineering-report.service';
|
||||
@@ -42,6 +41,12 @@ import { MenuEngineeringReportService } from './menu-engineering-report.service'
|
||||
],
|
||||
})
|
||||
export class MenuEngineeringReportComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toCsv = inject(ToCsvService);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(MenuEngineeringReportService);
|
||||
|
||||
@ViewChild('filterElement', { static: true }) filterElement?: ElementRef;
|
||||
@ViewChild(MatPaginator, { static: true }) paginator?: MatPaginator;
|
||||
@ViewChild(MatSort, { static: true }) sort?: MatSort;
|
||||
@@ -57,13 +62,7 @@ export class MenuEngineeringReportComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'price', 'saleCategory', 'menuCategory', 'quantity', 'sales'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toCsv: ToCsvService,
|
||||
private toaster: ToasterService,
|
||||
private ser: MenuEngineeringReportService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
startDate: new FormControl(new Date(), { nonNullable: true }),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { MenuEngineeringReportComponent } from './menu-engineering-report.component';
|
||||
import { menuEngineeringReportResolver } from './menu-engineering-report.resolver';
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { MenuEngineeringReport } from './menu-engineering-report';
|
||||
|
||||
const url = '/api/menu-engineering-report';
|
||||
@@ -14,10 +13,8 @@ const serviceName = 'MenuEngineeringReportService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class MenuEngineeringReportService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(startDate: string | null, finishDate: string | null): Observable<MenuEngineeringReport> {
|
||||
const options = { params: new HttpParams() };
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { ModifierCategoryDetailComponent } from './modifier-category-detail/modifier-category-detail.component';
|
||||
import { ModifierCategoryListComponent } from './modifier-category-list/modifier-category-list.component';
|
||||
import { modifierCategoryListResolver } from './modifier-category-list.resolver';
|
||||
import { ModifierCategoryListComponent } from './modifier-category-list/modifier-category-list.component';
|
||||
import { modifierCategoryResolver } from './modifier-category.resolver';
|
||||
|
||||
export const routes: Routes = [
|
||||
|
||||
+5
-5
@@ -24,9 +24,9 @@
|
||||
<mat-checkbox formControlName="isActive">Is Active?</mat-checkbox>
|
||||
</div>
|
||||
<mat-divider></mat-divider>
|
||||
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl" class="example-tree">
|
||||
<mat-tree [dataSource]="dataSource" #tree [childrenAccessor]="childrenAccessor" class="example-tree">
|
||||
<!-- This is the tree node template for leaf nodes -->
|
||||
<mat-tree-node *matTreeNodeDef="let node" matTreeNodeToggle>
|
||||
<mat-nested-tree-node *matTreeNodeDef="let node" class="mat-tree-node" [class.leaf-node]="!hasChild(0, node)">
|
||||
<li class="mat-tree-node">
|
||||
<!-- use a disabled button to provide padding for tree leaf -->
|
||||
<button mat-icon-button disabled></button>
|
||||
@@ -37,14 +37,14 @@
|
||||
>{{ node.name }}</mat-checkbox
|
||||
>
|
||||
</li>
|
||||
</mat-tree-node>
|
||||
</mat-nested-tree-node>
|
||||
<!-- This is the tree node template for expandable nodes -->
|
||||
<mat-nested-tree-node *matTreeNodeDef="let node; when: hasChild">
|
||||
<li>
|
||||
<div class="mat-tree-node">
|
||||
<button mat-icon-button matTreeNodeToggle [attr.aria-label]="'toggle ' + node.name">
|
||||
<mat-icon class="mat-icon-rtl-mirror">
|
||||
{{ treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right' }}
|
||||
{{ tree.isExpanded(node) ? 'expand_more' : 'chevron_right' }}
|
||||
</mat-icon>
|
||||
</button>
|
||||
<mat-checkbox
|
||||
@@ -54,7 +54,7 @@
|
||||
>{{ node.name }}</mat-checkbox
|
||||
>
|
||||
</div>
|
||||
<ul [class.example-tree-invisible]="!treeControl.isExpanded(node)">
|
||||
<ul [class.example-tree-invisible]="!tree.isExpanded(node)">
|
||||
<ng-container matTreeNodeOutlet></ng-container>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
+21
-12
@@ -1,5 +1,4 @@
|
||||
import { NestedTreeControl } from '@angular/cdk/tree';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -21,6 +20,16 @@ import { ConfirmDialogComponent } from '../../shared/confirm-dialog/confirm-dial
|
||||
import { ModifierCategoryService } from '../modifier-category.service';
|
||||
import { NodeItem } from '../node-item';
|
||||
|
||||
/**
|
||||
* Food data with nested structure.
|
||||
* Each node has a name and an optional list of children.
|
||||
*/
|
||||
interface ModifierCategoryNode {
|
||||
id: string;
|
||||
name: string;
|
||||
children?: ModifierCategoryNode[];
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-role-detail',
|
||||
templateUrl: './modifier-category-detail.component.html',
|
||||
@@ -38,6 +47,12 @@ import { NodeItem } from '../node-item';
|
||||
],
|
||||
})
|
||||
export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toaster = inject(ToasterService);
|
||||
private dialog = inject(MatDialog);
|
||||
private ser = inject(ModifierCategoryService);
|
||||
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
@@ -46,19 +61,15 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
isActive: FormControl<boolean>;
|
||||
}>;
|
||||
|
||||
childrenAccessor = (node: ModifierCategoryNode) => node.children ?? [];
|
||||
hasChild = (_: number, node: ModifierCategoryNode) => !!node.children && node.children.length > 0;
|
||||
|
||||
item: ModifierCategory = new ModifierCategory();
|
||||
treeControl = new NestedTreeControl<NodeItem>((node: NodeItem) => node.children);
|
||||
dataSource = new MatTreeNestedDataSource<NodeItem>();
|
||||
products: Map<string, Product> = new Map<string, Product>();
|
||||
productsOfMenuCategory: Map<string, Product[]> = new Map<string, Product[]>();
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toaster: ToasterService,
|
||||
private dialog: MatDialog,
|
||||
private ser: ModifierCategoryService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl<string>('', { nonNullable: true }),
|
||||
@@ -169,8 +180,6 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
hasChild = (_: number, node: NodeItem) => !!node.children && node.children.length > 0;
|
||||
|
||||
isProductSelected(node: NodeItem) {
|
||||
return (this.products.get(node.id) as Product).enabled;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { ModifierCategory } from '../core/modifier-category';
|
||||
|
||||
import { ModifierCategoryService } from './modifier-category.service';
|
||||
|
||||
export const modifierCategoryListResolver: ResolveFn<ModifierCategory[]> = () => {
|
||||
|
||||
+3
-4
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -6,7 +6,6 @@ import { MatTableModule } from '@angular/material/table';
|
||||
import { ActivatedRoute, RouterLink } from '@angular/router';
|
||||
|
||||
import { ModifierCategory } from '../../core/modifier-category';
|
||||
|
||||
import { ModifierCategoryListDatasource } from './modifier-category-list-datasource';
|
||||
|
||||
@Component({
|
||||
@@ -16,13 +15,13 @@ import { ModifierCategoryListDatasource } from './modifier-category-list-datasou
|
||||
imports: [MatButtonModule, MatCardModule, MatIconModule, MatTableModule, RouterLink],
|
||||
})
|
||||
export class ModifierCategoryListComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
|
||||
list: ModifierCategory[] = [];
|
||||
dataSource: ModifierCategoryListDatasource = new ModifierCategoryListDatasource(this.list);
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'minimum', 'maximum', 'products', 'isActive'];
|
||||
|
||||
constructor(private route: ActivatedRoute) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: ModifierCategory[] };
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { ModifierCategory } from '../core/modifier-category';
|
||||
|
||||
import { ModifierCategoryService } from './modifier-category.service';
|
||||
|
||||
export const modifierCategoryResolver: ResolveFn<ModifierCategory> = (route) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@@ -16,10 +16,8 @@ const serviceName = 'ModifierCategoryService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ModifierCategoryService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(id: string | null): Observable<ModifierCategory> {
|
||||
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -32,6 +32,12 @@ import { ModifierService } from '../modifier.service';
|
||||
],
|
||||
})
|
||||
export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private dialog = inject(MatDialog);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(ModifierService);
|
||||
|
||||
@ViewChild('name', { static: true }) nameElement?: ElementRef;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
@@ -44,13 +50,7 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
modifierCategories: ModifierCategory[] = [];
|
||||
item: Modifier = new Modifier();
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
private ser: ModifierService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl<string>('', { nonNullable: true }),
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Modifier } from '../core/modifier';
|
||||
|
||||
import { ModifierService } from './modifier.service';
|
||||
|
||||
export const modifierListResolver: ResolveFn<Modifier[]> = () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { CurrencyPipe } from '@angular/common';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -13,7 +13,6 @@ import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
import { Modifier } from '../../core/modifier';
|
||||
import { ModifierCategory } from '../../core/modifier-category';
|
||||
|
||||
import { ModifierListDataSource } from './modifier-list-datasource';
|
||||
|
||||
@Component({
|
||||
@@ -34,6 +33,9 @@ import { ModifierListDataSource } from './modifier-list-datasource';
|
||||
],
|
||||
})
|
||||
export class ModifierListComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
|
||||
// @ViewChild('table', { static: true }) table?: MatTable<Modifier>;
|
||||
filter = new BehaviorSubject<string>('');
|
||||
data: BehaviorSubject<Modifier[]> = new BehaviorSubject<Modifier[]>([]);
|
||||
@@ -47,10 +49,7 @@ export class ModifierListComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns: string[] = ['name', 'showInBill', 'price', 'isActive', 'modifierCategory'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
) {
|
||||
constructor() {
|
||||
this.form = new FormGroup({
|
||||
modifierCategory: new FormControl<string | null>(''),
|
||||
});
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Modifier } from '../core/modifier';
|
||||
|
||||
import { ModifierService } from './modifier.service';
|
||||
|
||||
export const modifierResolver: ResolveFn<Modifier> = (route) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@@ -15,10 +15,8 @@ const serviceName = 'ModifierService';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ModifierService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(id: string | null): Observable<Modifier> {
|
||||
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||
|
||||
@@ -2,10 +2,9 @@ import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
import { modifierCategoryListResolver } from '../modifier-categories/modifier-category-list.resolver';
|
||||
|
||||
import { ModifierDetailComponent } from './modifier-detail/modifier-detail.component';
|
||||
import { ModifierListComponent } from './modifier-list/modifier-list.component';
|
||||
import { modifierListResolver } from './modifier-list.resolver';
|
||||
import { ModifierListComponent } from './modifier-list/modifier-list.component';
|
||||
import { modifierResolver } from './modifier.resolver';
|
||||
|
||||
export const routes: Routes = [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AsyncPipe } from '@angular/common';
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatToolbarModule } from '@angular/material/toolbar';
|
||||
@@ -14,10 +14,8 @@ import { AuthService } from '../auth/auth.service';
|
||||
imports: [AsyncPipe, MatButtonModule, MatButtonModule, MatIconModule, MatToolbarModule, RouterLink],
|
||||
})
|
||||
export class NavBarComponent {
|
||||
constructor(
|
||||
private router: Router,
|
||||
public auth: AuthService,
|
||||
) {}
|
||||
private router = inject(Router);
|
||||
auth = inject(AuthService);
|
||||
|
||||
logout() {
|
||||
this.auth.logout();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -19,6 +19,12 @@ import { PrinterService } from '../printer.service';
|
||||
imports: [MatButtonModule, MatCardModule, MatFormFieldModule, MatInputModule, ReactiveFormsModule],
|
||||
})
|
||||
export class PrinterDetailComponent implements OnInit, AfterViewInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private dialog = inject(MatDialog);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(PrinterService);
|
||||
|
||||
@ViewChild('nameElement', { static: true }) nameElement?: ElementRef;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
@@ -28,13 +34,7 @@ export class PrinterDetailComponent implements OnInit, AfterViewInit {
|
||||
|
||||
item: Printer = new Printer();
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
private ser: PrinterService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl<string>('', { nonNullable: true }),
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Printer } from '../core/printer';
|
||||
|
||||
import { PrinterService } from './printer.service';
|
||||
|
||||
export const printerListResolver: ResolveFn<Printer[]> = () => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
@@ -6,7 +6,6 @@ import { MatTableModule } from '@angular/material/table';
|
||||
import { ActivatedRoute, RouterLink } from '@angular/router';
|
||||
|
||||
import { Printer } from '../../core/printer';
|
||||
|
||||
import { PrinterListDataSource } from './printer-list-datasource';
|
||||
|
||||
@Component({
|
||||
@@ -16,13 +15,13 @@ import { PrinterListDataSource } from './printer-list-datasource';
|
||||
imports: [MatButtonModule, MatCardModule, MatIconModule, MatTableModule, RouterLink],
|
||||
})
|
||||
export class PrinterListComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
|
||||
list: Printer[] = [];
|
||||
dataSource: PrinterListDataSource = new PrinterListDataSource(this.list);
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'address', 'cutCode'];
|
||||
|
||||
constructor(private route: ActivatedRoute) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data.subscribe((value) => {
|
||||
const data = value as { list: Printer[] };
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Printer } from '../core/printer';
|
||||
|
||||
import { PrinterService } from './printer.service';
|
||||
|
||||
export const printerResolver: ResolveFn<Printer> = (route) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
@@ -16,10 +16,8 @@ const serviceName = 'PrinterService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PrinterService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(id: string | null): Observable<Printer> {
|
||||
const getUrl: string = id === null ? url : `${url}/${id}`;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { PrinterDetailComponent } from './printer-detail/printer-detail.component';
|
||||
import { PrinterListComponent } from './printer-list/printer-list.component';
|
||||
import { printerListResolver } from './printer-list.resolver';
|
||||
import { PrinterListComponent } from './printer-list/printer-list.component';
|
||||
import { printerResolver } from './printer.resolver';
|
||||
|
||||
export const routes: Routes = [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -15,7 +15,6 @@ import moment from 'moment';
|
||||
import { Section } from '../core/section';
|
||||
import { ToasterService } from '../core/toaster.service';
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { ProductSaleReport } from './product-sale-report';
|
||||
import { ProductSaleReportDataSource } from './product-sale-report-datasource';
|
||||
import { ProductSaleReportService } from './product-sale-report.service';
|
||||
@@ -38,6 +37,12 @@ import { ProductSaleReportService } from './product-sale-report.service';
|
||||
],
|
||||
})
|
||||
export class ProductSaleReportComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toCsv = inject(ToCsvService);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(ProductSaleReportService);
|
||||
|
||||
sections: Section[] = [];
|
||||
info: ProductSaleReport = new ProductSaleReport();
|
||||
dataSource: ProductSaleReportDataSource = new ProductSaleReportDataSource(this.info.amounts);
|
||||
@@ -50,13 +55,7 @@ export class ProductSaleReportComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'unbilled', 'sale', 'noCharge', 'staff', 'cancel'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toCsv: ToCsvService,
|
||||
private toaster: ToasterService,
|
||||
private ser: ProductSaleReportService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
startDate: new FormControl(new Date(), { nonNullable: true }),
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
import { sectionListResolver } from '../sections/section-list.resolver';
|
||||
|
||||
import { ProductSaleReportComponent } from './product-sale-report.component';
|
||||
import { productSaleReportResolver } from './product-sale-report.resolver';
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { ProductSaleReport } from './product-sale-report';
|
||||
|
||||
const url = '/api/product-sale-report';
|
||||
@@ -14,10 +13,8 @@ const serviceName = 'ProductSaleReportService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ProductSaleReportService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(startDate: string | null, finishDate: string | null, section: string | null): Observable<ProductSaleReport> {
|
||||
const options = { params: new HttpParams() };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -11,7 +11,6 @@ import { ActivatedRoute, Router } from '@angular/router';
|
||||
import moment from 'moment';
|
||||
|
||||
import { ToCsvService } from '../shared/to-csv.service';
|
||||
|
||||
import { ProductUpdatesReport } from './product-updates-report';
|
||||
import { ProductUpdatesReportDataSource } from './product-updates-report-datasource';
|
||||
|
||||
@@ -31,6 +30,10 @@ import { ProductUpdatesReportDataSource } from './product-updates-report-datasou
|
||||
],
|
||||
})
|
||||
export class ProductUpdatesReportComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private toCsv = inject(ToCsvService);
|
||||
|
||||
info: ProductUpdatesReport = new ProductUpdatesReport();
|
||||
dataSource: ProductUpdatesReportDataSource = new ProductUpdatesReportDataSource(this.info.report);
|
||||
form: FormGroup<{
|
||||
@@ -41,11 +44,7 @@ export class ProductUpdatesReportComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['details'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private toCsv: ToCsvService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
startDate: new FormControl(new Date(), { nonNullable: true }),
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Routes } from '@angular/router';
|
||||
|
||||
import { authGuard } from '../auth/auth-guard.service';
|
||||
|
||||
import { ProductUpdatesReportComponent } from './product-updates-report.component';
|
||||
import { productUpdatesReportResolver } from './product-updates-report.resolver';
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
import { ErrorLoggerService } from '../core/error-logger.service';
|
||||
|
||||
import { ProductUpdatesReport } from './product-updates-report';
|
||||
|
||||
const url = '/api/product-updates-report';
|
||||
@@ -14,10 +13,8 @@ const serviceName = 'ProductUpdatesReportService';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ProductUpdatesReportService {
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
private log: ErrorLoggerService,
|
||||
) {}
|
||||
private http = inject(HttpClient);
|
||||
private log = inject(ErrorLoggerService);
|
||||
|
||||
get(startDate: string | null, finishDate: string | null): Observable<ProductUpdatesReport> {
|
||||
const options = { params: new HttpParams() };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -33,6 +33,12 @@ import { ProductService } from '../product.service';
|
||||
],
|
||||
})
|
||||
export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private router = inject(Router);
|
||||
private dialog = inject(MatDialog);
|
||||
private toaster = inject(ToasterService);
|
||||
private ser = inject(ProductService);
|
||||
|
||||
@ViewChild('name', { static: true }) nameElement?: ElementRef;
|
||||
form: FormGroup<{
|
||||
name: FormControl<string>;
|
||||
@@ -49,13 +55,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
saleCategories: SaleCategory[] = [];
|
||||
item: Product = new Product();
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private toaster: ToasterService,
|
||||
private ser: ProductService,
|
||||
) {
|
||||
constructor() {
|
||||
// Create form
|
||||
this.form = new FormGroup({
|
||||
name: new FormControl<string>('', { nonNullable: true }),
|
||||
|
||||
@@ -2,7 +2,6 @@ import { inject } from '@angular/core';
|
||||
import { ResolveFn } from '@angular/router';
|
||||
|
||||
import { Product } from '../core/product';
|
||||
|
||||
import { ProductService } from './product.service';
|
||||
|
||||
export const productListResolver: ResolveFn<Product[]> = () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CdkDragDrop, moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
|
||||
import { AsyncPipe, DecimalPipe, CurrencyPipe } from '@angular/common';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -19,7 +19,6 @@ import { Product } from '../../core/product';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ToCsvService } from '../../shared/to-csv.service';
|
||||
import { ProductService } from '../product.service';
|
||||
|
||||
import { ProductListDataSource } from './product-list-datasource';
|
||||
|
||||
@Component({
|
||||
@@ -44,6 +43,11 @@ import { ProductListDataSource } from './product-list-datasource';
|
||||
],
|
||||
})
|
||||
export class ProductListComponent implements OnInit {
|
||||
private route = inject(ActivatedRoute);
|
||||
private toaster = inject(ToasterService);
|
||||
private toCsv = inject(ToCsvService);
|
||||
private ser = inject(ProductService);
|
||||
|
||||
searchFilter = new Observable<string>();
|
||||
menuCategoryFilter = new BehaviorSubject<string>('');
|
||||
data: BehaviorSubject<Product[]> = new BehaviorSubject<Product[]>([]);
|
||||
@@ -59,12 +63,7 @@ export class ProductListComponent implements OnInit {
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns: string[] = ['name', 'price', 'menuCategory', 'saleCategory', 'info', 'quantity'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private toaster: ToasterService,
|
||||
private toCsv: ToCsvService,
|
||||
private ser: ProductService,
|
||||
) {
|
||||
constructor() {
|
||||
this.form = new FormGroup({
|
||||
menuCategory: new FormControl<string | null>(''),
|
||||
filter: new FormControl<string>('', { nonNullable: true }),
|
||||
|
||||
Loaded 100 of 203 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user