Skip to content

Commit 09a6ac1

Browse files
authored
Close #499 add gallery template (#514)
* Setup gallery template model (data layer) * Add gallery template UI * Add usage count & analytic * Bump version to 2.19.0+478
1 parent 34bff38 commit 09a6ac1

File tree

132 files changed

+2879
-430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+2879
-430
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"dart.lineLength": 120,
3+
"dart.mcpServer": true,
34
"editor.formatOnSave": true,
45
"editor.rulers": [120],
56
"editor.tabSize": 2,

assets/firestore_storage_map.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,25 @@
3232
"/backgrounds/textured_green_and_black_liquefy_abstract_background.txt": "/backgrounds/textured_green_and_black_liquefy_abstract_background-fc278b172cbaa729054e1f5fc4ad8938.txt",
3333
"/backgrounds/two_cloudy_tags_on_color_background.jpg": "/backgrounds/two_cloudy_tags_on_color_background-6c2223f69c2f6b96b39196ca7aa495d9.jpg",
3434
"/backgrounds/two_cloudy_tags_on_color_background.txt": "/backgrounds/two_cloudy_tags_on_color_background-4b1ba020975d7301b7274a06d8c481c9.txt",
35+
"/icons/hand_drawn/hand_drawn_angel_56x56.png": "/icons/hand_drawn/hand_drawn_angel_56x56-851b364e1c339adc97f0c5fca96ec722.png",
36+
"/icons/hand_drawn/hand_drawn_calendar_check_56x56.png": "/icons/hand_drawn/hand_drawn_calendar_check_56x56-9444460e180143c0c49eaae8d47160e4.png",
37+
"/icons/hand_drawn/hand_drawn_checklist_56x56.png": "/icons/hand_drawn/hand_drawn_checklist_56x56-168f8d244f4b802bf3d797cf0f44444b.png",
38+
"/icons/hand_drawn/hand_drawn_compass_56x56.png": "/icons/hand_drawn/hand_drawn_compass_56x56-58832bd33874777276cf12f94278ad89.png",
39+
"/icons/hand_drawn/hand_drawn_data_report_56x56.png": "/icons/hand_drawn/hand_drawn_data_report_56x56-d14c2bbe7beca0747e27b6b5ccdcbdc0.png",
40+
"/icons/hand_drawn/hand_drawn_diary_56x56.png": "/icons/hand_drawn/hand_drawn_diary_56x56-5f6497b40276638cbc5908c67685e836.png",
41+
"/icons/hand_drawn/hand_drawn_feedback_56x56.png": "/icons/hand_drawn/hand_drawn_feedback_56x56-41a5797f55c0fbbfaf3f03012bb72215.png",
42+
"/icons/hand_drawn/hand_drawn_give_love_56x56.png": "/icons/hand_drawn/hand_drawn_give_love_56x56-a03ad23d201ba5cdf7cccc2b05aa5b01.png",
43+
"/icons/hand_drawn/hand_drawn_goal_56x56.png": "/icons/hand_drawn/hand_drawn_goal_56x56-9472432825ae3793ef5212d83f29aaa8.png",
44+
"/icons/hand_drawn/hand_drawn_lightbulb_56x56.png": "/icons/hand_drawn/hand_drawn_lightbulb_56x56-c660ae1d624853c472581e236aba988c.png",
45+
"/icons/hand_drawn/hand_drawn_love_message_56x56.png": "/icons/hand_drawn/hand_drawn_love_message_56x56-ee06dcb3cc76d4817529e782809a7c5f.png",
46+
"/icons/hand_drawn/hand_drawn_meal_56x56.png": "/icons/hand_drawn/hand_drawn_meal_56x56-a46cb0b41a8ad0c87f90810a680d177c.png",
47+
"/icons/hand_drawn/hand_drawn_monster_56x56.png": "/icons/hand_drawn/hand_drawn_monster_56x56-86bc61cd87cb108e3819629ef4994332.png",
48+
"/icons/hand_drawn/hand_drawn_moon_56x56.png": "/icons/hand_drawn/hand_drawn_moon_56x56-780dbbd36734aa90dcebe56a0d644e31.png",
49+
"/icons/hand_drawn/hand_drawn_notepad_56x56.png": "/icons/hand_drawn/hand_drawn_notepad_56x56-5cef75cb69fce3c587bd2e0fb0de77a7.png",
50+
"/icons/hand_drawn/hand_drawn_photographer_56x56.png": "/icons/hand_drawn/hand_drawn_photographer_56x56-e2546b01ea1a249a8a43dbb0d34c12a3.png",
51+
"/icons/hand_drawn/hand_drawn_sun_56x56.png": "/icons/hand_drawn/hand_drawn_sun_56x56-71e61d2e176f06501044ab071324b0ad.png",
52+
"/icons/hand_drawn/hand_drawn_trophy_56x56.png": "/icons/hand_drawn/hand_drawn_trophy_56x56-142e5ddd71afdf0e306249e8b484de54.png",
53+
"/icons/hand_drawn/hand_drawn_workout_56x56.png": "/icons/hand_drawn/hand_drawn_workout_56x56-452b85fbdc3b7ee983654c0d525bc89e.png",
3554
"/relax_sounds/activity/typing.svg": "/relax_sounds/activity/typing-46d73a75bb444f79e13b05c1e574298c.svg",
3655
"/relax_sounds/activity/typing.txt": "/relax_sounds/activity/typing-4cbea22961ac40354091773530de0263.txt",
3756
"/relax_sounds/activity/typing.wav": "/relax_sounds/activity/typing-5b256259119706d60983f49b07e17279.wav",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
# Creates template documents in Firestore from YAML files in /templates directory.
3+
# This pre-populates the templates collection so device usage subcollections can be created.
4+
# Run this once after adding new gallery templates or before deploying analytics.
5+
6+
export GOOGLE_APPLICATION_CREDENTIALS="firestore_service_account.json"
7+
8+
cd bin/firebase_admin && node create_gallery_template_documents.js

