Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drizzle/0036_for_printers_field.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "project" ADD COLUMN "for_printers" text DEFAULT '' NOT NULL;
1 change: 1 addition & 0 deletions src/lib/server/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const project = pgTable('project', {

name: text(),
description: text(),
forPrinters: text().notNull().default(''), // Notes for whoever prints this project

url: text(),

Expand Down
1 change: 1 addition & 0 deletions src/routes/dashboard/projects/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function load({ locals }) {
id: project.id,
name: project.name,
description: project.description,
forPrinters: project.forPrinters,

url: project.url,
editorFileType: project.editorFileType,
Expand Down
1 change: 1 addition & 0 deletions src/routes/dashboard/projects/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
let forPrinters = $state(data.project.forPrinters ?? '');
<script lang="ts">
import { Lock, ExternalLink, Link, Download, Search, X } from '@lucide/svelte';
import relativeDate from 'tiny-relative-date';
Expand Down
1 change: 1 addition & 0 deletions src/routes/dashboard/projects/[id]/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export async function load({ params, locals }) {
userId: queriedProject.project.userId,
name: queriedProject.project.name,
description: queriedProject.project.description,
forPrinters: queriedProject.project.forPrinters,

url: queriedProject.project.url,
editorFileType: queriedProject.project.editorFileType,
Expand Down
33 changes: 33 additions & 0 deletions src/routes/dashboard/projects/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
let lapseUrlValidFormat: boolean = $state(false);
let lapse: Lapse | null = $state(null);

let forPrintersOpen = $state(false);

function onchange() {
timeSpent = lapse?.ok
? lapse.timelapse.durationMins
Expand Down Expand Up @@ -156,6 +158,37 @@
{/each}
</p>

{#if data.project.forPrinters}
<div class="mt-2">
<button
type="button"
class="flex items-center gap-1 text-sm opacity-60 transition-opacity hover:opacity-100"
onclick={() => (forPrintersOpen = !forPrintersOpen)}
>
<span>For Printers</span>
<svg
class="h-4 w-4 transition-transform {forPrintersOpen ? 'rotate-180' : ''}"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<polyline points="6 9 12 15 18 9" />
</svg>
</button>
{#if forPrintersOpen}
<div class="themed-box mt-1 p-3 text-sm">
{#each data.project.forPrinters.split('\n') as line}
{line}<br />
{/each}
</div>
{/if}
</div>
{/if}

{#if data.project.userId === data.user.id}
<div class="mt-3 flex gap-2">
<a
Expand Down
6 changes: 5 additions & 1 deletion src/routes/dashboard/projects/[id]/ship/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export async function load({ params, locals }) {
id: project.id,
name: project.name,
description: project.description,
forPrinters: project.forPrinters,

url: project.url,
editorFileType: project.editorFileType,
Expand All @@ -51,6 +52,7 @@ export async function load({ params, locals }) {
project.id,
project.name,
project.description,
project.forPrinters,
project.url,
project.createdAt,
project.status
Expand Down Expand Up @@ -93,6 +95,7 @@ export const actions = {
const modelFile = data.get('model_file') as File;
const submitAsClub = data.get('submit_as_club') === 'true';
const doubleDippingWith = data.get('doubledip') as typeof project.doubleDippingWith._.data;
const forPrinters = (data.get('for_printers')?.toString() ?? '').slice(0, 3000);

const printablesUrlString =
printablesUrl && printablesUrl.toString() ? sanitizeUrl(printablesUrl.toString()) : null;
Expand Down Expand Up @@ -299,7 +302,8 @@ export const actions = {
uploadedFileUrl: editorFileExists ? editorFilePath : undefined,

modelFile: modelPath,
doubleDippingWith
doubleDippingWith,
forPrinters
})
.where(
and(
Expand Down
15 changes: 15 additions & 0 deletions src/routes/dashboard/projects/[id]/ship/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
let editorUploadFile = $state(null);
let modelFile = $state(null);
let submitAsClub = $state(false);
let forPrinters = $state(data.project.forPrinters ?? '');

let hasEditorFile = $derived((editorUrl || editorUploadFile) && !(editorUrl && editorUploadFile));

Expand Down Expand Up @@ -165,6 +166,20 @@
{/if}
</label>

<label class="mt-2 flex grow flex-col gap-1">
<p>For Printers <span class="opacity-50">(optional, max 3000 characters)</span></p>
<textarea
name="for_printers"
maxlength="3000"
placeholder="Any notes for whoever prints your model — tolerances, supports, material suggestions, etc."
bind:value={forPrinters}
class="themed-input-on-box min-h-24 resize-y"
></textarea>
<p class="mt-0.5 text-sm opacity-50">
Only visible on your project page, not on project cards. Shown to printers after review.
</p>
</label>

{#if data.clubMembership}
<div class="mt-1">
<p class="mb-1 font-bold">Submit as</p>
Expand Down