Compare commits
23 Commits
f435300740
...
dashboard/
Author | SHA1 | Date | |
---|---|---|---|
![]() |
39a7d32fcd | ||
![]() |
85d1ecdc90 | ||
![]() |
b26e1ff167 | ||
![]() |
de415a37bc | ||
![]() |
01a8d2ca02 | ||
![]() |
e5b136b8b5 | ||
![]() |
031dbed6a9 | ||
![]() |
f20dfa00c2 | ||
![]() |
24c91cb6f0 | ||
![]() |
abca91c26a | ||
![]() |
3321eafffa | ||
![]() |
adc9275d3f | ||
![]() |
60eed00cb2 | ||
![]() |
c29ab4b920 | ||
![]() |
9d46de56c3 | ||
![]() |
3f9d88e733 | ||
![]() |
6e576919ab | ||
![]() |
9739583f43 | ||
![]() |
bc1ec72df1 | ||
![]() |
e62dc5f597 | ||
![]() |
b5e9c8ba34 | ||
![]() |
9a8fd1c073 | ||
![]() |
25c1d3c917 |
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* text=lf
|
5
.gitignore
vendored
5
.gitignore
vendored
@@ -2,8 +2,13 @@
|
|||||||
node_modules
|
node_modules
|
||||||
005_references/
|
005_references/
|
||||||
_archive/
|
_archive/
|
||||||
|
|
||||||
_del
|
_del
|
||||||
*.bak
|
*.bak
|
||||||
*.log
|
*.log
|
||||||
*.del
|
*.del
|
||||||
**/_del
|
**/_del
|
||||||
|
|
||||||
|
**/volumes/**
|
||||||
|
006_lab
|
||||||
|
**/*.draft
|
||||||
|
12
.vscode/extensions.json
vendored
Normal file
12
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"aflalo.dbml-formatter",
|
||||||
|
"bierner.markdown-mermaid",
|
||||||
|
"christian-kohler.path-intellisense",
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"humao.rest-client",
|
||||||
|
"matt-meyers.vscode-dbml",
|
||||||
|
"nicolas-liger.dbml-viewer",
|
||||||
|
"yzhang.markdown-all-in-one"
|
||||||
|
]
|
||||||
|
}
|
21
.vscode/settings.json
vendored
Normal file
21
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"[javascript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[javascriptreact]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[jsonc]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[typescript]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"[typescriptreact]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
},
|
||||||
|
"workbench.iconTheme": "material-icon-theme",
|
||||||
|
"workbench.colorTheme": "Default Dark Modern",
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"git.ignoreLimitWarning": true
|
||||||
|
}
|
25
000_AI_WORKSPACE/software-engineer/_examples/001_clone.md
Normal file
25
000_AI_WORKSPACE/software-engineer/_examples/001_clone.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
this `tsx` file is clone from elsewhere, please understand, modify and update the content of `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/app/dashboard/teachers/view/[id]/page.tsx.draft` to handle `Teacher` record thanks, modify comments/variables/paths/functions name please
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
please review and update all tsx files in folder `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/db/Users` to make it handle `user` record thanks
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- read and understand @/_AI_WORKSPACE/greetings/001_greetings.md -->
|
||||||
|
## clone source code from one type to another
|
||||||
|
|
||||||
|
please understand, modify and update the content of `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/components/dashboard/teacher/_GUIDELINES.md` to handle `Teacher` record thanks,
|
||||||
|
modify comments/variables/paths/functions name please
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
please help to update the tsx files inside folder `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/components/dashboard/student` to handle the `student` record
|
||||||
|
|
||||||
|
## steps
|
||||||
|
|
||||||
|
- list all `tsx` files inside directory, remember the list
|
||||||
|
- clone the original `<original>.tsx` files to `<original>.tsx.draft`
|
||||||
|
- do all your modification within `<original>.tsx.draft` files, leave `original.tsx` unchange
|
||||||
|
|
||||||
|
---
|
@@ -0,0 +1,33 @@
|
|||||||
|
Hi, i need your help.
|
||||||
|
|
||||||
|
## task
|
||||||
|
|
||||||
|
i am working on a `dbml` file
|
||||||
|
i got a `schema.json` which is exported from pocketbase
|
||||||
|
and i want to update it to my current `dbml` file (one way process for documentation usage)
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
- the collection from `json` file started with `_` can be ignored. they are system collection and should not appear in `dbml`
|
||||||
|
- one collection from `json` file mapped with one table in `dbml` file
|
||||||
|
- the `presentable` field from `json` file should be ignored.
|
||||||
|
- the `id` of collection in `json` file should be jod down in the comment of `dbml` file as an reference.
|
||||||
|
- you can find the comments in `schema.dbml` contains `pb_xxx` and that is the reference to the table in `schema.json` file.
|
||||||
|
|
||||||
|
## steps
|
||||||
|
|
||||||
|
- list the collection
|
||||||
|
|
||||||
|
## information
|
||||||
|
|
||||||
|
json file: `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/001_documentation/Requirements/REQ0006/schema.json`
|
||||||
|
dbml file: `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/001_documentation/Requirements/REQ0006/schema.dbml`
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
1. 对于json中有但dbml中没有的表,应该如何处理? 添加为新表
|
||||||
|
1. 是否需要保留dbml文件中现有的注释和关系定义? 完全保留
|
||||||
|
1. 字段类型映射是否有特殊规则? 沒有
|
||||||
|
1. please keep the existing comment
|
||||||
|
|
||||||
|
thanks
|
@@ -0,0 +1,11 @@
|
|||||||
|
# Greetings
|
||||||
|
|
||||||
|
Hi,
|
||||||
|
Imaging you are a software engineer and i will send you the guideline.
|
||||||
|
plesae read it, prepare yourself and i will tell you the task afterwards
|
||||||
|
|
||||||
|
please read and understand the markdown files in directory
|
||||||
|
`/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/000_AI_WORKSPACE/software_engineer/greetings`,
|
||||||
|
it provides background information of project i want you to help.
|
||||||
|
|
||||||
|
thanks
|
@@ -0,0 +1,32 @@
|
|||||||
|
# guideline
|
||||||
|
|
||||||
|
## principles
|
||||||
|
|
||||||
|
- at any time, please keep your answer, solution, explaination simple and short (K.I.S.S. or 大道至簡)
|
||||||
|
- please divide the problem into small parts
|
||||||
|
- if you found youself cannot understand the problem, please stop and ask how to do
|
||||||
|
- if you found youself cannot solve the problem, plesae stop and ask how to do
|
||||||
|
- review the whole solution before you reply to user
|
||||||
|
- if code syntax is already there, do follow (e.g. naming convention, syntax) the existing code
|
||||||
|
- no need to explain the reason until you are told to do so
|
||||||
|
- no need to show me the code change, at the end just simple summary in point form is ok
|
||||||
|
|
||||||
|
## highlighted project directories and their meanings
|
||||||
|
|
||||||
|
- `_ignore_this_directory` please ignore this directory and any files inside it
|
||||||
|
|
||||||
|
- `001_documentation` documentation of this project
|
||||||
|
- `002_source` source code of this project
|
||||||
|
- `002_source/cms` home of Context management system of this project
|
||||||
|
- use singular form for `src/components/dashboard` (e.g. `src/components/dashboard/student`)
|
||||||
|
- use plural form for `src/app/dashboard` (e.g. `src/app/dashboard/students`)
|
||||||
|
- `002_source/ionic_mobile` home of mobile client of this project
|
||||||
|
- `002_source/pocketbase` home of pocketbase home directory this project
|
||||||
|
- `003_test` e2e test of this project (not yet implemented)
|
||||||
|
- `004_marketing` marketing page of this project (not yet implemented)
|
||||||
|
- `005_references` opensource refence of this project
|
||||||
|
- `006_lab` my test (POC) of this project
|
||||||
|
- `README.md` Readme of this project
|
||||||
|
- `TODO.md` todo list of this project
|
||||||
|
|
||||||
|
- if the directory contains `_GUIDELINES.md`, please read it before operation
|
@@ -0,0 +1,12 @@
|
|||||||
|
# Knowledgebase
|
||||||
|
|
||||||
|
you can answer the question with below knowledge:
|
||||||
|
|
||||||
|
## frameworks and stacks
|
||||||
|
|
||||||
|
- if code syntax is already there, do follow (e.g. naming convention, syntax) the existing code
|
||||||
|
- make use of MCP `Context7` when you troubleshoot the problem with below topics:
|
||||||
|
- [pocketbase javascript SDK](https://context7.com/pocketbase/js-sdk/llms.txt)
|
||||||
|
- [DBML](https://context7.com/holistics/dbml/llms.txt)
|
||||||
|
- [ionic framework](https://context7.com/ionic-team/ionic-framework/llms.txt)
|
||||||
|
- [nextjs 14 app router](https://context7.com/nextjsargentina/next.js-docs/llms.txt)
|
22
000_AI_WORKSPACE/software-engineer/greetings/010_FAQ.md
Normal file
22
000_AI_WORKSPACE/software-engineer/greetings/010_FAQ.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# FAQ
|
||||||
|
|
||||||
|
Q: where is `dbml` file ?
|
||||||
|
A: dbml file located in `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/001_documentation/Requirements/REQ0006/schema.dbml`
|
||||||
|
|
||||||
|
Q: when file not found, do i need to search it in `_ignore_this_directory` ?
|
||||||
|
A: No, you just stop there and voice out.
|
||||||
|
|
||||||
|
Q: Shall I assume the component is already exist ?
|
||||||
|
A: yes, you can assume that
|
||||||
|
|
||||||
|
Q: Is `COL_USER_METAS` the collection for User related (e.g. `Teacher`, `Student`) collections?
|
||||||
|
A: yes
|
||||||
|
|
||||||
|
Q: Shall I verify `import` or `types` when do modification job ?
|
||||||
|
A: No, you just replace the name of the function, variables etc is ok. no need to check for dependencies thanks.
|
||||||
|
|
||||||
|
Q: how to list files with `.tsx.draft` extensions in `src/db/UserMetas` folder?
|
||||||
|
A: using command like `find src/db/UserMetas -name "*.tsx.draft" -type f -ls` to list the files with `.tsx.draft` extendions only exist in `src/db/UserMetas`
|
||||||
|
|
||||||
|
Q: when user want to modify `.tsx.draft` file, do i need to take care the `.tsx` file as well?
|
||||||
|
A: No, no don't need to, user will handle the remaining modifications. please restrict your modification in the mentioned file or directory only.
|
39
000_AI_WORKSPACE/software-engineer/greetings/013_DB.md
Normal file
39
000_AI_WORKSPACE/software-engineer/greetings/013_DB.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# database and schemas
|
||||||
|
|
||||||
|
## getting started
|
||||||
|
|
||||||
|
Imagine there is a:
|
||||||
|
|
||||||
|
1. developer (provide the modification)
|
||||||
|
2. QA engineer (provide the feedback, and testing)
|
||||||
|
3. software engineer
|
||||||
|
4. technical writer
|
||||||
|
|
||||||
|
they will:
|
||||||
|
|
||||||
|
- conclude and integrate the ideas from developer and QA engineer
|
||||||
|
- make decision to modify the code accordingly.
|
||||||
|
|
||||||
|
## project background and initial setup
|
||||||
|
|
||||||
|
- **IMPORTANT**: No need to reply me what you are going on and your digest in this phase.
|
||||||
|
No need to show me your code plan
|
||||||
|
Just reply me "OK" when done
|
||||||
|
|
||||||
|
- base_dir=`/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project`
|
||||||
|
|
||||||
|
- `schema.dbml`
|
||||||
|
- read `<base_dir>/001_documentation/Requirements/REQ0006/schema.dbml`
|
||||||
|
this is file in `dbml` format stating the main database structure
|
||||||
|
|
||||||
|
- `schema.json`
|
||||||
|
- read `<base_dir>/002_source/cms/src/db/schema.json`
|
||||||
|
this is the file of current pocketbase schema
|
||||||
|
|
||||||
|
- look into the md files in folder `<base_dir>/002_source/ionic_mobile/_AI_WORKSPACE/001_guideline`
|
||||||
|
|
||||||
|
- if the directory user provided contins `_GUIDELINES.md`, please read the file
|
||||||
|
|
||||||
|
- read the files, remember and link up the ideas in file stated above, i will tell them the task afterwards
|
||||||
|
|
||||||
|
- please review at least 3 times after you modified the code
|
21
000_AI_WORKSPACE/testing-engineer/_examples/001_clone.md
Normal file
21
000_AI_WORKSPACE/testing-engineer/_examples/001_clone.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
please review and update all tsx files in folder `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/db/Users` to make it handle `user` record thanks
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!-- read and understand @/_AI_WORKSPACE/greetings/001_greetings.md -->
|
||||||
|
## clone source code from one type to another
|
||||||
|
|
||||||
|
please understand, modify and update the content of `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/components/dashboard/teacher/_GUIDELINES.md` to handle `Teacher` record thanks,
|
||||||
|
modify comments/variables/paths/functions name please
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
please help to update the tsx files inside folder `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src/components/dashboard/student` to handle the `student` record
|
||||||
|
|
||||||
|
## steps
|
||||||
|
|
||||||
|
- list all `tsx` files inside directory, remember the list
|
||||||
|
- clone the original `<original>.tsx` files to `<original>.tsx.draft`
|
||||||
|
- do all your modification within `<original>.tsx.draft` files, leave `original.tsx` unchange
|
||||||
|
|
||||||
|
---
|
@@ -0,0 +1,33 @@
|
|||||||
|
Hi, i need your help.
|
||||||
|
|
||||||
|
## task
|
||||||
|
|
||||||
|
i am working on a `dbml` file
|
||||||
|
i got a `schema.json` which is exported from pocketbase
|
||||||
|
and i want to update it to my current `dbml` file (one way process for documentation usage)
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
- the collection from `json` file started with `_` can be ignored. they are system collection and should not appear in `dbml`
|
||||||
|
- one collection from `json` file mapped with one table in `dbml` file
|
||||||
|
- the `presentable` field from `json` file should be ignored.
|
||||||
|
- the `id` of collection in `json` file should be jod down in the comment of `dbml` file as an reference.
|
||||||
|
- you can find the comments in `schema.dbml` contains `pb_xxx` and that is the reference to the table in `schema.json` file.
|
||||||
|
|
||||||
|
## steps
|
||||||
|
|
||||||
|
- list the collection
|
||||||
|
|
||||||
|
## information
|
||||||
|
|
||||||
|
json file: `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/001_documentation/Requirements/REQ0006/schema.json`
|
||||||
|
dbml file: `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/001_documentation/Requirements/REQ0006/schema.dbml`
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
1. 对于json中有但dbml中没有的表,应该如何处理? 添加为新表
|
||||||
|
1. 是否需要保留dbml文件中现有的注释和关系定义? 完全保留
|
||||||
|
1. 字段类型映射是否有特殊规则? 沒有
|
||||||
|
1. please keep the existing comment
|
||||||
|
|
||||||
|
thanks
|
@@ -0,0 +1,8 @@
|
|||||||
|
Hi, i will send you the guideline,
|
||||||
|
plesae read it, prepare yourself and i will tell you the task afterwards
|
||||||
|
|
||||||
|
please read and understand the markdown files in directory
|
||||||
|
`/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/000_AI_WORKSPACE/_AI_WORKSPACE/greetings`,
|
||||||
|
it provides background information of project i want you to help.
|
||||||
|
|
||||||
|
thanks
|
28
000_AI_WORKSPACE/testing-engineer/greetings/002_guideline.md
Normal file
28
000_AI_WORKSPACE/testing-engineer/greetings/002_guideline.md
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# guideline
|
||||||
|
|
||||||
|
## principles
|
||||||
|
|
||||||
|
- at any time, please keep your answer, solution, explaination simple and short (K.I.S.S. or 大道至簡)
|
||||||
|
- please divide the problem into small parts
|
||||||
|
- if you found youself cannot understand the problem, please stop and ask how to do
|
||||||
|
- if you found youself cannot solve the problem, plesae stop and ask how to do
|
||||||
|
- review the whole solution before you reply to user
|
||||||
|
- if code syntax is already there, do follow (e.g. naming convention, syntax) the existing code
|
||||||
|
- no need to explain the reason until you are told to do so
|
||||||
|
- no need to show me the code change, at the end just simple summary in point form is ok
|
||||||
|
|
||||||
|
## highlighted project directories and their meanings
|
||||||
|
|
||||||
|
- `_ignore_this_directory` please ignore this directory and any files inside it
|
||||||
|
|
||||||
|
- `001_documentation` documentation of this project
|
||||||
|
- `002_source` source code of this project
|
||||||
|
- `002_source/cms` home of Context management system of this project
|
||||||
|
- `002_source/ionic_mobile` home of mobile client of this project
|
||||||
|
- `002_source/pocketbase` home of pocketbase home directory this project
|
||||||
|
- `003_test` e2e test of this project (not yet implemented)
|
||||||
|
- `004_marketing` marketing page of this project (not yet implemented)
|
||||||
|
- `005_references` opensource refence of this project
|
||||||
|
- `006_lab` my test (POC) of this project
|
||||||
|
- `README.md` Readme of this project
|
||||||
|
- `TODO.md` todo list of this project
|
@@ -0,0 +1,12 @@
|
|||||||
|
# Knowledgebase
|
||||||
|
|
||||||
|
you can answer the question with below knowledge:
|
||||||
|
|
||||||
|
## frameworks and stacks
|
||||||
|
|
||||||
|
- if code syntax is already there, do follow (e.g. naming convention, syntax) the existing code
|
||||||
|
- make use of MCP `Context7` when you troubleshoot the problem with below topics:
|
||||||
|
- [pocketbase javascript SDK](https://context7.com/pocketbase/js-sdk/llms.txt)
|
||||||
|
- [DBML](https://context7.com/holistics/dbml/llms.txt)
|
||||||
|
- [ionic framework](https://context7.com/ionic-team/ionic-framework/llms.txt)
|
||||||
|
- [nextjs 14 app router](https://context7.com/nextjsargentina/next.js-docs/llms.txt)
|
7
000_AI_WORKSPACE/testing-engineer/greetings/010_FAQ.md
Normal file
7
000_AI_WORKSPACE/testing-engineer/greetings/010_FAQ.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# FAQ
|
||||||
|
|
||||||
|
Q: where is `dbml` file ?
|
||||||
|
A: dbml file located in `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/001_documentation/Requirements/REQ0006/schema.dbml`
|
||||||
|
|
||||||
|
Q: when file not found, do i need to search it in `_ignore_this_directory` ?
|
||||||
|
A: No, you just stop there and voice out.
|
48
000_AI_WORKSPACE/testing-engineer/greetings/013_DB.md
Normal file
48
000_AI_WORKSPACE/testing-engineer/greetings/013_DB.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# database and schemas
|
||||||
|
|
||||||
|
## getting started
|
||||||
|
|
||||||
|
Imagine there is a:
|
||||||
|
|
||||||
|
1. developer (provide the modification)
|
||||||
|
2. QA engineer (provide the feedback, and testing)
|
||||||
|
3. software engineer
|
||||||
|
4. technical writer
|
||||||
|
|
||||||
|
they will:
|
||||||
|
|
||||||
|
- conclude and integrate the ideas from developer and QA engineer
|
||||||
|
- make decision to modify the code accordingly.
|
||||||
|
|
||||||
|
## project background and initial setup
|
||||||
|
|
||||||
|
- **IMPORTANT**: No need to reply me what you are going on and your digest in this phase.
|
||||||
|
No need to show me your code plan
|
||||||
|
Just reply me "OK" when done
|
||||||
|
|
||||||
|
- base_dir=`/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project`
|
||||||
|
|
||||||
|
- `schema.dbml`
|
||||||
|
- read `<base_dir>/001_documentation/Requirements/REQ0006/schema.dbml`
|
||||||
|
this is file in `dbml` format stating the main database structure
|
||||||
|
|
||||||
|
- `schema.json`
|
||||||
|
- read `<base_dir>/002_source/cms/src/db/schema.json`
|
||||||
|
this is the file of current pocketbase schema
|
||||||
|
|
||||||
|
- look into the md files in folder `<base_dir>/002_source/ionic_mobile/_AI_WORKSPACE/001_guideline`
|
||||||
|
|
||||||
|
- if the directory user provided contins `_GUIDELINES.md`, please read the file
|
||||||
|
|
||||||
|
- read the files, remember and link up the ideas in file stated above, i will tell them the task afterwards
|
||||||
|
|
||||||
|
- please review at least 3 times after you modified the code
|
||||||
|
|
||||||
|
## frameworks documentation and samples
|
||||||
|
|
||||||
|
- react
|
||||||
|
- ionic and capacitor
|
||||||
|
- pocketbase
|
||||||
|
- tanstack/react-query
|
||||||
|
- vite
|
||||||
|
- typescript
|
2
001_documentation/.vscode/extensions.json
vendored
2
001_documentation/.vscode/extensions.json
vendored
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"redhat.vscode-yaml",
|
|
||||||
"yzhang.markdown-all-in-one",
|
"yzhang.markdown-all-in-one",
|
||||||
"esbenp.prettier-vscode",
|
"esbenp.prettier-vscode",
|
||||||
"ms-python.python",
|
"ms-python.python",
|
||||||
@@ -8,7 +7,6 @@
|
|||||||
"ms-python.debugpy",
|
"ms-python.debugpy",
|
||||||
"ms-python.black-formatter",
|
"ms-python.black-formatter",
|
||||||
"ms-python.isort",
|
"ms-python.isort",
|
||||||
"ms-python.pylint",
|
|
||||||
"bierner.markdown-mermaid",
|
"bierner.markdown-mermaid",
|
||||||
"shd101wyy.markdown-preview-enhanced",
|
"shd101wyy.markdown-preview-enhanced",
|
||||||
"yzhang.markdown-all-in-one",
|
"yzhang.markdown-all-in-one",
|
||||||
|
7
001_documentation/Requirements/REQ0018/index.md
Normal file
7
001_documentation/Requirements/REQ0018/index.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
tags: mobile, cms, db
|
||||||
|
---
|
||||||
|
|
||||||
|
# family photo of frameworks
|
||||||
|
|
||||||
|
it should have a family photo of used framework
|
14
002_source/.env
Normal file
14
002_source/.env
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# THIS IS env file for use with docker-compose.yml
|
||||||
|
|
||||||
|
# cms
|
||||||
|
|
||||||
|
# doc
|
||||||
|
|
||||||
|
# ionic_mobile
|
||||||
|
|
||||||
|
# api_ts
|
||||||
|
|
||||||
|
# pocketbase
|
||||||
|
PB_HOSTNAME=pocketbase
|
||||||
|
PB_USERNAME=admin@123.com
|
||||||
|
PB_PASSWORD=Aa12345678
|
4
002_source/.gitignore
vendored
Normal file
4
002_source/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
**/*.del
|
||||||
|
**/*.log
|
||||||
|
**/_archive
|
||||||
|
**/_del
|
74
002_source/README.md
Normal file
74
002_source/README.md
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
# README
|
||||||
|
|
||||||
|
## to start production
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# start docker before hand
|
||||||
|
$ ./dc_build.sh
|
||||||
|
|
||||||
|
$ ./dc_up.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## to start develop
|
||||||
|
|
||||||
|
```bash
|
||||||
|
#
|
||||||
|
$ ./dc_build.sh
|
||||||
|
$ ./dc_dev.sh
|
||||||
|
$ docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d pocketbase api_ts --remove-orphans
|
||||||
|
$ docker compose logs -f pocketbase api_ts
|
||||||
|
```
|
||||||
|
|
||||||
|
## test api endpoint
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# browse to http://localhost:3000/helloworld
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# start docker before hand
|
||||||
|
|
||||||
|
$ cd 002_source
|
||||||
|
$ ./dev.sh
|
||||||
|
|
||||||
|
# docker containers up
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## deprecated
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# mobile
|
||||||
|
$ cd 002_source/mobile
|
||||||
|
$ pnpm run dev
|
||||||
|
|
||||||
|
# cms
|
||||||
|
$ cd 002_source/cms
|
||||||
|
$ npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
ideation
|
||||||
|
prototyping
|
||||||
|
testing
|
||||||
|
production deployment
|
||||||
|
evaluation
|
||||||
|
monitoring
|
||||||
|
|
||||||
|
## addresses
|
||||||
|
|
||||||
|
```
|
||||||
|
mobile:
|
||||||
|
http://localhost:5173
|
||||||
|
|
||||||
|
pocketbase:
|
||||||
|
http://localhost:8090/_
|
||||||
|
|
||||||
|
cms:
|
||||||
|
http://localhost:3000
|
||||||
|
|
||||||
|
documentation
|
||||||
|
http://localhost:3001
|
||||||
|
```
|
||||||
|
|
||||||
|
extend to vocabularies
|
@@ -29,6 +29,7 @@ export function AuthGuard({ children }: AuthGuardProps): React.JSX.Element | nul
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: here state that if user = null, eject user to login page
|
||||||
if (!user) {
|
if (!user) {
|
||||||
logger.debug('[AuthGuard]: User is not logged in, redirecting to sign in');
|
logger.debug('[AuthGuard]: User is not logged in, redirecting to sign in');
|
||||||
|
|
||||||
|
10
002_source/cms/src/components/auth/custom/_GUIDELINES.md
Normal file
10
002_source/cms/src/components/auth/custom/_GUIDELINES.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# GUIDELINES
|
||||||
|
|
||||||
|
This folder contains login pages
|
||||||
|
|
||||||
|
the `@` sign refer to `/home/logic/_wsl_workspace/001_github_ws/lettersoup-online-ws/lettersoup-online/project/002_source/cms/src`
|
||||||
|
|
||||||
|
## Assumption and Requirements
|
||||||
|
|
||||||
|
- assume `pb` is located in `@/lib/pb`
|
||||||
|
- no need to handle error in this function, i'll handle it in the caller
|
@@ -1,4 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
// RULES:
|
||||||
|
// refer to ticket REQ0016 for login flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import RouterLink from 'next/link';
|
import RouterLink from 'next/link';
|
||||||
@@ -25,6 +27,7 @@ import { authClient } from '@/lib/auth/custom/client';
|
|||||||
import { useUser } from '@/hooks/use-user';
|
import { useUser } from '@/hooks/use-user';
|
||||||
import { DynamicLogo } from '@/components/core/logo';
|
import { DynamicLogo } from '@/components/core/logo';
|
||||||
import { toast } from '@/components/core/toaster';
|
import { toast } from '@/components/core/toaster';
|
||||||
|
import { pb } from '@/lib/pb';
|
||||||
|
|
||||||
interface OAuthProvider {
|
interface OAuthProvider {
|
||||||
id: 'google' | 'discord';
|
id: 'google' | 'discord';
|
||||||
@@ -44,7 +47,7 @@ const schema = zod.object({
|
|||||||
|
|
||||||
type Values = zod.infer<typeof schema>;
|
type Values = zod.infer<typeof schema>;
|
||||||
|
|
||||||
const defaultValues = { email: '', password: '' } satisfies Values;
|
const defaultValues = { email: 'admin@123.com', password: 'admin@123.com' } satisfies Values;
|
||||||
|
|
||||||
export function SignInForm(): React.JSX.Element {
|
export function SignInForm(): React.JSX.Element {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -103,15 +106,31 @@ export function SignInForm(): React.JSX.Element {
|
|||||||
return (
|
return (
|
||||||
<Stack spacing={4}>
|
<Stack spacing={4}>
|
||||||
<div>
|
<div>
|
||||||
<Box component={RouterLink} href={paths.home} sx={{ display: 'inline-block', fontSize: 0 }}>
|
<Box
|
||||||
<DynamicLogo colorDark="light" colorLight="dark" height={32} width={122} />
|
component={RouterLink}
|
||||||
|
href={paths.home}
|
||||||
|
sx={{ display: 'inline-block', fontSize: 0 }}
|
||||||
|
>
|
||||||
|
<DynamicLogo
|
||||||
|
colorDark="light"
|
||||||
|
colorLight="dark"
|
||||||
|
height={32}
|
||||||
|
width={122}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</div>
|
</div>
|
||||||
<Stack spacing={1}>
|
<Stack spacing={1}>
|
||||||
<Typography variant="h5">Sign in</Typography>
|
<Typography variant="h5">Sign in</Typography>
|
||||||
<Typography color="text.secondary" variant="body2">
|
<Typography
|
||||||
|
color="text.secondary"
|
||||||
|
variant="body2"
|
||||||
|
>
|
||||||
Don't have an account?{' '}
|
Don't have an account?{' '}
|
||||||
<Link component={RouterLink} href={paths.auth.custom.signUp} variant="subtitle2">
|
<Link
|
||||||
|
component={RouterLink}
|
||||||
|
href={paths.auth.custom.signUp}
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
Sign up
|
Sign up
|
||||||
</Link>
|
</Link>
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -123,7 +142,15 @@ export function SignInForm(): React.JSX.Element {
|
|||||||
<Button
|
<Button
|
||||||
color="secondary"
|
color="secondary"
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
endIcon={<Box alt="" component="img" height={24} src={provider.logo} width={24} />}
|
endIcon={
|
||||||
|
<Box
|
||||||
|
alt=""
|
||||||
|
component="img"
|
||||||
|
height={24}
|
||||||
|
src={provider.logo}
|
||||||
|
width={24}
|
||||||
|
/>
|
||||||
|
}
|
||||||
key={provider.id}
|
key={provider.id}
|
||||||
onClick={(): void => {
|
onClick={(): void => {
|
||||||
onAuth(provider.id).catch(() => {
|
onAuth(provider.id).catch(() => {
|
||||||
@@ -147,7 +174,10 @@ export function SignInForm(): React.JSX.Element {
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormControl error={Boolean(errors.email)}>
|
<FormControl error={Boolean(errors.email)}>
|
||||||
<InputLabel>Email address</InputLabel>
|
<InputLabel>Email address</InputLabel>
|
||||||
<OutlinedInput {...field} type="email" />
|
<OutlinedInput
|
||||||
|
{...field}
|
||||||
|
type="email"
|
||||||
|
/>
|
||||||
{errors.email ? <FormHelperText>{errors.email.message}</FormHelperText> : null}
|
{errors.email ? <FormHelperText>{errors.email.message}</FormHelperText> : null}
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
@@ -187,27 +217,65 @@ export function SignInForm(): React.JSX.Element {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{errors.root ? <Alert color="error">{errors.root.message}</Alert> : null}
|
{errors.root ? <Alert color="error">{errors.root.message}</Alert> : null}
|
||||||
<Button disabled={isPending} type="submit" variant="contained">
|
<Button
|
||||||
|
disabled={isPending}
|
||||||
|
type="submit"
|
||||||
|
variant="contained"
|
||||||
|
>
|
||||||
Sign in
|
Sign in
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</form>
|
</form>
|
||||||
<div>
|
<div>
|
||||||
<Link component={RouterLink} href={paths.auth.custom.resetPassword} variant="subtitle2">
|
<Link
|
||||||
|
component={RouterLink}
|
||||||
|
href={paths.auth.custom.resetPassword}
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
Forgot password?
|
Forgot password?
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Alert color="warning">
|
<Alert color="warning">
|
||||||
Use{' '}
|
<Stack>
|
||||||
<Typography component="span" sx={{ fontWeight: 700 }} variant="inherit">
|
<Box>
|
||||||
sofia@devias.io
|
user:{' '}
|
||||||
</Typography>{' '}
|
<Typography
|
||||||
with password{' '}
|
component="span"
|
||||||
<Typography component="span" sx={{ fontWeight: 700 }} variant="inherit">
|
sx={{ fontWeight: 700 }}
|
||||||
Secret1
|
variant="inherit"
|
||||||
</Typography>
|
>
|
||||||
|
admin@123.com
|
||||||
|
</Typography>{' '}
|
||||||
|
password{' '}
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{ fontWeight: 700 }}
|
||||||
|
variant="inherit"
|
||||||
|
>
|
||||||
|
admin@123.com
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
user{' '}
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{ fontWeight: 700 }}
|
||||||
|
variant="inherit"
|
||||||
|
>
|
||||||
|
sofia@devias.io
|
||||||
|
</Typography>{' '}
|
||||||
|
password{' '}
|
||||||
|
<Typography
|
||||||
|
component="span"
|
||||||
|
sx={{ fontWeight: 700 }}
|
||||||
|
variant="inherit"
|
||||||
|
>
|
||||||
|
Secret1
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
</Alert>
|
</Alert>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
@@ -115,15 +115,31 @@ export function SignInForm(): React.JSX.Element {
|
|||||||
return (
|
return (
|
||||||
<Stack spacing={4}>
|
<Stack spacing={4}>
|
||||||
<div>
|
<div>
|
||||||
<Box component={RouterLink} href={paths.home} sx={{ display: 'inline-block', fontSize: 0 }}>
|
<Box
|
||||||
<DynamicLogo colorDark="light" colorLight="dark" height={32} width={122} />
|
component={RouterLink}
|
||||||
|
href={paths.home}
|
||||||
|
sx={{ display: 'inline-block', fontSize: 0 }}
|
||||||
|
>
|
||||||
|
<DynamicLogo
|
||||||
|
colorDark="light"
|
||||||
|
colorLight="dark"
|
||||||
|
height={32}
|
||||||
|
width={122}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</div>
|
</div>
|
||||||
<Stack spacing={1}>
|
<Stack spacing={1}>
|
||||||
<Typography variant="h5">Sign in</Typography>
|
<Typography variant="h5">Sign in</Typography>
|
||||||
<Typography color="text.secondary" variant="body2">
|
<Typography
|
||||||
|
color="text.secondary"
|
||||||
|
variant="body2"
|
||||||
|
>
|
||||||
Don't have an account?{' '}
|
Don't have an account?{' '}
|
||||||
<Link component={RouterLink} href={paths.auth.supabase.signUp} variant="subtitle2">
|
<Link
|
||||||
|
component={RouterLink}
|
||||||
|
href={paths.auth.supabase.signUp}
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
Sign up
|
Sign up
|
||||||
</Link>
|
</Link>
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -135,7 +151,15 @@ export function SignInForm(): React.JSX.Element {
|
|||||||
<Button
|
<Button
|
||||||
color="secondary"
|
color="secondary"
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
endIcon={<Box alt="" component="img" height={24} src={provider.logo} width={24} />}
|
endIcon={
|
||||||
|
<Box
|
||||||
|
alt=""
|
||||||
|
component="img"
|
||||||
|
height={24}
|
||||||
|
src={provider.logo}
|
||||||
|
width={24}
|
||||||
|
/>
|
||||||
|
}
|
||||||
key={provider.id}
|
key={provider.id}
|
||||||
onClick={(): void => {
|
onClick={(): void => {
|
||||||
onAuth(provider.id).catch(() => {
|
onAuth(provider.id).catch(() => {
|
||||||
@@ -159,7 +183,10 @@ export function SignInForm(): React.JSX.Element {
|
|||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormControl error={Boolean(errors.email)}>
|
<FormControl error={Boolean(errors.email)}>
|
||||||
<InputLabel>Email address</InputLabel>
|
<InputLabel>Email address</InputLabel>
|
||||||
<OutlinedInput {...field} type="email" />
|
<OutlinedInput
|
||||||
|
{...field}
|
||||||
|
type="email"
|
||||||
|
/>
|
||||||
{errors.email ? <FormHelperText>{errors.email.message}</FormHelperText> : null}
|
{errors.email ? <FormHelperText>{errors.email.message}</FormHelperText> : null}
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
@@ -199,13 +226,21 @@ export function SignInForm(): React.JSX.Element {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{errors.root ? <Alert color="error">{errors.root.message}</Alert> : null}
|
{errors.root ? <Alert color="error">{errors.root.message}</Alert> : null}
|
||||||
<Button disabled={isPending} type="submit" variant="contained">
|
<Button
|
||||||
|
disabled={isPending}
|
||||||
|
type="submit"
|
||||||
|
variant="contained"
|
||||||
|
>
|
||||||
Sign in
|
Sign in
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</form>
|
</form>
|
||||||
<div>
|
<div>
|
||||||
<Link component={RouterLink} href={paths.auth.supabase.resetPassword} variant="subtitle2">
|
<Link
|
||||||
|
component={RouterLink}
|
||||||
|
href={paths.auth.supabase.resetPassword}
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
Forgot password?
|
Forgot password?
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -112,9 +112,15 @@ export function ContactsPopover({ anchorEl, onClose, open = false }: ContactsPop
|
|||||||
<Typography variant="h6">Contacts</Typography>
|
<Typography variant="h6">Contacts</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ maxHeight: '400px', overflowY: 'auto', px: 1, pb: 2 }}>
|
<Box sx={{ maxHeight: '400px', overflowY: 'auto', px: 1, pb: 2 }}>
|
||||||
<List disablePadding sx={{ '& .MuiListItemButton-root': { borderRadius: 1 } }}>
|
<List
|
||||||
|
disablePadding
|
||||||
|
sx={{ '& .MuiListItemButton-root': { borderRadius: 1 } }}
|
||||||
|
>
|
||||||
{contacts.map((contact) => (
|
{contacts.map((contact) => (
|
||||||
<ListItem disablePadding key={contact.id}>
|
<ListItem
|
||||||
|
disablePadding
|
||||||
|
key={contact.id}
|
||||||
|
>
|
||||||
<ListItemButton>
|
<ListItemButton>
|
||||||
<ListItemAvatar>
|
<ListItemAvatar>
|
||||||
<Avatar src={contact.avatar} />
|
<Avatar src={contact.avatar} />
|
||||||
@@ -122,14 +128,28 @@ export function ContactsPopover({ anchorEl, onClose, open = false }: ContactsPop
|
|||||||
<ListItemText
|
<ListItemText
|
||||||
disableTypography
|
disableTypography
|
||||||
primary={
|
primary={
|
||||||
<Link color="text.primary" noWrap underline="none" variant="subtitle2">
|
<Link
|
||||||
|
color="text.primary"
|
||||||
|
noWrap
|
||||||
|
underline="none"
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
{contact.name}
|
{contact.name}
|
||||||
</Link>
|
</Link>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{contact.status !== 'offline' ? <Presence size="small" status={contact.status} /> : null}
|
{contact.status !== 'offline' ? (
|
||||||
|
<Presence
|
||||||
|
size="small"
|
||||||
|
status={contact.status}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
{contact.status === 'offline' && Boolean(contact.lastActivity) ? (
|
{contact.status === 'offline' && Boolean(contact.lastActivity) ? (
|
||||||
<Typography color="text.secondary" sx={{ whiteSpace: 'nowrap' }} variant="caption">
|
<Typography
|
||||||
|
color="text.secondary"
|
||||||
|
sx={{ whiteSpace: 'nowrap' }}
|
||||||
|
variant="caption"
|
||||||
|
>
|
||||||
{dayjs(contact.lastActivity).fromNow()}
|
{dayjs(contact.lastActivity).fromNow()}
|
||||||
</Typography>
|
</Typography>
|
||||||
) : null}
|
) : null}
|
||||||
|
@@ -34,6 +34,7 @@ export function HorizontalLayout({ children }: HorizontalLayoutProps): React.JSX
|
|||||||
color={settings.navColor}
|
color={settings.navColor}
|
||||||
items={layoutConfig.navItems}
|
items={layoutConfig.navItems}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
component="main"
|
component="main"
|
||||||
sx={{
|
sx={{
|
||||||
|
@@ -36,15 +36,15 @@ import { Logo } from '@/components/core/logo';
|
|||||||
import { SearchDialog } from '@/components/dashboard/layout/search-dialog';
|
import { SearchDialog } from '@/components/dashboard/layout/search-dialog';
|
||||||
import type { ColorScheme } from '@/styles/theme/types';
|
import type { ColorScheme } from '@/styles/theme/types';
|
||||||
|
|
||||||
import { ContactsPopover } from '../contacts-popover';
|
import { ContactsPopover } from '../../contacts-popover';
|
||||||
import { languageFlags, LanguagePopover } from '../language-popover';
|
import { languageFlags, LanguagePopover } from '../../language-popover';
|
||||||
import type { Language } from '../language-popover';
|
import type { Language } from '../../language-popover';
|
||||||
import { MobileNav } from '../mobile-nav';
|
import { MobileNav } from '../../mobile-nav';
|
||||||
import { icons } from '../nav-icons';
|
import { icons } from '../../nav-icons';
|
||||||
import { NotificationsPopover } from '../notifications-popover';
|
import { NotificationsPopover } from '../../notifications-popover';
|
||||||
import { UserPopover } from '../user-popover/user-popover';
|
import { UserPopover } from '../../user-popover/user-popover';
|
||||||
import { WorkspacesSwitch } from '../workspaces-switch';
|
import { WorkspacesSwitch } from '../../workspaces-switch';
|
||||||
import { navColorStyles } from './styles';
|
import { navColorStyles } from '../styles';
|
||||||
|
|
||||||
const logoColors = {
|
const logoColors = {
|
||||||
dark: { blend_in: 'light', discrete: 'light', evident: 'light' },
|
dark: { blend_in: 'light', discrete: 'light', evident: 'light' },
|
||||||
@@ -92,7 +92,11 @@ export function MainNav({ color = 'evident', items = [] }: MainNavProps): React.
|
|||||||
py: 1,
|
py: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack direction="row" spacing={2} sx={{ alignItems: 'center', flex: '1 1 auto' }}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'center', flex: '1 1 auto' }}
|
||||||
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={(): void => {
|
onClick={(): void => {
|
||||||
setOpenNav(true);
|
setOpenNav(true);
|
||||||
@@ -101,8 +105,16 @@ export function MainNav({ color = 'evident', items = [] }: MainNavProps): React.
|
|||||||
>
|
>
|
||||||
<ListIcon color="var(--NavItem-icon-color)" />
|
<ListIcon color="var(--NavItem-icon-color)" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Box component={RouterLink} href={paths.home} sx={{ display: { xs: 'none', md: 'inline-block' } }}>
|
<Box
|
||||||
<Logo color={logoColor} height={32} width={122} />
|
component={RouterLink}
|
||||||
|
href={paths.home}
|
||||||
|
sx={{ display: { xs: 'none', md: 'inline-block' } }}
|
||||||
|
>
|
||||||
|
<Logo
|
||||||
|
color={logoColor}
|
||||||
|
height={32}
|
||||||
|
width={122}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ display: { xs: 'none', md: 'block' } }}>
|
<Box sx={{ display: { xs: 'none', md: 'block' } }}>
|
||||||
<WorkspacesSwitch />
|
<WorkspacesSwitch />
|
||||||
@@ -154,11 +166,17 @@ function SearchButton(): React.JSX.Element {
|
|||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Tooltip title="Search">
|
<Tooltip title="Search">
|
||||||
<IconButton onClick={dialog.handleOpen} sx={{ display: { xs: 'none', md: 'inline-flex' } }}>
|
<IconButton
|
||||||
|
onClick={dialog.handleOpen}
|
||||||
|
sx={{ display: { xs: 'none', md: 'inline-flex' } }}
|
||||||
|
>
|
||||||
<MagnifyingGlassIcon color="var(--NavItem-icon-color)" />
|
<MagnifyingGlassIcon color="var(--NavItem-icon-color)" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<SearchDialog onClose={dialog.handleClose} open={dialog.open} />
|
<SearchDialog
|
||||||
|
onClose={dialog.handleClose}
|
||||||
|
open={dialog.open}
|
||||||
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -174,12 +192,19 @@ function NotificationsButton(): React.JSX.Element {
|
|||||||
sx={{ '& .MuiBadge-dot': { borderRadius: '50%', height: '10px', right: '6px', top: '6px', width: '10px' } }}
|
sx={{ '& .MuiBadge-dot': { borderRadius: '50%', height: '10px', right: '6px', top: '6px', width: '10px' } }}
|
||||||
variant="dot"
|
variant="dot"
|
||||||
>
|
>
|
||||||
<IconButton onClick={popover.handleOpen} ref={popover.anchorRef}>
|
<IconButton
|
||||||
|
onClick={popover.handleOpen}
|
||||||
|
ref={popover.anchorRef}
|
||||||
|
>
|
||||||
<BellIcon color="var(--NavItem-icon-color)" />
|
<BellIcon color="var(--NavItem-icon-color)" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Badge>
|
</Badge>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<NotificationsPopover anchorEl={popover.anchorRef.current} onClose={popover.handleClose} open={popover.open} />
|
<NotificationsPopover
|
||||||
|
anchorEl={popover.anchorRef.current}
|
||||||
|
onClose={popover.handleClose}
|
||||||
|
open={popover.open}
|
||||||
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -190,11 +215,18 @@ function ContactsButton(): React.JSX.Element {
|
|||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Tooltip title="Contacts">
|
<Tooltip title="Contacts">
|
||||||
<IconButton onClick={popover.handleOpen} ref={popover.anchorRef}>
|
<IconButton
|
||||||
|
onClick={popover.handleOpen}
|
||||||
|
ref={popover.anchorRef}
|
||||||
|
>
|
||||||
<UsersIcon color="var(--NavItem-icon-color)" />
|
<UsersIcon color="var(--NavItem-icon-color)" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<ContactsPopover anchorEl={popover.anchorRef.current} onClose={popover.handleClose} open={popover.open} />
|
<ContactsPopover
|
||||||
|
anchorEl={popover.anchorRef.current}
|
||||||
|
onClose={popover.handleClose}
|
||||||
|
open={popover.open}
|
||||||
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -214,11 +246,20 @@ function LanguageSwitch(): React.JSX.Element {
|
|||||||
sx={{ display: { xs: 'none', md: 'inline-flex' } }}
|
sx={{ display: { xs: 'none', md: 'inline-flex' } }}
|
||||||
>
|
>
|
||||||
<Box sx={{ height: '24px', width: '24px' }}>
|
<Box sx={{ height: '24px', width: '24px' }}>
|
||||||
<Box alt={language} component="img" src={flag} sx={{ height: 'auto', width: '100%' }} />
|
<Box
|
||||||
|
alt={language}
|
||||||
|
component="img"
|
||||||
|
src={flag}
|
||||||
|
sx={{ height: 'auto', width: '100%' }}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<LanguagePopover anchorEl={popover.anchorRef.current} onClose={popover.handleClose} open={popover.open} />
|
<LanguagePopover
|
||||||
|
anchorEl={popover.anchorRef.current}
|
||||||
|
onClose={popover.handleClose}
|
||||||
|
open={popover.open}
|
||||||
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -259,7 +300,11 @@ function UserButton(): React.JSX.Element {
|
|||||||
<Avatar src={user.avatar} />
|
<Avatar src={user.avatar} />
|
||||||
</Badge>
|
</Badge>
|
||||||
</Box>
|
</Box>
|
||||||
<UserPopover anchorEl={popover.anchorRef.current} onClose={popover.handleClose} open={popover.open} />
|
<UserPopover
|
||||||
|
anchorEl={popover.anchorRef.current}
|
||||||
|
onClose={popover.handleClose}
|
||||||
|
open={popover.open}
|
||||||
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -267,7 +312,11 @@ function UserButton(): React.JSX.Element {
|
|||||||
function renderNavGroups({ items = [], pathname }: { items?: NavItemConfig[]; pathname: string }): React.JSX.Element {
|
function renderNavGroups({ items = [], pathname }: { items?: NavItemConfig[]; pathname: string }): React.JSX.Element {
|
||||||
const children = items.reduce((acc: React.ReactNode[], curr: NavItemConfig): React.ReactNode[] => {
|
const children = items.reduce((acc: React.ReactNode[], curr: NavItemConfig): React.ReactNode[] => {
|
||||||
acc.push(
|
acc.push(
|
||||||
<Box component="li" key={curr.key} sx={{ flex: '0 0 auto' }}>
|
<Box
|
||||||
|
component="li"
|
||||||
|
key={curr.key}
|
||||||
|
sx={{ flex: '0 0 auto' }}
|
||||||
|
>
|
||||||
{renderNavItems({ pathname, items: curr.items })}
|
{renderNavItems({ pathname, items: curr.items })}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
@@ -276,7 +325,12 @@ function renderNavGroups({ items = [], pathname }: { items?: NavItemConfig[]; pa
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack component="ul" direction="row" spacing={2} sx={{ listStyle: 'none', m: 0, p: '8px 12px' }}>
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ listStyle: 'none', m: 0, p: '8px 12px' }}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
@@ -286,13 +340,24 @@ function renderNavItems({ items = [], pathname }: { items?: NavItemConfig[]; pat
|
|||||||
const children = items.reduce((acc: React.ReactNode[], curr: NavItemConfig): React.ReactNode[] => {
|
const children = items.reduce((acc: React.ReactNode[], curr: NavItemConfig): React.ReactNode[] => {
|
||||||
const { key, ...item } = curr;
|
const { key, ...item } = curr;
|
||||||
|
|
||||||
acc.push(<NavItem key={key} pathname={pathname} {...item} />);
|
acc.push(
|
||||||
|
<NavItem
|
||||||
|
key={key}
|
||||||
|
pathname={pathname}
|
||||||
|
{...item}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack component="ul" direction="row" spacing={2} sx={{ listStyle: 'none', m: 0, p: 0 }}>
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ listStyle: 'none', m: 0, p: 0 }}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
@@ -318,7 +383,10 @@ function NavItem({
|
|||||||
const isBranch = Boolean(items);
|
const isBranch = Boolean(items);
|
||||||
|
|
||||||
const element = (
|
const element = (
|
||||||
<Box component="li" sx={{ userSelect: 'none' }}>
|
<Box
|
||||||
|
component="li"
|
||||||
|
sx={{ userSelect: 'none' }}
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
{...(isBranch
|
{...(isBranch
|
||||||
? { role: 'button' }
|
? { role: 'button' }
|
||||||
@@ -373,10 +441,19 @@ function NavItem({
|
|||||||
{title}
|
{title}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
{label ? <Chip color="primary" label={label} size="small" /> : null}
|
{label ? (
|
||||||
|
<Chip
|
||||||
|
color="primary"
|
||||||
|
label={label}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
{external ? (
|
{external ? (
|
||||||
<Box sx={{ alignItems: 'center', display: 'flex', flex: '0 0 auto' }}>
|
<Box sx={{ alignItems: 'center', display: 'flex', flex: '0 0 auto' }}>
|
||||||
<ArrowSquareOutIcon color="var(--NavItem-icon-color)" fontSize="var(--icon-fontSize-sm)" />
|
<ArrowSquareOutIcon
|
||||||
|
color="var(--NavItem-icon-color)"
|
||||||
|
fontSize="var(--icon-fontSize-sm)"
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
) : null}
|
) : null}
|
||||||
{isBranch ? (
|
{isBranch ? (
|
||||||
@@ -415,13 +492,23 @@ function renderDropdownItems({
|
|||||||
const children = items.reduce((acc: React.ReactNode[], curr: NavItemConfig): React.ReactNode[] => {
|
const children = items.reduce((acc: React.ReactNode[], curr: NavItemConfig): React.ReactNode[] => {
|
||||||
const { key, ...item } = curr;
|
const { key, ...item } = curr;
|
||||||
|
|
||||||
acc.push(<DropdownItem key={key} pathname={pathname} {...item} />);
|
acc.push(
|
||||||
|
<DropdownItem
|
||||||
|
key={key}
|
||||||
|
pathname={pathname}
|
||||||
|
{...item}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack component="ul" spacing={1} sx={{ listStyle: 'none', m: 0, p: 0 }}>
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
spacing={1}
|
||||||
|
sx={{ listStyle: 'none', m: 0, p: 0 }}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
@@ -444,7 +531,10 @@ function DropdownItem({
|
|||||||
const isBranch = Boolean(items);
|
const isBranch = Boolean(items);
|
||||||
|
|
||||||
const element = (
|
const element = (
|
||||||
<Box component="li" sx={{ userSelect: 'none' }}>
|
<Box
|
||||||
|
component="li"
|
||||||
|
sx={{ userSelect: 'none' }}
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
{...(isBranch
|
{...(isBranch
|
||||||
? { role: 'button' }
|
? { role: 'button' }
|
@@ -37,7 +37,11 @@ export function CustomSignOut(): React.JSX.Element {
|
|||||||
}, [checkSession, router]);
|
}, [checkSession, router]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MenuItem component="div" onClick={handleSignOut} sx={{ justifyContent: 'center' }}>
|
<MenuItem
|
||||||
|
component="div"
|
||||||
|
onClick={handleSignOut}
|
||||||
|
sx={{ justifyContent: 'center' }}
|
||||||
|
>
|
||||||
Sign out
|
Sign out
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
);
|
);
|
||||||
|
@@ -23,8 +23,10 @@ import { CognitoSignOut } from './cognito-sign-out';
|
|||||||
import { CustomSignOut } from './custom-sign-out';
|
import { CustomSignOut } from './custom-sign-out';
|
||||||
import { FirebaseSignOut } from './firebase-sign-out';
|
import { FirebaseSignOut } from './firebase-sign-out';
|
||||||
import { SupabaseSignOut } from './supabase-sign-out';
|
import { SupabaseSignOut } from './supabase-sign-out';
|
||||||
|
import { authClient } from '@/lib/auth/custom/client';
|
||||||
|
import { logger } from '@/lib/default-logger';
|
||||||
|
|
||||||
const user = {
|
const defaultUser = {
|
||||||
id: 'USR-000',
|
id: 'USR-000',
|
||||||
name: 'Sofia Rivers',
|
name: 'Sofia Rivers',
|
||||||
avatar: '/assets/avatar.png',
|
avatar: '/assets/avatar.png',
|
||||||
@@ -38,6 +40,23 @@ export interface UserPopoverProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function UserPopover({ anchorEl, onClose, open }: UserPopoverProps): React.JSX.Element {
|
export function UserPopover({ anchorEl, onClose, open }: UserPopoverProps): React.JSX.Element {
|
||||||
|
const [userMeta, setUserMeta] = React.useState<User>(defaultUser);
|
||||||
|
async function loadUserMeta(): Promise<void> {
|
||||||
|
try {
|
||||||
|
const tempUserMeta = await authClient.getUser();
|
||||||
|
if (tempUserMeta.error) throw new Error(tempUserMeta.error);
|
||||||
|
setUserMeta(tempUserMeta.data as unknown as User);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
void loadUserMeta();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!userMeta) return <>loading</>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover
|
<Popover
|
||||||
anchorEl={anchorEl}
|
anchorEl={anchorEl}
|
||||||
@@ -48,26 +67,41 @@ export function UserPopover({ anchorEl, onClose, open }: UserPopoverProps): Reac
|
|||||||
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
|
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
|
||||||
>
|
>
|
||||||
<Box sx={{ p: 2 }}>
|
<Box sx={{ p: 2 }}>
|
||||||
<Typography>{user.name}</Typography>
|
<Typography>{userMeta.name}</Typography>
|
||||||
<Typography color="text.secondary" variant="body2">
|
<Typography
|
||||||
{user.email}
|
color="text.secondary"
|
||||||
|
variant="body2"
|
||||||
|
>
|
||||||
|
{userMeta.email}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Divider />
|
<Divider />
|
||||||
<List sx={{ p: 1 }}>
|
<List sx={{ p: 1 }}>
|
||||||
<MenuItem component={RouterLink} href={paths.dashboard.settings.account} onClick={onClose}>
|
<MenuItem
|
||||||
|
component={RouterLink}
|
||||||
|
href={paths.dashboard.settings.account}
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<UserIcon />
|
<UserIcon />
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
Account
|
Account
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem component={RouterLink} href={paths.dashboard.settings.security} onClick={onClose}>
|
<MenuItem
|
||||||
|
component={RouterLink}
|
||||||
|
href={paths.dashboard.settings.security}
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<LockKeyIcon />
|
<LockKeyIcon />
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
Security
|
Security
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem component={RouterLink} href={paths.dashboard.settings.billing} onClick={onClose}>
|
<MenuItem
|
||||||
|
component={RouterLink}
|
||||||
|
href={paths.dashboard.settings.billing}
|
||||||
|
onClick={onClose}
|
||||||
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<CreditCardIcon />
|
<CreditCardIcon />
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
|
@@ -1,216 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import * as React from 'react';
|
|
||||||
import Avatar from '@mui/material/Avatar';
|
|
||||||
import Badge from '@mui/material/Badge';
|
|
||||||
import Box from '@mui/material/Box';
|
|
||||||
import Divider from '@mui/material/Divider';
|
|
||||||
import IconButton from '@mui/material/IconButton';
|
|
||||||
import Stack from '@mui/material/Stack';
|
|
||||||
import Tooltip from '@mui/material/Tooltip';
|
|
||||||
import { Bell as BellIcon } from '@phosphor-icons/react/dist/ssr/Bell';
|
|
||||||
import { List as ListIcon } from '@phosphor-icons/react/dist/ssr/List';
|
|
||||||
import { MagnifyingGlass as MagnifyingGlassIcon } from '@phosphor-icons/react/dist/ssr/MagnifyingGlass';
|
|
||||||
import { Users as UsersIcon } from '@phosphor-icons/react/dist/ssr/Users';
|
|
||||||
import { useTranslation } from 'next-i18next';
|
|
||||||
|
|
||||||
import type { NavItemConfig } from '@/types/nav';
|
|
||||||
import type { User } from '@/types/user';
|
|
||||||
import { useDialog } from '@/hooks/use-dialog';
|
|
||||||
import { usePopover } from '@/hooks/use-popover';
|
|
||||||
|
|
||||||
import { ContactsPopover } from '../contacts-popover';
|
|
||||||
import { languageFlags, LanguagePopover } from '../language-popover';
|
|
||||||
import type { Language } from '../language-popover';
|
|
||||||
import { MobileNav } from '../mobile-nav';
|
|
||||||
import { NotificationsPopover } from '../notifications-popover';
|
|
||||||
import { SearchDialog } from '../search-dialog';
|
|
||||||
import { UserPopover } from '../user-popover/user-popover';
|
|
||||||
|
|
||||||
export interface MainNavProps {
|
|
||||||
items: NavItemConfig[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function MainNav({ items }: MainNavProps): React.JSX.Element {
|
|
||||||
const [openNav, setOpenNav] = React.useState<boolean>(false);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<Box
|
|
||||||
component="header"
|
|
||||||
sx={{
|
|
||||||
'--MainNav-background': 'var(--mui-palette-background-default)',
|
|
||||||
'--MainNav-divider': 'var(--mui-palette-divider)',
|
|
||||||
bgcolor: 'var(--MainNav-background)',
|
|
||||||
left: 0,
|
|
||||||
position: 'sticky',
|
|
||||||
pt: { lg: 'var(--Layout-gap)' },
|
|
||||||
top: 0,
|
|
||||||
width: '100%',
|
|
||||||
zIndex: 'var(--MainNav-zIndex)',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
borderBottom: '1px solid var(--MainNav-divider)',
|
|
||||||
display: 'flex',
|
|
||||||
flex: '1 1 auto',
|
|
||||||
minHeight: 'var(--MainNav-height)',
|
|
||||||
px: { xs: 2, lg: 3 },
|
|
||||||
py: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Stack direction="row" spacing={2} sx={{ alignItems: 'center', flex: '1 1 auto' }}>
|
|
||||||
<IconButton
|
|
||||||
onClick={(): void => {
|
|
||||||
setOpenNav(true);
|
|
||||||
}}
|
|
||||||
sx={{ display: { lg: 'none' } }}
|
|
||||||
>
|
|
||||||
<ListIcon />
|
|
||||||
</IconButton>
|
|
||||||
<SearchButton />
|
|
||||||
</Stack>
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
spacing={2}
|
|
||||||
sx={{ alignItems: 'center', flex: '1 1 auto', justifyContent: 'flex-end' }}
|
|
||||||
>
|
|
||||||
<NotificationsButton />
|
|
||||||
<ContactsButton />
|
|
||||||
<Divider
|
|
||||||
flexItem
|
|
||||||
orientation="vertical"
|
|
||||||
sx={{ borderColor: 'var(--MainNav-divider)', display: { xs: 'none', lg: 'block' } }}
|
|
||||||
/>
|
|
||||||
<LanguageSwitch />
|
|
||||||
<UserButton />
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<MobileNav
|
|
||||||
items={items}
|
|
||||||
onClose={() => {
|
|
||||||
setOpenNav(false);
|
|
||||||
}}
|
|
||||||
open={openNav}
|
|
||||||
/>
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function SearchButton(): React.JSX.Element {
|
|
||||||
const dialog = useDialog();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<Tooltip title="Search">
|
|
||||||
<IconButton onClick={dialog.handleOpen} sx={{ display: { xs: 'none', lg: 'inline-flex' } }}>
|
|
||||||
<MagnifyingGlassIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<SearchDialog onClose={dialog.handleClose} open={dialog.open} />
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ContactsButton(): React.JSX.Element {
|
|
||||||
const popover = usePopover<HTMLButtonElement>();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<Tooltip title="Contacts">
|
|
||||||
<IconButton onClick={popover.handleOpen} ref={popover.anchorRef}>
|
|
||||||
<UsersIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<ContactsPopover anchorEl={popover.anchorRef.current} onClose={popover.handleClose} open={popover.open} />
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function NotificationsButton(): React.JSX.Element {
|
|
||||||
const popover = usePopover<HTMLButtonElement>();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<Tooltip title="Notifications">
|
|
||||||
<Badge
|
|
||||||
color="error"
|
|
||||||
sx={{ '& .MuiBadge-dot': { borderRadius: '50%', height: '10px', right: '6px', top: '6px', width: '10px' } }}
|
|
||||||
variant="dot"
|
|
||||||
>
|
|
||||||
<IconButton onClick={popover.handleOpen} ref={popover.anchorRef}>
|
|
||||||
<BellIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Badge>
|
|
||||||
</Tooltip>
|
|
||||||
<NotificationsPopover anchorEl={popover.anchorRef.current} onClose={popover.handleClose} open={popover.open} />
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function LanguageSwitch(): React.JSX.Element {
|
|
||||||
const { i18n } = useTranslation();
|
|
||||||
const popover = usePopover<HTMLButtonElement>();
|
|
||||||
const language = (i18n.language || 'en') as Language;
|
|
||||||
const flag = languageFlags[language];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<Tooltip title="Language">
|
|
||||||
<IconButton
|
|
||||||
onClick={popover.handleOpen}
|
|
||||||
ref={popover.anchorRef}
|
|
||||||
sx={{ display: { xs: 'none', lg: 'inline-flex' } }}
|
|
||||||
>
|
|
||||||
<Box sx={{ height: '24px', width: '24px' }}>
|
|
||||||
<Box alt={language} component="img" src={flag} sx={{ height: 'auto', width: '100%' }} />
|
|
||||||
</Box>
|
|
||||||
</IconButton>
|
|
||||||
</Tooltip>
|
|
||||||
<LanguagePopover anchorEl={popover.anchorRef.current} onClose={popover.handleClose} open={popover.open} />
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const user = {
|
|
||||||
id: 'USR-000',
|
|
||||||
name: 'Sofia Rivers',
|
|
||||||
avatar: '/assets/avatar.png',
|
|
||||||
email: 'sofia@devias.io',
|
|
||||||
} satisfies User;
|
|
||||||
|
|
||||||
function UserButton(): React.JSX.Element {
|
|
||||||
const popover = usePopover<HTMLButtonElement>();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<Box
|
|
||||||
component="button"
|
|
||||||
onClick={popover.handleOpen}
|
|
||||||
ref={popover.anchorRef}
|
|
||||||
sx={{ border: 'none', background: 'transparent', cursor: 'pointer', p: 0 }}
|
|
||||||
>
|
|
||||||
<Badge
|
|
||||||
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
|
|
||||||
color="success"
|
|
||||||
sx={{
|
|
||||||
'& .MuiBadge-dot': {
|
|
||||||
border: '2px solid var(--MainNav-background)',
|
|
||||||
borderRadius: '50%',
|
|
||||||
bottom: '6px',
|
|
||||||
height: '12px',
|
|
||||||
right: '6px',
|
|
||||||
width: '12px',
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
variant="dot"
|
|
||||||
>
|
|
||||||
<Avatar src={user.avatar} />
|
|
||||||
</Badge>
|
|
||||||
</Box>
|
|
||||||
<UserPopover anchorEl={popover.anchorRef.current} onClose={popover.handleClose} open={popover.open} />
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
@@ -0,0 +1,3 @@
|
|||||||
|
# GUIDELINE
|
||||||
|
|
||||||
|
- please keep one default `export` per file
|
@@ -0,0 +1,32 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import IconButton from '@mui/material/IconButton';
|
||||||
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
|
import { Users as UsersIcon } from '@phosphor-icons/react/dist/ssr/Users';
|
||||||
|
|
||||||
|
import { usePopover } from '@/hooks/use-popover';
|
||||||
|
|
||||||
|
import { ContactsPopover } from '../../contacts-popover';
|
||||||
|
|
||||||
|
export function ContactsButton(): React.JSX.Element {
|
||||||
|
const popover = usePopover<HTMLButtonElement>();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Tooltip title="Contacts">
|
||||||
|
<IconButton
|
||||||
|
onClick={popover.handleOpen}
|
||||||
|
ref={popover.anchorRef}
|
||||||
|
>
|
||||||
|
<UsersIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<ContactsPopover
|
||||||
|
anchorEl={popover.anchorRef.current}
|
||||||
|
onClose={popover.handleClose}
|
||||||
|
open={popover.open}
|
||||||
|
/>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
@@ -0,0 +1,94 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
|
import Divider from '@mui/material/Divider';
|
||||||
|
import IconButton from '@mui/material/IconButton';
|
||||||
|
import Stack from '@mui/material/Stack';
|
||||||
|
import { List as ListIcon } from '@phosphor-icons/react/dist/ssr/List';
|
||||||
|
|
||||||
|
import type { NavItemConfig } from '@/types/nav';
|
||||||
|
|
||||||
|
import { MobileNav } from '../../mobile-nav';
|
||||||
|
// import { NotificationsButton } from './notifications-button';
|
||||||
|
import { LanguageSwitch } from './language-switch';
|
||||||
|
import { ContactsButton } from './contacts-button';
|
||||||
|
import { SearchButton } from './search-button';
|
||||||
|
import { NotificationsButton } from './notifications-button';
|
||||||
|
import { UserButton } from './user-button';
|
||||||
|
|
||||||
|
export interface MainNavProps {
|
||||||
|
items: NavItemConfig[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MainNav({ items }: MainNavProps): React.JSX.Element {
|
||||||
|
const [openNav, setOpenNav] = React.useState<boolean>(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Box
|
||||||
|
component="header"
|
||||||
|
sx={{
|
||||||
|
'--MainNav-background': 'var(--mui-palette-background-default)',
|
||||||
|
'--MainNav-divider': 'var(--mui-palette-divider)',
|
||||||
|
bgcolor: 'var(--MainNav-background)',
|
||||||
|
left: 0,
|
||||||
|
position: 'sticky',
|
||||||
|
pt: { lg: 'var(--Layout-gap)' },
|
||||||
|
top: 0,
|
||||||
|
width: '100%',
|
||||||
|
zIndex: 'var(--MainNav-zIndex)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
borderBottom: '1px solid var(--MainNav-divider)',
|
||||||
|
display: 'flex',
|
||||||
|
flex: '1 1 auto',
|
||||||
|
minHeight: 'var(--MainNav-height)',
|
||||||
|
px: { xs: 2, lg: 3 },
|
||||||
|
py: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'center', flex: '1 1 auto' }}
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
onClick={(): void => {
|
||||||
|
setOpenNav(true);
|
||||||
|
}}
|
||||||
|
sx={{ display: { lg: 'none' } }}
|
||||||
|
>
|
||||||
|
<ListIcon />
|
||||||
|
</IconButton>
|
||||||
|
<SearchButton />
|
||||||
|
</Stack>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'center', flex: '1 1 auto', justifyContent: 'flex-end' }}
|
||||||
|
>
|
||||||
|
<NotificationsButton />
|
||||||
|
<ContactsButton />
|
||||||
|
<Divider
|
||||||
|
flexItem
|
||||||
|
orientation="vertical"
|
||||||
|
sx={{ borderColor: 'var(--MainNav-divider)', display: { xs: 'none', lg: 'block' } }}
|
||||||
|
/>
|
||||||
|
<LanguageSwitch />
|
||||||
|
<UserButton />
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<MobileNav
|
||||||
|
items={items}
|
||||||
|
onClose={() => {
|
||||||
|
setOpenNav(false);
|
||||||
|
}}
|
||||||
|
open={openNav}
|
||||||
|
/>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
@@ -0,0 +1,45 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
|
import IconButton from '@mui/material/IconButton';
|
||||||
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
|
import { useTranslation } from 'next-i18next';
|
||||||
|
|
||||||
|
import { usePopover } from '@/hooks/use-popover';
|
||||||
|
|
||||||
|
import { languageFlags, LanguagePopover } from '../../language-popover';
|
||||||
|
import type { Language } from '../../language-popover';
|
||||||
|
|
||||||
|
export function LanguageSwitch(): React.JSX.Element {
|
||||||
|
const { i18n } = useTranslation();
|
||||||
|
const popover = usePopover<HTMLButtonElement>();
|
||||||
|
const language = (i18n.language || 'en') as Language;
|
||||||
|
const flag = languageFlags[language];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Tooltip title="Language">
|
||||||
|
<IconButton
|
||||||
|
onClick={popover.handleOpen}
|
||||||
|
ref={popover.anchorRef}
|
||||||
|
sx={{ display: { xs: 'none', lg: 'inline-flex' } }}
|
||||||
|
>
|
||||||
|
<Box sx={{ height: '24px', width: '24px' }}>
|
||||||
|
<Box
|
||||||
|
alt={language}
|
||||||
|
component="img"
|
||||||
|
src={flag}
|
||||||
|
sx={{ height: 'auto', width: '100%' }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<LanguagePopover
|
||||||
|
anchorEl={popover.anchorRef.current}
|
||||||
|
onClose={popover.handleClose}
|
||||||
|
open={popover.open}
|
||||||
|
/>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
@@ -0,0 +1,40 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import Badge from '@mui/material/Badge';
|
||||||
|
import IconButton from '@mui/material/IconButton';
|
||||||
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
|
import { Bell as BellIcon } from '@phosphor-icons/react/dist/ssr/Bell';
|
||||||
|
|
||||||
|
import { usePopover } from '@/hooks/use-popover';
|
||||||
|
|
||||||
|
import { NotificationsPopover } from '../../notifications-popover';
|
||||||
|
// import { NotificationsButton } from './notifications-button';
|
||||||
|
|
||||||
|
export function NotificationsButton(): React.JSX.Element {
|
||||||
|
const popover = usePopover<HTMLButtonElement>();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Tooltip title="Notifications">
|
||||||
|
<Badge
|
||||||
|
color="error"
|
||||||
|
sx={{ '& .MuiBadge-dot': { borderRadius: '50%', height: '10px', right: '6px', top: '6px', width: '10px' } }}
|
||||||
|
variant="dot"
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
onClick={popover.handleOpen}
|
||||||
|
ref={popover.anchorRef}
|
||||||
|
>
|
||||||
|
<BellIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Badge>
|
||||||
|
</Tooltip>
|
||||||
|
<NotificationsPopover
|
||||||
|
anchorEl={popover.anchorRef.current}
|
||||||
|
onClose={popover.handleClose}
|
||||||
|
open={popover.open}
|
||||||
|
/>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
@@ -0,0 +1,31 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import IconButton from '@mui/material/IconButton';
|
||||||
|
import Tooltip from '@mui/material/Tooltip';
|
||||||
|
import { MagnifyingGlass as MagnifyingGlassIcon } from '@phosphor-icons/react/dist/ssr/MagnifyingGlass';
|
||||||
|
|
||||||
|
import { useDialog } from '@/hooks/use-dialog';
|
||||||
|
|
||||||
|
import { SearchDialog } from '../../search-dialog';
|
||||||
|
|
||||||
|
export function SearchButton(): React.JSX.Element {
|
||||||
|
const dialog = useDialog();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Tooltip title="Search">
|
||||||
|
<IconButton
|
||||||
|
onClick={dialog.handleOpen}
|
||||||
|
sx={{ display: { xs: 'none', lg: 'inline-flex' } }}
|
||||||
|
>
|
||||||
|
<MagnifyingGlassIcon />
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
<SearchDialog
|
||||||
|
onClose={dialog.handleClose}
|
||||||
|
open={dialog.open}
|
||||||
|
/>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
@@ -0,0 +1,63 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import Avatar from '@mui/material/Avatar';
|
||||||
|
import Badge from '@mui/material/Badge';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
|
|
||||||
|
import type { User } from '@/types/user';
|
||||||
|
import { usePopover } from '@/hooks/use-popover';
|
||||||
|
|
||||||
|
import { UserPopover } from '../../user-popover/user-popover';
|
||||||
|
import { useUser } from '@/hooks/use-user';
|
||||||
|
import getImageUrlFromFile from '@/lib/get-image-url-from-file.ts';
|
||||||
|
// import { NotificationsButton } from './notifications-button';
|
||||||
|
|
||||||
|
// TODO:remove me
|
||||||
|
const user1 = {
|
||||||
|
id: 'USR-000',
|
||||||
|
name: 'Sofia Rivers',
|
||||||
|
avatar: '/assets/avatar.png',
|
||||||
|
email: 'sofia@devias.io',
|
||||||
|
} satisfies User;
|
||||||
|
|
||||||
|
export function UserButton(): React.JSX.Element {
|
||||||
|
const popover = usePopover<HTMLButtonElement>();
|
||||||
|
const { user, error, isLoading } = useUser();
|
||||||
|
|
||||||
|
if (!user) return <>loading</>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Box
|
||||||
|
component="button"
|
||||||
|
onClick={popover.handleOpen}
|
||||||
|
ref={popover.anchorRef}
|
||||||
|
sx={{ border: 'none', background: 'transparent', cursor: 'pointer', p: 0 }}
|
||||||
|
>
|
||||||
|
<Badge
|
||||||
|
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
|
||||||
|
color="success"
|
||||||
|
sx={{
|
||||||
|
'& .MuiBadge-dot': {
|
||||||
|
border: '2px solid var(--MainNav-background)',
|
||||||
|
borderRadius: '50%',
|
||||||
|
bottom: '6px',
|
||||||
|
height: '12px',
|
||||||
|
right: '6px',
|
||||||
|
width: '12px',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
variant="dot"
|
||||||
|
>
|
||||||
|
<Avatar src={getImageUrlFromFile(user.collectionId, user.id, user.avatar)} />
|
||||||
|
</Badge>
|
||||||
|
</Box>
|
||||||
|
<UserPopover
|
||||||
|
anchorEl={popover.anchorRef.current}
|
||||||
|
onClose={popover.handleClose}
|
||||||
|
open={popover.open}
|
||||||
|
/>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
@@ -0,0 +1,9 @@
|
|||||||
|
'use client';
|
||||||
|
import type { User } from '@/types/user';
|
||||||
|
|
||||||
|
export const user = {
|
||||||
|
id: 'USR-000',
|
||||||
|
name: 'Sofia Rivers',
|
||||||
|
avatar: '/assets/avatar.png',
|
||||||
|
email: 'sofia@devias.io',
|
||||||
|
} satisfies User;
|
@@ -0,0 +1,98 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import RouterLink from 'next/link';
|
||||||
|
import { usePathname } from 'next/navigation';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
|
import Chip from '@mui/material/Chip';
|
||||||
|
import Stack from '@mui/material/Stack';
|
||||||
|
import Typography from '@mui/material/Typography';
|
||||||
|
import { ArrowSquareOut as ArrowSquareOutIcon } from '@phosphor-icons/react/dist/ssr/ArrowSquareOut';
|
||||||
|
import { CaretDown as CaretDownIcon } from '@phosphor-icons/react/dist/ssr/CaretDown';
|
||||||
|
import { CaretRight as CaretRightIcon } from '@phosphor-icons/react/dist/ssr/CaretRight';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import type { NavItemConfig } from '@/types/nav';
|
||||||
|
import type { NavColor } from '@/types/settings';
|
||||||
|
import { paths } from '@/paths';
|
||||||
|
import { isNavItemActive } from '@/lib/is-nav-item-active';
|
||||||
|
import { useSettings } from '@/hooks/use-settings';
|
||||||
|
import { Logo } from '@/components/core/logo';
|
||||||
|
import type { ColorScheme } from '@/styles/theme/types';
|
||||||
|
|
||||||
|
import { icons } from '../../nav-icons';
|
||||||
|
import { WorkspacesSwitch } from '../../workspaces-switch';
|
||||||
|
import { navColorStyles } from '../styles';
|
||||||
|
import { RenderNavGroups } from './render-nav-groups';
|
||||||
|
|
||||||
|
const logoColors = {
|
||||||
|
dark: { blend_in: 'light', discrete: 'light', evident: 'light' },
|
||||||
|
light: { blend_in: 'dark', discrete: 'dark', evident: 'light' },
|
||||||
|
} as Record<ColorScheme, Record<NavColor, 'dark' | 'light'>>;
|
||||||
|
|
||||||
|
export interface SideNavProps {
|
||||||
|
color?: NavColor;
|
||||||
|
items?: NavItemConfig[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function SideNav({ color = 'evident', items = [] }: SideNavProps): React.JSX.Element {
|
||||||
|
const pathname = usePathname();
|
||||||
|
|
||||||
|
const {
|
||||||
|
settings: { colorScheme = 'light' },
|
||||||
|
} = useSettings();
|
||||||
|
|
||||||
|
const styles = navColorStyles[colorScheme][color];
|
||||||
|
const logoColor = logoColors[colorScheme][color];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
...styles,
|
||||||
|
bgcolor: 'var(--SideNav-background)',
|
||||||
|
borderRight: 'var(--SideNav-border)',
|
||||||
|
color: 'var(--SideNav-color)',
|
||||||
|
display: { xs: 'none', lg: 'flex' },
|
||||||
|
flexDirection: 'column',
|
||||||
|
height: '100%',
|
||||||
|
left: 0,
|
||||||
|
position: 'fixed',
|
||||||
|
top: 0,
|
||||||
|
width: 'var(--SideNav-width)',
|
||||||
|
zIndex: 'var(--SideNav-zIndex)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
spacing={2}
|
||||||
|
sx={{ p: 2 }}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<Box
|
||||||
|
component={RouterLink}
|
||||||
|
href={paths.home}
|
||||||
|
sx={{ display: 'inline-flex' }}
|
||||||
|
>
|
||||||
|
<Logo
|
||||||
|
color={logoColor}
|
||||||
|
height={32}
|
||||||
|
width={122}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
<WorkspacesSwitch />
|
||||||
|
</Stack>
|
||||||
|
<Box
|
||||||
|
component="nav"
|
||||||
|
sx={{
|
||||||
|
flex: '1 1 auto',
|
||||||
|
overflowY: 'auto',
|
||||||
|
p: 2,
|
||||||
|
scrollbarWidth: 'none',
|
||||||
|
'&::-webkit-scrollbar': { display: 'none' },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{RenderNavGroups({ items, pathname })}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
@@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import RouterLink from 'next/link';
|
import RouterLink from 'next/link';
|
||||||
import { usePathname } from 'next/navigation';
|
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
import Chip from '@mui/material/Chip';
|
import Chip from '@mui/material/Chip';
|
||||||
import Stack from '@mui/material/Stack';
|
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import { ArrowSquareOut as ArrowSquareOutIcon } from '@phosphor-icons/react/dist/ssr/ArrowSquareOut';
|
import { ArrowSquareOut as ArrowSquareOutIcon } from '@phosphor-icons/react/dist/ssr/ArrowSquareOut';
|
||||||
import { CaretDown as CaretDownIcon } from '@phosphor-icons/react/dist/ssr/CaretDown';
|
import { CaretDown as CaretDownIcon } from '@phosphor-icons/react/dist/ssr/CaretDown';
|
||||||
@@ -13,136 +11,9 @@ import { CaretRight as CaretRightIcon } from '@phosphor-icons/react/dist/ssr/Car
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import type { NavItemConfig } from '@/types/nav';
|
import type { NavItemConfig } from '@/types/nav';
|
||||||
import type { NavColor } from '@/types/settings';
|
|
||||||
import { paths } from '@/paths';
|
|
||||||
import { isNavItemActive } from '@/lib/is-nav-item-active';
|
import { isNavItemActive } from '@/lib/is-nav-item-active';
|
||||||
import { useSettings } from '@/hooks/use-settings';
|
|
||||||
import { Logo } from '@/components/core/logo';
|
|
||||||
import type { ColorScheme } from '@/styles/theme/types';
|
|
||||||
|
|
||||||
import { icons } from '../nav-icons';
|
import { icons } from '../../nav-icons';
|
||||||
import { WorkspacesSwitch } from '../workspaces-switch';
|
|
||||||
import { navColorStyles } from './styles';
|
|
||||||
|
|
||||||
const logoColors = {
|
|
||||||
dark: { blend_in: 'light', discrete: 'light', evident: 'light' },
|
|
||||||
light: { blend_in: 'dark', discrete: 'dark', evident: 'light' },
|
|
||||||
} as Record<ColorScheme, Record<NavColor, 'dark' | 'light'>>;
|
|
||||||
|
|
||||||
export interface SideNavProps {
|
|
||||||
color?: NavColor;
|
|
||||||
items?: NavItemConfig[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function SideNav({ color = 'evident', items = [] }: SideNavProps): React.JSX.Element {
|
|
||||||
const pathname = usePathname();
|
|
||||||
|
|
||||||
const {
|
|
||||||
settings: { colorScheme = 'light' },
|
|
||||||
} = useSettings();
|
|
||||||
|
|
||||||
const styles = navColorStyles[colorScheme][color];
|
|
||||||
const logoColor = logoColors[colorScheme][color];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
...styles,
|
|
||||||
bgcolor: 'var(--SideNav-background)',
|
|
||||||
borderRight: 'var(--SideNav-border)',
|
|
||||||
color: 'var(--SideNav-color)',
|
|
||||||
display: { xs: 'none', lg: 'flex' },
|
|
||||||
flexDirection: 'column',
|
|
||||||
height: '100%',
|
|
||||||
left: 0,
|
|
||||||
position: 'fixed',
|
|
||||||
top: 0,
|
|
||||||
width: 'var(--SideNav-width)',
|
|
||||||
zIndex: 'var(--SideNav-zIndex)',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Stack spacing={2} sx={{ p: 2 }}>
|
|
||||||
<div>
|
|
||||||
<Box component={RouterLink} href={paths.home} sx={{ display: 'inline-flex' }}>
|
|
||||||
<Logo color={logoColor} height={32} width={122} />
|
|
||||||
</Box>
|
|
||||||
</div>
|
|
||||||
<WorkspacesSwitch />
|
|
||||||
</Stack>
|
|
||||||
<Box
|
|
||||||
component="nav"
|
|
||||||
sx={{
|
|
||||||
flex: '1 1 auto',
|
|
||||||
overflowY: 'auto',
|
|
||||||
p: 2,
|
|
||||||
scrollbarWidth: 'none',
|
|
||||||
'&::-webkit-scrollbar': { display: 'none' },
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{RenderNavGroups({ items, pathname })}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function RenderNavGroups({ items, pathname }: { items: NavItemConfig[]; pathname: string }): React.JSX.Element {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const children = items.reduce((acc: React.ReactNode[], curr: NavItemConfig): React.ReactNode[] => {
|
|
||||||
acc.push(
|
|
||||||
<Stack component="li" key={curr.key} spacing={1.5}>
|
|
||||||
{curr.title ? (
|
|
||||||
<div>
|
|
||||||
<Typography sx={{ color: 'var(--NavGroup-title-color)', fontSize: '0.875rem', fontWeight: 500 }}>
|
|
||||||
{t(curr.title)}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
<div>{renderNavItems({ depth: 0, items: curr.items, pathname })}</div>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack component="ul" spacing={2} sx={{ listStyle: 'none', m: 0, p: 0 }}>
|
|
||||||
{children}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function renderNavItems({
|
|
||||||
depth = 0,
|
|
||||||
items = [],
|
|
||||||
pathname,
|
|
||||||
}: {
|
|
||||||
depth: number;
|
|
||||||
items?: NavItemConfig[];
|
|
||||||
pathname: string;
|
|
||||||
}): React.JSX.Element {
|
|
||||||
const children = items.reduce((acc: React.ReactNode[], curr: NavItemConfig): React.ReactNode[] => {
|
|
||||||
const { items: childItems, key, ...item } = curr;
|
|
||||||
|
|
||||||
const forceOpen = childItems
|
|
||||||
? Boolean(childItems.find((childItem) => childItem.href && pathname.startsWith(childItem.href)))
|
|
||||||
: false;
|
|
||||||
|
|
||||||
acc.push(
|
|
||||||
<NavItem depth={depth} forceOpen={forceOpen} key={key} pathname={pathname} {...item}>
|
|
||||||
{childItems ? renderNavItems({ depth: depth + 1, pathname, items: childItems }) : null}
|
|
||||||
</NavItem>
|
|
||||||
);
|
|
||||||
|
|
||||||
return acc;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack component="ul" data-depth={depth} spacing={1} sx={{ listStyle: 'none', m: 0, p: 0 }}>
|
|
||||||
{children}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface NavItemProps extends Omit<NavItemConfig, 'items'> {
|
interface NavItemProps extends Omit<NavItemConfig, 'items'> {
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
@@ -151,7 +22,7 @@ interface NavItemProps extends Omit<NavItemConfig, 'items'> {
|
|||||||
pathname: string;
|
pathname: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function NavItem({
|
export function NavItem({
|
||||||
children,
|
children,
|
||||||
depth,
|
depth,
|
||||||
disabled,
|
disabled,
|
||||||
@@ -173,7 +44,11 @@ function NavItem({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box component="li" data-depth={depth} sx={{ userSelect: 'none' }}>
|
<Box
|
||||||
|
component="li"
|
||||||
|
data-depth={depth}
|
||||||
|
sx={{ userSelect: 'none' }}
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
{...(isBranch
|
{...(isBranch
|
||||||
? {
|
? {
|
||||||
@@ -254,15 +129,27 @@ function NavItem({
|
|||||||
{t(title || '')}
|
{t(title || '')}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
{label ? <Chip color="primary" label={label} size="small" /> : null}
|
{label ? (
|
||||||
|
<Chip
|
||||||
|
color="primary"
|
||||||
|
label={label}
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
{external ? (
|
{external ? (
|
||||||
<Box sx={{ alignItems: 'center', display: 'flex', flex: '0 0 auto' }}>
|
<Box sx={{ alignItems: 'center', display: 'flex', flex: '0 0 auto' }}>
|
||||||
<ArrowSquareOutIcon color="var(--NavItem-icon-color)" fontSize="var(--icon-fontSize-sm)" />
|
<ArrowSquareOutIcon
|
||||||
|
color="var(--NavItem-icon-color)"
|
||||||
|
fontSize="var(--icon-fontSize-sm)"
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
) : null}
|
) : null}
|
||||||
{isBranch ? (
|
{isBranch ? (
|
||||||
<Box sx={{ alignItems: 'center', display: 'flex', flex: '0 0 auto' }}>
|
<Box sx={{ alignItems: 'center', display: 'flex', flex: '0 0 auto' }}>
|
||||||
<ExpandIcon color="var(--NavItem-expand-color)" fontSize="var(--icon-fontSize-sm)" />
|
<ExpandIcon
|
||||||
|
color="var(--NavItem-expand-color)"
|
||||||
|
fontSize="var(--icon-fontSize-sm)"
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
) : null}
|
) : null}
|
||||||
</Box>
|
</Box>
|
@@ -0,0 +1,45 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import Stack from '@mui/material/Stack';
|
||||||
|
import Typography from '@mui/material/Typography';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
import type { NavItemConfig } from '@/types/nav';
|
||||||
|
|
||||||
|
import { renderNavItems } from './render-nav-items';
|
||||||
|
|
||||||
|
export function RenderNavGroups({ items, pathname }: { items: NavItemConfig[]; pathname: string }): React.JSX.Element {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const children = items.reduce((acc: React.ReactNode[], curr: NavItemConfig): React.ReactNode[] => {
|
||||||
|
acc.push(
|
||||||
|
<Stack
|
||||||
|
component="li"
|
||||||
|
key={curr.key}
|
||||||
|
spacing={1.5}
|
||||||
|
>
|
||||||
|
{curr.title ? (
|
||||||
|
<div>
|
||||||
|
<Typography sx={{ color: 'var(--NavGroup-title-color)', fontSize: '0.875rem', fontWeight: 500 }}>
|
||||||
|
{t(curr.title)}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
<div>{renderNavItems({ depth: 0, items: curr.items, pathname })}</div>
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ listStyle: 'none', m: 0, p: 0 }}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
@@ -0,0 +1,51 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import Stack from '@mui/material/Stack';
|
||||||
|
|
||||||
|
import type { NavItemConfig } from '@/types/nav';
|
||||||
|
|
||||||
|
import { NavItem } from './nav-item';
|
||||||
|
|
||||||
|
export function renderNavItems({
|
||||||
|
depth = 0,
|
||||||
|
items = [],
|
||||||
|
pathname,
|
||||||
|
}: {
|
||||||
|
depth: number;
|
||||||
|
items?: NavItemConfig[];
|
||||||
|
pathname: string;
|
||||||
|
}): React.JSX.Element {
|
||||||
|
const children = items.reduce((acc: React.ReactNode[], curr: NavItemConfig): React.ReactNode[] => {
|
||||||
|
const { items: childItems, key, ...item } = curr;
|
||||||
|
|
||||||
|
const forceOpen = childItems
|
||||||
|
? Boolean(childItems.find((childItem) => childItem.href && pathname.startsWith(childItem.href)))
|
||||||
|
: false;
|
||||||
|
|
||||||
|
acc.push(
|
||||||
|
<NavItem
|
||||||
|
depth={depth}
|
||||||
|
forceOpen={forceOpen}
|
||||||
|
key={key}
|
||||||
|
pathname={pathname}
|
||||||
|
{...item}
|
||||||
|
>
|
||||||
|
{childItems ? renderNavItems({ depth: depth + 1, pathname, items: childItems }) : null}
|
||||||
|
</NavItem>
|
||||||
|
);
|
||||||
|
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
data-depth={depth}
|
||||||
|
spacing={1}
|
||||||
|
sx={{ listStyle: 'none', m: 0, p: 0 }}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
@@ -1,138 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
import * as React from 'react';
|
|
||||||
import Avatar from '@mui/material/Avatar';
|
|
||||||
import Box from '@mui/material/Box';
|
|
||||||
import Button from '@mui/material/Button';
|
|
||||||
import Card from '@mui/material/Card';
|
|
||||||
import CardActions from '@mui/material/CardActions';
|
|
||||||
import CardContent from '@mui/material/CardContent';
|
|
||||||
import CardHeader from '@mui/material/CardHeader';
|
|
||||||
import FormControl from '@mui/material/FormControl';
|
|
||||||
import FormHelperText from '@mui/material/FormHelperText';
|
|
||||||
import InputAdornment from '@mui/material/InputAdornment';
|
|
||||||
import InputLabel from '@mui/material/InputLabel';
|
|
||||||
import Link from '@mui/material/Link';
|
|
||||||
import OutlinedInput from '@mui/material/OutlinedInput';
|
|
||||||
import Select from '@mui/material/Select';
|
|
||||||
import Stack from '@mui/material/Stack';
|
|
||||||
import Typography from '@mui/material/Typography';
|
|
||||||
import { Camera as CameraIcon } from '@phosphor-icons/react/dist/ssr/Camera';
|
|
||||||
import { User as UserIcon } from '@phosphor-icons/react/dist/ssr/User';
|
|
||||||
|
|
||||||
import { Option } from '@/components/core/option';
|
|
||||||
|
|
||||||
export function AccountDetails(): React.JSX.Element {
|
|
||||||
return (
|
|
||||||
<Card>
|
|
||||||
<CardHeader
|
|
||||||
avatar={
|
|
||||||
<Avatar>
|
|
||||||
<UserIcon fontSize="var(--Icon-fontSize)" />
|
|
||||||
</Avatar>
|
|
||||||
}
|
|
||||||
title="Basic details"
|
|
||||||
/>
|
|
||||||
<CardContent>
|
|
||||||
<Stack spacing={3}>
|
|
||||||
<Stack direction="row" spacing={2} sx={{ alignItems: 'center' }}>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
border: '1px dashed var(--mui-palette-divider)',
|
|
||||||
borderRadius: '50%',
|
|
||||||
display: 'inline-flex',
|
|
||||||
p: '4px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box sx={{ borderRadius: 'inherit', position: 'relative' }}>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
alignItems: 'center',
|
|
||||||
bgcolor: 'rgba(0, 0, 0, 0.5)',
|
|
||||||
borderRadius: 'inherit',
|
|
||||||
bottom: 0,
|
|
||||||
color: 'var(--mui-palette-common-white)',
|
|
||||||
cursor: 'pointer',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'center',
|
|
||||||
left: 0,
|
|
||||||
opacity: 0,
|
|
||||||
position: 'absolute',
|
|
||||||
right: 0,
|
|
||||||
top: 0,
|
|
||||||
zIndex: 1,
|
|
||||||
'&:hover': { opacity: 1 },
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Stack direction="row" spacing={1} sx={{ alignItems: 'center' }}>
|
|
||||||
<CameraIcon fontSize="var(--icon-fontSize-md)" />
|
|
||||||
<Typography color="inherit" variant="subtitle2">
|
|
||||||
Select
|
|
||||||
</Typography>
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
<Avatar src="/assets/avatar.png" sx={{ '--Avatar-size': '100px' }} />
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
<Button color="secondary" size="small">
|
|
||||||
Remove
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
<Stack spacing={2}>
|
|
||||||
<FormControl>
|
|
||||||
<InputLabel>Full name</InputLabel>
|
|
||||||
<OutlinedInput defaultValue="Sofia Rivers" name="fullName" />
|
|
||||||
</FormControl>
|
|
||||||
<FormControl disabled>
|
|
||||||
<InputLabel>Email address</InputLabel>
|
|
||||||
<OutlinedInput name="email" type="email" value="sofia@devias.io" />
|
|
||||||
<FormHelperText>
|
|
||||||
Please <Link variant="inherit">contact us</Link> to change your email
|
|
||||||
</FormHelperText>
|
|
||||||
</FormControl>
|
|
||||||
<Stack direction="row" spacing={2}>
|
|
||||||
<FormControl sx={{ width: '160px' }}>
|
|
||||||
<InputLabel>Dial code</InputLabel>
|
|
||||||
<Select
|
|
||||||
name="countryCode"
|
|
||||||
startAdornment={
|
|
||||||
<InputAdornment position="start">
|
|
||||||
<Box
|
|
||||||
alt="Spain"
|
|
||||||
component="img"
|
|
||||||
src="/assets/flag-es.svg"
|
|
||||||
sx={{ display: 'block', height: '20px', width: 'auto' }}
|
|
||||||
/>
|
|
||||||
</InputAdornment>
|
|
||||||
}
|
|
||||||
value="+34"
|
|
||||||
>
|
|
||||||
<Option value="+1">United States</Option>
|
|
||||||
<Option value="+49">Germany</Option>
|
|
||||||
<Option value="+34">Spain</Option>
|
|
||||||
</Select>
|
|
||||||
</FormControl>
|
|
||||||
<FormControl sx={{ flex: '1 1 auto' }}>
|
|
||||||
<InputLabel>Phone number</InputLabel>
|
|
||||||
<OutlinedInput defaultValue="965 245 7623" name="phone" />
|
|
||||||
</FormControl>
|
|
||||||
</Stack>
|
|
||||||
<FormControl>
|
|
||||||
<InputLabel>Title</InputLabel>
|
|
||||||
<OutlinedInput name="title" placeholder="e.g Golang Developer" />
|
|
||||||
</FormControl>
|
|
||||||
<FormControl>
|
|
||||||
<InputLabel>Biography (optional)</InputLabel>
|
|
||||||
<OutlinedInput name="bio" placeholder="Describe yourself..." />
|
|
||||||
<FormHelperText>0/200 characters</FormHelperText>
|
|
||||||
</FormControl>
|
|
||||||
</Stack>
|
|
||||||
</Stack>
|
|
||||||
</CardContent>
|
|
||||||
<CardActions sx={{ justifyContent: 'flex-end' }}>
|
|
||||||
<Button color="secondary">Cancel</Button>
|
|
||||||
<Button variant="contained">Save changes</Button>
|
|
||||||
</CardActions>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
@@ -0,0 +1,3 @@
|
|||||||
|
# GUIDELINES
|
||||||
|
|
||||||
|
- use i18n
|
@@ -0,0 +1,348 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import RouterLink from 'next/link';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { COL_USER_METAS } from '@/constants';
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
import { LoadingButton } from '@mui/lab';
|
||||||
|
import Avatar from '@mui/material/Avatar';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
|
import Button from '@mui/material/Button';
|
||||||
|
import Card from '@mui/material/Card';
|
||||||
|
import CardActions from '@mui/material/CardActions';
|
||||||
|
import CardContent from '@mui/material/CardContent';
|
||||||
|
import CardHeader from '@mui/material/CardHeader';
|
||||||
|
import FormControl from '@mui/material/FormControl';
|
||||||
|
import FormHelperText from '@mui/material/FormHelperText';
|
||||||
|
import InputAdornment from '@mui/material/InputAdornment';
|
||||||
|
import InputLabel from '@mui/material/InputLabel';
|
||||||
|
import Link from '@mui/material/Link';
|
||||||
|
import OutlinedInput from '@mui/material/OutlinedInput';
|
||||||
|
import Select from '@mui/material/Select';
|
||||||
|
import Stack from '@mui/material/Stack';
|
||||||
|
import Typography from '@mui/material/Typography';
|
||||||
|
import { Camera as CameraIcon } from '@phosphor-icons/react/dist/ssr/Camera';
|
||||||
|
import { User as UserIcon } from '@phosphor-icons/react/dist/ssr/User';
|
||||||
|
import { Controller, useForm } from 'react-hook-form';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { z as zod } from 'zod';
|
||||||
|
|
||||||
|
import { paths } from '@/paths';
|
||||||
|
import { logger } from '@/lib/default-logger';
|
||||||
|
import { fileToBase64 } from '@/lib/file-to-base64';
|
||||||
|
import getImageUrlFromFile from '@/lib/get-image-url-from-file.ts';
|
||||||
|
import { pb } from '@/lib/pb';
|
||||||
|
import { useUser } from '@/hooks/use-user';
|
||||||
|
import { Option } from '@/components/core/option';
|
||||||
|
import { toast } from '@/components/core/toaster';
|
||||||
|
import FormLoading from '@/components/loading';
|
||||||
|
|
||||||
|
import ErrorDisplay from '../../error';
|
||||||
|
|
||||||
|
const schema = zod.object({
|
||||||
|
name: zod.string().min(1, 'Name is required').max(255),
|
||||||
|
email: zod.string().email('Must be a valid email').min(1, 'Email is required').max(255),
|
||||||
|
phone: zod.string().min(1, 'Phone is required').max(25),
|
||||||
|
company: zod.string().max(255).optional(),
|
||||||
|
billingAddress: zod.object({
|
||||||
|
country: zod.string().min(1, 'Country is required').max(255),
|
||||||
|
state: zod.string().min(1, 'State is required').max(255),
|
||||||
|
city: zod.string().min(1, 'City is required').max(255),
|
||||||
|
zipCode: zod.string().min(1, 'Zip code is required').max(255),
|
||||||
|
line1: zod.string().min(1, 'Street line 1 is required').max(255),
|
||||||
|
line2: zod.string().max(255).optional(),
|
||||||
|
}),
|
||||||
|
taxId: zod.string().max(255).optional(),
|
||||||
|
timezone: zod.string().min(1, 'Timezone is required').max(255),
|
||||||
|
language: zod.string().min(1, 'Language is required').max(255),
|
||||||
|
currency: zod.string().min(1, 'Currency is required').max(255),
|
||||||
|
avatar: zod.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Values = zod.infer<typeof schema>;
|
||||||
|
|
||||||
|
const defaultValues = {
|
||||||
|
name: '',
|
||||||
|
email: '',
|
||||||
|
phone: '',
|
||||||
|
company: '',
|
||||||
|
billingAddress: {
|
||||||
|
country: '',
|
||||||
|
state: '',
|
||||||
|
city: '',
|
||||||
|
zipCode: '',
|
||||||
|
line1: '',
|
||||||
|
line2: '',
|
||||||
|
},
|
||||||
|
taxId: '',
|
||||||
|
timezone: '',
|
||||||
|
language: '',
|
||||||
|
currency: '',
|
||||||
|
avatar: '',
|
||||||
|
} satisfies Values;
|
||||||
|
|
||||||
|
export function AccountDetails(): React.JSX.Element {
|
||||||
|
const router = useRouter();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const { user, isLoading } = useUser();
|
||||||
|
const [isUpdating, setIsUpdating] = React.useState<boolean>(false);
|
||||||
|
const [showLoading, setShowLoading] = React.useState<boolean>(false);
|
||||||
|
const [showError, setShowError] = React.useState({ show: false, detail: '' });
|
||||||
|
|
||||||
|
const onSubmit = React.useCallback(
|
||||||
|
async (values: Values): Promise<void> => {
|
||||||
|
setIsUpdating(true);
|
||||||
|
|
||||||
|
// const updateData = {
|
||||||
|
// name: values.name,
|
||||||
|
// email: values.email,
|
||||||
|
// phone: values.phone,
|
||||||
|
// company: values.company,
|
||||||
|
// billingAddress: values.billingAddress,
|
||||||
|
// taxId: values.taxId,
|
||||||
|
// timezone: values.timezone,
|
||||||
|
// language: values.language,
|
||||||
|
// currency: values.currency,
|
||||||
|
// avatar: values.avatar ? await base64ToFile(values.avatar) : null,
|
||||||
|
// };
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// await pb.collection(COL_CUSTOMERS).update(customerId, updateData);
|
||||||
|
// toast.success('Customer updated successfully');
|
||||||
|
// router.push(paths.dashboard.students.list);
|
||||||
|
// } catch (error) {
|
||||||
|
// logger.error(error);
|
||||||
|
// toast.error('Failed to update customer');
|
||||||
|
// } finally {
|
||||||
|
// setIsUpdating(false);
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
[router]
|
||||||
|
);
|
||||||
|
|
||||||
|
const {
|
||||||
|
control,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
setValue,
|
||||||
|
reset,
|
||||||
|
watch,
|
||||||
|
} = useForm<Values>({ defaultValues, resolver: zodResolver(schema) });
|
||||||
|
|
||||||
|
const loadExistingData = React.useCallback(async () => {
|
||||||
|
setShowLoading(true);
|
||||||
|
if (user) {
|
||||||
|
try {
|
||||||
|
const result = await pb.collection(COL_USER_METAS).getOne(user.id);
|
||||||
|
reset({ ...defaultValues, ...result });
|
||||||
|
console.log({ result });
|
||||||
|
|
||||||
|
if (result.avatar) {
|
||||||
|
// TODO: remove me
|
||||||
|
// const fetchResult = await fetch(
|
||||||
|
// `http://127.0.0.1:8090/api/files/${result.collectionId}/${result.id}/${result.avatar}`
|
||||||
|
// );
|
||||||
|
const fetchResult = await fetch(getImageUrlFromFile(result.collectionId, result.id, result.avatar));
|
||||||
|
const blob = await fetchResult.blob();
|
||||||
|
const url = await fileToBase64(blob);
|
||||||
|
setValue('avatar', url);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
|
||||||
|
// TODO: add i18n here
|
||||||
|
toast.error('Failed to load customer data');
|
||||||
|
|
||||||
|
setShowError({ show: true, detail: JSON.stringify(error, null, 2) });
|
||||||
|
} finally {
|
||||||
|
setShowLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [user, reset, setValue]);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
void loadExistingData();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (showLoading) return <FormLoading />;
|
||||||
|
if (!user) return <>loading</>;
|
||||||
|
|
||||||
|
if (showError.show)
|
||||||
|
return (
|
||||||
|
<ErrorDisplay
|
||||||
|
message={t('error.unable-to-process-request')}
|
||||||
|
code="500"
|
||||||
|
details={showError.detail}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<Card>
|
||||||
|
<CardHeader
|
||||||
|
avatar={
|
||||||
|
<Avatar>
|
||||||
|
<UserIcon fontSize="var(--Icon-fontSize)" />
|
||||||
|
</Avatar>
|
||||||
|
}
|
||||||
|
title="Basic details"
|
||||||
|
/>
|
||||||
|
<CardContent>
|
||||||
|
<Stack spacing={3}>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'center' }}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
border: '1px dashed var(--mui-palette-divider)',
|
||||||
|
borderRadius: '50%',
|
||||||
|
display: 'inline-flex',
|
||||||
|
p: '4px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box sx={{ borderRadius: 'inherit', position: 'relative' }}>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
alignItems: 'center',
|
||||||
|
bgcolor: 'rgba(0, 0, 0, 0.5)',
|
||||||
|
borderRadius: 'inherit',
|
||||||
|
bottom: 0,
|
||||||
|
color: 'var(--mui-palette-common-white)',
|
||||||
|
cursor: 'pointer',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
left: 0,
|
||||||
|
opacity: 0,
|
||||||
|
position: 'absolute',
|
||||||
|
right: 0,
|
||||||
|
top: 0,
|
||||||
|
zIndex: 1,
|
||||||
|
'&:hover': { opacity: 1 },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={1}
|
||||||
|
sx={{ alignItems: 'center' }}
|
||||||
|
>
|
||||||
|
<CameraIcon fontSize="var(--icon-fontSize-md)" />
|
||||||
|
<Typography
|
||||||
|
color="inherit"
|
||||||
|
variant="subtitle2"
|
||||||
|
>
|
||||||
|
{t('select')}
|
||||||
|
</Typography>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
<Avatar
|
||||||
|
src={getImageUrlFromFile(user.collectionId, user.id, user.avatar)}
|
||||||
|
sx={{ '--Avatar-size': '100px' }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Button
|
||||||
|
color="secondary"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
{t('remove')}
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
<Stack spacing={2}>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="name"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormControl
|
||||||
|
error={Boolean(errors.name)}
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
<InputLabel required>Name</InputLabel>
|
||||||
|
<OutlinedInput {...field} />
|
||||||
|
{errors.name ? <FormHelperText>{errors.name.message}</FormHelperText> : null}
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
disabled
|
||||||
|
control={control}
|
||||||
|
name="email"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormControl
|
||||||
|
error={Boolean(errors.email)}
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
<InputLabel required>Email</InputLabel>
|
||||||
|
<OutlinedInput
|
||||||
|
{...field}
|
||||||
|
type="email"
|
||||||
|
/>
|
||||||
|
{errors.email ? <FormHelperText>{errors.email.message}</FormHelperText> : null}
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
>
|
||||||
|
<Controller
|
||||||
|
control={control}
|
||||||
|
name="phone"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormControl
|
||||||
|
error={Boolean(errors.phone)}
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
<InputLabel required>Phone</InputLabel>
|
||||||
|
<OutlinedInput {...field} />
|
||||||
|
{errors.phone ? <FormHelperText>{errors.phone.message}</FormHelperText> : null}
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
<FormControl>
|
||||||
|
<InputLabel>Title</InputLabel>
|
||||||
|
<OutlinedInput
|
||||||
|
name="title"
|
||||||
|
placeholder="e.g Golang Developer"
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormControl>
|
||||||
|
<InputLabel>Biography (optional)</InputLabel>
|
||||||
|
<OutlinedInput
|
||||||
|
name="bio"
|
||||||
|
placeholder="Describe yourself..."
|
||||||
|
/>
|
||||||
|
<FormHelperText>0/200 characters</FormHelperText>
|
||||||
|
</FormControl>
|
||||||
|
</Stack>
|
||||||
|
</Stack>
|
||||||
|
</CardContent>
|
||||||
|
<CardActions sx={{ justifyContent: 'flex-end' }}>
|
||||||
|
<Button
|
||||||
|
color="secondary"
|
||||||
|
component={RouterLink}
|
||||||
|
href={paths.dashboard.overview}
|
||||||
|
>
|
||||||
|
{t('edit.cancelButton')}
|
||||||
|
</Button>
|
||||||
|
{/* <Button variant="contained">Save changes</Button> */}
|
||||||
|
<LoadingButton
|
||||||
|
disabled={isUpdating}
|
||||||
|
loading={isUpdating}
|
||||||
|
type="submit"
|
||||||
|
variant="contained"
|
||||||
|
>
|
||||||
|
{t('edit.updateButton')}
|
||||||
|
</LoadingButton>
|
||||||
|
</CardActions>
|
||||||
|
</Card>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
@@ -20,11 +20,17 @@ export function DeleteAccount(): React.JSX.Element {
|
|||||||
title="Delete account"
|
title="Delete account"
|
||||||
/>
|
/>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Stack spacing={3} sx={{ alignItems: 'flex-start' }}>
|
<Stack
|
||||||
|
spacing={3}
|
||||||
|
sx={{ alignItems: 'flex-start' }}
|
||||||
|
>
|
||||||
<Typography variant="subtitle1">
|
<Typography variant="subtitle1">
|
||||||
Delete your account and all of your source data. This is irreversible.
|
Delete your account and all of your source data. This is irreversible.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Button color="error" variant="outlined">
|
<Button
|
||||||
|
color="error"
|
||||||
|
variant="outlined"
|
||||||
|
>
|
||||||
Delete account
|
Delete account
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
@@ -71,29 +71,55 @@ export function SideNav(): React.JSX.Element {
|
|||||||
width: { xs: '100%', md: '240px' },
|
width: { xs: '100%', md: '240px' },
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack component="ul" spacing={3} sx={{ listStyle: 'none', m: 0, p: 0 }}>
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
spacing={3}
|
||||||
|
sx={{ listStyle: 'none', m: 0, p: 0 }}
|
||||||
|
>
|
||||||
{navItems.map((group) => (
|
{navItems.map((group) => (
|
||||||
<Stack component="li" key={group.key} spacing={2}>
|
<Stack
|
||||||
|
component="li"
|
||||||
|
key={group.key}
|
||||||
|
spacing={2}
|
||||||
|
>
|
||||||
{group.title ? (
|
{group.title ? (
|
||||||
<div>
|
<div>
|
||||||
<Typography color="text.secondary" variant="caption">
|
<Typography
|
||||||
|
color="text.secondary"
|
||||||
|
variant="caption"
|
||||||
|
>
|
||||||
{group.title}
|
{group.title}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<Stack component="ul" spacing={1} sx={{ listStyle: 'none', m: 0, p: 0 }}>
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
spacing={1}
|
||||||
|
sx={{ listStyle: 'none', m: 0, p: 0 }}
|
||||||
|
>
|
||||||
{group.items.map((item) => (
|
{group.items.map((item) => (
|
||||||
<NavItem {...item} key={item.key} pathname={pathname} />
|
<NavItem
|
||||||
|
{...item}
|
||||||
|
key={item.key}
|
||||||
|
pathname={pathname}
|
||||||
|
/>
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack direction="row" spacing={2} sx={{ alignItems: 'center' }}>
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'center' }}
|
||||||
|
>
|
||||||
<Avatar src="/assets/avatar.png">AV</Avatar>
|
<Avatar src="/assets/avatar.png">AV</Avatar>
|
||||||
<div>
|
<div>
|
||||||
<Typography variant="subtitle1">Sofia Rivers</Typography>
|
<Typography variant="subtitle1">Sofia Rivers</Typography>
|
||||||
<Typography color="text.secondary" variant="caption">
|
<Typography
|
||||||
|
color="text.secondary"
|
||||||
|
variant="caption"
|
||||||
|
>
|
||||||
sofia@devias.io
|
sofia@devias.io
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
@@ -112,7 +138,10 @@ function NavItem({ disabled, external, href, icon, pathname, title }: NavItemPro
|
|||||||
const Icon = icon ? icons[icon] : null;
|
const Icon = icon ? icons[icon] : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box component="li" sx={{ userSelect: 'none' }}>
|
<Box
|
||||||
|
component="li"
|
||||||
|
sx={{ userSelect: 'none' }}
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
{...(href
|
{...(href
|
||||||
? {
|
? {
|
||||||
|
@@ -20,8 +20,8 @@ import { DropdownPopover } from '@/components/core/dropdown/dropdown-popover';
|
|||||||
import { DropdownTrigger } from '@/components/core/dropdown/dropdown-trigger';
|
import { DropdownTrigger } from '@/components/core/dropdown/dropdown-trigger';
|
||||||
import { Logo } from '@/components/core/logo';
|
import { Logo } from '@/components/core/logo';
|
||||||
|
|
||||||
import { MobileNav } from './mobile-nav';
|
import { MobileNav } from '../mobile-nav';
|
||||||
import { PagesPopover } from './pages-popover';
|
import { PagesPopover } from '../pages-popover';
|
||||||
|
|
||||||
export function MainNav(): React.JSX.Element {
|
export function MainNav(): React.JSX.Element {
|
||||||
const [openNav, setOpenNav] = React.useState<boolean>(false);
|
const [openNav, setOpenNav] = React.useState<boolean>(false);
|
||||||
@@ -41,15 +41,46 @@ export function MainNav(): React.JSX.Element {
|
|||||||
zIndex: 'var(--MainNav-zIndex)',
|
zIndex: 'var(--MainNav-zIndex)',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Container maxWidth="lg" sx={{ display: 'flex', minHeight: 'var(--MainNav-height)', py: '16px' }}>
|
<Container
|
||||||
<Stack direction="row" spacing={2} sx={{ alignItems: 'center', flex: '1 1 auto' }}>
|
maxWidth="lg"
|
||||||
<Box component={RouterLink} href={paths.home} sx={{ display: 'inline-flex' }}>
|
sx={{ display: 'flex', minHeight: 'var(--MainNav-height)', py: '16px' }}
|
||||||
<Logo color="light" height={32} width={122} />
|
>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
spacing={2}
|
||||||
|
sx={{ alignItems: 'center', flex: '1 1 auto' }}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
component={RouterLink}
|
||||||
|
href={paths.home}
|
||||||
|
sx={{ display: 'inline-flex' }}
|
||||||
|
>
|
||||||
|
<Logo
|
||||||
|
color="light"
|
||||||
|
height={32}
|
||||||
|
width={122}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box component="nav" sx={{ display: { xs: 'none', md: 'block' } }}>
|
<Box
|
||||||
<Stack component="ul" direction="row" spacing={1} sx={{ listStyle: 'none', m: 0, p: 0 }}>
|
component="nav"
|
||||||
<NavItem href={paths.components.index} pathname={pathname} title="Components" />
|
sx={{ display: { xs: 'none', md: 'block' } }}
|
||||||
<NavItem href={paths.docs} pathname={pathname} title="Documentation" />
|
>
|
||||||
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
direction="row"
|
||||||
|
spacing={1}
|
||||||
|
sx={{ listStyle: 'none', m: 0, p: 0 }}
|
||||||
|
>
|
||||||
|
<NavItem
|
||||||
|
href={paths.components.index}
|
||||||
|
pathname={pathname}
|
||||||
|
title="Components"
|
||||||
|
/>
|
||||||
|
<NavItem
|
||||||
|
href={paths.docs}
|
||||||
|
pathname={pathname}
|
||||||
|
title="Documentation"
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -58,9 +89,20 @@ export function MainNav(): React.JSX.Element {
|
|||||||
spacing={2}
|
spacing={2}
|
||||||
sx={{ alignItems: 'center', flex: '1 1 auto', justifyContent: 'flex-end' }}
|
sx={{ alignItems: 'center', flex: '1 1 auto', justifyContent: 'flex-end' }}
|
||||||
>
|
>
|
||||||
<Box component="nav" sx={{ display: { xs: 'none', md: 'block' } }}>
|
<Box
|
||||||
<Stack component="ul" direction="row" spacing={1} sx={{ listStyle: 'none', m: 0, p: 0 }}>
|
component="nav"
|
||||||
<NavItem pathname={pathname} title="Pages">
|
sx={{ display: { xs: 'none', md: 'block' } }}
|
||||||
|
>
|
||||||
|
<Stack
|
||||||
|
component="ul"
|
||||||
|
direction="row"
|
||||||
|
spacing={1}
|
||||||
|
sx={{ listStyle: 'none', m: 0, p: 0 }}
|
||||||
|
>
|
||||||
|
<NavItem
|
||||||
|
pathname={pathname}
|
||||||
|
title="Pages"
|
||||||
|
>
|
||||||
<PagesPopover />
|
<PagesPopover />
|
||||||
</NavItem>
|
</NavItem>
|
||||||
</Stack>
|
</Stack>
|
||||||
@@ -113,7 +155,10 @@ export function NavItem({
|
|||||||
const hasPopover = Boolean(children);
|
const hasPopover = Boolean(children);
|
||||||
|
|
||||||
const element = (
|
const element = (
|
||||||
<Box component="li" sx={{ userSelect: 'none' }}>
|
<Box
|
||||||
|
component="li"
|
||||||
|
sx={{ userSelect: 'none' }}
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
{...(hasPopover
|
{...(hasPopover
|
||||||
? {
|
? {
|
||||||
@@ -157,7 +202,10 @@ export function NavItem({
|
|||||||
}}
|
}}
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
>
|
>
|
||||||
<Box component="span" sx={{ flex: '1 1 auto' }}>
|
<Box
|
||||||
|
component="span"
|
||||||
|
sx={{ flex: '1 1 auto' }}
|
||||||
|
>
|
||||||
<Typography
|
<Typography
|
||||||
component="span"
|
component="span"
|
||||||
sx={{ color: 'inherit', fontSize: '0.875rem', fontWeight: 500, lineHeight: '28px' }}
|
sx={{ color: 'inherit', fontSize: '0.875rem', fontWeight: 500, lineHeight: '28px' }}
|
@@ -1,5 +1,8 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import { getUserMetaById } from '@/db/UserMetas/GetById';
|
||||||
|
import { logger } from '@/lib/default-logger';
|
||||||
|
import { pb } from '@/lib/pb';
|
||||||
import type { User } from '@/types/user';
|
import type { User } from '@/types/user';
|
||||||
|
|
||||||
function generateToken(): string {
|
function generateToken(): string {
|
||||||
@@ -8,7 +11,7 @@ function generateToken(): string {
|
|||||||
return Array.from(arr, (v) => v.toString(16).padStart(2, '0')).join('');
|
return Array.from(arr, (v) => v.toString(16).padStart(2, '0')).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = {
|
const user_xxx = {
|
||||||
id: 'USR-000',
|
id: 'USR-000',
|
||||||
avatar: '/assets/avatar.png',
|
avatar: '/assets/avatar.png',
|
||||||
firstName: 'Sofia',
|
firstName: 'Sofia',
|
||||||
@@ -54,17 +57,23 @@ class AuthClient {
|
|||||||
async signInWithPassword(params: SignInWithPasswordParams): Promise<{ error?: string }> {
|
async signInWithPassword(params: SignInWithPasswordParams): Promise<{ error?: string }> {
|
||||||
const { email, password } = params;
|
const { email, password } = params;
|
||||||
|
|
||||||
// Make API request
|
try {
|
||||||
|
// Make API request
|
||||||
|
await pb.collection('users').authWithPassword(email, password);
|
||||||
|
|
||||||
// We do not handle the API, so we'll check if the credentials match with the hardcoded ones.
|
// // We do not handle the API, so we'll check if the credentials match with the hardcoded ones.
|
||||||
if (email !== 'sofia@devias.io' || password !== 'Secret1') {
|
// if (email !== 'sofia@devias.io' || password !== 'Secret1') {
|
||||||
|
// return { error: 'Invalid credentials' };
|
||||||
|
// }
|
||||||
|
// const token = generateToken();
|
||||||
|
|
||||||
|
localStorage.setItem('custom-auth-token', pb.authStore.token);
|
||||||
|
|
||||||
|
return {};
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
return { error: 'Invalid credentials' };
|
return { error: 'Invalid credentials' };
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = generateToken();
|
|
||||||
localStorage.setItem('custom-auth-token', token);
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async resetPassword(_: ResetPasswordParams): Promise<{ error?: string }> {
|
async resetPassword(_: ResetPasswordParams): Promise<{ error?: string }> {
|
||||||
@@ -79,16 +88,28 @@ class AuthClient {
|
|||||||
// Make API request
|
// Make API request
|
||||||
|
|
||||||
// We do not handle the API, so just check if we have a token in localStorage.
|
// We do not handle the API, so just check if we have a token in localStorage.
|
||||||
const token = localStorage.getItem('custom-auth-token');
|
// const token = localStorage.getItem('custom-auth-token');
|
||||||
|
// if (!token) {
|
||||||
|
// return { data: null };
|
||||||
|
// }
|
||||||
|
try {
|
||||||
|
logger.debug(JSON.stringify(`getUser: ${pb.authStore.record?.id}`));
|
||||||
|
//
|
||||||
|
if (pb.authStore.record?.id !== undefined) {
|
||||||
|
const userMeta = await getUserMetaById(pb.authStore.record?.id);
|
||||||
|
logger.debug({ userMeta });
|
||||||
|
return { data: userMeta as unknown as User };
|
||||||
|
}
|
||||||
|
|
||||||
if (!token) {
|
|
||||||
return { data: null };
|
return { data: null };
|
||||||
|
} catch (error) {
|
||||||
|
return { error: 'sorry cannot get user meta' };
|
||||||
}
|
}
|
||||||
|
|
||||||
return { data: user };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async signOut(): Promise<{ error?: string }> {
|
async signOut(): Promise<{ error?: string }> {
|
||||||
|
pb.authStore.clear();
|
||||||
|
|
||||||
localStorage.removeItem('custom-auth-token');
|
localStorage.removeItem('custom-auth-token');
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
33
002_source/docker-compose.dev.yml
Normal file
33
002_source/docker-compose.dev.yml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
services:
|
||||||
|
cms:
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=development
|
||||||
|
# command: "sleep infinity"
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "1"
|
||||||
|
|
||||||
|
doc:
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=development
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "1"
|
||||||
|
|
||||||
|
ionic_mobile:
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=development
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "1"
|
||||||
|
|
||||||
|
api_ts:
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=development
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "1"
|
149
002_source/docker-compose.yml
Normal file
149
002_source/docker-compose.yml
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
volumes:
|
||||||
|
shared:
|
||||||
|
dist:
|
||||||
|
|
||||||
|
services:
|
||||||
|
cms:
|
||||||
|
image: 192.168.10.61:5000/cms_ubuntu
|
||||||
|
# build: ./cms
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ./cms:/app
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
working_dir: /app
|
||||||
|
command: ./scripts/docker/entrypoint.sh
|
||||||
|
depends_on:
|
||||||
|
pocketbase:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
#optional (recommended) since v0.10.0
|
||||||
|
test: wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "0.5"
|
||||||
|
reservations:
|
||||||
|
cpus: "0.01"
|
||||||
|
|
||||||
|
doc:
|
||||||
|
build: ./doc
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ./doc:/app
|
||||||
|
ports:
|
||||||
|
- 3001:3000
|
||||||
|
working_dir: /app
|
||||||
|
command: ./scripts/docker/entrypoint.sh
|
||||||
|
healthcheck:
|
||||||
|
#optional (recommended) since v0.10.0
|
||||||
|
test: wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "0.5"
|
||||||
|
reservations:
|
||||||
|
cpus: "0.01"
|
||||||
|
|
||||||
|
ionic_mobile:
|
||||||
|
# image: node:20-bullseye-slim
|
||||||
|
# build: ./ionic_mobile
|
||||||
|
image: 192.168.10.61:5000/ionic_mobile_ubuntu
|
||||||
|
# user: 1000:1000
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ./ionic_mobile:/app
|
||||||
|
ports:
|
||||||
|
- 5173:5173
|
||||||
|
working_dir: /app
|
||||||
|
command: ./scripts/docker/entrypoint.sh
|
||||||
|
depends_on:
|
||||||
|
pocketbase:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
#optional (recommended) since v0.10.0
|
||||||
|
test: wget --no-verbose --tries=1 --spider http://localhost:5173 || exit 1
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: "0.5"
|
||||||
|
reservations:
|
||||||
|
cpus: "0.01"
|
||||||
|
|
||||||
|
api_ts:
|
||||||
|
image: 192.168.10.61:5000/api_ts_ubuntu
|
||||||
|
# build: ./api_ts
|
||||||
|
volumes:
|
||||||
|
- ./api_ts:/app
|
||||||
|
working_dir: /app
|
||||||
|
# env_file:
|
||||||
|
# - .env
|
||||||
|
environment:
|
||||||
|
- NODE_ENV=production
|
||||||
|
- PB_HOSTNAME=pocketbase
|
||||||
|
- PB_USERNAME=admin@123.com
|
||||||
|
- PB_PASSWORD=Aa12345678
|
||||||
|
ports:
|
||||||
|
- 8080:3000
|
||||||
|
# command: sleep infinity
|
||||||
|
command: ./entrypoint.sh
|
||||||
|
# depends_on:
|
||||||
|
# pocketbase:
|
||||||
|
# condition: service_healthy
|
||||||
|
# healthcheck:
|
||||||
|
# #optional (recommended) since v0.10.0
|
||||||
|
# test: wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1
|
||||||
|
# interval: 5s
|
||||||
|
# timeout: 5s
|
||||||
|
# retries: 5
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: 0.5
|
||||||
|
reservations:
|
||||||
|
cpus: 0.01
|
||||||
|
|
||||||
|
pocketbase:
|
||||||
|
# image: ghcr.io/muchobien/pocketbase:latest
|
||||||
|
build:
|
||||||
|
context: ./pocketbase/docker
|
||||||
|
args:
|
||||||
|
- VERSION=0.26.6 # Specify the PocketBase version here
|
||||||
|
# hostname: pocketbase
|
||||||
|
restart: always
|
||||||
|
# environment:
|
||||||
|
# ENCRYPTION: example #optional
|
||||||
|
ports:
|
||||||
|
- 8090:8090
|
||||||
|
volumes:
|
||||||
|
- ./pocketbase/volumes/pb_data:/pb_data
|
||||||
|
- ./pocketbase/pb_hooks:/pb_hooks
|
||||||
|
- ./pocketbase/pb_migrations:/pb_migrations
|
||||||
|
# healthcheck:
|
||||||
|
# #optional (recommended) since v0.10.0
|
||||||
|
# test: wget --no-verbose --tries=1 --spider http://localhost:8090/api/health || exit 1
|
||||||
|
# interval: 5s
|
||||||
|
# timeout: 5s
|
||||||
|
# retries: 5
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: 0.5
|
||||||
|
reservations:
|
||||||
|
cpus: 0.01
|
@@ -12,12 +12,12 @@ const QuestionProgress: React.FC<ContainerProps> = ({ num_rating = 0, num_full_r
|
|||||||
<>
|
<>
|
||||||
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', gap: '0.15rem' }}>
|
<div style={{ display: 'flex', flexDirection: 'row', alignItems: 'center', gap: '0.15rem' }}>
|
||||||
{Array.from({ length: num_rating }, (_, index) => (
|
{Array.from({ length: num_rating }, (_, index) => (
|
||||||
<IonButton shape="round" fill="outline" size="small" color="success">
|
<IonButton key={index} shape="round" fill="outline" size="small" color="success">
|
||||||
<IonIcon slot="icon-only" icon={checkmarkOutline}></IonIcon>
|
<IonIcon slot="icon-only" icon={checkmarkOutline}></IonIcon>
|
||||||
</IonButton>
|
</IonButton>
|
||||||
))}
|
))}
|
||||||
{Array.from({ length: num_full_rating - num_rating }, (_, index) => (
|
{Array.from({ length: num_full_rating - num_rating }, (_, index) => (
|
||||||
<IonButton shape="round" fill="outline" size="small" color="medium">
|
<IonButton key={index} shape="round" fill="outline" size="small" color="medium">
|
||||||
<IonIcon slot="icon-only"></IonIcon>
|
<IonIcon slot="icon-only"></IonIcon>
|
||||||
</IonButton>
|
</IonButton>
|
||||||
))}
|
))}
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"printWidth": 180
|
"printWidth": 360
|
||||||
}
|
}
|
3
002_source/pocketbase/TODO.md
Normal file
3
002_source/pocketbase/TODO.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# TODO
|
||||||
|
|
||||||
|
- [ ] blablabla
|
BIN
002_source/pocketbase/pb_hooks/assets/run.jpg
Normal file
BIN
002_source/pocketbase/pb_hooks/assets/run.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
BIN
002_source/pocketbase/pb_hooks/assets/swim.jpg
Normal file
BIN
002_source/pocketbase/pb_hooks/assets/swim.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 49 KiB |
@@ -18,6 +18,7 @@ $app.rootCmd.addCommand(
|
|||||||
require(`${__hooks}/seed/004_clean_users.js`)($app);
|
require(`${__hooks}/seed/004_clean_users.js`)($app);
|
||||||
require(`${__hooks}/seed/005_Users_teacher.js`)($app);
|
require(`${__hooks}/seed/005_Users_teacher.js`)($app);
|
||||||
require(`${__hooks}/seed/006_Users_student.js`)($app);
|
require(`${__hooks}/seed/006_Users_student.js`)($app);
|
||||||
|
require(`${__hooks}/seed/007_Users_admin.js`)($app);
|
||||||
require(`${__hooks}/seed/010_Vocabularies.js`)($app);
|
require(`${__hooks}/seed/010_Vocabularies.js`)($app);
|
||||||
//
|
//
|
||||||
require(`${__hooks}/seed/020_QuizLPCategories.js`)($app);
|
require(`${__hooks}/seed/020_QuizLPCategories.js`)($app);
|
||||||
@@ -30,12 +31,11 @@ $app.rootCmd.addCommand(
|
|||||||
require(`${__hooks}/seed/041_QuizCRQuestions.js`)($app);
|
require(`${__hooks}/seed/041_QuizCRQuestions.js`)($app);
|
||||||
//
|
//
|
||||||
require(`${__hooks}/seed/050_Customers.js`)($app);
|
require(`${__hooks}/seed/050_Customers.js`)($app);
|
||||||
require(`${__hooks}/seed/051_Teachers.js`)($app);
|
// require(`${__hooks}/seed/051_Teachers_xxx.js`)($app);
|
||||||
require(`${__hooks}/seed/052_Students.js`)($app);
|
require(`${__hooks}/seed/052_Students.js`)($app);
|
||||||
//
|
//
|
||||||
require(`${__hooks}/seed/060_Notifications.js`)($app);
|
require(`${__hooks}/seed/060_Notifications.js`)($app);
|
||||||
|
|
||||||
|
|
||||||
$app.reloadCachedCollections();
|
$app.reloadCachedCollections();
|
||||||
$app.reloadSettings();
|
$app.reloadSettings();
|
||||||
},
|
},
|
||||||
|
@@ -1,14 +1,19 @@
|
|||||||
module.exports = $app => {
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
const ASSETS_DIR = '/pb_hooks/assets';
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
const getAsset = name => $filesystem.fileFromPath(ASSETS_DIR + '/' + name);
|
|
||||||
|
module.exports = ($app) => {
|
||||||
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
|
|
||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
let t1_collection = $app.findCollectionByNameOrId('t1');
|
let t1_collection = $app.findCollectionByNameOrId("t1");
|
||||||
|
|
||||||
let record = new Record(t1_collection);
|
let record = new Record(t1_collection);
|
||||||
record.set('hello', 'world');
|
record.set("hello", "world");
|
||||||
let test_png = getAsset('1.png');
|
let test_png = getAsset("1.png");
|
||||||
record.set('test_file', test_png);
|
record.set("test_file", test_png);
|
||||||
|
|
||||||
$app.save(record);
|
$app.save(record);
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,18 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
|
|
||||||
let draft_lesson_types = [
|
let draft_lesson_types = [
|
||||||
["1".padStart(15, 0), "Vocabulary", "vocabulary", 0, "visible"],
|
[getId("1"), "Vocabulary", "vocabulary", 0, "visible"],
|
||||||
["2".padStart(15, 0), "Connectives", "connectives", 1, "visible"],
|
[getId("2"), "Connectives", "connectives", 1, "visible"],
|
||||||
["3".padStart(15, 0), "Testing visible", "testing", 3, "visible"],
|
[getId("3"), "Testing visible", "testing", 3, "visible"],
|
||||||
["4".padStart(15, 0), "Testing hidden", "testing", 3, "hidden"],
|
[getId("4"), "Testing hidden", "testing", 3, "hidden"],
|
||||||
["5".padStart(15, 0), "lesson type 5", "testing", 3, "hidden"],
|
[getId("5"), "lesson type 5", "testing", 3, "hidden"],
|
||||||
["6".padStart(15, 0), "中文 6", "testing", 3, "hidden"],
|
[getId("6"), "中文 6", "testing", 3, "hidden"],
|
||||||
["7".padStart(15, 0), "レッスン7 レッスン7 レッスン7", "testing", 3, "hidden"],
|
[getId("7"), "レッスン7 レッスン7 レッスン7", "testing", 3, "hidden"],
|
||||||
];
|
];
|
||||||
dirtyTruncateTable("LessonsTypes");
|
dirtyTruncateTable("LessonsTypes");
|
||||||
|
|
||||||
@@ -28,9 +34,3 @@ module.exports = ($app) => {
|
|||||||
}
|
}
|
||||||
console.log("001 lesson types seeding done");
|
console.log("001 lesson types seeding done");
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
|
||||||
cmd_to_exec.output();
|
|
||||||
};
|
|
||||||
|
@@ -1,19 +1,25 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { CR_cat_id_news, CR_cat_id_technology, id_v, id_c } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
|
// const id_v = "1".padStart(15, 0); //id_vocabulary
|
||||||
|
// const id_c = "2".padStart(15, 0); //id_connectives
|
||||||
|
|
||||||
let row_array = [
|
let row_array = [
|
||||||
["1".padStart(15, 0), "news", "", getAsset("ci_news.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("1"), "news", "", getAsset("ci_news.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["2".padStart(15, 0), "sports", "", getAsset("ci_sports.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("2"), "sports", "", getAsset("ci_sports.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["3".padStart(15, 0), "technology", "", getAsset("ci_technology.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("3"), "technology", "", getAsset("ci_technology.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["4".padStart(15, 0), "art", "", getAsset("ci_art.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("4"), "art", "", getAsset("ci_art.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["5".padStart(15, 0), "basic", "", getAsset("ci_basic.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("5"), "basic", "", getAsset("ci_basic.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["6".padStart(15, 0), "nature", "", getAsset("ci_nature.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("6"), "nature", "", getAsset("ci_nature.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["7".padStart(15, 0), "workplace", "", getAsset("ci_workplace.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("7"), "workplace", "", getAsset("ci_workplace.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["8".padStart(15, 0), "workplace", "", getAsset("ci_workplace.jpg"), 1, "hidden", id_v, "desc", "remarks"],
|
[getId("8"), "workplace", "", getAsset("ci_workplace.jpg"), 1, "hidden", id_v, "desc", "remarks"],
|
||||||
["99".padStart(15, 0), "connectives", "", getAsset("1.png"), 1, "visible", id_c, "desc", "remarks"],
|
[getId("99"), "connectives", "", getAsset("1.png"), 1, "visible", id_c, "desc", "remarks"],
|
||||||
// ["2".padStart(15, 0), "Connectives", "connectivse", 1, "visible"],
|
// ["2".padStart(15, 0), "Connectives", "connectivse", 1, "visible"],
|
||||||
// ["3".padStart(15, 0), "Testing visible", "testing", 3, "visible"],
|
// ["3".padStart(15, 0), "Testing visible", "testing", 3, "visible"],
|
||||||
// ["4".padStart(15, 0), "Testing hidden", "testing", 3, "hidden"],
|
// ["4".padStart(15, 0), "Testing hidden", "testing", 3, "hidden"],
|
||||||
@@ -41,9 +47,3 @@ module.exports = ($app) => {
|
|||||||
|
|
||||||
console.log("002 lesson categories seeding done");
|
console.log("002 lesson categories seeding done");
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
|
||||||
cmd_to_exec.output();
|
|
||||||
};
|
|
||||||
|
@@ -1,18 +1,28 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
|
const { CR_cat_id_news, CR_cat_id_technology, id_v, id_c } = config;
|
||||||
|
|
||||||
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
|
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
// const id_v = "1".padStart(15, 0); //id_vocabulary
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
// const id_c = "2".padStart(15, 0); //id_connectives
|
||||||
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
|
|
||||||
let row_array = [
|
let row_array = [
|
||||||
["1".padStart(15, 0), "news", "", getAsset("ci_news.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("1"), "news", "", getAsset("ci_news.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["2".padStart(15, 0), "sports", "", getAsset("ci_sports.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("2"), "sports", "", getAsset("ci_sports.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["3".padStart(15, 0), "technology", "", getAsset("ci_technology.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("3"), "technology", "", getAsset("ci_technology.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["4".padStart(15, 0), "art", "", getAsset("ci_art.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("4"), "art", "", getAsset("ci_art.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["5".padStart(15, 0), "basic", "", getAsset("ci_basic.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("5"), "basic", "", getAsset("ci_basic.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["6".padStart(15, 0), "nature", "", getAsset("ci_nature.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
|
||||||
["7".padStart(15, 0), "workplace", "", getAsset("ci_workplace.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
[getId("6"), "nature", "", getAsset("ci_nature.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
["99".padStart(15, 0), "connectives", "", getAsset("1.png"), 1, "visible", id_c, "desc", "remarks"],
|
[getId("7"), "workplace", "", getAsset("ci_workplace.jpg"), 1, "visible", id_v, "desc", "remarks"],
|
||||||
|
[getId("11"), "connectives", "", getAsset("1.png"), 1, "visible", id_c, "desc", "remarks"],
|
||||||
|
[getId("12"), "connectives_2", "", getAsset("1.png"), 1, "visible", id_c, "desc", "remarks"],
|
||||||
// ["2".padStart(15, 0), "Connectives", "connectivse", 1, "visible"],
|
// ["2".padStart(15, 0), "Connectives", "connectivse", 1, "visible"],
|
||||||
// ["3".padStart(15, 0), "Testing visible", "testing", 3, "visible"],
|
// ["3".padStart(15, 0), "Testing visible", "testing", 3, "visible"],
|
||||||
// ["4".padStart(15, 0), "Testing hidden", "testing", 3, "hidden"],
|
// ["4".padStart(15, 0), "Testing hidden", "testing", 3, "hidden"],
|
||||||
@@ -41,8 +51,8 @@ module.exports = ($app) => {
|
|||||||
console.log("003 categories seeding done");
|
console.log("003 categories seeding done");
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
cmd_to_exec.output();
|
// cmd_to_exec.output();
|
||||||
};
|
// };
|
||||||
|
@@ -1,4 +1,10 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
|
|
||||||
console.log("004 clean user table start");
|
console.log("004 clean user table start");
|
||||||
|
|
||||||
dirtyTruncateTable("Users");
|
dirtyTruncateTable("Users");
|
||||||
@@ -7,8 +13,8 @@ module.exports = ($app) => {
|
|||||||
console.log("004 clean user table done");
|
console.log("004 clean user table done");
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
cmd_to_exec.output();
|
// cmd_to_exec.output();
|
||||||
};
|
// };
|
||||||
|
@@ -1,46 +1,21 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
|
||||||
|
|
||||||
let row_array = [
|
let row_array = [
|
||||||
["11".padStart(15, 0), "teacher1@123.com", "teacher1@123.com", "teacher1@123.com", true, true, "test_user_1"],
|
[getId("11"), "teacher1@123.com", "teacher1@123.com", "teacher1@123.com", true, true, "test_teacher_1"],
|
||||||
["12".padStart(15, 0), "teacher2@123.com", "teacher2@123.com", "teacher2@123.com", true, true, "test_user_2"],
|
[getId("12"), "teacher2@123.com", "teacher2@123.com", "teacher2@123.com", true, true, "test_teacher_2"],
|
||||||
["13".padStart(15, 0), "teacher3@123.com", "teacher3@123.com", "teacher3@123.com", true, true, "test_user_3"],
|
[getId("13"), "teacher3@123.com", "teacher3@123.com", "teacher3@123.com", true, true, "test_teacher_3"],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// um = user_meta
|
||||||
let um_row_array = [
|
let um_row_array = [
|
||||||
[
|
[getId("11"), "teacher1@123.com", "active", getId("11"), JSON.stringify({}), getAsset("people1.png"), "teacher", "teacher_1"],
|
||||||
"11".padStart(15, 0),
|
[getId("12"), "teacher2@123.com", "pending", getId("12"), JSON.stringify({}), getAsset("people2.png"), "teacher", "teacher_2"],
|
||||||
"teacher1@123.com",
|
[getId("13"), "teacher3@123.com", "blocked", getId("13"), JSON.stringify({}), getAsset("people3.png"), "teacher", "teacher_3"],
|
||||||
"active",
|
|
||||||
"11".padStart(15, 0),
|
|
||||||
JSON.stringify({}),
|
|
||||||
getAsset("people1.png"),
|
|
||||||
"teacher",
|
|
||||||
//
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"12".padStart(15, 0),
|
|
||||||
"teacher2@123.com",
|
|
||||||
"active",
|
|
||||||
"12".padStart(15, 0),
|
|
||||||
JSON.stringify({}),
|
|
||||||
getAsset("people2.png"),
|
|
||||||
"teacher",
|
|
||||||
//
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"13".padStart(15, 0),
|
|
||||||
"teacher3@123.com",
|
|
||||||
"active",
|
|
||||||
"13".padStart(15, 0),
|
|
||||||
JSON.stringify({}),
|
|
||||||
getAsset("people3.png"),
|
|
||||||
"teacher",
|
|
||||||
//
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
let users_collection = $app.findCollectionByNameOrId("users");
|
let users_collection = $app.findCollectionByNameOrId("users");
|
||||||
@@ -63,19 +38,29 @@ module.exports = ($app) => {
|
|||||||
let um_record = new Record(user_metas_collection);
|
let um_record = new Record(user_metas_collection);
|
||||||
um_record.set("id", um[0]);
|
um_record.set("id", um[0]);
|
||||||
um_record.set("helloworld", um[1]);
|
um_record.set("helloworld", um[1]);
|
||||||
um_record.set("state", um[2]);
|
um_record.set("status", um[2]);
|
||||||
um_record.set("user_id", um[3]);
|
um_record.set("user_id", um[3]);
|
||||||
um_record.set("meta", um[4]);
|
um_record.set("meta", um[4]);
|
||||||
|
|
||||||
|
// NOTE: obslete "avatar" and use "avatar_file"
|
||||||
um_record.set("avatar", um[5]);
|
um_record.set("avatar", um[5]);
|
||||||
|
um_record.set("avatar_file", um[5]);
|
||||||
|
//
|
||||||
|
|
||||||
um_record.set("role", um[6]);
|
um_record.set("role", um[6]);
|
||||||
|
um_record.set("name", um[7]);
|
||||||
|
um_record.set("email", user[3]);
|
||||||
|
um_record.set("phone", "9123456" + i.toString());
|
||||||
|
|
||||||
$app.save(um_record);
|
$app.save(um_record);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("005 add teacher user done");
|
console.log("005 add teacher user done");
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: delete this ?
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,23 +1,25 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
|
||||||
|
|
||||||
let row_array = [
|
let row_array = [
|
||||||
["1".padStart(15, 0), "user1@123.com", "user1@123.com", "user1@123.com", true, true, "test_user_1"],
|
[getId("1"), "user1@123.com", "user1@123.com", "user1@123.com", true, true, "test_student_1"],
|
||||||
["2".padStart(15, 0), "user2@123.com", "user2@123.com", "user2@123.com", true, true, "test_user_2"],
|
[getId("2"), "user2@123.com", "user2@123.com", "user2@123.com", true, true, "test_student_2"],
|
||||||
["3".padStart(15, 0), "user3@123.com", "user3@123.com", "user3@123.com", true, true, "test_user_3"],
|
[getId("3"), "user3@123.com", "user3@123.com", "user3@123.com", true, true, "test_student_3"],
|
||||||
["4".padStart(15, 0), "user4@123.com", "user4@123.com", "user4@123.com", true, true, "test_user_4"],
|
[getId("4"), "user4@123.com", "user4@123.com", "user4@123.com", true, true, "test_student_4"],
|
||||||
["5".padStart(15, 0), "user5@123.com", "user5@123.com", "user5@123.com", true, true, "test_user_5"],
|
[getId("5"), "user5@123.com", "user5@123.com", "user5@123.com", true, true, "test_student_5"],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// um = user_meta
|
||||||
let um_row_array = [
|
let um_row_array = [
|
||||||
["1".padStart(15, 0), "user1@123.com", "active", "1".padStart(15, 0), JSON.stringify({}), getAsset("people1.png"), "student"],
|
[getId("1"), "user1@123.com", "active", getId("1"), JSON.stringify({}), getAsset("people1.png"), "student", "student_1"],
|
||||||
["2".padStart(15, 0), "user2@123.com", "active", "2".padStart(15, 0), JSON.stringify({}), getAsset("people2.png"), "student"],
|
[getId("2"), "user2@123.com", "pending", getId("2"), JSON.stringify({}), getAsset("people2.png"), "student", "student_2"],
|
||||||
["3".padStart(15, 0), "user3@123.com", "active", "3".padStart(15, 0), JSON.stringify({}), getAsset("people3.png"), "student"],
|
[getId("3"), "user3@123.com", "blocked", getId("3"), JSON.stringify({}), getAsset("people3.png"), "student", "student_3"],
|
||||||
["4".padStart(15, 0), "user4@123.com", "active", "4".padStart(15, 0), JSON.stringify({}), getAsset("people4.png"), "student"],
|
[getId("4"), "user4@123.com", "active", getId("4"), JSON.stringify({}), getAsset("people4.png"), "student", "student_4"],
|
||||||
["5".padStart(15, 0), "user5@123.com", "active", "5".padStart(15, 0), JSON.stringify({}), getAsset("people5.png"), "student"],
|
[getId("5"), "user5@123.com", "pending", getId("5"), JSON.stringify({}), getAsset("people5.png"), "student", "student_5"],
|
||||||
];
|
];
|
||||||
|
|
||||||
let users_collection = $app.findCollectionByNameOrId("users");
|
let users_collection = $app.findCollectionByNameOrId("users");
|
||||||
@@ -40,19 +42,29 @@ module.exports = ($app) => {
|
|||||||
let um_record = new Record(user_metas_collection);
|
let um_record = new Record(user_metas_collection);
|
||||||
um_record.set("id", um[0]);
|
um_record.set("id", um[0]);
|
||||||
um_record.set("helloworld", um[1]);
|
um_record.set("helloworld", um[1]);
|
||||||
um_record.set("state", um[2]);
|
um_record.set("status", um[2]);
|
||||||
um_record.set("user_id", um[3]);
|
um_record.set("user_id", um[3]);
|
||||||
um_record.set("meta", um[4]);
|
um_record.set("meta", um[4]);
|
||||||
|
|
||||||
|
// NOTE: obslete "avatar" and use "avatar_file"
|
||||||
um_record.set("avatar", um[5]);
|
um_record.set("avatar", um[5]);
|
||||||
|
um_record.set("avatar_file", um[5]);
|
||||||
|
//
|
||||||
|
|
||||||
um_record.set("role", um[6]);
|
um_record.set("role", um[6]);
|
||||||
|
um_record.set("name", um[7]);
|
||||||
|
um_record.set("email", user[3]);
|
||||||
|
um_record.set("phone", "9123456" + i.toString());
|
||||||
|
|
||||||
$app.save(um_record);
|
$app.save(um_record);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("006 add student user done");
|
console.log("006 add student user done");
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: delete this ?
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
52
002_source/pocketbase/pb_hooks/seed/007_Users_admin.js
Normal file
52
002_source/pocketbase/pb_hooks/seed/007_Users_admin.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
|
module.exports = ($app) => {
|
||||||
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
|
const { getId, getAsset } = utils;
|
||||||
|
const ADMIN_USER_ID = getId("999");
|
||||||
|
|
||||||
|
let row_array = [[ADMIN_USER_ID, "admin@123.com", "admin@123.com", "admin@123.com", true, true, "test_admin_1"]];
|
||||||
|
|
||||||
|
// um = user_meta
|
||||||
|
let um_row_array = [[ADMIN_USER_ID, "admin@123.com", "active", ADMIN_USER_ID, JSON.stringify({}), getAsset("people1.png"), "admin", "admin_1"]];
|
||||||
|
|
||||||
|
let users_collection = $app.findCollectionByNameOrId("users");
|
||||||
|
let user_metas_collection = $app.findCollectionByNameOrId("UserMetas");
|
||||||
|
|
||||||
|
for (let i = 0; i < row_array.length; i++) {
|
||||||
|
let user = row_array[i];
|
||||||
|
let um = um_row_array[i];
|
||||||
|
|
||||||
|
let record = new Record(users_collection);
|
||||||
|
record.set("id", user[0]);
|
||||||
|
record.set("password", user[1]);
|
||||||
|
record.set("passwordConfirm", user[2]);
|
||||||
|
record.set("email", user[3]);
|
||||||
|
record.set("emailVisibility", user[4]);
|
||||||
|
record.set("verified", user[5]);
|
||||||
|
record.set("name", user[6]);
|
||||||
|
$app.save(record);
|
||||||
|
|
||||||
|
let um_record = new Record(user_metas_collection);
|
||||||
|
um_record.set("id", um[0]);
|
||||||
|
um_record.set("helloworld", um[1]);
|
||||||
|
um_record.set("status", um[2]);
|
||||||
|
um_record.set("user_id", um[3]);
|
||||||
|
um_record.set("meta", um[4]);
|
||||||
|
|
||||||
|
// NOTE: obslete "avatar" and use "avatar_file"
|
||||||
|
um_record.set("avatar", um[5]);
|
||||||
|
um_record.set("avatar_file", um[5]);
|
||||||
|
//
|
||||||
|
|
||||||
|
um_record.set("role", um[6]);
|
||||||
|
um_record.set("name", um[7]);
|
||||||
|
um_record.set("email", user[3]);
|
||||||
|
um_record.set("phone", "9123456" + i.toString());
|
||||||
|
|
||||||
|
$app.save(um_record);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("007 add admin user done");
|
||||||
|
};
|
@@ -1,40 +1,58 @@
|
|||||||
const config = require('/pb_hooks/seed/config.js');
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
const utils = require('/pb_hooks/seed/utils.js');
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = $app => {
|
module.exports = ($app) => {
|
||||||
const { getAsset } = utils;
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const { id_v, id_c, cat_id_tech } = config;
|
const { id_v, id_c, cat_id_news, cat_id_sport, cat_id_tech, cat_id_art, cat_id_basic, cat_id_nature, cat_id_workplace, cat_id_connectives_1 } = config;
|
||||||
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
|
|
||||||
let row_datas = [
|
let row_datas = [
|
||||||
['1'.padStart(15, 0), getAsset('keyboard.jpg'), getAsset('keyboard.mp3'), 'keyboard', '鍵盤', 'sample_e', 'sample_c', cat_id_tech, '', id_v],
|
[getId("1"), getAsset("keyboard.jpg"), getAsset("keyboard.mp3"), "keyboard", "鍵盤", "sample_e", "sample_c", cat_id_tech, "", id_v, "visible"],
|
||||||
['2'.padStart(15, 0), getAsset('mouse.jpg'), getAsset('mouse.mp3'), 'mouse', '滑鼠', 'sample_e mouse', 'sample_c mouse', cat_id_tech, '', id_v],
|
[getId("2"), getAsset("mouse.jpg"), getAsset("mouse.mp3"), "mouse", "滑鼠", "sample_e mouse", "sample_c mouse", cat_id_tech, "", id_v, "visible"],
|
||||||
|
[getId("3"), getAsset("run.jpg"), getAsset("mouse.mp3"), "run", "跑步", "sample_e run", "sample_c run", cat_id_sport, "", id_v, "visible"],
|
||||||
|
[getId("4"), getAsset("swim.jpg"), getAsset("mouse.mp3"), "swim", "游泳", "sample_e swim", "sample_c swim", cat_id_sport, "", id_v, "visible"],
|
||||||
|
//
|
||||||
|
[getId("5"), getAsset("news1.jpg"), getAsset("news1.mp3"), "news", "新聞", "sample_e news1", "sample_c news1", cat_id_news, "", id_v, "visible"],
|
||||||
|
[getId("6"), getAsset("news2.jpg"), getAsset("news2.mp3"), "news", "新聞", "sample_e news2", "sample_c news2", cat_id_news, "", id_v, "visible"],
|
||||||
|
[getId("7"), getAsset("art1.jpg"), getAsset("art1.mp3"), "art", "藝術", "sample_e art1", "sample_c art1", cat_id_art, "", id_v, "visible"],
|
||||||
|
[getId("8"), getAsset("art2.jpg"), getAsset("art2.mp3"), "art", "藝術", "sample_e art2", "sample_c art2", cat_id_art, "", id_v, "visible"],
|
||||||
|
[getId("9"), getAsset("basic1.jpg"), getAsset("basic1.mp3"), "basic", "基礎", "sample_e basic1", "sample_c basic1", cat_id_basic, "", id_v, "visible"],
|
||||||
|
[getId("10"), getAsset("basic2.jpg"), getAsset("basic2.mp3"), "basic", "基礎", "sample_e basic2", "sample_c basic2", cat_id_basic, "", id_v, "visible"],
|
||||||
|
[getId("11"), getAsset("nature1.jpg"), getAsset("nature1.mp3"), "nature", "自然", "sample_e nature1", "sample_c nature1", cat_id_nature, "", id_v, "visible"],
|
||||||
|
[getId("12"), getAsset("nature2.jpg"), getAsset("nature2.mp3"), "nature", "自然", "sample_e nature2", "sample_c nature2", cat_id_nature, "", id_v, "visible"],
|
||||||
|
[getId("13"), getAsset("workplace1.jpg"), getAsset("workplace1.mp3"), "workplace", "工作場所", "sample_e workplace1", "sample_c workplace1", cat_id_workplace, "", id_v, "visible"],
|
||||||
|
[getId("14"), getAsset("workplace2.jpg"), getAsset("workplace2.mp3"), "workplace", "工作場所", "sample_e workplace2", "sample_c workplace2", cat_id_workplace, "", id_v, "visible"],
|
||||||
|
//
|
||||||
|
[getId("21"), getAsset("mouse.jpg"), getAsset("mouse.mp3"), "connectives 1", "連接詞 1", "connective sample_e 1", "connective sample_c 1", cat_id_connectives_1, "", id_c, "visible"],
|
||||||
];
|
];
|
||||||
|
|
||||||
dirtyTruncateTable('Vocabularies');
|
dirtyTruncateTable("Vocabularies");
|
||||||
|
|
||||||
for (let i = 0; i < row_datas.length; i++) {
|
for (let i = 0; i < row_datas.length; i++) {
|
||||||
let vocabularies_collection = $app.findCollectionByNameOrId('Vocabularies');
|
let vocabularies_collection = $app.findCollectionByNameOrId("Vocabularies");
|
||||||
let data = row_datas[i];
|
let data = row_datas[i];
|
||||||
|
|
||||||
let record = new Record(vocabularies_collection);
|
let record = new Record(vocabularies_collection);
|
||||||
record.set('id', data[0]);
|
record.set("id", data[0]);
|
||||||
record.set('image', data[1]);
|
record.set("image", data[1]);
|
||||||
record.set('sound', data[2]);
|
record.set("sound", data[2]);
|
||||||
record.set('word', data[3]);
|
record.set("word", data[3]);
|
||||||
record.set('word_c', data[4]);
|
record.set("word_c", data[4]);
|
||||||
record.set('sample_e', data[5]);
|
record.set("sample_e", data[5]);
|
||||||
record.set('sample_c', data[6]);
|
record.set("sample_c", data[6]);
|
||||||
record.set('cat_id', data[7]);
|
record.set("cat_id", data[7]);
|
||||||
record.set('category', data[8]);
|
record.set("category", data[8]);
|
||||||
record.set('lesson_type_id', data[9]);
|
record.set("lesson_type_id", data[9]);
|
||||||
|
record.set("visible", data[10]);
|
||||||
|
|
||||||
$app.save(record);
|
$app.save(record);
|
||||||
}
|
}
|
||||||
console.log('done ?');
|
console.log("done ?");
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = COLLECTION_NAME => {
|
// TODO: delete me ?
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd('sqlite3', '/pb_data/data.db', `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,9 +1,14 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
const getId = (id) => id.padStart(15, 0);
|
// const id_v = "1".padStart(15, 0); //id_vocabulary
|
||||||
|
// const id_c = "2".padStart(15, 0); //id_connectives
|
||||||
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
let row_array = [
|
let row_array = [
|
||||||
[getId("1"), "news (listening)", getAsset("ci_news.jpg"), 1, {}, "visible"],
|
[getId("1"), "news (listening)", getAsset("ci_news.jpg"), 1, {}, "visible"],
|
||||||
[getId("2"), "sports (listening)", getAsset("ci_sports.jpg"), 2, {}, "visible"],
|
[getId("2"), "sports (listening)", getAsset("ci_sports.jpg"), 2, {}, "visible"],
|
||||||
@@ -36,8 +41,9 @@ module.exports = ($app) => {
|
|||||||
console.log(`020_QuizLPCategories done`);
|
console.log(`020_QuizLPCategories done`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: delete me ?
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,20 +1,20 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { LP_cat_id_news, LP_cat_id_sports, LP_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
|
||||||
const cat_id_technology = "3".padStart(15, 0);
|
|
||||||
const getId = (id) => id.padStart(15, 0);
|
|
||||||
let row_array = [
|
let row_array = [
|
||||||
[getId("1") ,"news (LP)" ,getAsset("ci_news.jpg") ,1 ,{} ,"visible" ,"news" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("1"), "news (LP)", getAsset("ci_news.jpg"), 1, ["A", "B", "C"], "visible", "news", getAsset("keyboard.mp3"), LP_cat_id_news],
|
||||||
[getId("2") ,"sports (LP)" ,getAsset("ci_sports.jpg") ,2 ,{} ,"visible" ,"sports" ,getAsset("mouse.mp3") ,cat_id_technology] ,
|
[getId("2"), "sports (LP)", getAsset("ci_sports.jpg"), 2, ["A", "B", "C"], "visible", "sports", getAsset("mouse.mp3"), LP_cat_id_news],
|
||||||
[getId("3") ,"technology (LP)" ,getAsset("ci_technology.jpg") ,3 ,{} ,"visible" ,"technology" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("3"), "technology (LP)", getAsset("ci_technology.jpg"), 3, ["A", "B", "C"], "visible", "technology", getAsset("keyboard.mp3"), LP_cat_id_news],
|
||||||
[getId("4") ,"art (LP)" ,getAsset("ci_art.jpg") ,4 ,{} ,"visible" ,"art" ,getAsset("mouse.mp3") ,cat_id_technology] ,
|
[getId("4"), "art (LP)", getAsset("ci_art.jpg"), 4, ["A", "B", "C"], "visible", "art", getAsset("mouse.mp3"), LP_cat_id_sports],
|
||||||
[getId("5") ,"basic (LP)" ,getAsset("ci_basic.jpg") ,5 ,{} ,"visible" ,"basic" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("5"), "basic (LP)", getAsset("ci_basic.jpg"), 5, ["A", "B", "C"], "visible", "basic", getAsset("keyboard.mp3"), LP_cat_id_sports],
|
||||||
[getId("6") ,"nature (LP)" ,getAsset("ci_nature.jpg") ,6 ,{} ,"visible" ,"nature" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("6"), "nature (LP)", getAsset("ci_nature.jpg"), 6, ["A", "B", "C"], "visible", "nature", getAsset("keyboard.mp3"), LP_cat_id_sports],
|
||||||
[getId("7") ,"workplace (LP)" ,getAsset("ci_workplace.jpg") ,7 ,{} ,"visible" ,"workplace" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("7"), "workplace (LP)", getAsset("ci_workplace.jpg"), 7, ["A", "B", "C"], "visible", "workplace", getAsset("keyboard.mp3"), LP_cat_id_technology],
|
||||||
[getId("8") ,"workplace (LP)" ,getAsset("ci_workplace.jpg") ,8 ,{} ,"visible" ,"workplace" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("8"), "workplace (LP)", getAsset("ci_workplace.jpg"), 8, ["A", "B", "C"], "visible", "workplace", getAsset("keyboard.mp3"), LP_cat_id_technology],
|
||||||
[getId("99") ,"test hidden (LP)" ,getAsset("ci_workplace.jpg") ,9 ,{} ,"hidden" ,"test" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("99"), "test hidden (LP)", getAsset("ci_workplace.jpg"), 9, ["A", "B", "C"], "hidden", "test", getAsset("keyboard.mp3"), LP_cat_id_technology],
|
||||||
];
|
];
|
||||||
dirtyTruncateTable("QuizLPQuestions");
|
dirtyTruncateTable("QuizLPQuestions");
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ module.exports = ($app) => {
|
|||||||
record.set("visible", lesson_type[5]);
|
record.set("visible", lesson_type[5]);
|
||||||
record.set("word", lesson_type[6]);
|
record.set("word", lesson_type[6]);
|
||||||
record.set("sound", lesson_type[7]);
|
record.set("sound", lesson_type[7]);
|
||||||
record.set("cat_id", lesson_type[7]);
|
record.set("cat_id", lesson_type[8]);
|
||||||
|
|
||||||
$app.save(record);
|
$app.save(record);
|
||||||
}
|
}
|
||||||
@@ -40,8 +40,9 @@ module.exports = ($app) => {
|
|||||||
console.log(`021_QuizLPQuestions done`);
|
console.log(`021_QuizLPQuestions done`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: remove me
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,35 +0,0 @@
|
|||||||
module.exports = ($app) => {
|
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
|
||||||
const getId = (id) => id.padStart(15, 0);
|
|
||||||
const id_v = getId("1"); //id_vocabulary
|
|
||||||
const id_c = getId("2"); //id_connectives
|
|
||||||
|
|
||||||
let row_array = [
|
|
||||||
[getId("1"), "keyboard", getAsset("keyboard.jpg"), getId("1")],
|
|
||||||
[getId("2"), "mouse", getAsset("mouse.jpg"), getId("1")],
|
|
||||||
];
|
|
||||||
dirtyTruncateTable("QuizLPQuestions");
|
|
||||||
|
|
||||||
let lt_collection = $app.findCollectionByNameOrId("QuizLPQuestions");
|
|
||||||
|
|
||||||
for (let i = 0; i < row_array.length; i++) {
|
|
||||||
let lesson_type = row_array[i];
|
|
||||||
|
|
||||||
let record = new Record(lt_collection);
|
|
||||||
record.set("id", lesson_type[0]);
|
|
||||||
record.set("word", lesson_type[1]);
|
|
||||||
record.set("sound", lesson_type[2]);
|
|
||||||
record.set("cat_id", lesson_type[3]);
|
|
||||||
|
|
||||||
$app.save(record);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`021 QuizLPQuestions done`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
|
||||||
cmd_to_exec.output();
|
|
||||||
};
|
|
@@ -1,9 +1,15 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
const getId = (id) => id.padStart(15, 0);
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
|
// const id_v = "1".padStart(15, 0); //id_vocabulary
|
||||||
|
// const id_c = "2".padStart(15, 0); //id_connectives
|
||||||
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
let row_array = [
|
let row_array = [
|
||||||
[getId("1"), "news (matching)", getAsset("ci_news.jpg"), 1, {}, "visible"],
|
[getId("1"), "news (matching)", getAsset("ci_news.jpg"), 1, {}, "visible"],
|
||||||
[getId("2"), "sports (matching)", getAsset("ci_sports.jpg"), 2, {}, "visible"],
|
[getId("2"), "sports (matching)", getAsset("ci_sports.jpg"), 2, {}, "visible"],
|
||||||
@@ -36,8 +42,9 @@ module.exports = ($app) => {
|
|||||||
console.log(`030_QuizMFCategories done`);
|
console.log(`030_QuizMFCategories done`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: remove me
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,20 +1,20 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { MF_cat_id_news, MF_cat_id_sports, MF_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
|
||||||
const cat_id_technology = "3".padStart(15, 0);
|
|
||||||
const getId = (id) => id.padStart(15, 0);
|
|
||||||
let row_array = [
|
let row_array = [
|
||||||
[getId("1") ,"news (MF)" ,getAsset("ci_news.jpg") ,1 ,{} ,"visible" ,"news" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("1"), "news (MF)", getAsset("ci_news.jpg"), 1, ["A", "B", "C"], "visible", "chinese_1", getAsset("keyboard.mp3"), MF_cat_id_news, "中文1"],
|
||||||
[getId("2") ,"sports (MF)" ,getAsset("ci_sports.jpg") ,2 ,{} ,"visible" ,"sports" ,getAsset("mouse.mp3") ,cat_id_technology] ,
|
[getId("2"), "sports (MF)", getAsset("ci_sports.jpg"), 2, ["A", "B", "C"], "visible", "chinese_2", getAsset("mouse.mp3"), MF_cat_id_news, "中文2"],
|
||||||
[getId("3") ,"technology (MF)" ,getAsset("ci_technology.jpg") ,3 ,{} ,"visible" ,"technology" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("3"), "technology (MF)", getAsset("ci_technology.jpg"), 3, ["A", "B", "C"], "visible", "chinese_3", getAsset("keyboard.mp3"), MF_cat_id_news, "中文3"],
|
||||||
[getId("4") ,"art (MF)" ,getAsset("ci_art.jpg") ,4 ,{} ,"visible" ,"art" ,getAsset("mouse.mp3") ,cat_id_technology] ,
|
[getId("4"), "art (MF)", getAsset("ci_art.jpg"), 4, ["A", "B", "C"], "visible", "chinese_1", getAsset("mouse.mp3"), MF_cat_id_sports, "中文1"],
|
||||||
[getId("5") ,"basic (MF)" ,getAsset("ci_basic.jpg") ,5 ,{} ,"visible" ,"basic" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("5"), "basic (MF)", getAsset("ci_basic.jpg"), 5, ["A", "B", "C"], "visible", "chinese_2", getAsset("keyboard.mp3"), MF_cat_id_sports, "中文2"],
|
||||||
[getId("6") ,"nature (MF)" ,getAsset("ci_nature.jpg") ,6 ,{} ,"visible" ,"nature" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("6"), "nature (MF)", getAsset("ci_nature.jpg"), 6, ["A", "B", "C"], "visible", "chinese_3", getAsset("keyboard.mp3"), MF_cat_id_sports, "中文3"],
|
||||||
[getId("7") ,"workplace (MF)" ,getAsset("ci_workplace.jpg") ,7 ,{} ,"visible" ,"workplace" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("7"), "workplace (MF)", getAsset("ci_workplace.jpg"), 7, ["A", "B", "C"], "visible", "chinese_1", getAsset("keyboard.mp3"), MF_cat_id_technology, "中文1"],
|
||||||
[getId("8") ,"workplace (MF)" ,getAsset("ci_workplace.jpg") ,8 ,{} ,"visible" ,"workplace" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("8"), "workplace (MF)", getAsset("ci_workplace.jpg"), 8, ["A", "B", "C"], "visible", "chinese_2", getAsset("keyboard.mp3"), MF_cat_id_technology, "中文2"],
|
||||||
[getId("99") ,"test hidden (MF)" ,getAsset("ci_workplace.jpg") ,9 ,{} ,"hidden" ,"test" ,getAsset("keyboard.mp3") ,cat_id_technology] ,
|
[getId("99"), "test hidden (MF)", getAsset("ci_workplace.jpg"), 9, ["A", "B", "C"], "hidden", "chinese_3", getAsset("keyboard.mp3"), MF_cat_id_technology, "中文3"],
|
||||||
];
|
];
|
||||||
dirtyTruncateTable("QuizMFQuestions");
|
dirtyTruncateTable("QuizMFQuestions");
|
||||||
|
|
||||||
@@ -32,7 +32,8 @@ module.exports = ($app) => {
|
|||||||
record.set("visible", lesson_type[5]);
|
record.set("visible", lesson_type[5]);
|
||||||
record.set("word", lesson_type[6]);
|
record.set("word", lesson_type[6]);
|
||||||
record.set("sound", lesson_type[7]);
|
record.set("sound", lesson_type[7]);
|
||||||
record.set("cat_id", lesson_type[7]);
|
record.set("cat_id", lesson_type[8]);
|
||||||
|
record.set("word_c", lesson_type[9]);
|
||||||
|
|
||||||
$app.save(record);
|
$app.save(record);
|
||||||
}
|
}
|
||||||
@@ -40,8 +41,9 @@ module.exports = ($app) => {
|
|||||||
console.log(`031_QuizMFQuestions done`);
|
console.log(`031_QuizMFQuestions done`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: remove me
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,9 +1,16 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
const getId = (id) => id.padStart(15, 0);
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
|
// const id_v = "1".padStart(15, 0); //id_vocabulary
|
||||||
|
// const id_c = "2".padStart(15, 0); //id_connectives
|
||||||
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
|
|
||||||
let row_array = [
|
let row_array = [
|
||||||
[getId("1"), "news (connective)", getAsset("ci_news.jpg"), 1, {}, "visible"],
|
[getId("1"), "news (connective)", getAsset("ci_news.jpg"), 1, {}, "visible"],
|
||||||
[getId("2"), "sports (connective)", getAsset("ci_sports.jpg"), 2, {}, "visible"],
|
[getId("2"), "sports (connective)", getAsset("ci_sports.jpg"), 2, {}, "visible"],
|
||||||
@@ -36,8 +43,9 @@ module.exports = ($app) => {
|
|||||||
console.log(`040_QuizCRCategories done`);
|
console.log(`040_QuizCRCategories done`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: remove me
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,155 +1,26 @@
|
|||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
const cat_id_technology = "3".padStart(15, 0);
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
const getId = (id) => id.padStart(15, 0);
|
// const id_v = "1".padStart(15, 0); //id_vocabulary
|
||||||
|
// const id_c = "2".padStart(15, 0); //id_connectives
|
||||||
|
// const cat_id_technology = "3".padStart(15, 0);
|
||||||
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
let row_array = [
|
let row_array = [
|
||||||
[
|
[getId("1"), "news (CR)", getAsset("ci_news.jpg"), 1, ["A", "B", "C"], "visible", "news", getAsset("keyboard.mp3"), CR_cat_id_technology, "question_fh_1", "question_sh_1", "modal_ans_1", CR_cat_id_news, ["A", "B", "C"]],
|
||||||
getId("1"),
|
[getId("2"), "sports (CR)", getAsset("ci_sports.jpg"), 2, ["A", "B", "C"], "visible", "sports", getAsset("mouse.mp3"), CR_cat_id_technology, "question_fh_2", "question_sh_2", "modal_ans_2", CR_cat_id_news, ["A", "B", "C"]],
|
||||||
"news (CR)",
|
[getId("3"), "technology (CR)", getAsset("ci_technology.jpg"), 3, ["A", "B", "C"], "visible", "technology", getAsset("keyboard.mp3"), CR_cat_id_technology, "question_fh_3", "question_sh_3", "modal_ans_3", CR_cat_id_news, ["A", "B", "C"]],
|
||||||
getAsset("ci_news.jpg"),
|
[getId("4"), "art (CR)", getAsset("ci_art.jpg"), 4, ["A", "B", "C"], "visible", "art", getAsset("mouse.mp3"), CR_cat_id_technology, "question_fh_4", "question_sh_4", "modal_ans_4", CR_cat_id_news, ["A", "B", "C"]],
|
||||||
1,
|
[getId("5"), "basic (CR)", getAsset("ci_basic.jpg"), 5, ["A", "B", "C"], "visible", "basic", getAsset("keyboard.mp3"), CR_cat_id_technology, "question_fh_5", "question_sh_5", "modal_ans_5", CR_cat_id_news, ["A", "B", "C"]],
|
||||||
["A", "B", "C"],
|
[getId("6"), "nature (CR)", getAsset("ci_nature.jpg"), 6, ["A", "B", "C"], "visible", "nature", getAsset("keyboard.mp3"), CR_cat_id_technology, "question_fh_6", "question_sh_6", "modal_ans_6", CR_cat_id_technology, ["A", "B", "C"]],
|
||||||
"visible",
|
[getId("7"), "workplace (CR)", getAsset("ci_workplace.jpg"), 7, ["A", "B", "C"], "visible", "workplace", getAsset("keyboard.mp3"), CR_cat_id_technology, "question_fh_7", "question_sh_7", "modal_ans_7", CR_cat_id_technology, ["A", "B", "C"]],
|
||||||
"news",
|
[getId("8"), "workplace (CR)", getAsset("ci_workplace.jpg"), 8, ["A", "B", "C"], "visible", "workplace", getAsset("keyboard.mp3"), CR_cat_id_technology, "question_fh_8", "question_sh_8", "modal_ans_8", CR_cat_id_technology, ["A", "B", "C"]],
|
||||||
getAsset("keyboard.mp3"),
|
[getId("99"), "test hidden (CR)", getAsset("ci_workplace.jpg"), 9, ["A", "B", "C"], "hidden", "test", getAsset("keyboard.mp3"), CR_cat_id_technology, "question_fh_9", "question_sh_9", "modal_ans_9", CR_cat_id_technology, ["A", "B", "C"]],
|
||||||
cat_id_technology,
|
|
||||||
"question_fh_1",
|
|
||||||
"question_sh_1",
|
|
||||||
"modal_ans_1",
|
|
||||||
cat_id_technology,
|
|
||||||
["A", "B", "C"],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId("2"),
|
|
||||||
"sports (CR)",
|
|
||||||
getAsset("ci_sports.jpg"),
|
|
||||||
2,
|
|
||||||
["A", "B", "C"],
|
|
||||||
"visible",
|
|
||||||
"sports",
|
|
||||||
getAsset("mouse.mp3"),
|
|
||||||
cat_id_technology,
|
|
||||||
"question_fh_2",
|
|
||||||
"question_sh_2",
|
|
||||||
"modal_ans_2",
|
|
||||||
cat_id_technology,
|
|
||||||
["A", "B", "C"],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId("3"),
|
|
||||||
"technology (CR)",
|
|
||||||
getAsset("ci_technology.jpg"),
|
|
||||||
3,
|
|
||||||
["A", "B", "C"],
|
|
||||||
"visible",
|
|
||||||
"technology",
|
|
||||||
getAsset("keyboard.mp3"),
|
|
||||||
cat_id_technology,
|
|
||||||
"question_fh_3",
|
|
||||||
"question_sh_3",
|
|
||||||
"modal_ans_3",
|
|
||||||
cat_id_technology,
|
|
||||||
["A", "B", "C"],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId("4"),
|
|
||||||
"art (CR)",
|
|
||||||
getAsset("ci_art.jpg"),
|
|
||||||
4,
|
|
||||||
["A", "B", "C"],
|
|
||||||
"visible",
|
|
||||||
"art",
|
|
||||||
getAsset("mouse.mp3"),
|
|
||||||
cat_id_technology,
|
|
||||||
"question_fh_4",
|
|
||||||
"question_sh_4",
|
|
||||||
"modal_ans_4",
|
|
||||||
cat_id_technology,
|
|
||||||
["A", "B", "C"],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId("5"),
|
|
||||||
"basic (CR)",
|
|
||||||
getAsset("ci_basic.jpg"),
|
|
||||||
5,
|
|
||||||
["A", "B", "C"],
|
|
||||||
"visible",
|
|
||||||
"basic",
|
|
||||||
getAsset("keyboard.mp3"),
|
|
||||||
cat_id_technology,
|
|
||||||
"question_fh_5",
|
|
||||||
"question_sh_5",
|
|
||||||
"modal_ans_5",
|
|
||||||
cat_id_technology,
|
|
||||||
["A", "B", "C"],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId("6"),
|
|
||||||
"nature (CR)",
|
|
||||||
getAsset("ci_nature.jpg"),
|
|
||||||
6,
|
|
||||||
["A", "B", "C"],
|
|
||||||
"visible",
|
|
||||||
"nature",
|
|
||||||
getAsset("keyboard.mp3"),
|
|
||||||
cat_id_technology,
|
|
||||||
"question_fh_6",
|
|
||||||
"question_sh_6",
|
|
||||||
"modal_ans_6",
|
|
||||||
cat_id_technology,
|
|
||||||
["A", "B", "C"],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId("7"),
|
|
||||||
"workplace (CR)",
|
|
||||||
getAsset("ci_workplace.jpg"),
|
|
||||||
7,
|
|
||||||
["A", "B", "C"],
|
|
||||||
"visible",
|
|
||||||
"workplace",
|
|
||||||
getAsset("keyboard.mp3"),
|
|
||||||
cat_id_technology,
|
|
||||||
"question_fh_7",
|
|
||||||
"question_sh_7",
|
|
||||||
"modal_ans_7",
|
|
||||||
cat_id_technology,
|
|
||||||
["A", "B", "C"],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId("8"),
|
|
||||||
"workplace (CR)",
|
|
||||||
getAsset("ci_workplace.jpg"),
|
|
||||||
8,
|
|
||||||
["A", "B", "C"],
|
|
||||||
"visible",
|
|
||||||
"workplace",
|
|
||||||
getAsset("keyboard.mp3"),
|
|
||||||
cat_id_technology,
|
|
||||||
"question_fh_8",
|
|
||||||
"question_sh_8",
|
|
||||||
"modal_ans_8",
|
|
||||||
cat_id_technology,
|
|
||||||
["A", "B", "C"],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId("99"),
|
|
||||||
"test hidden (CR)",
|
|
||||||
getAsset("ci_workplace.jpg"),
|
|
||||||
9,
|
|
||||||
["A", "B", "C"],
|
|
||||||
"hidden",
|
|
||||||
"test",
|
|
||||||
getAsset("keyboard.mp3"),
|
|
||||||
cat_id_technology,
|
|
||||||
"question_fh_9",
|
|
||||||
"question_sh_9",
|
|
||||||
"modal_ans_9",
|
|
||||||
cat_id_technology,
|
|
||||||
["A", "B", "C"],
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
dirtyTruncateTable("QuizCRQuestions");
|
dirtyTruncateTable("QuizCRQuestions");
|
||||||
|
|
||||||
@@ -167,7 +38,7 @@ module.exports = ($app) => {
|
|||||||
record.set("visible", lesson_type[5]);
|
record.set("visible", lesson_type[5]);
|
||||||
record.set("word", lesson_type[6]);
|
record.set("word", lesson_type[6]);
|
||||||
record.set("sound", lesson_type[7]);
|
record.set("sound", lesson_type[7]);
|
||||||
record.set("cat_id", lesson_type[7]);
|
// record.set("cat_id", lesson_type[7]);
|
||||||
record.set("question_fh", lesson_type[9]);
|
record.set("question_fh", lesson_type[9]);
|
||||||
record.set("question_sh", lesson_type[10]);
|
record.set("question_sh", lesson_type[10]);
|
||||||
record.set("modal_ans", lesson_type[11]);
|
record.set("modal_ans", lesson_type[11]);
|
||||||
@@ -180,8 +51,9 @@ module.exports = ($app) => {
|
|||||||
console.log(`041_QuizCRQuestions done`);
|
console.log(`041_QuizCRQuestions done`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: remove me
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,17 +1,23 @@
|
|||||||
//
|
//
|
||||||
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
|
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
|
||||||
//
|
//
|
||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
//
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
const getId = (id) => id.padStart(15, 0);
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
|
// const id_v = "1".padStart(15, 0); //id_vocabulary
|
||||||
|
// const id_c = "2".padStart(15, 0); //id_connectives
|
||||||
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
|
|
||||||
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
||||||
const SAMPLE_CUSTOMER_ARRAY = [
|
const SAMPLE_CUSTOMER_ARRAY = [
|
||||||
[
|
[
|
||||||
"000000000000001",
|
getId("1"),
|
||||||
"May",
|
"May",
|
||||||
getAsset("customer1.png"),
|
getAsset("customer1.png"),
|
||||||
"June_Wintheiser33@hotmail.com",
|
"June_Wintheiser33@hotmail.com",
|
||||||
@@ -32,7 +38,7 @@ module.exports = ($app) => {
|
|||||||
"active",
|
"active",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"000000000000002",
|
getId("2"),
|
||||||
"Marilyne",
|
"Marilyne",
|
||||||
getAsset("customer2.png"),
|
getAsset("customer2.png"),
|
||||||
"Carol_Blick@yahoo.com",
|
"Carol_Blick@yahoo.com",
|
||||||
@@ -53,7 +59,7 @@ module.exports = ($app) => {
|
|||||||
"pending",
|
"pending",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"000000000000003",
|
getId("3"),
|
||||||
"Jacklyn",
|
"Jacklyn",
|
||||||
getAsset("customer3.png"),
|
getAsset("customer3.png"),
|
||||||
"Tamara_Lynch11@yahoo.com",
|
"Tamara_Lynch11@yahoo.com",
|
||||||
@@ -74,7 +80,7 @@ module.exports = ($app) => {
|
|||||||
"blocked",
|
"blocked",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"000000000000004",
|
getId("4"),
|
||||||
"Alana",
|
"Alana",
|
||||||
getAsset("customer4.png"),
|
getAsset("customer4.png"),
|
||||||
"Ahmed_Willms@hotmail.com",
|
"Ahmed_Willms@hotmail.com",
|
||||||
@@ -95,7 +101,7 @@ module.exports = ($app) => {
|
|||||||
"active",
|
"active",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"000000000000005",
|
getId("5"),
|
||||||
"Rocky",
|
"Rocky",
|
||||||
getAsset("customer5.png"),
|
getAsset("customer5.png"),
|
||||||
"Angela_Kuhic@gmail.com",
|
"Angela_Kuhic@gmail.com",
|
||||||
@@ -145,8 +151,9 @@ module.exports = ($app) => {
|
|||||||
console.log(`050_Customers done`);
|
console.log(`050_Customers done`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: remove me
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,13 +1,17 @@
|
|||||||
//
|
//
|
||||||
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
|
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
|
||||||
//
|
//
|
||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
//
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
const getId = (id) => id.padStart(15, 0);
|
// const id_v = "1".padStart(15, 0); //id_vocabulary
|
||||||
|
// const id_c = "2".padStart(15, 0); //id_connectives
|
||||||
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
||||||
const TEACHER_ARRAY = [
|
const TEACHER_ARRAY = [
|
||||||
[
|
[
|
||||||
@@ -145,8 +149,9 @@ module.exports = ($app) => {
|
|||||||
console.log(`051_Teacher done`);
|
console.log(`051_Teacher done`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: remove me
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
@@ -1,12 +1,18 @@
|
|||||||
//
|
//
|
||||||
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
|
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
|
||||||
//
|
//
|
||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
//
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
const getId = (id) => id.padStart(15, 0);
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
|
// const id_v = "1".padStart(15, 0); //id_vocabulary
|
||||||
|
// const id_c = "2".padStart(15, 0); //id_connectives
|
||||||
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
|
|
||||||
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
||||||
const STUDENT_ARRAY = [
|
const STUDENT_ARRAY = [
|
||||||
@@ -145,8 +151,9 @@ module.exports = ($app) => {
|
|||||||
console.log(`052_Students done`);
|
console.log(`052_Students done`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: remove me
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,53 +1,25 @@
|
|||||||
//
|
//
|
||||||
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
|
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
|
||||||
//
|
//
|
||||||
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
const utils = require("/pb_hooks/seed/utils.js");
|
||||||
|
//
|
||||||
module.exports = ($app) => {
|
module.exports = ($app) => {
|
||||||
const ASSETS_DIR = "/pb_hooks/assets";
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
||||||
const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
||||||
const id_v = "1".padStart(15, 0); //id_vocabulary
|
|
||||||
const id_c = "2".padStart(15, 0); //id_connectives
|
// const ASSETS_DIR = "/pb_hooks/assets";
|
||||||
const getId = (id) => id.padStart(15, 0);
|
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
|
||||||
|
// const id_v = "1".padStart(15, 0); //id_vocabulary
|
||||||
|
// const id_c = "2".padStart(15, 0); //id_connectives
|
||||||
|
// const getId = (id) => id.padStart(15, 0);
|
||||||
|
|
||||||
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
||||||
const SAMPLE_CUSTOMER_ARRAY = [
|
const SAMPLE_CUSTOMER_ARRAY = [
|
||||||
[
|
[getId("1"), "EV-004", false, "new_job", { id: getId("1"), name: "Jie Yan", avatar: "/assets/avatar-8.png" }, { title: "Remote React / React Native Developer" }, ""],
|
||||||
getId('1'),
|
[getId("2"), "EV-003", true, "new_job", { id: getId("2"), name: "Fran Perez", avatar: "/assets/avatar-5.png" }, { title: "Senior Golang Backend Engineer" }, ""],
|
||||||
'EV-004',
|
[getId("3"), "EV-002", true, "new_feature", "", "", "Logistics management is now available"],
|
||||||
false,
|
[getId("4"), "EV-001", true, "new_company", { id: getId("3"), name: "Jie Yan", avatar: "/assets/avatar-8.png" }, { name: "Stripe" }, ""],
|
||||||
'new_job',
|
|
||||||
{ "id":getId("1"),"name": 'Jie Yan', "avatar": '/assets/avatar-8.png' },
|
|
||||||
{ "title": 'Remote React / React Native Developer' },
|
|
||||||
""
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId('2'),
|
|
||||||
'EV-003',
|
|
||||||
true,
|
|
||||||
'new_job',
|
|
||||||
{ "id": getId("2"),"name": 'Fran Perez', "avatar": '/assets/avatar-5.png' },
|
|
||||||
{ "title": 'Senior Golang Backend Engineer' },
|
|
||||||
""
|
|
||||||
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId('3'),
|
|
||||||
'EV-002',
|
|
||||||
true,
|
|
||||||
'new_feature',
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
'Logistics management is now available'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
getId('4'),
|
|
||||||
'EV-001',
|
|
||||||
true,
|
|
||||||
'new_company',
|
|
||||||
{"id":getId("3"), "name": 'Jie Yan', "avatar": '/assets/avatar-8.png' },
|
|
||||||
{ "name": 'Stripe' },
|
|
||||||
""
|
|
||||||
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
let row_array = SAMPLE_CUSTOMER_ARRAY;
|
let row_array = SAMPLE_CUSTOMER_ARRAY;
|
||||||
@@ -73,8 +45,9 @@ module.exports = ($app) => {
|
|||||||
console.log(`060_Notifications done`);
|
console.log(`060_Notifications done`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dirtyTruncateTable = (COLLECTION_NAME) => {
|
// TODO: remove me
|
||||||
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
// const dirtyTruncateTable = (COLLECTION_NAME) => {
|
||||||
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
// console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
cmd_to_exec.output();
|
// const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
};
|
// cmd_to_exec.output();
|
||||||
|
// };
|
||||||
|
@@ -1,6 +1,27 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
ASSETS_DIR: '/pb_hooks/assets',
|
ASSETS_DIR: "/pb_hooks/assets",
|
||||||
id_v: '1'.padStart(15, 0), //id_vocabulary
|
id_v: "1".padStart(15, 0), //id_vocabulary
|
||||||
id_c: '2'.padStart(15, 0), //id_connectives
|
id_c: "2".padStart(15, 0), //id_connectives
|
||||||
cat_id_tech: '3'.padStart(15, 0), // category id of technology
|
//
|
||||||
|
cat_id_news: "1".padStart(15, 0), // category id of news
|
||||||
|
cat_id_sport: "2".padStart(15, 0), // category id of sports
|
||||||
|
cat_id_tech: "3".padStart(15, 0), // category id of technology
|
||||||
|
cat_id_art: "4".padStart(15, 0), // category id of art
|
||||||
|
cat_id_basic: "5".padStart(15, 0), // category id of basic
|
||||||
|
cat_id_nature: "6".padStart(15, 0), // category id of nature
|
||||||
|
cat_id_workplace: "7".padStart(15, 0), // category id of workplace
|
||||||
|
//
|
||||||
|
cat_id_connectives_1: "11".padStart(15, 0), // category id of workplace
|
||||||
|
//
|
||||||
|
LP_cat_id_news: "1".padStart(15, 0),
|
||||||
|
LP_cat_id_sports: "2".padStart(15, 0),
|
||||||
|
LP_cat_id_technology: "3".padStart(15, 0),
|
||||||
|
//
|
||||||
|
MF_cat_id_news: "1".padStart(15, 0),
|
||||||
|
MF_cat_id_sports: "2".padStart(15, 0),
|
||||||
|
MF_cat_id_technology: "3".padStart(15, 0),
|
||||||
|
//
|
||||||
|
CR_cat_id_news: "1".padStart(15, 0),
|
||||||
|
CR_cat_id_sports: "2".padStart(15, 0),
|
||||||
|
CR_cat_id_technology: "3".padStart(15, 0),
|
||||||
};
|
};
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,12 +1,19 @@
|
|||||||
const config = require('/pb_hooks/seed/config.js');
|
const config = require("/pb_hooks/seed/config.js");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getAsset: name => {
|
getAsset: (name) => {
|
||||||
const file_full_path = config.ASSETS_DIR + '/' + name;
|
const file_full_path = config.ASSETS_DIR + "/" + name;
|
||||||
try {
|
try {
|
||||||
return $filesystem.fileFromPath(file_full_path);
|
return $filesystem.fileFromPath(file_full_path);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('file not found: ' + file_full_path, +'please check if file exist');
|
console.log("file not found: " + file_full_path, +"please check if file exist");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getId: (id) => id.padStart(15, 0),
|
||||||
|
|
||||||
|
dirtyTruncateTable: (COLLECTION_NAME) => {
|
||||||
|
console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`);
|
||||||
|
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
|
||||||
|
cmd_to_exec.output();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@@ -1,28 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_2109205374")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": "",
|
|
||||||
"deleteRule": "",
|
|
||||||
"listRule": "",
|
|
||||||
"updateRule": "",
|
|
||||||
"viewRule": ""
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_2109205374")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": null,
|
|
||||||
"deleteRule": null,
|
|
||||||
"listRule": null,
|
|
||||||
"updateRule": null,
|
|
||||||
"viewRule": null
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,42 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update field
|
|
||||||
collection.fields.addAt(1, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text4192936109",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "address",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update field
|
|
||||||
collection.fields.addAt(1, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text4192936109",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "helloworld",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,29 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(4, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text2744374011",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "state",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("text2744374011")
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,26 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": "",
|
|
||||||
"listRule": "",
|
|
||||||
"updateRule": "",
|
|
||||||
"viewRule": ""
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": null,
|
|
||||||
"listRule": null,
|
|
||||||
"updateRule": null,
|
|
||||||
"viewRule": null
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,28 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": "",
|
|
||||||
"deleteRule": "",
|
|
||||||
"listRule": "",
|
|
||||||
"updateRule": "",
|
|
||||||
"viewRule": ""
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": null,
|
|
||||||
"deleteRule": null,
|
|
||||||
"listRule": null,
|
|
||||||
"updateRule": null,
|
|
||||||
"viewRule": null
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,29 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(7, new Field({
|
|
||||||
"hidden": false,
|
|
||||||
"id": "file376926767",
|
|
||||||
"maxSelect": 1,
|
|
||||||
"maxSize": 0,
|
|
||||||
"mimeTypes": [],
|
|
||||||
"name": "avatar",
|
|
||||||
"presentable": false,
|
|
||||||
"protected": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"thumbs": [],
|
|
||||||
"type": "file"
|
|
||||||
}))
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("file376926767")
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,29 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_3639453778")
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(5, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text2058414169",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "visible",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_3639453778")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("text2058414169")
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,29 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_3639453778")
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(8, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text2560465762",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "slug",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_3639453778")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("text2560465762")
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,28 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": "",
|
|
||||||
"deleteRule": "",
|
|
||||||
"listRule": "",
|
|
||||||
"updateRule": "",
|
|
||||||
"viewRule": ""
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": null,
|
|
||||||
"deleteRule": null,
|
|
||||||
"listRule": null,
|
|
||||||
"updateRule": null,
|
|
||||||
"viewRule": null
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,29 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_84667061")
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(5, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text2058414169",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "visible",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_84667061")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("text2058414169")
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,153 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_742947356")
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(4, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text1125157303",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "cat_name",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(5, new Field({
|
|
||||||
"hidden": false,
|
|
||||||
"id": "file2034676914",
|
|
||||||
"maxSelect": 1,
|
|
||||||
"maxSize": 0,
|
|
||||||
"mimeTypes": [],
|
|
||||||
"name": "cat_image",
|
|
||||||
"presentable": false,
|
|
||||||
"protected": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"thumbs": [],
|
|
||||||
"type": "file"
|
|
||||||
}))
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(6, new Field({
|
|
||||||
"hidden": false,
|
|
||||||
"id": "number2161764012",
|
|
||||||
"max": null,
|
|
||||||
"min": null,
|
|
||||||
"name": "pos",
|
|
||||||
"onlyInt": false,
|
|
||||||
"presentable": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "number"
|
|
||||||
}))
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(7, new Field({
|
|
||||||
"hidden": false,
|
|
||||||
"id": "json3915970527",
|
|
||||||
"maxSize": 0,
|
|
||||||
"name": "init_answer",
|
|
||||||
"presentable": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "json"
|
|
||||||
}))
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(8, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text2058414169",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "visible",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(9, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text2560465762",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "slug",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(10, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text1156222427",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "remarks",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(11, new Field({
|
|
||||||
"convertURLs": false,
|
|
||||||
"hidden": false,
|
|
||||||
"id": "editor1843675174",
|
|
||||||
"maxSize": 0,
|
|
||||||
"name": "description",
|
|
||||||
"presentable": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "editor"
|
|
||||||
}))
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_742947356")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("text1125157303")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("file2034676914")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("number2161764012")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("json3915970527")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("text2058414169")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("text2560465762")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("text1156222427")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("editor1843675174")
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,28 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": "",
|
|
||||||
"deleteRule": "",
|
|
||||||
"listRule": "",
|
|
||||||
"updateRule": "",
|
|
||||||
"viewRule": ""
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": null,
|
|
||||||
"deleteRule": null,
|
|
||||||
"listRule": null,
|
|
||||||
"updateRule": null,
|
|
||||||
"viewRule": null
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,28 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": "",
|
|
||||||
"deleteRule": "",
|
|
||||||
"listRule": "",
|
|
||||||
"updateRule": "",
|
|
||||||
"viewRule": ""
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_1305841361")
|
|
||||||
|
|
||||||
// update collection data
|
|
||||||
unmarshal({
|
|
||||||
"createRule": null,
|
|
||||||
"deleteRule": null,
|
|
||||||
"listRule": null,
|
|
||||||
"updateRule": null,
|
|
||||||
"viewRule": null
|
|
||||||
}, collection)
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,29 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_3346420851")
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(4, new Field({
|
|
||||||
"autogeneratePattern": "",
|
|
||||||
"hidden": false,
|
|
||||||
"id": "text2058414169",
|
|
||||||
"max": 0,
|
|
||||||
"min": 0,
|
|
||||||
"name": "visible",
|
|
||||||
"pattern": "",
|
|
||||||
"presentable": false,
|
|
||||||
"primaryKey": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"type": "text"
|
|
||||||
}))
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_3346420851")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("text2058414169")
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
@@ -1,48 +0,0 @@
|
|||||||
/// <reference path="../pb_data/types.d.ts" />
|
|
||||||
migrate((app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_3346420851")
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(7, new Field({
|
|
||||||
"hidden": false,
|
|
||||||
"id": "file4170105732",
|
|
||||||
"maxSelect": 1,
|
|
||||||
"maxSize": 0,
|
|
||||||
"mimeTypes": [],
|
|
||||||
"name": "sound",
|
|
||||||
"presentable": false,
|
|
||||||
"protected": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"thumbs": [],
|
|
||||||
"type": "file"
|
|
||||||
}))
|
|
||||||
|
|
||||||
// add field
|
|
||||||
collection.fields.addAt(8, new Field({
|
|
||||||
"hidden": false,
|
|
||||||
"id": "file2034676914",
|
|
||||||
"maxSelect": 1,
|
|
||||||
"maxSize": 0,
|
|
||||||
"mimeTypes": [],
|
|
||||||
"name": "cat_image",
|
|
||||||
"presentable": false,
|
|
||||||
"protected": false,
|
|
||||||
"required": false,
|
|
||||||
"system": false,
|
|
||||||
"thumbs": [],
|
|
||||||
"type": "file"
|
|
||||||
}))
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
}, (app) => {
|
|
||||||
const collection = app.findCollectionByNameOrId("pbc_3346420851")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("file4170105732")
|
|
||||||
|
|
||||||
// remove field
|
|
||||||
collection.fields.removeById("file2034676914")
|
|
||||||
|
|
||||||
return app.save(collection)
|
|
||||||
})
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user