bin/firebase_admin/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2+
firestore_service_account.json
23
service_account.json
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import admin from "firebase-admin";
2+
import { applicationDefault } from "firebase-admin/app";
3+
import fs from "fs/promises";
4+
import path from "path";
5+
import yaml from "js-yaml";
6+
7+
const templatesDir = path.join("../../templates");
8+
9+
await admin.initializeApp({
10+
credential: applicationDefault(),
11+
storageBucket: "tc-write-story.appspot.com",
12+
});
13+
14+
const db = admin.firestore();
15+
16+
async function createTemplateDocuments() {
17+
try {
18+
const files = await fs.readdir(templatesDir);
19+
const yamlFiles = files.filter((file) => file.endsWith(".yaml"));
20+
21+
for (const file of yamlFiles) {
22+
const filePath = path.join(templatesDir, file);
23+
const fileContent = await fs.readFile(filePath, "utf-8");
24+
const doc = yaml.load(fileContent);
25+
26+
if (doc && doc.templates) {
27+
for (const template of doc.templates) {
28+
if (template.id) {
29+
const templateId = template.id;
30+
const docRef = db.collection("templates").doc(templateId);
31+
32+
console.log(`Setting document for template ${templateId}...`);
33+
await docRef.set(
34+
{
35+
updated_at: admin.firestore.FieldValue.serverTimestamp(),
36+
name: template.name,
37+
purpose: template.purpose,
38+
},
39+
{ merge: true }
40+
);
41+
42+
docRef
43+
.collection("devices")
44+
.doc("placeholder")
45+
.set({ initialized: true });
46+
47+
console.log(`Document for template ${templateId} set.`);
48+
}
49+
}
50+
}
51+
}
52+
console.log("Finished processing all templates.");
53+
} catch (error) {
54+
console.error("Error processing templates:", error);
55+
}
56+
}
57+
58+
createTemplateDocuments();

