Skip to content

Commit 0a9360b

Browse files
committed
Added markation of type plus filtering
1 parent f629624 commit 0a9360b

File tree

4 files changed

+55
-10
lines changed

4 files changed

+55
-10
lines changed

src/lib/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,10 @@ export function calculateMarketPrice(
7878
return Math.round(-m * shopScoreRemainder + maxPrice);
7979
}
8080
}
81+
82+
export function getProjectLinkType(editorFileType: string | null, editorUrl: string | null, uploadedFileUrl: string | null): string {
83+
if (editorFileType === 'url' && editorUrl?.includes('cad.onshape.com')) return 'onshape';
84+
if (editorFileType === 'url' && editorUrl?.includes('autodesk360.com')) return 'fusion-link';
85+
if (editorFileType === 'upload' && uploadedFileUrl?.endsWith('.f3d')) return 'fusion-file';
86+
return 'unknown';
87+
}

src/routes/dashboard/admin/review/+page.server.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export async function load({ locals }) {
1212
throw error(403, { message: 'oi get out' });
1313
}
1414

15-
const projects = await getProjects(['submitted'], [], []);
15+
const projects = await getProjects(['submitted'], [], [], []);
1616

1717
const allProjects = await db
1818
.select({
@@ -61,14 +61,18 @@ export const actions = {
6161
return parseInt(userId.toString());
6262
});
6363

64-
const projects = await getProjects(statusFilter, projectFilter, userFilter);
64+
const typeFilter = data.getAll('type') as string[];
65+
66+
67+
const projects = await getProjects(statusFilter, projectFilter, userFilter, typeFilter);
6568

6669
return {
6770
projects,
6871
fields: {
6972
status: statusFilter,
7073
project: projectFilter,
71-
user: userFilter
74+
user: userFilter,
75+
type: typeFilter
7276
}
7377
};
7478
}
@@ -77,7 +81,8 @@ export const actions = {
7781
async function getProjects(
7882
statusFilter: (typeof project.status._.data)[],
7983
projectFilter: number[],
80-
userFilter: number[]
84+
userFilter: number[],
85+
typeFilter: string[]
8186
) {
8287
return await db
8388
.select({
@@ -86,8 +91,11 @@ async function getProjects(
8691
name: project.name,
8792
description: project.description,
8893
url: project.url,
89-
createdAt: project.createdAt,
90-
status: project.status
94+
editorFileType: project.editorFileType,
95+
editorUrl: project.editorUrl,
96+
uploadedFileUrl: project.uploadedFileUrl,
97+
status: project.status,
98+
createdAt: project.createdAt
9199
},
92100
user: {
93101
id: user.id,
@@ -112,6 +120,9 @@ async function getProjects(
112120
project.name,
113121
project.description,
114122
project.url,
123+
project.editorFileType,
124+
project.editorUrl,
125+
project.uploadedFileUrl,
115126
project.createdAt,
116127
project.status,
117128
user.id,

src/routes/dashboard/admin/review/+page.svelte

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<script lang="ts">
22
import { enhance } from '$app/forms';
33
import Head from '$lib/components/Head.svelte';
4-
import { projectStatuses } from '$lib/utils.js';
4+
import { projectStatuses, getProjectLinkType } from '$lib/utils.js';
55
import { ExternalLink } from '@lucide/svelte';
66
import relativeDate from 'tiny-relative-date';
77
88
let { data, form } = $props();
99
1010
let projectSearch = $state('');
1111
let userSearch = $state('');
12+
let typeFilter = $state<string[]>([]);
1213
1314
let projects = $derived(form?.projects ?? data.projects);
1415
@@ -20,6 +21,12 @@
2021
let filteredUsers = $derived(
2122
data.users.filter((user) => user.name.toLowerCase().includes(userSearch.toLowerCase()))
2223
);
24+
let displayedProjects = $derived(
25+
projects.filter(p =>
26+
typeFilter.length === 0 ||
27+
typeFilter.includes(getProjectLinkType(p.project.editorFileType, p.project.editorUrl, p.project.uploadedFileUrl))
28+
)
29+
);
2330
2431
let formPending = $state(false);
2532
</script>
@@ -42,7 +49,7 @@
4249
};
4350
}}
4451
>
45-
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3">
52+
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-4">
4653
<!-- Project status -->
4754
<label class="flex flex-col gap-1">
4855
<span class="font-medium">Status</span>
@@ -103,6 +110,22 @@
103110
</select>
104111
</div>
105112
</label>
113+
<!-- Type-->
114+
<label class="flex flex-col gap-1">
115+
116+
<span class="font-medium">Type</span>
117+
<select
118+
class="h-40 grow border-3 border-primary-700 bg-primary-900 fill-primary-50 p-2 text-sm ring-primary-900 placeholder:text-primary-900 active:ring-3"
119+
name="type"
120+
bind:value={typeFilter}
121+
multiple
122+
>
123+
<option value="onshape" class="truncate">Onshape</option>
124+
<option value="fusion-link" class="truncate">Fusion Link</option>
125+
<option value="fusion-file" class="truncate">Fusion File</option>
126+
<option value="unknown" class="truncate">Unknown</option>
127+
</select>
128+
</label>
106129
</div>
107130
<button type="submit" class="button md primary mt-3 w-full" disabled={formPending}
108131
>Apply!</button
@@ -147,7 +170,7 @@
147170
</div>
148171
{:else}
149172
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2 2xl:grid-cols-3">
150-
{#each projects as project}
173+
{#each displayedProjects as project}
151174
<div
152175
class="themed-box relative flex flex-col p-3 shadow-lg/20 transition-all hover:scale-102"
153176
>
@@ -176,6 +199,9 @@
176199
{:else}
177200
<div class="mb-2"></div>
178201
{/if}
202+
<p class="text-sm">
203+
Type: {getProjectLinkType(project.project.editorFileType, project.project.editorUrl, project.project.uploadedFileUrl)}
204+
</p>
179205
<p class="text-sm">
180206
{project.devlogCount} journal{project.devlogCount !== 1 ? 's' : ''} ∙ {Math.floor(
181207
project.timeSpent / 60

src/routes/dashboard/admin/review/[id]/+page.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import Devlog from '$lib/components/Devlog.svelte';
44
import Head from '$lib/components/Head.svelte';
55
import { enhance } from '$app/forms';
6-
import { projectStatuses } from '$lib/utils.js';
6+
import { projectStatuses, getProjectLinkType} from '$lib/utils.js';
77
import ProjectLinks from '$lib/components/ProjectLinks.svelte';
88
import Spinny3DPreview from '$lib/components/Spinny3DPreview.svelte';
99
import { Download } from '@lucide/svelte';
@@ -49,6 +49,7 @@
4949
uploadedFileUrl={data.project.project.uploadedFileUrl}
5050
/>
5151
</div>
52+
<p class="text-sm">Type: {getProjectLinkType(data.project.project.editorFileType, data.project.project.editorUrl, data.project.project.uploadedFileUrl)}</p>
5253
</div>
5354

5455
<div>

0 commit comments

Comments
 (0)