update notifications,

This commit is contained in:
louiscklaw
2025-04-24 20:03:26 +08:00
parent 2dcc765072
commit 0785fcd144
43 changed files with 1991 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

View File

@@ -27,6 +27,14 @@ $app.rootCmd.addCommand(
require(`${__hooks}/seed/031_QuizMFQuestions.js`)($app);
//
require(`${__hooks}/seed/040_QuizCRCategories.js`)($app);
require(`${__hooks}/seed/041_QuizCRQuestions.js`)($app);
//
require(`${__hooks}/seed/050_Customers.js`)($app);
require(`${__hooks}/seed/051_Teachers.js`)($app);
require(`${__hooks}/seed/052_Students.js`)($app);
//
require(`${__hooks}/seed/060_Notifications.js`)($app);
$app.reloadCachedCollections();
$app.reloadSettings();

View File

@@ -33,7 +33,7 @@ module.exports = ($app) => {
$app.save(record);
}
console.log(`030_QuizCRCategories done`);
console.log(`040_QuizCRCategories done`);
};
const dirtyTruncateTable = (COLLECTION_NAME) => {

View File

@@ -0,0 +1,187 @@
module.exports = ($app) => {
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
const cat_id_technology = "3".padStart(15, 0);
const getId = (id) => id.padStart(15, 0);
let row_array = [
[
getId("1"),
"news (CR)",
getAsset("ci_news.jpg"),
1,
{},
"visible",
"news",
getAsset("keyboard.mp3"),
cat_id_technology,
"question_fh_1",
"question_sh_1",
"modal_ans_1",
cat_id_technology,
{},
],
[
getId("2"),
"sports (CR)",
getAsset("ci_sports.jpg"),
2,
{},
"visible",
"sports",
getAsset("mouse.mp3"),
cat_id_technology,
"question_fh_2",
"question_sh_2",
"modal_ans_2",
cat_id_technology,
{},
],
[
getId("3"),
"technology (CR)",
getAsset("ci_technology.jpg"),
3,
{},
"visible",
"technology",
getAsset("keyboard.mp3"),
cat_id_technology,
"question_fh_3",
"question_sh_3",
"modal_ans_3",
cat_id_technology,
{},
],
[
getId("4"),
"art (CR)",
getAsset("ci_art.jpg"),
4,
{},
"visible",
"art",
getAsset("mouse.mp3"),
cat_id_technology,
"question_fh_4",
"question_sh_4",
"modal_ans_4",
cat_id_technology,
{},
],
[
getId("5"),
"basic (CR)",
getAsset("ci_basic.jpg"),
5,
{},
"visible",
"basic",
getAsset("keyboard.mp3"),
cat_id_technology,
"question_fh_5",
"question_sh_5",
"modal_ans_5",
cat_id_technology,
{},
],
[
getId("6"),
"nature (CR)",
getAsset("ci_nature.jpg"),
6,
{},
"visible",
"nature",
getAsset("keyboard.mp3"),
cat_id_technology,
"question_fh_6",
"question_sh_6",
"modal_ans_6",
cat_id_technology,
{},
],
[
getId("7"),
"workplace (CR)",
getAsset("ci_workplace.jpg"),
7,
{},
"visible",
"workplace",
getAsset("keyboard.mp3"),
cat_id_technology,
"question_fh_7",
"question_sh_7",
"modal_ans_7",
cat_id_technology,
{},
],
[
getId("8"),
"workplace (CR)",
getAsset("ci_workplace.jpg"),
8,
{},
"visible",
"workplace",
getAsset("keyboard.mp3"),
cat_id_technology,
"question_fh_8",
"question_sh_8",
"modal_ans_8",
cat_id_technology,
{},
],
[
getId("99"),
"test hidden (CR)",
getAsset("ci_workplace.jpg"),
9,
{},
"hidden",
"test",
getAsset("keyboard.mp3"),
cat_id_technology,
"question_fh_9",
"question_sh_9",
"modal_ans_9",
cat_id_technology,
{},
],
];
dirtyTruncateTable("QuizCRQuestions");
let lt_collection = $app.findCollectionByNameOrId("QuizCRQuestions");
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("cat_name", lesson_type[1]);
record.set("cat_image", lesson_type[2]);
record.set("pos", lesson_type[3]);
record.set("init_answer", lesson_type[4]);
record.set("visible", lesson_type[5]);
record.set("word", lesson_type[6]);
record.set("sound", lesson_type[7]);
record.set("cat_id", lesson_type[7]);
record.set("question_fh", lesson_type[9]);
record.set("question_sh", lesson_type[10]);
record.set("modal_ans", lesson_type[11]);
record.set("caf_id", lesson_type[12]);
record.set("options", lesson_type[13]);
$app.save(record);
}
console.log(`041_QuizCRQuestions 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();
};

View File

@@ -0,0 +1,152 @@
//
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
//
module.exports = ($app) => {
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
const getId = (id) => id.padStart(15, 0);
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
const SAMPLE_CUSTOMER_ARRAY = [
[
"000000000000001",
"May",
getAsset("customer1.png"),
"June_Wintheiser33@hotmail.com",
"281-378-5900 x822",
"Green, Rempel and Hoeger",
{
country: "UK",
state: "Arizona",
city: "Winfieldburgh",
zipCode: "92017-8004",
line1: "1838 Willa Freeway",
line2: "Suite 307",
},
98,
"Asia/Urumqi",
"fr",
"USD",
"active",
],
[
"000000000000002",
"Marilyne",
getAsset("customer2.png"),
"Carol_Blick@yahoo.com",
"(893) 919-2445 x193",
"White - Hessel",
{
country: "US",
state: "Nevada",
city: "Casa Grande",
zipCode: "83831-3843",
line1: "6984 Alberto Radial",
line2: "Suite 154",
},
49,
"Africa/Tunis",
"es",
"EUR",
"pending",
],
[
"000000000000003",
"Jacklyn",
getAsset("customer3.png"),
"Tamara_Lynch11@yahoo.com",
"597-593-0144 x168",
"Rolfson LLC",
{
country: "CA",
state: "Georgia",
city: "New Brodyfort",
zipCode: "18887-7075",
line1: "493 Pfannerstill Meadow",
line2: "Apt. 358",
},
44,
"Asia/Manila",
"en",
"GBP",
"blocked",
],
[
"000000000000004",
"Alana",
getAsset("customer4.png"),
"Ahmed_Willms@hotmail.com",
"401.212.0386 x31125",
"Friesen, Langworth and Thompson",
{
country: "UK",
state: "North Carolina",
city: "Fort Jerrell",
zipCode: "14211",
line1: "1763 West Street",
line2: "Suite 699",
},
34,
"America/Boa_Vista",
"es",
"USD",
"active",
],
[
"000000000000005",
"Rocky",
getAsset("customer5.png"),
"Angela_Kuhic@gmail.com",
"653.964.0412",
"Hayes - Morar",
{
country: "US",
state: "New York",
city: "Kayton",
zipCode: "82048-0645",
line1: "636 Angel Junction",
line2: "Apt. 361",
},
70,
"America/Grand_Turk",
"fr",
"EUR",
"pending",
],
];
let row_array = SAMPLE_CUSTOMER_ARRAY;
dirtyTruncateTable("Customers");
let lt_collection = $app.findCollectionByNameOrId("Customers");
for (let i = 0; i < row_array.length; i++) {
let customer = row_array[i];
let record = new Record(lt_collection);
record.set("id", customer[0]);
record.set("name", customer[1]);
record.set("avatar_file", customer[2]);
record.set("email", customer[3]);
record.set("phone", customer[4]);
record.set("company", customer[5]);
record.set("billingAddress", customer[6]);
record.set("taxId", customer[7]);
record.set("timezone", customer[8]);
record.set("language", customer[9]);
record.set("currency", customer[10]);
record.set("status", customer[11]);
$app.save(record);
}
console.log(`050_Customers 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();
};

View File

@@ -0,0 +1,152 @@
//
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
//
module.exports = ($app) => {
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
const getId = (id) => id.padStart(15, 0);
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
const TEACHER_ARRAY = [
[
getId("1"),
"May",
getAsset("teacher1.png"),
"June_Wintheiser33@hotmail.com",
"281-378-5900 x822",
"Green, Rempel and Hoeger",
{
country: "UK",
state: "Arizona",
city: "Winfieldburgh",
zipCode: "92017-8004",
line1: "1838 Willa Freeway",
line2: "Suite 307",
},
98,
"Asia/Urumqi",
"fr",
"USD",
"active",
],
[
getId("2"),
"Marilyne",
getAsset("teacher2.png"),
"Carol_Blick@yahoo.com",
"(893) 919-2445 x193",
"White - Hessel",
{
country: "US",
state: "Nevada",
city: "Casa Grande",
zipCode: "83831-3843",
line1: "6984 Alberto Radial",
line2: "Suite 154",
},
49,
"Africa/Tunis",
"es",
"EUR",
"pending",
],
[
getId("3"),
"Jacklyn",
getAsset("teacher3.png"),
"Tamara_Lynch11@yahoo.com",
"597-593-0144 x168",
"Rolfson LLC",
{
country: "CA",
state: "Georgia",
city: "New Brodyfort",
zipCode: "18887-7075",
line1: "493 Pfannerstill Meadow",
line2: "Apt. 358",
},
44,
"Asia/Manila",
"en",
"GBP",
"blocked",
],
[
getId("4"),
"Alana",
getAsset("teacher4.png"),
"Ahmed_Willms@hotmail.com",
"401.212.0386 x31125",
"Friesen, Langworth and Thompson",
{
country: "UK",
state: "North Carolina",
city: "Fort Jerrell",
zipCode: "14211",
line1: "1763 West Street",
line2: "Suite 699",
},
34,
"America/Boa_Vista",
"es",
"USD",
"active",
],
[
getId("5"),
"Rocky",
getAsset("teacher5.png"),
"Angela_Kuhic@gmail.com",
"653.964.0412",
"Hayes - Morar",
{
country: "US",
state: "New York",
city: "Kayton",
zipCode: "82048-0645",
line1: "636 Angel Junction",
line2: "Apt. 361",
},
70,
"America/Grand_Turk",
"fr",
"EUR",
"pending",
],
];
let row_array = TEACHER_ARRAY;
dirtyTruncateTable("Teachers");
let lt_collection = $app.findCollectionByNameOrId("Teachers");
for (let i = 0; i < row_array.length; i++) {
let teacher = row_array[i];
let record = new Record(lt_collection);
record.set("id", teacher[0]);
record.set("name", teacher[1]);
record.set("avatar_file", teacher[2]);
record.set("email", teacher[3]);
record.set("phone", teacher[4]);
record.set("company", teacher[5]);
record.set("billingAddress", teacher[6]);
record.set("taxId", teacher[7]);
record.set("timezone", teacher[8]);
record.set("language", teacher[9]);
record.set("currency", teacher[10]);
record.set("status", teacher[11]);
$app.save(record);
}
console.log(`051_Teacher 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();
};

View File

@@ -0,0 +1,152 @@
//
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
//
module.exports = ($app) => {
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
const getId = (id) => id.padStart(15, 0);
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
const STUDENT_ARRAY = [
[
getId("1"),
"May",
getAsset("student1.png"),
"June_Wintheiser33@hotmail.com",
"281-378-5900 x822",
"Green, Rempel and Hoeger",
{
country: "UK",
state: "Arizona",
city: "Winfieldburgh",
zipCode: "92017-8004",
line1: "1838 Willa Freeway",
line2: "Suite 307",
},
98,
"Asia/Urumqi",
"fr",
"USD",
"active",
],
[
getId("2"),
"Marilyne",
getAsset("student2.png"),
"Carol_Blick@yahoo.com",
"(893) 919-2445 x193",
"White - Hessel",
{
country: "US",
state: "Nevada",
city: "Casa Grande",
zipCode: "83831-3843",
line1: "6984 Alberto Radial",
line2: "Suite 154",
},
49,
"Africa/Tunis",
"es",
"EUR",
"pending",
],
[
getId("3"),
"Jacklyn",
getAsset("student3.png"),
"Tamara_Lynch11@yahoo.com",
"597-593-0144 x168",
"Rolfson LLC",
{
country: "CA",
state: "Georgia",
city: "New Brodyfort",
zipCode: "18887-7075",
line1: "493 Pfannerstill Meadow",
line2: "Apt. 358",
},
44,
"Asia/Manila",
"en",
"GBP",
"blocked",
],
[
getId("4"),
"Alana",
getAsset("student4.png"),
"Ahmed_Willms@hotmail.com",
"401.212.0386 x31125",
"Friesen, Langworth and Thompson",
{
country: "UK",
state: "North Carolina",
city: "Fort Jerrell",
zipCode: "14211",
line1: "1763 West Street",
line2: "Suite 699",
},
34,
"America/Boa_Vista",
"es",
"USD",
"active",
],
[
getId("5"),
"Rocky",
getAsset("student5.png"),
"Angela_Kuhic@gmail.com",
"653.964.0412",
"Hayes - Morar",
{
country: "US",
state: "New York",
city: "Kayton",
zipCode: "82048-0645",
line1: "636 Angel Junction",
line2: "Apt. 361",
},
70,
"America/Grand_Turk",
"fr",
"EUR",
"pending",
],
];
let row_array = STUDENT_ARRAY;
dirtyTruncateTable("Students");
let lt_collection = $app.findCollectionByNameOrId("Students");
for (let i = 0; i < row_array.length; i++) {
let student = row_array[i];
let record = new Record(lt_collection);
record.set("id", student[0]);
record.set("name", student[1]);
record.set("avatar_file", student[2]);
record.set("email", student[3]);
record.set("phone", student[4]);
record.set("company", student[5]);
record.set("billingAddress", student[6]);
record.set("taxId", student[7]);
record.set("timezone", student[8]);
record.set("language", student[9]);
record.set("currency", student[10]);
record.set("status", student[11]);
$app.save(record);
}
console.log(`052_Students 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();
};

View File

@@ -0,0 +1,80 @@
//
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
//
module.exports = ($app) => {
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
const getId = (id) => id.padStart(15, 0);
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
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('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;
dirtyTruncateTable("Notifications");
let lt_collection = $app.findCollectionByNameOrId("Notifications");
for (let i = 0; i < row_array.length; i++) {
let customer = row_array[i];
let record = new Record(lt_collection);
record.set("id", customer[0]);
record.set("NOTI_ID", customer[1]);
record.set("read", customer[2]);
record.set("type", customer[3]);
record.set("author", customer[4]);
record.set("job", customer[5]);
record.set("description", customer[6]);
$app.save(record);
}
console.log(`060_Notifications 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();
};

View File

@@ -0,0 +1,12 @@
# task
i want you to draft `041_QuizCRQuestions.js`
## steps
1. read file `021_QuizLPQuestions.js`
1. read file `031_QuizMFQuestions.js`
1. read file `041_QuizCRQuestions.js`
1. update the constants, variables and functions name in `041_QuizCRQuestions.js`
thanks