bin/firebase_admin/package-lock.json

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/firebase_admin/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"license": "ISC",
1111
"description": "Manage Firestore",
1212
"dependencies": {
13-
"firebase-admin": "^13.2.0"
13+
"firebase-admin": "^13.2.0",
14+
"js-yaml": "^4.1.0"
1415
}
1516
}

bin/firebase_admin/upload_cache.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,24 @@
106106
"../../firestore_storages/relax_sounds/water/ocean_waves.wav": "e3314b906cfa52065417f9c51c9b2f59",
107107
"../../firestore_storages/relax_sounds/water/river_stream.svg": "c138f14d67e6badf526d96d6bb0ca1d0",
108108
"../../firestore_storages/relax_sounds/water/river_stream.txt": "230636fa87deb1c789ce49711b7671c4",
109-
"../../firestore_storages/relax_sounds/water/river_stream.wav": "fd60b586ac2bc25d511a2c41ef7c6faa"
109+
"../../firestore_storages/relax_sounds/water/river_stream.wav": "fd60b586ac2bc25d511a2c41ef7c6faa",
110+
"../../firestore_storages/icons/hand_drawn/hand_drawn_notepad_56x56.png": "5cef75cb69fce3c587bd2e0fb0de77a7",
111+
"../../firestore_storages/icons/hand_drawn/hand_drawn_sun_56x56.png": "71e61d2e176f06501044ab071324b0ad",
112+
"../../firestore_storages/icons/hand_drawn/hand_drawn_angel_56x56.png": "851b364e1c339adc97f0c5fca96ec722",
113+
"../../firestore_storages/icons/hand_drawn/hand_drawn_calendar_check_56x56.png": "9444460e180143c0c49eaae8d47160e4",
114+
"../../firestore_storages/icons/hand_drawn/hand_drawn_checklist_56x56.png": "168f8d244f4b802bf3d797cf0f44444b",
115+
"../../firestore_storages/icons/hand_drawn/hand_drawn_compass_56x56.png": "58832bd33874777276cf12f94278ad89",
116+
"../../firestore_storages/icons/hand_drawn/hand_drawn_data_report_56x56.png": "d14c2bbe7beca0747e27b6b5ccdcbdc0",
117+
"../../firestore_storages/icons/hand_drawn/hand_drawn_feedback_56x56.png": "41a5797f55c0fbbfaf3f03012bb72215",
118+
"../../firestore_storages/icons/hand_drawn/hand_drawn_give_love_56x56.png": "a03ad23d201ba5cdf7cccc2b05aa5b01",
119+
"../../firestore_storages/icons/hand_drawn/hand_drawn_goal_56x56.png": "9472432825ae3793ef5212d83f29aaa8",
120+
"../../firestore_storages/icons/hand_drawn/hand_drawn_lightbulb_56x56.png": "c660ae1d624853c472581e236aba988c",
121+
"../../firestore_storages/icons/hand_drawn/hand_drawn_love_message_56x56.png": "ee06dcb3cc76d4817529e782809a7c5f",
122+
"../../firestore_storages/icons/hand_drawn/hand_drawn_meal_56x56.png": "a46cb0b41a8ad0c87f90810a680d177c",
123+
"../../firestore_storages/icons/hand_drawn/hand_drawn_monster_56x56.png": "86bc61cd87cb108e3819629ef4994332",
124+
"../../firestore_storages/icons/hand_drawn/hand_drawn_moon_56x56.png": "780dbbd36734aa90dcebe56a0d644e31",
125+
"../../firestore_storages/icons/hand_drawn/hand_drawn_photographer_56x56.png": "e2546b01ea1a249a8a43dbb0d34c12a3",
126+
"../../firestore_storages/icons/hand_drawn/hand_drawn_workout_56x56.png": "452b85fbdc3b7ee983654c0d525bc89e",
127+
"../../firestore_storages/icons/hand_drawn/hand_drawn_trophy_56x56.png": "142e5ddd71afdf0e306249e8b484de54",
128+
"../../firestore_storages/icons/hand_drawn/hand_drawn_diary_56x56.png": "5f6497b40276638cbc5908c67685e836"
110129
}

0 commit comments

Comments
 (0)