move frontend to subfolder.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
# create-svelte
|
||||
|
||||
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
|
||||
|
||||
## Creating a project
|
||||
|
||||
If you're seeing this, you've probably already done this step. Congrats!
|
||||
|
||||
```bash
|
||||
# create a new project in the current directory
|
||||
npm init svelte@next
|
||||
|
||||
# create a new project in my-app
|
||||
npm init svelte@next my-app
|
||||
```
|
||||
|
||||
> Note: the `@next` is temporary
|
||||
|
||||
## Developing
|
||||
|
||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
|
||||
# or start the server and open the app in a new browser tab
|
||||
npm run dev -- --open
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
To create a production version of your app:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
You can preview the production build with `npm run preview`.
|
||||
|
||||
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
|
||||
Generated
+8578
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "stufflog3",
|
||||
"version": "0.0.1",
|
||||
"scripts": {
|
||||
"dev": "svelte-kit dev",
|
||||
"build": "svelte-kit build",
|
||||
"package": "svelte-kit package",
|
||||
"preview": "svelte-kit preview",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"lint": "eslint --ignore-path .gitignore ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fortawesome/free-solid-svg-icons": "^6.0.0",
|
||||
"@sveltejs/adapter-auto": "next",
|
||||
"@sveltejs/kit": "next",
|
||||
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
||||
"@typescript-eslint/parser": "^5.10.1",
|
||||
"@yarbsemaj/adapter-lambda": "^0.2.1",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-svelte3": "^3.2.1",
|
||||
"fa-svelte": "^3.1.0",
|
||||
"mysql2": "^2.3.3",
|
||||
"node-sass": "^7.0.1",
|
||||
"sass": "^1.49.9",
|
||||
"svelte": "^3.44.0",
|
||||
"svelte-check": "^2.2.6",
|
||||
"svelte-preprocess": "^4.10.1",
|
||||
"tslib": "^2.3.1",
|
||||
"typescript": "~4.5.4"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE scope (
|
||||
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`abbreviation` CHAR(8) NOT NULL
|
||||
)
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS scope;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,17 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE scope_member (
|
||||
`scope_id` INT NOT NULL,
|
||||
`user_id` CHAR(36) NOT NULL,
|
||||
`name` VARCHAR(63) NOT NULL,
|
||||
`owner` BOOLEAN NOT NULL,
|
||||
|
||||
PRIMARY KEY (`scope_id`, `user_id`),
|
||||
UNIQUE (`scope_id`, `name`)
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS scope_member;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,18 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE stat (
|
||||
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`scope_id` INT NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
`weight` FLOAT NOT NULL,
|
||||
`allowed_amounts` JSON,
|
||||
|
||||
UNIQUE (`scope_id`, `name`)
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS stat;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,18 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE project (
|
||||
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`scope_id` INT NOT NULL,
|
||||
`author_id` CHAR(36) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`status` INT NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
|
||||
UNIQUE (`scope_id`, `name`)
|
||||
)
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS project;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,16 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE project_requirement (
|
||||
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`scope_id` INT NOT NULL,
|
||||
`project_id` INT NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`status` INT NOT NULL,
|
||||
`description` TEXT NOT NULL
|
||||
)
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS project_requirement;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,19 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE item (
|
||||
`id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`scope_id` INT NOT NULL,
|
||||
`project_requirement_id` INT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`description` TEXT NOT NULL,
|
||||
`created_time` DATETIME NOT NULL,
|
||||
`created_user_id` CHAR(36) NOT NULL,
|
||||
`acquired_time` DATETIME,
|
||||
`scheduled_date` DATE
|
||||
)
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS item;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,17 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE item_stat_progress (
|
||||
`item_id` INT NOT NULL,
|
||||
`stat_id` INT NOT NULL,
|
||||
`acquired` INT NOT NULL,
|
||||
`required` INT NOT NULL,
|
||||
|
||||
PRIMARY KEY (`item_id`, `stat_id`),
|
||||
UNIQUE (`stat_id`, `item_id`)
|
||||
)
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS item_stat_progress;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,15 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE project_requirement_stat (
|
||||
`project_requirement_id` INT NOT NULL,
|
||||
`stat_id` INT NOT NULL,
|
||||
`required` INT NOT NULL,
|
||||
|
||||
PRIMARY KEY (`project_requirement_id`, `stat_id`)
|
||||
)
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS project_requirement_stat;
|
||||
-- +goose StatementEnd
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
/// <reference types="@sveltejs/kit" />
|
||||
|
||||
import type { ScopeEntry } from "$lib/models/scope";
|
||||
import type Scope from "$lib/models/scope";
|
||||
import type User from "$lib/models/user";
|
||||
|
||||
// See https://kit.svelte.dev/docs/types#the-app-namespace
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
declare namespace App {
|
||||
interface Locals {
|
||||
user: User,
|
||||
scopes: ScopeEntry[],
|
||||
}
|
||||
|
||||
// interface Platform {}
|
||||
// interface Session {}
|
||||
interface Stuff {
|
||||
scope?: Scope
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="description" content="" />
|
||||
<link rel="icon" href="%svelte.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<style>
|
||||
body {
|
||||
background-color: hsl(240, 12%, 5%);
|
||||
color: #aaa;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
</style>
|
||||
%svelte.head%
|
||||
</head>
|
||||
<body>
|
||||
<div id="root">%svelte.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,25 @@
|
||||
import config from "$lib/config";
|
||||
import type { Handle } from "@sveltejs/kit";
|
||||
|
||||
export const handle: Handle = async({ event, resolve }) => {
|
||||
if (process.env.STUFFLOG3_USE_DUMMY_USER === "true") {
|
||||
event.locals.user = {
|
||||
id: "c11230be-4912-4313-83b0-410a248b5bd1",
|
||||
name: "Developer",
|
||||
}
|
||||
} else {
|
||||
event.locals.user = {id: "", name: "Guest"};
|
||||
|
||||
// Actual login check.
|
||||
}
|
||||
|
||||
if (event.locals.user.id !== "") {
|
||||
const db = await config.database();
|
||||
event.locals.scopes = await db.withUser(event.locals.user.id).scopes().list()
|
||||
} else {
|
||||
event.locals.scopes = [];
|
||||
}
|
||||
|
||||
const response = await resolve(event);
|
||||
return response;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
$color-entry0: hsl(240, 5%, 7%)
|
||||
$color-entry0-transparent: hsla(240, 5%, 10%, 0.7)
|
||||
$color-entry1: hsl(240, 5%, 14%)
|
||||
$color-entry1-transparent: hsla(240, 5%, 17%, 0.8)
|
||||
$color-entry2: hsl(240, 5%, 21%)
|
||||
$color-entry2-transparent: hsla(240, 5%, 24%, 0.8)
|
||||
$color-entry3: hsl(240, 5%, 28%)
|
||||
$color-entry4: hsl(240, 5%, 35%)
|
||||
$color-entry5: hsl(240, 5%, 42%)
|
||||
$color-entry6: hsl(240, 5%, 49%)
|
||||
$color-entry7: hsl(240, 5%, 56%)
|
||||
$color-entry8: hsl(240, 5%, 63%)
|
||||
$color-entry9: hsl(240, 5%, 70%)
|
||||
$color-entry10: hsl(240, 5%, 77%)
|
||||
$color-entry11: hsl(240, 5%, 84%)
|
||||
$color-entry12: hsl(240, 5%, 91%)
|
||||
$color-entry13: hsl(240, 5%, 98%)
|
||||
|
||||
$opacity-entry4: 0.40
|
||||
$opacity-entry5: 0.60
|
||||
$opacity-entry6: 0.80
|
||||
|
||||
$color-green: hsl(120, 50%, 74%)
|
||||
$color-green-dark: hsl(120, 50%, 35%)
|
||||
@@ -0,0 +1,59 @@
|
||||
<script lang="ts">
|
||||
import type { StandaloneItem } from "$lib/models/item";
|
||||
import CardEntry from "../layout/CardEntry.svelte";
|
||||
import EntryAmounts from "../layout/EntryAmounts.svelte";
|
||||
import EntryButton from "../layout/EntryButton.svelte";
|
||||
import EntryCompletionIcon from "../layout/EntryCompletionIcon.svelte";
|
||||
import EntryDate from "../layout/EntryDate.svelte";
|
||||
import EntryDescription from "../layout/EntryDescription.svelte";
|
||||
import EntryName from "../layout/EntryName.svelte";
|
||||
import Icon from "../layout/Icon.svelte";
|
||||
|
||||
export let item: StandaloneItem
|
||||
export let compact: boolean = false;
|
||||
|
||||
let link = "";
|
||||
let amounts = [];
|
||||
let subtitle = "";
|
||||
|
||||
$: if (item.project != null) {
|
||||
link = `/${item.scope.id}/project/${item.project.id}?focusitem=${item.id}`
|
||||
} else {
|
||||
link = `/${item.scope.id}/item/${item.id}`
|
||||
}
|
||||
|
||||
$: amounts = item.stats.map(s => ({amount: s.acquired || s.required, label: s.name}))
|
||||
$: subtitle = item.project != null ? item.project.name : item.scope.abbreviation
|
||||
</script>
|
||||
|
||||
<a href={link}>
|
||||
<CardEntry>
|
||||
{#if !item.acquireTime}
|
||||
<EntryButton>
|
||||
<Icon name="check" />
|
||||
</EntryButton>
|
||||
{:else}
|
||||
<EntryButton>
|
||||
<Icon name="pen" />
|
||||
</EntryButton>
|
||||
{/if}
|
||||
<EntryCompletionIcon condition={!!item.acquireTime} />
|
||||
<EntryName subtitle={subtitle}>{item.name}</EntryName>
|
||||
{#if !compact}
|
||||
{#if !!item.acquireTime}
|
||||
<EntryDate green value={item.acquireTime} verb="Acquired" />
|
||||
{:else}
|
||||
<EntryDate value={item.createdTime} verb="Created" />
|
||||
{/if}
|
||||
<EntryDescription>{item.description}</EntryDescription>
|
||||
{/if}
|
||||
<EntryAmounts values={amounts} />
|
||||
</CardEntry>
|
||||
</a>
|
||||
|
||||
<style>
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,46 @@
|
||||
<script lang="ts">
|
||||
import type { StandaloneRequirement } from "$lib/models/project";
|
||||
import Status from "$lib/models/status";
|
||||
|
||||
import CardEntry from "../layout/CardEntry.svelte";
|
||||
import EntryButton from "../layout/EntryButton.svelte";
|
||||
import EntryDescription from "../layout/EntryDescription.svelte";
|
||||
import EntryName from "../layout/EntryName.svelte";
|
||||
import EntryProgress from "../layout/EntryProgress.svelte";
|
||||
import EntryProgressRow from "../layout/EntryProgressRow.svelte";
|
||||
import EntryStatusIcon from "../layout/EntryStatusIcon.svelte";
|
||||
import EntryStatusLine from "../layout/EntryStatusLine.svelte";
|
||||
import Icon from "../layout/Icon.svelte";
|
||||
|
||||
export let requirement: StandaloneRequirement
|
||||
export let compact: boolean = false;
|
||||
export let boat: number = null;
|
||||
</script>
|
||||
|
||||
<a href="/{requirement.scope.id}/{requirement.project.id}?requirement={requirement.id}">
|
||||
<CardEntry>
|
||||
{#if requirement.status === Status.Active}
|
||||
<EntryButton>
|
||||
<Icon name="plus" />
|
||||
</EntryButton>
|
||||
{/if}
|
||||
<EntryStatusIcon status={requirement.status} />
|
||||
<EntryName subtitle={requirement.project.name}>{requirement.name}</EntryName>
|
||||
{#if !compact}
|
||||
<EntryStatusLine status={requirement.status} />
|
||||
<EntryDescription>{requirement.description}</EntryDescription>
|
||||
{/if}
|
||||
<EntryProgressRow>
|
||||
{#each requirement.stats as stat (stat.id)}
|
||||
<EntryProgress boat={boat} name={stat.name} acquired={stat.acquired} required={stat.required} />
|
||||
{/each}
|
||||
</EntryProgressRow>
|
||||
</CardEntry>
|
||||
</a>
|
||||
|
||||
<style>
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script lang="ts">
|
||||
import type { ScopeEntry } from "$lib/models/scope";
|
||||
import CardEntry from "../layout/CardEntry.svelte";
|
||||
import EntryName from "../layout/EntryName.svelte";
|
||||
|
||||
export let scope: ScopeEntry
|
||||
</script>
|
||||
|
||||
<a href="/{scope.id}/">
|
||||
<CardEntry>
|
||||
<EntryName subtitle={scope.abbreviation}>{scope.name}</EntryName>
|
||||
</CardEntry>
|
||||
</a>
|
||||
|
||||
<style>
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,134 @@
|
||||
<script lang="ts">
|
||||
import type Sprint from "$lib/models/sprint";
|
||||
import type { StatAggregate, StatEntry } from "$lib/models/stat";
|
||||
import { calculateAggregate } from "$lib/utils/aggregate";
|
||||
|
||||
import currentTime from "$lib/stores/currentTime";
|
||||
|
||||
import CardEntry from "../layout/CardEntry.svelte";
|
||||
import EntryDescription from "../layout/EntryDescription.svelte";
|
||||
import EntryName from "../layout/EntryName.svelte";
|
||||
import EntryProgress from "../layout/EntryProgress.svelte";
|
||||
import EntryProgressRow from "../layout/EntryProgressRow.svelte";
|
||||
import ItemLink from "./ItemLink.svelte";
|
||||
import RequirementLink from "./RequirementLink.svelte";
|
||||
import EntryButton from "../layout/EntryButton.svelte";
|
||||
import Icon from "../layout/Icon.svelte";
|
||||
import Status from "$lib/models/status";
|
||||
|
||||
export let sprint: Sprint
|
||||
|
||||
let fromDate: Date;
|
||||
let toDate: Date;
|
||||
let boat: number;
|
||||
let itemsAcquired: number;
|
||||
let itemsRequired: number;
|
||||
let aggregate: StatAggregate;
|
||||
let reqAggregate: Record<string, StatAggregate>;
|
||||
|
||||
$: {
|
||||
fromDate = new Date(sprint.from);
|
||||
toDate = new Date(sprint.to);
|
||||
boat = ($currentTime.getTime() - fromDate.getTime()) / (toDate.getTime() - fromDate.getTime());
|
||||
boat = Math.max(0, Math.min(1, boat));
|
||||
}
|
||||
|
||||
$: {
|
||||
if (sprint.items != null) {
|
||||
itemsAcquired = sprint.items.filter(i => !!i.acquireTime).length;
|
||||
itemsRequired = sprint.items.length;
|
||||
} else {
|
||||
itemsAcquired = 0;
|
||||
itemsRequired = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$: {
|
||||
switch (sprint.kind) {
|
||||
case "items": {
|
||||
aggregate = calculateAggregate(sprint.items.map(i => i.stats).flat());
|
||||
break;
|
||||
}
|
||||
case "requirements": {
|
||||
// Completed, failed or dropped should fix.
|
||||
aggregate = calculateAggregate(sprint.requirements.map(r => (
|
||||
r.status >= Status.Completed
|
||||
? r.stats.map(s => ({...s, acquired: Math.max(s.required, s.acquired)}))
|
||||
: r.stats
|
||||
)).flat());
|
||||
break;
|
||||
}
|
||||
case "stats": {
|
||||
aggregate = calculateAggregate(sprint.stats);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sprint.aggregateRequired > 0) {
|
||||
aggregate.required = sprint.aggregateRequired;
|
||||
}
|
||||
|
||||
reqAggregate = {};
|
||||
for (const requirement of (sprint.requirements || [])) {
|
||||
reqAggregate[requirement.id] = calculateAggregate(requirement.stats);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<a href="/{sprint.scope.id}/sprints?sprint={sprint.id}">
|
||||
<CardEntry>
|
||||
{#if sprint.kind === "stats"}
|
||||
<EntryButton>
|
||||
<Icon name="plus" />
|
||||
</EntryButton>
|
||||
{/if}
|
||||
<EntryName subtitle="{sprint.scope.abbreviation} {sprint.kind} sprint">{sprint.name}</EntryName>
|
||||
<EntryDescription>{sprint.description}</EntryDescription>
|
||||
<EntryProgressRow>
|
||||
{#if sprint.kind === "items"}
|
||||
<EntryProgress
|
||||
fullwidth green
|
||||
name="Items"
|
||||
acquired={itemsAcquired}
|
||||
required={itemsRequired}
|
||||
boat={boat}
|
||||
/>
|
||||
{:else}
|
||||
<EntryProgress
|
||||
fullwidth
|
||||
name={sprint.aggregateName || "Total"}
|
||||
acquired={aggregate.acquired}
|
||||
required={aggregate.required}
|
||||
boat={boat}
|
||||
/>
|
||||
{/if}
|
||||
{#if !sprint.coarse}
|
||||
{#each sprint.stats as stat (stat.id)}
|
||||
<EntryProgress
|
||||
name={stat.name}
|
||||
acquired={stat.acquired}
|
||||
required={stat.required}
|
||||
boat={boat}
|
||||
/>
|
||||
{/each}
|
||||
{/if}
|
||||
</EntryProgressRow>
|
||||
{#each sprint.items as item (item.id)}
|
||||
{#if !item.acquireTime}
|
||||
<ItemLink compact item={item} />
|
||||
{/if}
|
||||
{/each}
|
||||
{#each sprint.requirements as requirement (requirement.id)}
|
||||
{#if requirement.status < Status.Completed}
|
||||
<RequirementLink compact boat={boat} requirement={requirement} />
|
||||
{/if}
|
||||
{/each}
|
||||
</CardEntry>
|
||||
</a>
|
||||
|
||||
<style lang="scss">
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte";
|
||||
|
||||
export let initialOrientation: "portrait" | "landscape" = "portrait";
|
||||
export let src = "/background.jpg";
|
||||
export let opacity = 1.0;
|
||||
|
||||
let landscape = (initialOrientation === "landscape");
|
||||
let image: HTMLImageElement;
|
||||
|
||||
onMount(() => {
|
||||
if (image.complete && typeof(image.naturalHeight) !== 'undefined' && image.naturalHeight !== 0) {
|
||||
const width = image.naturalWidth;
|
||||
const height = image.naturalHeight;
|
||||
|
||||
landscape = (width > (height * 1.50));
|
||||
} else {
|
||||
image.onload = () => {
|
||||
const width = image.naturalWidth;
|
||||
const height = image.naturalHeight;
|
||||
|
||||
landscape = (width > (height * 1.50));
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<img
|
||||
bind:this={image}
|
||||
class:landscape
|
||||
src={src}
|
||||
style={`opacity: ${opacity};`}
|
||||
alt="Background"
|
||||
/>
|
||||
|
||||
<style>
|
||||
|
||||
img {
|
||||
/* Set rules to fill background */
|
||||
width: 100%;
|
||||
/* Set up proportionate scaling */
|
||||
min-height: 100%;
|
||||
height: auto;
|
||||
/* Set up positioning */
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
user-select: none;
|
||||
-webkit-user-drag: none;
|
||||
|
||||
transition: 250ms;
|
||||
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
img.landscape {
|
||||
/* Set rules to fill background */
|
||||
height: 100%;
|
||||
/* Set up proportionate scaling */
|
||||
min-width: 100%;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,38 @@
|
||||
<div class="entry">
|
||||
<slot></slot>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
@import "../colors.sass";
|
||||
|
||||
div.entry {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
color: $color-entry9;
|
||||
background-color: $color-entry1-transparent;
|
||||
border-bottom-right-radius: 0.75em;
|
||||
margin: 0.5em 0;
|
||||
padding: 0.25em 0.5ch;
|
||||
transition: 250ms;
|
||||
overflow-y: hidden;
|
||||
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
div.entry:hover {
|
||||
background-color: $color-entry2-transparent;
|
||||
color: $color-entry11;
|
||||
}
|
||||
|
||||
:global(div.entry div.entry) {
|
||||
margin: 0.25em 0;
|
||||
}
|
||||
:global(div.entry div.entry) {
|
||||
border-bottom-right-radius: 0.5em;
|
||||
}
|
||||
:global(div.entry div.entry:hover) {
|
||||
background-color: $color-entry3;
|
||||
}
|
||||
|
||||
div.entry:last-of-type {
|
||||
margin-bottom: 0.1em;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,42 @@
|
||||
<script lang="ts" context="module">
|
||||
export interface Amount {
|
||||
label: string
|
||||
amount: 0
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export let values: Amount[];
|
||||
</script>
|
||||
|
||||
<div class="amounts">
|
||||
{#each values as value}
|
||||
<div class="amount">
|
||||
<span class="value">{value.amount}×</span>
|
||||
<span class="label">{value.label}</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
@import "../colors.sass";
|
||||
|
||||
div.amounts {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 0.5em;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
div.amounts:empty {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
div.amount {
|
||||
padding-right: 1ch;
|
||||
}
|
||||
|
||||
span.label {
|
||||
opacity: $opacity-entry4;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
import Icon, { DEFAULT_ICON } from "./Icon.svelte";
|
||||
import type { IconName } from "./Icon.svelte";
|
||||
|
||||
export let name: IconName = DEFAULT_ICON;
|
||||
</script>
|
||||
|
||||
<div class="bgicon">
|
||||
<Icon name={name} />
|
||||
</div>
|
||||
|
||||
<style>
|
||||
div.bgicon {
|
||||
position: relative;
|
||||
top: 0.1em;
|
||||
height: 0;
|
||||
width: 1.75ch;
|
||||
font-size: 3em;
|
||||
margin-left: auto;
|
||||
background: none;
|
||||
pointer-events: none;
|
||||
opacity: 0.05;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,36 @@
|
||||
<div class="button-wrapper">
|
||||
<div class="button-row">
|
||||
<div class="button" on:click>
|
||||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
@import "../colors.sass";
|
||||
|
||||
div.button {
|
||||
color: $color-entry4;
|
||||
font-size: 1.5em;
|
||||
margin: 0 0.1ch;
|
||||
padding: 0;
|
||||
transition: 250ms;
|
||||
|
||||
&:hover {
|
||||
color: $color-entry10;
|
||||
}
|
||||
}
|
||||
|
||||
div.button-row {
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
div.button-wrapper {
|
||||
position: relative;
|
||||
top: 0.05em;
|
||||
height: 0;
|
||||
margin-left: auto;
|
||||
background: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import Status from "$lib/models/status";
|
||||
|
||||
import EntryBgIcon from "./EntryBgIcon.svelte";
|
||||
import StatusColor from "./StatusColor.svelte";
|
||||
|
||||
export let condition: boolean;
|
||||
</script>
|
||||
|
||||
{#if condition}
|
||||
<StatusColor status={Status.Completed}>
|
||||
<EntryBgIcon name="check" />
|
||||
</StatusColor>
|
||||
{/if}
|
||||
@@ -0,0 +1,67 @@
|
||||
<script lang="ts">
|
||||
import currentTime from "$lib/stores/currentTime";
|
||||
export let value: Date | string;
|
||||
export let green: boolean = false;
|
||||
export let verb: string = "Created";
|
||||
|
||||
let dateStr = "";
|
||||
let timeStr = "";
|
||||
|
||||
$: {
|
||||
const date = (value instanceof Date) ? value : new Date(value);
|
||||
const today = new Date($currentTime.getFullYear(), $currentTime.getMonth(), $currentTime.getDate(), 0, 0, 0, 0);
|
||||
const thisYear = new Date($currentTime.getFullYear(), 0, 1, 0, 0, 0, 0);
|
||||
const nextYear = new Date($currentTime.getFullYear()+1, 0, 1, 0, 0, 0, 0);
|
||||
const offset = date.getTime() - today.getTime();
|
||||
|
||||
if (offset >= DAY * 2 || offset < DAY * -1) {
|
||||
if (date < thisYear || date >= nextYear) {
|
||||
dateStr = `${date.getDate()} ${MONTHS[date.getMonth()]} ${date.getFullYear()}`
|
||||
} else {
|
||||
dateStr = `${date.getDate()} ${MONTHS[date.getMonth()]}`
|
||||
}
|
||||
} else if (offset >= DAY * 1) {
|
||||
dateStr = "tomrrow";
|
||||
} else if (offset >= 0) {
|
||||
dateStr = "today";
|
||||
} else {
|
||||
dateStr = "yesterday";
|
||||
}
|
||||
|
||||
timeStr = `${pad(date.getHours())}:${pad(date.getMinutes())}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="date" class:green>
|
||||
<span class="verb">{verb}</span>
|
||||
<span class="value">{dateStr}</span>
|
||||
<span class="verb">at</span>
|
||||
<span class="value">{timeStr}</span>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
@import "../colors.sass";
|
||||
|
||||
div.date {
|
||||
font-size: 0.75em;
|
||||
font-weight: 600;
|
||||
|
||||
&.green {
|
||||
color: $color-green;
|
||||
}
|
||||
|
||||
> span.verb {
|
||||
opacity: $opacity-entry4;
|
||||
}
|
||||
> span.value {
|
||||
opacity: $opacity-entry5;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script lang="ts" context="module">
|
||||
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
||||
const DAY = 86400000;
|
||||
|
||||
function pad(n: number) { return n > 10 ? n.toString() : `0${n}` };
|
||||
</script>
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
</script>
|
||||
|
||||
<div class="description">
|
||||
<span><slot></slot></span>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
div.description {
|
||||
margin-top: 0.25em;
|
||||
font-size: 1em;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
export let subtitle: string = ""
|
||||
</script>
|
||||
|
||||
<div class="name">
|
||||
<span><slot></slot></span>
|
||||
<span class="abbreviation">{subtitle}</span>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
@import "../colors.sass";
|
||||
|
||||
div.name {
|
||||
font-size: 1em;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
span.abbreviation {
|
||||
font-size: 1em;
|
||||
opacity: $opacity-entry4;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1500px) {
|
||||
span.abbreviation {
|
||||
display: block;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,214 @@
|
||||
<script lang="ts" context="module">
|
||||
export const PROGRESS_COLORS = [
|
||||
"none",
|
||||
"bronze",
|
||||
"silver",
|
||||
"gold",
|
||||
]
|
||||
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export let name: string;
|
||||
export let acquired: number;
|
||||
export let required: number;
|
||||
export let boat: number | null = null;
|
||||
export let big: boolean = false;
|
||||
export let bare: boolean = false;
|
||||
export let fullwidth: boolean = false;
|
||||
export let percentage: boolean = false;
|
||||
export let green: boolean = false;
|
||||
|
||||
let offClass = PROGRESS_COLORS[0];
|
||||
let onClass = PROGRESS_COLORS[1];
|
||||
let ons = 0;
|
||||
let offs = 1;
|
||||
let segmented = false;
|
||||
let boatClass = "gray";
|
||||
let boatDone = false;
|
||||
let ratio = 0;
|
||||
|
||||
$: {
|
||||
const acq = Math.floor(acquired);
|
||||
const req = Math.floor(required);
|
||||
|
||||
ratio = acq / req;
|
||||
|
||||
if (req > 0) {
|
||||
let level = Math.floor(acq / req);
|
||||
if (level >= PROGRESS_COLORS.length - 1) {
|
||||
offs = 0;
|
||||
ons = req;
|
||||
offClass = "gold";
|
||||
onClass = "gold";
|
||||
} else {
|
||||
ons = acq - (level * req);
|
||||
offs = req - ons;
|
||||
offClass = PROGRESS_COLORS[level];
|
||||
onClass = PROGRESS_COLORS[level + 1];
|
||||
}
|
||||
|
||||
// Mark it non-segmented if the required is too high. This prevents a clunky progress bar,
|
||||
// or a browser freeze if you set the required very high.
|
||||
segmented = !percentage && (req <= (fullwidth ? 60 : 15));
|
||||
} else {
|
||||
offClass = "none";
|
||||
segmented = true;
|
||||
ons = 0;
|
||||
offs = 1;
|
||||
}
|
||||
|
||||
if (green) {
|
||||
onClass = "green";
|
||||
offClass = "none";
|
||||
|
||||
if (acq >= req) {
|
||||
ons = req;
|
||||
offs = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$: {
|
||||
if (boat != null && required > 0) {
|
||||
const diff = ratio - boat;
|
||||
if (diff < -0.05) {
|
||||
boatClass = "red";
|
||||
} else if (diff > 0.05) {
|
||||
boatClass = "green";
|
||||
} else {
|
||||
boatClass = "gray";
|
||||
}
|
||||
|
||||
boatDone = ratio >= 1.0;
|
||||
} else {
|
||||
boatClass = "gray";
|
||||
boatDone = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="progress" class:fullwidth>
|
||||
<!-- Header -->
|
||||
{#if !bare}
|
||||
<div class="header">
|
||||
<span>{name}</span>
|
||||
{#if percentage}
|
||||
<span class="ackreq">({((acquired / required) * 100).toFixed(0)}%)</span>
|
||||
{:else}
|
||||
<span class="ackreq">({Math.floor(acquired)} / {Math.ceil(required)})</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<!-- Progress Bar -->
|
||||
<div class="bar" class:big>
|
||||
{#if segmented}
|
||||
{#each {length: Math.max(ons, 0)} as _}
|
||||
<div class="segmented on {onClass}"></div>
|
||||
{/each}
|
||||
{#each {length: Math.max(offs, 0)} as _}
|
||||
<div class="segmented off {offClass}"></div>
|
||||
{/each}
|
||||
{:else}
|
||||
{#if ons > 0}
|
||||
<div style="flex: {ons}" class="non-segmented on {onClass}"></div>
|
||||
{/if}
|
||||
{#if offs > 0}
|
||||
<div style="flex: {offs}" class="non-segmented off {offClass}"></div>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- "Boat" -->
|
||||
{#if boat != null && !boatDone}
|
||||
<div class="bar boat">
|
||||
<div style="flex: {Math.min(boat, 1)}" class="non-segmented on {boatClass}"></div>
|
||||
<div style="flex: {Math.max(1 - boat, 0)}" class="non-segmented off none"></div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
@import "../colors.sass";
|
||||
|
||||
div.progress {
|
||||
padding: 0.25em 0.5ch;
|
||||
font-size: 0.9em;
|
||||
flex-basis: calc(33.33% - 1ch);
|
||||
|
||||
@media screen and (max-width: 1300px) {
|
||||
flex-basis: calc(50% - 1ch);
|
||||
}
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
font-size: 1.2em;
|
||||
flex-basis: calc(100% - 1ch);
|
||||
}
|
||||
|
||||
&.fullwidth {
|
||||
flex-basis: calc(100% - 1ch);
|
||||
}
|
||||
}
|
||||
|
||||
div.bar {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin: 0;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
height: 8px;
|
||||
margin: 0.5px 0;
|
||||
transform: skew(-11.25deg, 0);
|
||||
|
||||
margin-top: 0.2em;
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
&.big {
|
||||
height: 12px;
|
||||
}
|
||||
&.boat {
|
||||
transform: skew(-11.25deg, 0) translateX(-1.1px);
|
||||
margin-top: 0em;
|
||||
height: 2.5px;
|
||||
}
|
||||
|
||||
> div {
|
||||
flex-grow: 1;
|
||||
flex-basis: 0;
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
margin: 0 1px;
|
||||
border: 1px solid #000;
|
||||
|
||||
div.non-segmented {
|
||||
flex-grow: inherit;
|
||||
flex-basis: inherit;
|
||||
}
|
||||
|
||||
&.on {opacity: 0.75; }
|
||||
&.none { background-color: #000; }
|
||||
&.gray { background-color: #999; opacity: 1; }
|
||||
&.bronze { background-color: #f4b083; }
|
||||
&.silver { background-color: #d8dce4; opacity: 0.8; }
|
||||
&.gold { background-color: #ffd966; opacity: 0.9; }
|
||||
&.green { background-color: #8ef88e; opacity: 0.8; }
|
||||
&.red { background-color: hsl(0, 95%, 70%); opacity: 0.8; }
|
||||
&.off {opacity: 0.30; }
|
||||
|
||||
@media (-webkit-min-device-pixel-ratio: 1.3) {
|
||||
border-width: 0.5px;
|
||||
}
|
||||
@media (-webkit-min-device-pixel-ratio: 1.8) {
|
||||
border-width: 0.25px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
span.ackreq {
|
||||
opacity: $opacity-entry4;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,16 @@
|
||||
<div class="progress-row">
|
||||
<slot></slot>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
div.progress-row {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 0.5em;
|
||||
font-size: 0.75em;
|
||||
}
|
||||
div.progress-row:empty {
|
||||
margin-top: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
import type Status from "$lib/models/status";
|
||||
import EntryBgIcon from "./EntryBgIcon.svelte";
|
||||
import type { IconName } from "./Icon.svelte";
|
||||
import StatusColor from "./StatusColor.svelte";
|
||||
|
||||
export let status: Status;
|
||||
let icon: IconName
|
||||
|
||||
$: switch (status) {
|
||||
case 0: icon = "hourglass"; break;
|
||||
case 1: icon = "lightbulb"; break;
|
||||
case 2: icon = "calendar"; break;
|
||||
case 3: icon = "spinner"; break;
|
||||
case 4: icon = "check"; break;
|
||||
case 5: icon = "times"; break;
|
||||
case 6: icon = "times"; break;
|
||||
default: icon = "question";
|
||||
}
|
||||
</script>
|
||||
|
||||
<StatusColor status={status}>
|
||||
<EntryBgIcon name={icon} />
|
||||
</StatusColor>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
import type Status from "$lib/models/status";
|
||||
import StatusColor from "./StatusColor.svelte";
|
||||
import StatusIcon from "./StatusIcon.svelte";
|
||||
import StatusText from "./StatusText.svelte";
|
||||
|
||||
export let status: Status
|
||||
</script>
|
||||
|
||||
<div class="entry-status">
|
||||
<StatusColor status={status}>
|
||||
<StatusIcon status={status} />
|
||||
<StatusText status={status} />
|
||||
</StatusColor>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
@import "../colors.sass";
|
||||
|
||||
div.entry-status {
|
||||
font-size: 0.75em;
|
||||
font-weight: 600;
|
||||
opacity: $opacity-entry5;
|
||||
|
||||
:global(.icon) {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,39 @@
|
||||
<script lang="ts">
|
||||
export let subtitle: string = "";
|
||||
export let fullwidth: boolean = false;
|
||||
</script>
|
||||
|
||||
<div class="header-wrapper" class:fullwidth>
|
||||
<h1><slot></slot></h1>
|
||||
<h2>{subtitle}</h2>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
div.header-wrapper {
|
||||
&.fullwidth {
|
||||
width: 180ch;
|
||||
max-width: 95%;
|
||||
margin: auto;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0.333em 0;
|
||||
margin-bottom: 0;
|
||||
font-size: 3em;
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1em;
|
||||
margin: 1em 0;
|
||||
margin-top: 0;
|
||||
font-style: italic;
|
||||
font-weight: 100;
|
||||
|
||||
&:empty {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,71 @@
|
||||
<script lang="ts">
|
||||
import Icon from "fa-svelte";
|
||||
|
||||
export let name: IconName = "question";
|
||||
export let block: boolean = false;
|
||||
</script>
|
||||
|
||||
{#if block}
|
||||
<div>
|
||||
<Icon class="icon" icon={icons[name] || icons.question} />
|
||||
</div>
|
||||
{:else}
|
||||
<Icon class="icon" icon={icons[name] || icons.question} />
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
div {
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script lang="ts" context="module">
|
||||
import { faQuestion } from "@fortawesome/free-solid-svg-icons/faQuestion";
|
||||
import { faPlus } from "@fortawesome/free-solid-svg-icons/faPlus";
|
||||
import { faPen } from "@fortawesome/free-solid-svg-icons/faPen";
|
||||
import { faArchive } from "@fortawesome/free-solid-svg-icons/faArchive";
|
||||
import { faCheckToSlot } from "@fortawesome/free-solid-svg-icons/faCheckToSlot";
|
||||
import { faCog } from "@fortawesome/free-solid-svg-icons/faCog";
|
||||
import { faLink } from "@fortawesome/free-solid-svg-icons/faLink";
|
||||
import { faStar } from "@fortawesome/free-solid-svg-icons/faStar";
|
||||
import { faTimes } from "@fortawesome/free-solid-svg-icons/faTimes";
|
||||
import { faSpinner } from "@fortawesome/free-solid-svg-icons/faSpinner";
|
||||
import { faHourglass } from "@fortawesome/free-solid-svg-icons/faHourglass";
|
||||
import { faCalendar } from "@fortawesome/free-solid-svg-icons/faCalendar";
|
||||
import { faExpand } from "@fortawesome/free-solid-svg-icons/faExpand";
|
||||
import { faSearch } from "@fortawesome/free-solid-svg-icons/faSearch";
|
||||
import { faClock } from "@fortawesome/free-solid-svg-icons/faClock";
|
||||
import { faThumbtack } from "@fortawesome/free-solid-svg-icons/faThumbtack";
|
||||
import { faHistory } from "@fortawesome/free-solid-svg-icons/faHistory";
|
||||
import { faLightbulb } from "@fortawesome/free-solid-svg-icons/faLightbulb";
|
||||
import { faChevronRight } from "@fortawesome/free-solid-svg-icons/faChevronRight";
|
||||
import { faChevronDown } from "@fortawesome/free-solid-svg-icons/faChevronDown";
|
||||
|
||||
const icons = {
|
||||
"clock": faClock,
|
||||
"thumbtack": faThumbtack,
|
||||
"history": faHistory,
|
||||
"question": faQuestion,
|
||||
"plus": faPlus,
|
||||
"pen": faPen,
|
||||
"archive": faArchive,
|
||||
"check": faCheckToSlot,
|
||||
"cog": faCog,
|
||||
"link": faLink,
|
||||
"star": faStar,
|
||||
"times": faTimes,
|
||||
"lightbulb": faLightbulb,
|
||||
"spinner": faSpinner,
|
||||
"hourglass": faHourglass,
|
||||
"calendar": faCalendar,
|
||||
"expand": faExpand,
|
||||
"search": faSearch,
|
||||
"chevron_right": faChevronRight,
|
||||
"chevron_down": faChevronDown,
|
||||
};
|
||||
|
||||
export type IconName = keyof typeof icons;
|
||||
|
||||
export const iconNames = Object.keys(icons).sort() as IconName[];
|
||||
export const DEFAULT_ICON: IconName = "question";
|
||||
</script>
|
||||
@@ -0,0 +1,67 @@
|
||||
<script lang="ts">
|
||||
import type Status from "$lib/models/status";
|
||||
import type { IconName } from "./Icon.svelte";
|
||||
import Icon from "./Icon.svelte";
|
||||
import StatusColor from "./StatusColor.svelte";
|
||||
import StatusIcon from "./StatusIcon.svelte";
|
||||
import StatusText from "./StatusText.svelte";
|
||||
|
||||
export let status: Status | null = null;
|
||||
export let expanded: boolean | null = null;
|
||||
export let title: string = "";
|
||||
|
||||
let expandIcon: IconName;
|
||||
|
||||
function onClick() {
|
||||
if (expanded !== null) {
|
||||
expanded = !expanded;
|
||||
}
|
||||
}
|
||||
|
||||
$: expandIcon = expanded ? "chevron_down" : "chevron_right";
|
||||
</script>
|
||||
|
||||
<div class="category">
|
||||
<div on:click={onClick} class="category-header">
|
||||
{#if expanded !== null}
|
||||
<Icon name={expandIcon} />
|
||||
{/if}
|
||||
{#if status !== null}
|
||||
<StatusColor status={status}>
|
||||
<StatusIcon status={status} />
|
||||
<StatusText status={status} />
|
||||
</StatusColor>
|
||||
{:else}
|
||||
<span>{title}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if expanded !== false}
|
||||
<div class="category-body">
|
||||
<slot></slot>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
@import "../colors.sass";
|
||||
|
||||
div.category {
|
||||
border-left: 3px solid $color-entry1;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
div.category-body {
|
||||
margin-top: 0.1em;
|
||||
}
|
||||
|
||||
div.category-header {
|
||||
padding-left: 0.5ch;
|
||||
font-weight: 600;
|
||||
user-select: none;
|
||||
opacity: $opacity-entry4;
|
||||
|
||||
:global(.icon) {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,77 @@
|
||||
<script lang="ts">
|
||||
import { page } from "$app/stores";
|
||||
|
||||
export let href: string = "";
|
||||
export let subtitle: string = "";
|
||||
|
||||
let selected: boolean;
|
||||
$: selected = $page.url.pathname === href;
|
||||
</script>
|
||||
|
||||
{#if !!href}
|
||||
<a href={href}>
|
||||
<div on:click class="menu-item" class:selected>
|
||||
<div class="subtitle">{subtitle}</div>
|
||||
<div><slot></slot></div>
|
||||
</div>
|
||||
</a>
|
||||
{:else}
|
||||
<div on:click class="menu-item" class:selected>
|
||||
<div class="subtitle">{subtitle}</div>
|
||||
<div><slot></slot></div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style lang="scss">
|
||||
@import "../colors.sass";
|
||||
|
||||
div.menu-item {
|
||||
color: $color-entry9;
|
||||
font-size: 0.8em;
|
||||
padding: 0.15em 0;
|
||||
padding-left: 0.5ch;
|
||||
|
||||
transition: 0.25s;
|
||||
|
||||
&.selected {
|
||||
color: $color-entry13;
|
||||
background-color: $color-entry0-transparent;
|
||||
}
|
||||
|
||||
> div {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
> div {
|
||||
display: block;
|
||||
}
|
||||
|
||||
> div.subtitle {
|
||||
font-size: 0.75em;
|
||||
}
|
||||
}
|
||||
|
||||
div.subtitle {
|
||||
color: $color-entry5;
|
||||
|
||||
&:empty {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: $color-entry13;
|
||||
background-color: $color-entry1-transparent;
|
||||
|
||||
div.subtitle {
|
||||
color: $color-entry8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,44 @@
|
||||
<script lang="ts">
|
||||
import type Status from "$lib/models/status";
|
||||
|
||||
export let status: Status;
|
||||
</script>
|
||||
|
||||
<span class="status-color status-{status}"><slot></slot></span>
|
||||
|
||||
<style lang="scss">
|
||||
// Blocked = 0
|
||||
span.status-color.status-0 {
|
||||
color: #78c9ff;
|
||||
}
|
||||
|
||||
// Available = 1
|
||||
span.status-color.status-1 {
|
||||
color: #e7e55e;
|
||||
}
|
||||
|
||||
// Background = 2
|
||||
span.status-color.status-2 {
|
||||
color: #e7a75e;
|
||||
}
|
||||
|
||||
// Active = 3
|
||||
span.status-color.status-3 {
|
||||
color: #bdbdbd;
|
||||
}
|
||||
|
||||
// Completed = 4
|
||||
span.status-color.status-4 {
|
||||
color: #78ff78;
|
||||
}
|
||||
|
||||
// Failed = 5
|
||||
span.status-color.status-5 {
|
||||
color: #852a24;
|
||||
}
|
||||
|
||||
// Dropped = 6
|
||||
span.status-color.status-6 {
|
||||
color: #e75ed0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import type Status from "$lib/models/status";
|
||||
import Icon, { type IconName } from "./Icon.svelte";
|
||||
|
||||
export let status: Status;
|
||||
export let block: boolean = false;
|
||||
</script>
|
||||
|
||||
<Icon block={block} name={STATUS_ICONS[status]} />
|
||||
|
||||
<script lang="ts" context="module">
|
||||
const STATUS_ICONS: Record<Status, IconName> = {
|
||||
0: "hourglass",
|
||||
1: "lightbulb",
|
||||
2: "calendar",
|
||||
3: "spinner",
|
||||
4: "check",
|
||||
5: "times",
|
||||
6: "times",
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,19 @@
|
||||
<script lang="ts">
|
||||
import type Status from "$lib/models/status";
|
||||
|
||||
export let status: Status;
|
||||
</script>
|
||||
|
||||
<span>{STATUS_NAMES[status]}</span>
|
||||
|
||||
<script lang="ts" context="module">
|
||||
const STATUS_NAMES: Record<Status, string> = {
|
||||
0: "Blocked",
|
||||
1: "Available",
|
||||
2: "Background",
|
||||
3: "Active",
|
||||
4: "Completed",
|
||||
5: "Failed",
|
||||
6: "Dropped",
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { Database } from "./database/interfaces";
|
||||
import MysqlDB from "./database/mysql/database";
|
||||
|
||||
let databasePromise: Promise<Database> | null = null;
|
||||
let databaseTime: number = 0;
|
||||
|
||||
const config = {
|
||||
database() {
|
||||
if (databasePromise == null || Date.now() < (databaseTime - 60000)) {
|
||||
databasePromise = MysqlDB.connectEnv();
|
||||
databaseTime = Date.now();
|
||||
}
|
||||
|
||||
return databasePromise;
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { ScopeEntry, ScopeInput } from "$lib/models/scope";
|
||||
import type Scope from "$lib/models/scope";
|
||||
import type { StatEntry } from "$lib/models/stat";
|
||||
import type Stat from "$lib/models/stat";
|
||||
|
||||
export class NotFoundError extends Error {
|
||||
constructor(subject: string) {
|
||||
super(`${subject} not found`);
|
||||
}
|
||||
}
|
||||
|
||||
export interface Database {
|
||||
userId: string
|
||||
|
||||
scopes(): ScopeRepo
|
||||
stats(scopeId: number): StatRepo
|
||||
withUser(userId: string): Database
|
||||
}
|
||||
|
||||
export interface ScopeRepo {
|
||||
userId: string
|
||||
|
||||
find(id: number): Promise<Scope>
|
||||
list(): Promise<ScopeEntry[]>
|
||||
create(input: ScopeInput): Promise<Scope>
|
||||
update(id: number, input: Partial<ScopeInput>): Promise<Scope>
|
||||
delete(id: number): Promise<void>
|
||||
}
|
||||
|
||||
export interface StatRepo {
|
||||
userId: string
|
||||
scopeId: number
|
||||
|
||||
find(id: number): Promise<Stat>
|
||||
findEntries(...ids: number[]): Promise<StatEntry[]>
|
||||
list(): Promise<Stat[]>
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import {createPool} from "mysql2/promise"
|
||||
import type {Pool} from "mysql2/promise";
|
||||
|
||||
import type { Database, ScopeRepo, StatRepo } from "../interfaces";
|
||||
import MysqlDBScopes from "./scopes";
|
||||
|
||||
|
||||
export default class MysqlDB implements Database {
|
||||
connection: Pool
|
||||
userId: string;
|
||||
|
||||
private constructor(userId: string, connection: Pool) {
|
||||
this.userId = userId;
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
scopes(): ScopeRepo {
|
||||
return new MysqlDBScopes(this.connection, this.userId);
|
||||
}
|
||||
stats(scopeId: number): StatRepo {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
withUser(userId: string): Database {
|
||||
return new MysqlDB(userId, this.connection);
|
||||
}
|
||||
|
||||
static async connectEnv(): Promise<MysqlDB> {
|
||||
return this.connect(
|
||||
process.env.STUFFLOG3_MYSQL_HOST,
|
||||
parseInt(process.env.STUFFLOG3_MYSQL_PORT),
|
||||
process.env.STUFFLOG3_MYSQL_USERNAME,
|
||||
process.env.STUFFLOG3_MYSQL_PASSWORD,
|
||||
process.env.STUFFLOG3_MYSQL_SCHEMA,
|
||||
)
|
||||
}
|
||||
|
||||
static async connect(host: string, port: number, user: string, password: string, database: string): Promise<MysqlDB> {
|
||||
const connection = await createPool({
|
||||
host, user, database, password, port,
|
||||
waitForConnections: true,
|
||||
connectionLimit: 20,
|
||||
queueLimit: 0,
|
||||
});
|
||||
|
||||
return new MysqlDB("", connection);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import type {Pool} from "mysql2/promise";
|
||||
|
||||
import type Scope from "$lib/models/scope";
|
||||
import type { ScopeEntry, ScopeInput } from "$lib/models/scope";
|
||||
import type { ScopeRepo } from "../interfaces";
|
||||
|
||||
export default class MysqlDBScopes implements ScopeRepo {
|
||||
userId: string;
|
||||
connection: Pool;
|
||||
|
||||
constructor(connection: Pool, userId: string) {
|
||||
this.connection = connection;
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
async find(id: number): Promise<Scope> {
|
||||
const [[scopeRows], [projectRows], [statRows]] = await Promise.all([
|
||||
this.connection.execute(`
|
||||
SELECT scope.*, scope_member.name as display_name
|
||||
FROM scope
|
||||
INNER JOIN scope_member ON scope.id = scope_member.scope_id
|
||||
WHERE scope.id = ?
|
||||
`, [id]),
|
||||
this.connection.execute(`
|
||||
SELECT id,name,status
|
||||
FROM project
|
||||
WHERE scope_id = ?
|
||||
`, [id]).catch(() => []),
|
||||
this.connection.execute(`
|
||||
SELECT *
|
||||
FROM stats
|
||||
WHERE scope_id = ?
|
||||
`, [id]).catch(() => []),
|
||||
]);
|
||||
|
||||
const r = scopeRows[0] as any;
|
||||
if (!r) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
id: r.id,
|
||||
name: r.name,
|
||||
abbreviation: r.abbreviation,
|
||||
displayName: r.display_name,
|
||||
projects: ((projectRows||[]) as any[]).map((p:any) => ({
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
status: p.status,
|
||||
})),
|
||||
stats: ((statRows||[]) as any[]).map((s:any) => ({
|
||||
id: s.id,
|
||||
name: s.name,
|
||||
weight: s.weight,
|
||||
description: s.description,
|
||||
allowedAmounts: s.allowed_amounts || void(0),
|
||||
})),
|
||||
}
|
||||
}
|
||||
async list(): Promise<ScopeEntry[]> {
|
||||
const [rows] = await this.connection.execute(`
|
||||
SELECT scope.*, scope_member.name as display_name
|
||||
FROM scope
|
||||
INNER JOIN scope_member ON id = scope_id
|
||||
WHERE user_id = ?
|
||||
`, [this.userId]);
|
||||
|
||||
return (rows as any[]).map(r => ({
|
||||
id: r.id,
|
||||
name: r.name,
|
||||
abbreviation: r.abbreviation,
|
||||
displayName: r.display_name,
|
||||
}))
|
||||
}
|
||||
create(input: ScopeInput): Promise<Scope> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
update(id: number, input: Partial<ScopeInput>): Promise<Scope> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
delete(id: number): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { ProjectEntry } from "./project";
|
||||
import type { ScopeEntry } from "./scope";
|
||||
import type { StatProgressEntry } from "./stat";
|
||||
|
||||
export default interface Item {
|
||||
id: number
|
||||
name: string
|
||||
description: string
|
||||
createdTime: Date
|
||||
createdBy: string
|
||||
acquireTime?: Date
|
||||
scheduledDate?: string
|
||||
stats: StatProgressEntry[]
|
||||
}
|
||||
|
||||
export interface StandaloneItem extends Item {
|
||||
scope: ScopeEntry
|
||||
project?: ProjectEntry
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { ScopeEntry } from "./scope";
|
||||
import type { StatProgressEntry } from "./stat";
|
||||
import type Status from "./status";
|
||||
|
||||
export default interface Project extends ProjectEntry {
|
||||
description: string
|
||||
author: string
|
||||
|
||||
scope: ScopeEntry
|
||||
requirements: Requirement[]
|
||||
}
|
||||
|
||||
export interface ProjectEntry {
|
||||
id: number
|
||||
name: string
|
||||
status: Status
|
||||
}
|
||||
|
||||
export interface Requirement {
|
||||
id: number
|
||||
name: string
|
||||
description: string
|
||||
status: Status
|
||||
|
||||
stats: StatProgressEntry[]
|
||||
}
|
||||
|
||||
export interface StandaloneRequirement extends Requirement {
|
||||
scope: ScopeEntry
|
||||
project: ProjectEntry
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { ProjectEntry } from "./project";
|
||||
import type Stat from "./stat";
|
||||
|
||||
export default interface Scope extends ScopeEntry {
|
||||
projects: ProjectEntry[]
|
||||
stats: Stat[]
|
||||
}
|
||||
|
||||
export interface ScopeEntry {
|
||||
id: number
|
||||
name: string
|
||||
abbreviation: string
|
||||
displayName: string
|
||||
}
|
||||
|
||||
export interface ScopeInput {
|
||||
name: string
|
||||
abbreviation: string
|
||||
displayName: string
|
||||
}
|
||||
|
||||
export interface ScopeMember {
|
||||
name: string
|
||||
owner: boolean
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { StandaloneItem } from "./item";
|
||||
import type { StandaloneRequirement } from "./project";
|
||||
import type { ScopeEntry } from "./scope";
|
||||
import type { StatAggregate, StatProgressEntry } from "./stat";
|
||||
|
||||
export default interface Sprint {
|
||||
id: number
|
||||
name: string
|
||||
description: string
|
||||
from: string
|
||||
to: string
|
||||
timed: boolean
|
||||
coarse: boolean
|
||||
kind: "items" | "requirements" | "stats"
|
||||
scope: ScopeEntry
|
||||
items: StandaloneItem[]
|
||||
requirements: StandaloneRequirement[]
|
||||
aggregateRequired: number,
|
||||
aggregateName: string
|
||||
stats: StatProgressEntry[]
|
||||
}
|
||||
|
||||
export interface StandaloneSprint extends Sprint {
|
||||
scope: ScopeEntry
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
export default interface Stat extends StatEntry {
|
||||
description: string
|
||||
allowedAmounts?: Record<string, number>
|
||||
}
|
||||
|
||||
export interface StatEntry {
|
||||
id: number
|
||||
weight: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface StatProgressEntry extends StatEntry {
|
||||
acquired: number
|
||||
required: number
|
||||
}
|
||||
|
||||
export interface StatAggregate {
|
||||
acquired: number
|
||||
required: number
|
||||
}
|
||||
|
||||
const EXAMPLE2: Stat = {
|
||||
id: 12,
|
||||
name: "Assets",
|
||||
description: "The amount of 'assets' produced in the end. This does not contribute towards the weight",
|
||||
weight: 0,
|
||||
}
|
||||
|
||||
const EXAMPLE3: Stat = {
|
||||
id: 12,
|
||||
name: "Hard Surface Practice",
|
||||
description: "A value of the asset complexity, indicating how much general modeling practice is involved.",
|
||||
weight: 0.5,
|
||||
allowedAmounts: {
|
||||
"Rote": 1,
|
||||
"Novel": 2,
|
||||
"Tutorial": 4,
|
||||
"Difficult": 7,
|
||||
}
|
||||
}
|
||||
|
||||
const EXAMPLE: Stat = {
|
||||
id: 12,
|
||||
name: "Complexity Points",
|
||||
description: "A value of the asset complexity, indicating how much general modeling practice is involved.",
|
||||
weight: 1,
|
||||
allowedAmounts: {
|
||||
"Small": 1,
|
||||
"Moderate": 3,
|
||||
"Complex": 7,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
enum Status {
|
||||
Blocked = 0,
|
||||
Available = 1,
|
||||
Background = 2,
|
||||
Active = 3,
|
||||
Completed = 4,
|
||||
Failed = 5,
|
||||
Dropped = 6,
|
||||
}
|
||||
|
||||
|
||||
export interface LabeledStatus {
|
||||
value: Status
|
||||
name: string
|
||||
}
|
||||
|
||||
export const allStatuses: LabeledStatus[] = [
|
||||
{value: Status.Active, name: "Active"},
|
||||
{value: Status.Background, name: "Background"},
|
||||
{value: Status.Available, name: "Available"},
|
||||
{value: Status.Blocked, name: "Blocked"},
|
||||
{value: Status.Completed, name: "Completed"},
|
||||
{value: Status.Failed, name: "Failed"},
|
||||
{value: Status.Dropped, name: "Dropped"},
|
||||
];
|
||||
|
||||
// Blocked -> Available -> Active -> Completed
|
||||
// -> Failed
|
||||
// -> Dropped
|
||||
// -> Inactive -> Active
|
||||
|
||||
//
|
||||
// (X) Create basic furniture [S v] [/] [X]
|
||||
// ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
|
||||
// There needs to be a servicable library of
|
||||
// furntirue for this project
|
||||
//
|
||||
// Asset Complexity HS Practice
|
||||
// [ ] [ ] 0
|
||||
|
||||
export default Status
|
||||
@@ -0,0 +1,4 @@
|
||||
export default interface User {
|
||||
id: string
|
||||
name: string
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { writable, type Readable } from "svelte/store";
|
||||
|
||||
const currentTimeWritable = writable(new Date());
|
||||
|
||||
setInterval(() => {
|
||||
currentTimeWritable.set(new Date());
|
||||
}, 15000);
|
||||
|
||||
/**
|
||||
* A readable store that is updated twice every minute with the current time. Mainly for the progress
|
||||
* bar timers, but other coarse-grained timers could use it as well.
|
||||
*/
|
||||
const currentTime: Readable<Date> = { subscribe: currentTimeWritable.subscribe }
|
||||
|
||||
export default currentTime;
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { StatAggregate, StatProgressEntry } from "$lib/models/stat";
|
||||
|
||||
export function calculateAggregate(entries: StatProgressEntry[]): StatAggregate {
|
||||
return entries.reduce<StatAggregate>((acc, entry) => {
|
||||
return {
|
||||
acquired: acc.acquired + (entry.acquired * entry.weight),
|
||||
required: acc.required + (entry.required * entry.weight),
|
||||
}
|
||||
}, {acquired: 0, required: 0});
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { RequestHandler } from "@sveltejs/kit";
|
||||
|
||||
import config from "$lib/config";
|
||||
|
||||
export const get: RequestHandler = async({params, locals}) => {
|
||||
const scopeId = parseInt(params.scope);
|
||||
|
||||
const db = await config.database();
|
||||
const scope = await db.withUser(locals.user.id).scopes().find(scopeId)
|
||||
if (scope === null) {
|
||||
return {
|
||||
status: 404,
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
message: "Scope not found",
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
scope
|
||||
}),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<script lang="ts" context="module">
|
||||
import type { Load } from "@sveltejs/kit/types/internal";
|
||||
|
||||
export const load: Load = async({ fetch, params }) => {
|
||||
const res = await fetch(`/${params.scope}.json`);
|
||||
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
|
||||
return {
|
||||
props: {
|
||||
...data,
|
||||
},
|
||||
stuff: {
|
||||
scope: data.scope,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {fallthrough: true};
|
||||
}
|
||||
|
||||
const STATUS_ORDER = [
|
||||
Status.Active,
|
||||
Status.Background,
|
||||
Status.Available,
|
||||
Status.Blocked,
|
||||
Status.Completed,
|
||||
Status.Failed,
|
||||
Status.Dropped,
|
||||
]
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type Scope from "$lib/models/scope";
|
||||
import Header from "$lib/components/layout/Header.svelte";
|
||||
import Status from "$lib/models/status";
|
||||
import MenuCategory from "$lib/components/layout/MenuCategory.svelte";
|
||||
import type { ProjectEntry } from "$lib/models/project";
|
||||
import MenuItem from "$lib/components/layout/MenuItem.svelte";
|
||||
|
||||
export let scope: Scope;
|
||||
|
||||
let projects = scope.projects;
|
||||
let projectsByStatus: Record<Status, ProjectEntry[]>;
|
||||
|
||||
$: projectsByStatus = projects.reduce((p, c) => ({...p, [c.status]: [...p[c.status], c]}), {
|
||||
0: [], 1: [], 2: [], 3: [], 4: [], 5: [], 6: [],
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class="scope-layout">
|
||||
<div class="column main">
|
||||
<slot></slot>
|
||||
</div>
|
||||
<div class="column side">
|
||||
<Header subtitle={scope.name}>{scope.abbreviation}</Header>
|
||||
<MenuCategory title="Scope">
|
||||
<MenuItem href="/{scope.id}">Overview</MenuItem>
|
||||
<MenuItem href="/{scope.id}/history">History</MenuItem>
|
||||
</MenuCategory>
|
||||
{#each STATUS_ORDER as status (status)}
|
||||
{#if projectsByStatus[status].length > 0}
|
||||
<MenuCategory status={status}>
|
||||
{#each projectsByStatus[status] as project (project.id)}
|
||||
<MenuItem href="/{scope.id}/project/{project.id}" subtitle={
|
||||
project.name.includes(": ") ? project.name.split(": ")[0] + ": " : ""
|
||||
}>{
|
||||
project.name.includes(": ") ? project.name.split(": ").slice(1).join(": ") : project.name
|
||||
}</MenuItem>
|
||||
{/each}
|
||||
</MenuCategory>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
div.scope-layout {
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
flex-basis: 100%;
|
||||
flex: 1;
|
||||
|
||||
width: 90ch;
|
||||
max-width: 95%;
|
||||
margin: auto;
|
||||
|
||||
@media screen and (max-width: 600px) {
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
> div.column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 5;
|
||||
|
||||
&.side {
|
||||
flex: 2;
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
margin-top: 1em;
|
||||
font-size: 1em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<script lang="ts" context="module">
|
||||
import type { Load } from "@sveltejs/kit/types/internal";
|
||||
|
||||
export const load: Load = async({ stuff }) => {
|
||||
return {
|
||||
props: {
|
||||
scope: stuff.scope,
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import type Scope from "$lib/models/scope";
|
||||
import { page } from "$app/stores";
|
||||
|
||||
export let scope: Scope;
|
||||
</script>
|
||||
|
||||
<h1>{$page.stuff.scope.name}</h1>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,10 @@
|
||||
<script>
|
||||
import { page } from "$app/stores";
|
||||
import Backgrond from "$lib/components/layout/Backgrond.svelte";
|
||||
|
||||
let opacity = 0.175;
|
||||
|
||||
$: opacity = $page.url.pathname === "/" ? 0.3 : 0.2;
|
||||
</script>
|
||||
<Backgrond initialOrientation="landscape" opacity={opacity} />
|
||||
<slot></slot>
|
||||
@@ -0,0 +1,112 @@
|
||||
<script lang="ts" context="module">
|
||||
import type { LoadInput } from "@sveltejs/kit/types/internal";
|
||||
|
||||
export async function load({ url, fetch }: LoadInput ) {
|
||||
const res = await fetch("indexdata.json");
|
||||
|
||||
if (res.ok) {
|
||||
return {
|
||||
props: {
|
||||
...await res.json(),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
status: res.status,
|
||||
error: `Failed: ${res.status}`
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import ItemLink from "$lib/components/frontpage/ItemLink.svelte";
|
||||
import ScopeLink from "$lib/components/frontpage/ScopeLink.svelte";
|
||||
import RequirementLink from "$lib/components/frontpage/RequirementLink.svelte";
|
||||
import type { ScopeEntry } from "$lib/models/scope";
|
||||
import type { StandaloneItem } from "$lib/models/item";
|
||||
import type { StandaloneRequirement } from "$lib/models/project";
|
||||
import type { StandaloneSprint } from "$lib/models/sprint";
|
||||
import SprintLink from "$lib/components/frontpage/SprintLink.svelte";
|
||||
import Header from "$lib/components/layout/Header.svelte";
|
||||
export let scopes: ScopeEntry[] = [];
|
||||
export let items: StandaloneItem[] = [];
|
||||
export let requirements: StandaloneRequirement[] = [];
|
||||
export let sprints: StandaloneSprint[] = [];
|
||||
</script>
|
||||
|
||||
<Header fullwidth subtitle="Logging your stuff">Stufflog</Header>
|
||||
|
||||
<main>
|
||||
<div class="column">
|
||||
<div class="row">
|
||||
<h2>Scopes</h2>
|
||||
{#each scopes as scope (scope.id)}
|
||||
<ScopeLink scope={scope} />
|
||||
{/each}
|
||||
</div>
|
||||
<div class="row">
|
||||
<h2>Today</h2>
|
||||
<p>When you mark an item as aquired today, it will appear here.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="row">
|
||||
<h2>Suggestions</h2>
|
||||
{#each items as item (item.id)}
|
||||
<ItemLink item={item} />
|
||||
{/each}
|
||||
{#each requirements as requirement (requirement.id)}
|
||||
<RequirementLink requirement={requirement} />
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="row">
|
||||
<h2>Sprints</h2>
|
||||
{#each sprints as sprint (sprint.id)}
|
||||
<SprintLink sprint={sprint} />
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<style lang="scss">
|
||||
p {
|
||||
margin-top: 0.25em;
|
||||
}
|
||||
|
||||
main {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-basis: 100%;
|
||||
flex: 1;
|
||||
|
||||
width: 180ch;
|
||||
max-width: 95%;
|
||||
margin: auto;
|
||||
|
||||
@media screen and (max-width: 1000px) {
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
> div.column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-basis: 50;
|
||||
flex: 1;
|
||||
|
||||
> div.row {
|
||||
margin: 0.5em 1ch;
|
||||
padding: 0.5em 1ch;
|
||||
|
||||
> h2 {
|
||||
font-size: 1.25em;
|
||||
margin: 0;
|
||||
margin-bottom: 0.25em;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,190 @@
|
||||
import type { RequestHandler } from "@sveltejs/kit"
|
||||
|
||||
import type { StandaloneItem } from "$lib/models/item"
|
||||
import type { StandaloneRequirement } from "$lib/models/project"
|
||||
import type { ScopeEntry } from "$lib/models/scope"
|
||||
import Status from "$lib/models/status"
|
||||
import type { StandaloneSprint } from "$lib/models/sprint"
|
||||
|
||||
export const get: RequestHandler = async({locals}) => {
|
||||
const scopes: ScopeEntry[] = locals.scopes;
|
||||
|
||||
const items: StandaloneItem[] = [
|
||||
{
|
||||
id: 1, scope: scopes[0],
|
||||
name: "Table",
|
||||
description: "A table for the Redrock rec-room.",
|
||||
acquireDate: "2022-03-14T00:00:00Z",
|
||||
createdDate: new Date(Date.now() - 3623511).toISOString(),
|
||||
stats: [
|
||||
{id: 1, name: "Asset", weight: 0.2, required: 1, acquired: 1},
|
||||
{id: 2, name: "Complexity", weight: 1, required: 3, acquired: 5},
|
||||
],
|
||||
project: {
|
||||
id: 443,
|
||||
name: "3D Maps: Proving the concept",
|
||||
status: Status.Active
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 2, scope: scopes[0],
|
||||
name: "Datapad Set",
|
||||
description: "I need one, at least, but more is better.",
|
||||
createdDate: new Date(Date.now() - 3623511).toISOString(),
|
||||
stats: [
|
||||
{id: 1, name: "Asset", weight: 0.2, required: 1, acquired: 0},
|
||||
{id: 2, name: "Complexity", weight: 1, required: 3, acquired: 0},
|
||||
{id: 3, name: "Hard Surface", weight: 0.333, required: 1, acquired: 0},
|
||||
],
|
||||
project: {
|
||||
id: 443,
|
||||
name: "3D Maps: Proving the concept",
|
||||
status: Status.Active
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 3, scope: scopes[1],
|
||||
name: "Enila/Renala: Technicalities",
|
||||
description: "Renala is answering Leah's concern and takes the shift at the Respite.",
|
||||
createdDate: new Date(Date.now() - 3623511).toISOString(),
|
||||
stats: [
|
||||
{id: 1, name: "Story", weight: 3, required: 1, acquired: 0},
|
||||
{id: 2, name: "Story Word", weight: 0.002, required: 500, acquired: 0},
|
||||
],
|
||||
project: {
|
||||
id: 1,
|
||||
name: "Background Stories",
|
||||
status: Status.Active
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
const requirements: StandaloneRequirement[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Basic Furniture",
|
||||
description: "I need a lot of it.",
|
||||
project: {
|
||||
id: 443,
|
||||
name: "3D Maps: Proving the concept",
|
||||
status: Status.Active
|
||||
},
|
||||
status: Status.Background,
|
||||
stats: [
|
||||
{id: 1, name: "Asset", weight: 0.2, acquired: 8, required: 15},
|
||||
{id: 2, name: "Complexity", weight: 1, acquired: 69, required: 30},
|
||||
{id: 3, name: "Hard Surface", weight: 0.333, acquired: 20, required: 5},
|
||||
],
|
||||
scope: scopes[0],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Catching Up",
|
||||
description: "Write a few stories to get back up to speed with less written characters.",
|
||||
project: {
|
||||
id: 1,
|
||||
name: "Background Stories",
|
||||
status: Status.Active
|
||||
},
|
||||
status: Status.Completed,
|
||||
stats: [
|
||||
{id: 1, name: "Story", weight: 3, required: 10, acquired: 3},
|
||||
{id: 2, name: "Story Word", weight: 0.002, required: 5000, acquired: 2173},
|
||||
{id: 3, name: "Worldbuilding", weight: 0.5, required: 5, acquired: 1},
|
||||
],
|
||||
scope: scopes[1],
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Chapter 3",
|
||||
description: "it's go time",
|
||||
project: {
|
||||
id: 1,
|
||||
name: "Wenera's Job",
|
||||
status: Status.Active
|
||||
},
|
||||
status: Status.Available,
|
||||
stats: [
|
||||
{id: 1, name: "Story", weight: 3, required: 5, acquired: 1},
|
||||
{id: 2, name: "Story Word", weight: 0.002, required: 4000, acquired: 759},
|
||||
],
|
||||
scope: scopes[1],
|
||||
}
|
||||
]
|
||||
|
||||
const sprints: StandaloneSprint[] = [
|
||||
{
|
||||
id: 553,
|
||||
name: "March Sprint",
|
||||
description: "Hey kid, wanna model some trees?",
|
||||
from: "2022-03-01T00:00:00+0200",
|
||||
to: "2022-03-30T23:59:59+0200",
|
||||
coarse: false,
|
||||
kind: "stats",
|
||||
scope: scopes[0],
|
||||
timed: true,
|
||||
stats: [
|
||||
{id: 1, name: "Asset", weight: 0, acquired: 13, required: 15},
|
||||
{id: 2, name: "Complexity", weight: 1, acquired: 37, required: 30},
|
||||
{id: 3, name: "Hard Surface", weight: 0.25, acquired: 8, required: 5},
|
||||
{id: 4, name: "UV Mapping", weight: 0.25, acquired: 3, required: 5},
|
||||
],
|
||||
items: [],
|
||||
requirements: [],
|
||||
aggregateRequired: 30,
|
||||
aggregateName: "3D Modeling",
|
||||
},
|
||||
{
|
||||
id: 643,
|
||||
name: "March Sprint",
|
||||
description: "Crank out stories",
|
||||
from: "2022-03-01T00:00:00+0200",
|
||||
to: "2022-03-30T23:59:59+0200",
|
||||
coarse: false,
|
||||
kind: "requirements",
|
||||
scope: scopes[1],
|
||||
timed: true,
|
||||
stats: [],
|
||||
items: [],
|
||||
requirements: [
|
||||
requirements[1],
|
||||
requirements[2],
|
||||
],
|
||||
aggregateRequired: 0,
|
||||
aggregateName: "",
|
||||
},
|
||||
{
|
||||
id: 771,
|
||||
name: "March Sprint",
|
||||
description: "Do these",
|
||||
from: "2022-03-01T00:00:00+0200",
|
||||
to: "2022-03-30T23:59:59+0200",
|
||||
coarse: false,
|
||||
kind: "items",
|
||||
scope: scopes[0],
|
||||
timed: true,
|
||||
stats: [
|
||||
{id: 1, name: "Asset", weight: 0.2, required: 2, acquired: 1},
|
||||
{id: 2, name: "Complexity", weight: 1, required: 8, acquired: 5},
|
||||
{id: 3, name: "Hard Surface", weight: 0.333, required: 1, acquired: 0},
|
||||
],
|
||||
items: [
|
||||
items[0],
|
||||
items[1],
|
||||
],
|
||||
requirements: [],
|
||||
aggregateRequired: 0,
|
||||
aggregateName: "",
|
||||
}
|
||||
]
|
||||
|
||||
return {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
scopes, items, requirements, sprints
|
||||
}),
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 495 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,15 @@
|
||||
import adapter from '@sveltejs/adapter-auto';
|
||||
import preprocess from 'svelte-preprocess';
|
||||
|
||||
/** @type {import('@sveltejs/kit').Config} */
|
||||
const config = {
|
||||
// Consult https://github.com/sveltejs/svelte-preprocess
|
||||
// for more information about preprocessors
|
||||
preprocess: preprocess(),
|
||||
|
||||
kit: {
|
||||
adapter: adapter()
|
||||
}
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "node",
|
||||
"module": "es2020",
|
||||
"lib": ["es2020", "DOM"],
|
||||
"target": "es2020",
|
||||
/**
|
||||
svelte-preprocess cannot figure out whether you have a value or a type, so tell TypeScript
|
||||
to enforce using \`import type\` instead of \`import\` for Types.
|
||||
*/
|
||||
"importsNotUsedAsValues": "error",
|
||||
/**
|
||||
TypeScript doesn't know about import usages in the template because it only sees the
|
||||
script of a Svelte file. Therefore preserve all value imports. Requires TS 4.5 or higher.
|
||||
*/
|
||||
"preserveValueImports": true,
|
||||
"isolatedModules": true,
|
||||
"resolveJsonModule": true,
|
||||
/**
|
||||
To have warnings/errors of the Svelte compiler at the correct position,
|
||||
enable source maps by default.
|
||||
*/
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"baseUrl": ".",
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"paths": {
|
||||
"$lib": ["src/lib"],
|
||||
"$lib/*": ["src/lib/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.ts", "src/**/*.svelte"]
|
||||
}
|
||||
Reference in New Issue
Block a user