Skip to content

Commit

Permalink
Partially implemented projects page
Browse files Browse the repository at this point in the history
  • Loading branch information
Joery-M committed Apr 15, 2024
1 parent e98d4ec commit 04287de
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/safelight/src/views/projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,22 @@
</template>

<script setup lang="ts">
import type { StoredProject } from '@safelight/shared/base/Storage';
import { Storage, type StoredProject } from '@safelight/shared/base/Storage';
import { DateTime } from 'luxon';
const projects = ref<StoredProject[]>([]);
onMounted(() => {
Storage.getStorage()
.getProjects()
.then((p) => {
projects.value = p;
})
.catch(() => {
});
});
function formatDateTime(dt: string) {
const date = DateTime.fromISO(dt).toLocal();
const thisYear = DateTime.now().year;
Expand Down
3 changes: 3 additions & 0 deletions packages/shared/src/Storage/IndexedDbStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export default class IndexedDbStorageController extends BaseStorageController {
}
});
}
getProjects(): Promise<StoredProject[]> {
return this.db.project.toArray();
}

async SaveMedia(media: Media | StoredMedia): Promise<SaveResults> {
const storedMedia: StoredMedia =
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/base/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default abstract class BaseStorageController {

abstract SaveProject(project: BaseProject): Promise<SaveResults>;
abstract LoadProject(projectId: string): Promise<BaseProject | undefined>;
abstract getProjects(): Promise<StoredProject[]>;

abstract SaveMedia(media: StoredMedia): Promise<SaveResults>;
abstract SaveMedia(media: Media): Promise<SaveResults>;
Expand Down

0 comments on commit 04287de

Please sign in to comment.