docs: skærmbillederne er engelske, og der er to mennesker i dem
Landingssiden og dokumentationen læses på engelsk, og billederne var danske hele vejen — både grænsefladen og indholdet. Kontoen bliver nu oprettet med engelsk sprog frem for at oversætte noget her: det er sådan appen selv gør det, og det er også dét, der får en glemt oversættelse til at stå i et billede i stedet for at vente på en bruger. Demodataene er skrevet om til engelsk arbejde og husholdning. Og der er en person mere: en invitation, en konto, tre opgaver hun sidder på og en kommentar. Halvdelen af det, appen er til for, findes først, når der er to i den — en ansvarlig på en opgave, et navn i historikken, og "Venter på andre" som andet end en tom side. Tre billeder viste ikke det, teksten sagde. `detail` var en tom formular, så opgaven har fået beskrivelse, undertasks, en fil, en påmindelse og en samtale. `themes` viste profilfeltet over temaerne, så den ruller nu ned til dem. `delegated` var en tom tilstand. Noterne er kommet til — listen med en note åben, og den samme note som kilde. Fjorten billeder i alt. WebP'en skrives af den browser, der i forvejen står åben, frem for af cwebp: et program mere at installere hører ikke til i et script, hvis hele pointe er, at der ikke er noget at installere. PNG'erne ligger nu kun i docs/ og WebP'en kun i site/, hvilket er præcis dét, de to steder læser — før lagde et kørsel tolv usporede PNG'er i site/, som ingen brugte. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 239 KiB |
|
Before Width: | Height: | Size: 181 KiB After Width: | Height: | Size: 276 KiB |
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 306 KiB |
|
Before Width: | Height: | Size: 243 KiB After Width: | Height: | Size: 241 KiB |
|
After Width: | Height: | Size: 328 KiB |
|
After Width: | Height: | Size: 308 KiB |
|
Before Width: | Height: | Size: 176 KiB After Width: | Height: | Size: 215 KiB |
|
Before Width: | Height: | Size: 230 KiB After Width: | Height: | Size: 240 KiB |
|
Before Width: | Height: | Size: 199 KiB After Width: | Height: | Size: 232 KiB |
|
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 222 KiB |
|
Before Width: | Height: | Size: 153 KiB After Width: | Height: | Size: 221 KiB |
|
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 209 KiB |
|
Before Width: | Height: | Size: 167 KiB After Width: | Height: | Size: 180 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
@@ -9,17 +9,22 @@
|
|||||||
* It replaces the hand-driven half of `go run ./tools/shots`, which needs a
|
* It replaces the hand-driven half of `go run ./tools/shots`, which needs a
|
||||||
* running instance and a session cookie pasted in by hand — and which therefore
|
* running instance and a session cookie pasted in by hand — and which therefore
|
||||||
* ran rarely enough that the images fell many rounds behind the app they show.
|
* ran rarely enough that the images fell many rounds behind the app they show.
|
||||||
* This one starts the real binary, creates its own account, fills it with the
|
* This one starts the real binary, creates its own two accounts, fills them with
|
||||||
* demo data, and takes the pictures. Nothing to set up and nothing to remember.
|
* the demo data, and takes the pictures. Nothing to set up and nothing to remember.
|
||||||
*
|
*
|
||||||
* The binary, not the dev server: the screenshots should show what ships. That
|
* The binary, not the dev server: the screenshots should show what ships. That
|
||||||
* means building the frontend and copying it into cmd/verdande/webbuild first,
|
* means building the frontend and copying it into cmd/verdande/webbuild first,
|
||||||
* exactly as the smoke tests do — a capture of a stale embedded build would be a
|
* exactly as the smoke tests do — a capture of a stale embedded build would be a
|
||||||
* picture of an app nobody is running.
|
* picture of an app nobody is running.
|
||||||
|
*
|
||||||
|
* English, because the people who read the landing page and the docs read English.
|
||||||
|
* Not by translating anything here: the account is created with an English locale
|
||||||
|
* and the app is then in English by itself, which also means a string nobody
|
||||||
|
* translated shows up in a picture instead of hiding until a user finds it.
|
||||||
*/
|
*/
|
||||||
import { chromium } from '@playwright/test';
|
import { chromium } from '@playwright/test';
|
||||||
import { spawn, execSync } from 'node:child_process';
|
import { spawn, execSync } from 'node:child_process';
|
||||||
import { mkdirSync, rmSync, writeFileSync, copyFileSync } from 'node:fs';
|
import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import { dirname, join } from 'node:path';
|
import { dirname, join } from 'node:path';
|
||||||
|
|
||||||
@@ -31,13 +36,21 @@ const dataDir = join(web, '.screenshot-data');
|
|||||||
const PORT = 8098;
|
const PORT = 8098;
|
||||||
const baseURL = `http://127.0.0.1:${PORT}`;
|
const baseURL = `http://127.0.0.1:${PORT}`;
|
||||||
const USER = { name: 'Kristian', email: '[email protected]', password: 'et langt kodeord' };
|
const USER = { name: 'Kristian', email: '[email protected]', password: 'et langt kodeord' };
|
||||||
|
// Somebody to share with. Half of what the app is for only exists once there are
|
||||||
|
// two people in it: an assignee on a task, a name in the history, a face in the
|
||||||
|
// members list, and "Waiting on others" as something other than an empty page.
|
||||||
|
const COLLEAGUE = { name: 'Mette', email: '[email protected]', password: 'et andet langt kodeord' };
|
||||||
|
|
||||||
// 1400×900 is what the landing page's <img> declares. A capture at another size
|
// 1400×900 is what the landing page's <img> declares. A capture at another size
|
||||||
// would be resampled by the browser and look soft next to the text beside it.
|
// would be resampled by the browser and look soft next to the text beside it.
|
||||||
const WIDTH = 1400;
|
const WIDTH = 1400;
|
||||||
const HEIGHT = 900;
|
const HEIGHT = 900;
|
||||||
|
|
||||||
const OUT = [join(repo, 'site', 'screenshots'), join(repo, 'docs', 'screenshots')];
|
// The docs and the README read the PNGs; the landing page reads the WebP, which is
|
||||||
|
// a fifth of the weight over the wire. Both are written from the same capture, so
|
||||||
|
// the two sets can never drift apart.
|
||||||
|
const PNG_DIR = join(repo, 'docs', 'screenshots');
|
||||||
|
const WEBP_DIR = join(repo, 'site', 'screenshots');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The pictures, and why each one is here.
|
* The pictures, and why each one is here.
|
||||||
@@ -54,31 +67,64 @@ const SHOTS = [
|
|||||||
// The same project as a list, which is where sections read as bands rather than
|
// The same project as a list, which is where sections read as bands rather than
|
||||||
// as columns — and the shape most people actually work in.
|
// as columns — and the shape most people actually work in.
|
||||||
{ name: 'sections', path: (ids) => `/projekt/${ids.work}`, theme: 'dark', prepare: showList },
|
{ name: 'sections', path: (ids) => `/projekt/${ids.work}`, theme: 'dark', prepare: showList },
|
||||||
{ name: 'detail', path: '/', theme: 'dark', prepare: openFirstTask },
|
// By address rather than by clicking the first row: the drawer has to be over
|
||||||
|
// the one task that was given a description, sub-tasks, a file, a reminder and a
|
||||||
|
// conversation, or the picture shows an empty form and proves nothing.
|
||||||
|
{ name: 'detail', path: (ids) => `/opgave/${ids.detail}`, theme: 'dark' },
|
||||||
|
{ name: 'notes', path: '/noter', theme: 'dark', prepare: openMeetingNote },
|
||||||
|
{ name: 'notes-source', path: '/noter', theme: 'dark', prepare: showNoteSource },
|
||||||
|
{ name: 'delegated', path: '/uddelegeret', theme: 'dark' },
|
||||||
{ name: 'settings', path: '/indstillinger/integrationer', theme: 'dark' },
|
{ name: 'settings', path: '/indstillinger/integrationer', theme: 'dark' },
|
||||||
{ name: 'themes', path: '/indstillinger', theme: 'dark' },
|
// Scrolled, because the themes are the second panel on the page and a picture
|
||||||
|
// captioned "five themes" that shows the profile form is a caption about
|
||||||
|
// nothing.
|
||||||
|
{ name: 'themes', path: '/indstillinger', theme: 'dark', prepare: showThemes },
|
||||||
{ name: 'admin', path: '/indstillinger/brugere', theme: 'dark' },
|
{ name: 'admin', path: '/indstillinger/brugere', theme: 'dark' },
|
||||||
{ name: 'history', path: '/indstillinger/historik', theme: 'dark' },
|
{ name: 'history', path: '/indstillinger/historik', theme: 'dark' }
|
||||||
{ name: 'delegated', path: '/uddelegeret', theme: 'dark' }
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const NOTE_TITLE = 'Launch meeting — agenda';
|
||||||
|
|
||||||
async function showList(page) {
|
async function showList(page) {
|
||||||
await page.getByRole('button', { name: 'Liste', exact: true }).click();
|
await page.getByRole('button', { name: 'List', exact: true }).click();
|
||||||
await page.waitForTimeout(600);
|
await page.waitForTimeout(600);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showMonth(page) {
|
async function showMonth(page) {
|
||||||
await page.getByRole('button', { name: 'Måned', exact: true }).click();
|
await page.getByRole('button', { name: 'Month', exact: true }).click();
|
||||||
await page.waitForTimeout(800);
|
await page.waitForTimeout(800);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function showWeek(page) {
|
async function showWeek(page) {
|
||||||
await page.getByRole('button', { name: 'Uge', exact: true }).click();
|
await page.getByRole('button', { name: 'Week', exact: true }).click();
|
||||||
await page.waitForTimeout(800);
|
await page.waitForTimeout(800);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openFirstTask(page) {
|
async function openMeetingNote(page) {
|
||||||
await page.locator('.row').first().click();
|
// By text inside the row rather than by its accessible name: a row's name is its
|
||||||
|
// title, its date, the first line of its body and the project it is filed in,
|
||||||
|
// all run together.
|
||||||
|
await page.locator('button.row', { hasText: NOTE_TITLE }).first().click();
|
||||||
|
await page.waitForTimeout(800);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function showNoteSource(page) {
|
||||||
|
await openMeetingNote(page);
|
||||||
|
await page.getByRole('button', { name: 'Show as code' }).click();
|
||||||
|
await page.waitForTimeout(600);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function showThemes(page) {
|
||||||
|
// scrollIntoView rather than Playwright's scrollIntoViewIfNeeded: the heading is
|
||||||
|
// already a few pixels inside the viewport when the page loads, so "if needed"
|
||||||
|
// decides nothing is needed and the picture is of the profile form above it.
|
||||||
|
//
|
||||||
|
// `.first()`, because the looks below the themes carry the same heading — one
|
||||||
|
// panel, two questions, and both of them called Appearance.
|
||||||
|
await page
|
||||||
|
.getByRole('heading', { name: 'Appearance' })
|
||||||
|
.first()
|
||||||
|
.evaluate((el) => el.closest('section').scrollIntoView({ block: 'start' }));
|
||||||
await page.waitForTimeout(600);
|
await page.waitForTimeout(600);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,29 +160,42 @@ let browser;
|
|||||||
try {
|
try {
|
||||||
await waitForHealth();
|
await waitForHealth();
|
||||||
|
|
||||||
browser = await chromium.launch();
|
// The browser's own language, which is not the same setting as the context's.
|
||||||
const page = await browser.newPage({
|
// `<input type="date">` is drawn by Chromium, not by the app, and it takes its
|
||||||
viewport: { width: WIDTH, height: HEIGHT },
|
// order from this one — so without it the drawer shows an American date inside
|
||||||
// The same pinning the smoke tests use, and for the same reason: the sign-up
|
// a day-month app, which is the exact thing i18n.svelte.js warns about.
|
||||||
// form sends navigator.language as the account's locale, and every due date
|
browser = await chromium.launch({ args: ['--lang=en-GB'] });
|
||||||
// is resolved in the account's zone.
|
const context = await browser.newContext(viewing());
|
||||||
locale: 'da-DK',
|
const page = await context.newPage();
|
||||||
timezoneId: 'Europe/Copenhagen',
|
|
||||||
deviceScaleFactor: 2
|
|
||||||
});
|
|
||||||
|
|
||||||
await page.goto(baseURL);
|
await page.goto(baseURL);
|
||||||
|
// The sign-up form is the one screen that is always Danish: it is drawn before
|
||||||
|
// there is an account to read a language off, and Danish is the fallback. So
|
||||||
|
// these labels are Danish on purpose, and the app is English from the moment
|
||||||
|
// the account exists — which is every screen this script photographs.
|
||||||
await page.getByLabel(/Navn/).fill(USER.name);
|
await page.getByLabel(/Navn/).fill(USER.name);
|
||||||
await page.getByLabel(/E-mail/).fill(USER.email);
|
await page.getByLabel(/E-mail/).fill(USER.email);
|
||||||
await page.getByLabel(/Adgangskode/).fill(USER.password);
|
await page.getByLabel(/Adgangskode/).fill(USER.password);
|
||||||
await page.getByRole('button', { name: 'Opret konto' }).click();
|
await page.getByRole('button', { name: 'Opret konto' }).click();
|
||||||
await page.getByRole('navigation', { name: 'Hovedmenu' }).waitFor();
|
await page.getByRole('navigation', { name: 'Main menu' }).waitFor();
|
||||||
|
|
||||||
console.log('seeding…');
|
console.log('seeding…');
|
||||||
const ids = await page.evaluate(seed);
|
const ids = await page.evaluate(seed, { colleague: COLLEAGUE.email, noteTitle: NOTE_TITLE });
|
||||||
|
|
||||||
mkdirSync(OUT[0], { recursive: true });
|
console.log('adding the second person…');
|
||||||
mkdirSync(OUT[1], { recursive: true });
|
const ids2 = await addColleague(browser, ids);
|
||||||
|
Object.assign(ids, ids2);
|
||||||
|
await page.reload();
|
||||||
|
await page.getByRole('navigation', { name: 'Main menu' }).waitFor();
|
||||||
|
|
||||||
|
mkdirSync(PNG_DIR, { recursive: true });
|
||||||
|
mkdirSync(WEBP_DIR, { recursive: true });
|
||||||
|
|
||||||
|
// A page of its own for the WebP encoding, on about:blank: the app's pages send
|
||||||
|
// a content security policy, and an encoder that borrows whichever page was last
|
||||||
|
// photographed would be one policy change away from silently producing nothing.
|
||||||
|
const encoder = await context.newPage();
|
||||||
|
await encoder.goto('about:blank');
|
||||||
|
|
||||||
for (const shot of SHOTS) {
|
for (const shot of SHOTS) {
|
||||||
const path = typeof shot.path === 'function' ? shot.path(ids) : shot.path;
|
const path = typeof shot.path === 'function' ? shot.path(ids) : shot.path;
|
||||||
@@ -151,9 +210,9 @@ try {
|
|||||||
await page.waitForTimeout(400);
|
await page.waitForTimeout(400);
|
||||||
}
|
}
|
||||||
const png = await page.screenshot();
|
const png = await page.screenshot();
|
||||||
writeFileSync(join(OUT[0], `${shot.name}.png`), png);
|
writeFileSync(join(PNG_DIR, `${shot.name}.png`), png);
|
||||||
copyFileSync(join(OUT[0], `${shot.name}.png`), join(OUT[1], `${shot.name}.png`));
|
writeFileSync(join(WEBP_DIR, `${shot.name}.webp`), await toWebP(encoder, png));
|
||||||
console.log(` ${shot.name}.png`);
|
console.log(` ${shot.name}`);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await browser?.close();
|
await browser?.close();
|
||||||
@@ -166,6 +225,25 @@ try {
|
|||||||
rmSync(dataDir, { recursive: true, force: true });
|
rmSync(dataDir, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The browser settings every context here shares. */
|
||||||
|
function viewing() {
|
||||||
|
return {
|
||||||
|
viewport: { width: WIDTH, height: HEIGHT },
|
||||||
|
// The locale is not a formatting preference: the sign-up form sends
|
||||||
|
// navigator.language as the account's language, so this is what makes the
|
||||||
|
// interface, the Inbox's name and every date English. The zone is pinned for
|
||||||
|
// the same reason the smoke tests pin it — every due date is resolved in it.
|
||||||
|
locale: 'en-GB',
|
||||||
|
timezoneId: 'Europe/Copenhagen',
|
||||||
|
// Dark, because that is what the shots are forced to below. app.html reads
|
||||||
|
// prefers-color-scheme before first paint, and Playwright's default is light
|
||||||
|
// — which left the settings page rendering dark with the *light* theme
|
||||||
|
// ringed as the chosen one.
|
||||||
|
colorScheme: 'dark',
|
||||||
|
deviceScaleFactor: 2
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
async function waitForHealth() {
|
async function waitForHealth() {
|
||||||
for (let i = 0; i < 240; i++) {
|
for (let i = 0; i < 240; i++) {
|
||||||
try {
|
try {
|
||||||
@@ -179,6 +257,92 @@ async function waitForHealth() {
|
|||||||
throw new Error('the server never came up');
|
throw new Error('the server never came up');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes a PNG as WebP, in the browser that is already open.
|
||||||
|
*
|
||||||
|
* Chromium encodes WebP itself, so the alternative — shelling out to `cwebp` —
|
||||||
|
* would be something to install first, in a script whose whole point is that there
|
||||||
|
* is nothing to install. Resized on the way through: the landing page shows these
|
||||||
|
* 1400 CSS pixels wide, and a full-resolution WebP is twice the bytes for detail
|
||||||
|
* no screen renders.
|
||||||
|
*/
|
||||||
|
async function toWebP(encoder, png) {
|
||||||
|
const base64 = await encoder.evaluate(
|
||||||
|
async ({ data, width, quality }) => {
|
||||||
|
const image = new Image();
|
||||||
|
image.src = `data:image/png;base64,${data}`;
|
||||||
|
await image.decode();
|
||||||
|
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
canvas.width = width;
|
||||||
|
canvas.height = Math.round((image.naturalHeight / image.naturalWidth) * width);
|
||||||
|
const ctx = canvas.getContext('2d');
|
||||||
|
// The default resampler leaves the interface's hairlines ragged, which on a
|
||||||
|
// screenshot of a screenshot is the first thing the eye finds.
|
||||||
|
ctx.imageSmoothingQuality = 'high';
|
||||||
|
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
||||||
|
return canvas.toDataURL('image/webp', quality).split(',')[1];
|
||||||
|
},
|
||||||
|
// 0.75 is cwebp's default and where these stop getting smaller for anything
|
||||||
|
// the eye finds: 0.85 is a fifth more bytes for a difference that survives
|
||||||
|
// only under magnification, and the landing page's first image is the one
|
||||||
|
// somebody waits for.
|
||||||
|
{ data: png.toString('base64'), width: 1800, quality: 0.75 }
|
||||||
|
);
|
||||||
|
return Buffer.from(base64, 'base64');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signs the second person up through the invite the seed left behind, has them say
|
||||||
|
* something, and hands their work back to the first.
|
||||||
|
*
|
||||||
|
* A context of its own because a session is a cookie: signing up in the page the
|
||||||
|
* screenshots are taken from would replace the account they are taken as.
|
||||||
|
*/
|
||||||
|
async function addColleague(browser, ids) {
|
||||||
|
const context = await browser.newContext(viewing());
|
||||||
|
const page = await context.newPage();
|
||||||
|
try {
|
||||||
|
await page.goto(ids.invite);
|
||||||
|
// Danish labels again, and for the same reason: nobody is signed in yet.
|
||||||
|
await page.getByLabel(/Navn/).fill(COLLEAGUE.name);
|
||||||
|
await page.getByLabel(/Adgangskode/).fill(COLLEAGUE.password);
|
||||||
|
await page.getByRole('button', { name: 'Opret konto' }).click();
|
||||||
|
await page.getByRole('navigation', { name: 'Main menu' }).waitFor();
|
||||||
|
return await page.evaluate(handOver, ids);
|
||||||
|
} finally {
|
||||||
|
await context.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What the second person does, from inside their own session: answer the task they
|
||||||
|
* were opened on, and take the three they are being waited for.
|
||||||
|
*
|
||||||
|
* The assignments are made here rather than by the owner because an editor may
|
||||||
|
* assign, and doing it from this side proves it. Written as one function because it
|
||||||
|
* is passed to the browser as source.
|
||||||
|
*/
|
||||||
|
async function handOver(ids) {
|
||||||
|
const api = async (path, body, method = 'POST') => {
|
||||||
|
const r = await fetch(`/api/v1${path}`, {
|
||||||
|
method,
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: body ? JSON.stringify(body) : undefined
|
||||||
|
});
|
||||||
|
if (!r.ok) throw new Error(`${method} ${path} → ${r.status}`);
|
||||||
|
return r.status === 204 ? null : r.json();
|
||||||
|
};
|
||||||
|
|
||||||
|
const me = await api('/auth/me', null, 'GET');
|
||||||
|
for (const id of ids.delegate) await api(`/tasks/${id}`, { assignee_id: me.id }, 'PATCH');
|
||||||
|
|
||||||
|
await api(`/tasks/${ids.detail}/comments`, {
|
||||||
|
body: 'Room is booked for ten. Summer numbers are in the shared folder — the labels are still with the printer, I chase them Thursday.'
|
||||||
|
});
|
||||||
|
return { colleague: me.id };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The demo data, created through the app's own API from inside the page.
|
* The demo data, created through the app's own API from inside the page.
|
||||||
*
|
*
|
||||||
@@ -186,11 +350,11 @@ async function waitForHealth() {
|
|||||||
* header the API insists on come along without being reconstructed here. Written
|
* header the API insists on come along without being reconstructed here. Written
|
||||||
* as one function because it is passed to the browser as source.
|
* as one function because it is passed to the browser as source.
|
||||||
*
|
*
|
||||||
* The content is ordinary Danish household and work tasks. Screenshots of "Task
|
* Ordinary English household and work tasks, the same shape the Danish set had.
|
||||||
* 1, Task 2, Task 3" show the layout and hide whether the app is any good at the
|
* Screenshots of "Task 1, Task 2, Task 3" show the layout and hide whether the app
|
||||||
* thing it is for.
|
* is any good at the thing it is for.
|
||||||
*/
|
*/
|
||||||
async function seed() {
|
async function seed({ colleague, noteTitle }) {
|
||||||
const api = async (path, body, method = 'POST') => {
|
const api = async (path, body, method = 'POST') => {
|
||||||
const r = await fetch(`/api/v1${path}`, {
|
const r = await fetch(`/api/v1${path}`, {
|
||||||
method,
|
method,
|
||||||
@@ -210,63 +374,199 @@ async function seed() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Two headings over the projects, which is what the sidebar grew for.
|
// Two headings over the projects, which is what the sidebar grew for.
|
||||||
const arbejde = await api('/project-groups', { name: 'Arbejde' });
|
const work = await api('/project-groups', { name: 'Work' });
|
||||||
const privat = await api('/project-groups', { name: 'Privat' });
|
const home = await api('/project-groups', { name: 'Home' });
|
||||||
await api(`/project-groups/${arbejde.id}`, { color: 'indigo' }, 'PATCH');
|
await api(`/project-groups/${work.id}`, { color: 'indigo' }, 'PATCH');
|
||||||
await api(`/project-groups/${privat.id}`, { color: 'green' }, 'PATCH');
|
await api(`/project-groups/${home.id}`, { color: 'green' }, 'PATCH');
|
||||||
|
|
||||||
const work = await api('/projects', {
|
const launch = await api('/projects', {
|
||||||
name: 'Sæsonstart',
|
name: 'Autumn launch',
|
||||||
color: 'indigo',
|
color: 'indigo',
|
||||||
view_mode: 'board',
|
view_mode: 'board',
|
||||||
group_id: arbejde.id
|
group_id: work.id
|
||||||
});
|
});
|
||||||
const house = await api('/projects', { name: 'Huset', color: 'amber', group_id: privat.id });
|
const house = await api('/projects', { name: 'House', color: 'amber', group_id: home.id });
|
||||||
const garden = await api('/projects', { name: 'Haven', color: 'green', group_id: privat.id });
|
const garden = await api('/projects', { name: 'Garden', color: 'green', group_id: home.id });
|
||||||
|
|
||||||
const planning = await api(`/projects/${work.id}/sections`, { name: 'Planlægning' });
|
const planning = await api(`/projects/${launch.id}/sections`, { name: 'Planning' });
|
||||||
const inFlight = await api(`/projects/${work.id}/sections`, { name: 'I gang' });
|
const inFlight = await api(`/projects/${launch.id}/sections`, { name: 'In progress' });
|
||||||
const done = await api(`/projects/${work.id}/sections`, { name: 'Til gennemsyn' });
|
const review = await api(`/projects/${launch.id}/sections`, { name: 'Up for review' });
|
||||||
|
|
||||||
const tasks = [
|
const tasks = [
|
||||||
|
// One thing that slipped. Today with an overdue band on it is what a Thursday
|
||||||
|
// actually looks like, and it is the only way to photograph the band at all.
|
||||||
|
{
|
||||||
|
content: 'Chase the printer about the labels',
|
||||||
|
due_date: day(-2),
|
||||||
|
priority: 2,
|
||||||
|
project_id: launch.id,
|
||||||
|
section_id: inFlight.id,
|
||||||
|
labels: ['waiting']
|
||||||
|
},
|
||||||
|
|
||||||
// Today, in the Inbox and across the projects: the Today view is the first
|
// Today, in the Inbox and across the projects: the Today view is the first
|
||||||
// picture and it has to look like a real day.
|
// picture and it has to look like a real day.
|
||||||
{ content: 'Ring til tømreren om taget', due_date: day(0), priority: 1, project_id: house.id },
|
{ content: 'Call the roofer about the ridge tiles', due_date: day(0), priority: 1, project_id: house.id },
|
||||||
{ content: 'Aflever cyklen til service', due_date: day(0), priority: 3, labels: ['ærinder'] },
|
|
||||||
{
|
{
|
||||||
content: 'Skriv oplæg til sæsonmødet',
|
content: 'Write the opening notes for the launch meeting',
|
||||||
due_date: day(0),
|
due_date: day(0),
|
||||||
priority: 2,
|
priority: 2,
|
||||||
project_id: work.id,
|
project_id: launch.id,
|
||||||
section_id: planning.id,
|
section_id: planning.id,
|
||||||
duration_min: 90
|
duration_min: 90,
|
||||||
|
labels: ['meeting']
|
||||||
},
|
},
|
||||||
{ content: 'Vand drivhuset', due_date: day(0), recurrence_rule: 'FREQ=DAILY', project_id: garden.id },
|
{ content: 'Drop the bike off for its service', due_date: day(0), priority: 3, labels: ['errands'] },
|
||||||
{ content: 'Hent pakken på posthuset', due_date: day(0), labels: ['ærinder'] },
|
{ content: 'Water the greenhouse', due_date: day(0), recurrence_rule: 'FREQ=DAILY', project_id: garden.id },
|
||||||
|
{ content: 'Collect the parcel from the post office', due_date: day(0), labels: ['errands'] },
|
||||||
|
|
||||||
// The next couple of weeks, so Kommende and the month grid have something in
|
// The next couple of weeks, so Upcoming and the month grid have something in
|
||||||
// them rather than a row of empty cells.
|
// them rather than a row of empty cells.
|
||||||
{ content: 'Book håndværker til badeværelset', due_date: day(1), priority: 2, project_id: house.id },
|
{ content: 'Book a plumber for the bathroom', due_date: day(1), priority: 2, project_id: house.id },
|
||||||
{ content: 'Beskær den grønne hæk', due_date: day(2), project_id: garden.id },
|
{ content: 'Cut the beech hedge back', due_date: day(2), project_id: garden.id },
|
||||||
{ content: 'Gennemgå budgettet', due_date: day(3), priority: 1, project_id: work.id, section_id: inFlight.id },
|
{ content: 'Go through the budget', due_date: day(3), priority: 1, project_id: launch.id, section_id: inFlight.id },
|
||||||
{ content: 'Bestil løg til efteråret', due_date: day(5), project_id: garden.id },
|
{ content: 'Order bulbs for the autumn planting', due_date: day(5), project_id: garden.id },
|
||||||
{ content: 'Skift dæk', due_date: day(8), priority: 3 },
|
{ content: 'Swap the winter tyres on', due_date: day(8), priority: 3 },
|
||||||
{ content: 'Send referat ud', due_date: day(9), project_id: work.id, section_id: done.id },
|
{ content: 'Send the minutes round', due_date: day(9), project_id: launch.id, section_id: review.id },
|
||||||
{ content: 'Male vindueskarmene', due_date: day(12), project_id: house.id, priority: 2 },
|
{ content: 'Paint the window sills', due_date: day(12), project_id: house.id, priority: 2 },
|
||||||
{ content: 'Så vinterurter', due_date: day(15), project_id: garden.id },
|
{ content: 'Sow winter herbs in the cold frame', due_date: day(15), project_id: garden.id },
|
||||||
{ content: 'Kvartalsopfølgning', due_date: day(21), priority: 1, project_id: work.id, section_id: planning.id },
|
{ content: 'Quarterly review', due_date: day(21), priority: 1, project_id: launch.id, section_id: planning.id },
|
||||||
{ content: 'Rens tagrenderne', due_date: day(26), project_id: house.id },
|
{ content: 'Clear the gutters before the autumn rain', due_date: day(26), project_id: house.id },
|
||||||
|
|
||||||
// A few without dates, so the board has cards that are not all deadlines.
|
// A few without dates, so the board has cards that are not all deadlines.
|
||||||
{ content: 'Find ny leverandør af emballage', project_id: work.id, section_id: planning.id, priority: 3 },
|
{ content: 'Find a new packaging supplier', project_id: launch.id, section_id: planning.id, priority: 3 },
|
||||||
{ content: 'Skriv stillingsopslag', project_id: work.id, section_id: inFlight.id },
|
{ content: 'Write the job advert', project_id: launch.id, section_id: inFlight.id },
|
||||||
{ content: 'Opdater prislisten', project_id: work.id, section_id: done.id, labels: ['gennemsyn'] }
|
{ content: 'Update the price list', project_id: launch.id, section_id: review.id, labels: ['review'] }
|
||||||
];
|
];
|
||||||
for (const task of tasks) await api('/tasks', task);
|
const made = {};
|
||||||
|
for (const task of tasks) made[task.content] = await api('/tasks', task);
|
||||||
|
|
||||||
// A saved filter, because the sidebar shows them and an empty heading reads as
|
// A saved filter, because the sidebar shows them and an empty heading reads as
|
||||||
// a feature that does not work.
|
// a feature that does not work.
|
||||||
await api('/filters', { name: 'Vigtigt i denne uge', query: 'p1 & 7 days' });
|
await api('/filters', { name: 'Important this week', query: 'p1 & 7 days' });
|
||||||
|
|
||||||
return { work: work.id, house: house.id, garden: garden.id };
|
// The one task that is photographed open. Everything the drawer can hold, so the
|
||||||
|
// picture answers "what is in there" rather than showing an empty form.
|
||||||
|
const detail = made['Write the opening notes for the launch meeting'];
|
||||||
|
await api(
|
||||||
|
`/tasks/${detail.id}`,
|
||||||
|
{
|
||||||
|
description:
|
||||||
|
'Fifteen minutes, no slides. What shipped over the summer, what is left, and what we are deliberately not doing before the first.'
|
||||||
|
},
|
||||||
|
'PATCH'
|
||||||
|
);
|
||||||
|
for (const content of [
|
||||||
|
'Pull the numbers from last season',
|
||||||
|
'Ask Mette for the packaging quotes',
|
||||||
|
'Book the room'
|
||||||
|
]) {
|
||||||
|
await api('/tasks', { content, parent_id: detail.id, project_id: launch.id });
|
||||||
|
}
|
||||||
|
await api(`/tasks/${detail.id}/reminders`, { offset_min: 60 });
|
||||||
|
await api(`/tasks/${detail.id}/comments`, {
|
||||||
|
body: 'Keeping it to three points. Anything else goes on the list for the week after.'
|
||||||
|
});
|
||||||
|
|
||||||
|
// A file on the task, because "comments, attachments" is a claim and an empty
|
||||||
|
// Files heading is the opposite of proof.
|
||||||
|
const form = new FormData();
|
||||||
|
form.append('file', new Blob([new Uint8Array(9400)], { type: 'application/pdf' }), 'packaging-quote.pdf');
|
||||||
|
await fetch(`/api/v1/tasks/${detail.id}/attachments`, { method: 'POST', body: form });
|
||||||
|
|
||||||
|
// The notes, newest last: the list opens on what was touched most recently, so
|
||||||
|
// the one the screenshots open is the one written last.
|
||||||
|
const notes = [
|
||||||
|
{
|
||||||
|
body: `# Reading list
|
||||||
|
|
||||||
|
- *Shape Up* — the six-week bit, not the pitch bit
|
||||||
|
- The SQLite WAL paper, again
|
||||||
|
- Anything at all about pricing`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
project_id: garden.id,
|
||||||
|
body: `# The bulb order
|
||||||
|
|
||||||
|
Two hundred, split three ways, in before the first frost:
|
||||||
|
|
||||||
|
1. Narcissus along the south wall
|
||||||
|
2. Alliums in the bed by the shed
|
||||||
|
3. Crocus wherever there is room
|
||||||
|
|
||||||
|
The bed by the shed is heavy — grit in the hole, or they rot. #Garden`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
body: `# What the roofer said
|
||||||
|
|
||||||
|
Ridge tiles have moved, maybe a metre of them. Not urgent, not something to leave
|
||||||
|
over a winter either.
|
||||||
|
|
||||||
|
- Quote by the end of the month
|
||||||
|
- Two days' work, scaffold on the north side
|
||||||
|
- Ask whether the gutters can be done at the same time
|
||||||
|
|
||||||
|
#House`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
project_id: launch.id,
|
||||||
|
body: `# Price list — what changes
|
||||||
|
|
||||||
|
Nothing has been looked at since March.
|
||||||
|
|
||||||
|
- 250 g bag: **79 → 85**
|
||||||
|
- 1 kg bag: **265 → 279**
|
||||||
|
- Subscription: **199 → 209**
|
||||||
|
|
||||||
|
Subscribers keep the old price for three months. That is the whole of the goodwill
|
||||||
|
budget and it is worth it.`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pinned: true,
|
||||||
|
project_id: launch.id,
|
||||||
|
body: `# ${noteTitle}
|
||||||
|
|
||||||
|
Thursday, fifteen minutes, no slides.
|
||||||
|
|
||||||
|
## What shipped over the summer
|
||||||
|
|
||||||
|
- The new packaging, minus the labels
|
||||||
|
- A CalDAV feed nobody asked for and everybody uses
|
||||||
|
|
||||||
|
## What is left
|
||||||
|
|
||||||
|
- Labels. Still with the printer, chased on Thursday
|
||||||
|
- The price list: [[Price list — what changes]]
|
||||||
|
|
||||||
|
> If it is not on the list by Friday it is not in the launch.
|
||||||
|
|
||||||
|
The build we cut the release from:
|
||||||
|
|
||||||
|
\`\`\`bash
|
||||||
|
cd web && npm run build && cd ..
|
||||||
|
go build -tags embedweb -o verdande ./cmd/verdande
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
|
Room is booked. Coffee is **not** my job this week.
|
||||||
|
|
||||||
|
The opening notes are a task, so they can be ticked off: task:${detail.id}`
|
||||||
|
}
|
||||||
|
];
|
||||||
|
for (const note of notes) await api('/notes', note);
|
||||||
|
|
||||||
|
// Shared with somebody, and an invite left standing to the instance itself: two
|
||||||
|
// of the three states the members page has, and the one it never showed before.
|
||||||
|
const invite = await api(`/projects/${launch.id}/invites`, { email: colleague, role: 'editor' });
|
||||||
|
await api('/users', { email: '[email protected]' });
|
||||||
|
|
||||||
|
return {
|
||||||
|
work: launch.id,
|
||||||
|
detail: detail.id,
|
||||||
|
invite: invite.link,
|
||||||
|
delegate: [
|
||||||
|
made['Send the minutes round'].id,
|
||||||
|
made['Update the price list'].id,
|
||||||
|
made['Find a new packaging supplier'].id
|
||||||
|
]
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||