-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Arzte/wip/style-engine
Add menu to swap between different projects
- Loading branch information
Showing
6 changed files
with
147 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<template> | ||
<div class="dialog-container"> | ||
<div class="dialog bg-dark-subtle text-light"> | ||
<h5>Default Files</h5> | ||
<ul class="list-group mb-3"> | ||
<li | ||
v-for="projects in projectList.items" | ||
:key="projects.title" | ||
class="list-group-item" | ||
> | ||
<a | ||
href="#" | ||
:data-fileurl="projects.remoteFileUrl" | ||
@click.prevent="loadRemoteFile" | ||
> | ||
{{ projects.title }} | ||
</a> | ||
</li> | ||
</ul> | ||
<div | ||
v-if="isLoading" | ||
class="d-flex align-items-center justify-content-start gap-3 mb-3" | ||
> | ||
<div class="spinner-border text-primary" role="status"> | ||
<span class="visually-hidden">Loading...</span> | ||
</div> | ||
<strong>Loading ...</strong> | ||
</div> | ||
|
||
<h5>Load File</h5> | ||
<LoadProject /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ViewerProjectList } from 'composables/viewer'; | ||
import { useProjectRefs, useProjectStore } from '~/composables/store/project'; | ||
import { useViewerStore } from '~/composables/store/viewer'; | ||
const isLoading = ref<boolean>(false); | ||
const { projectList } = defineProps<{ | ||
projectList: ViewerProjectList; | ||
}>(); | ||
const { loadProject, unloadProject } = useProjectStore(); | ||
const { toggleProjectMenu } = useViewerStore(); | ||
const { isLoaded } = useProjectRefs(); | ||
const loadRemoteFile = async ({ target }: MouseEvent) => { | ||
if (target && target instanceof HTMLAnchorElement) { | ||
const fileURL = target.dataset.fileurl; | ||
if (!fileURL) return; | ||
isLoading.value = true; | ||
const result: any = await $fetch(fileURL, { parseResponse: JSON.parse }); | ||
if (!isLoaded.value) { | ||
loadProject(result, fileURL); | ||
} else { | ||
unloadProject(); | ||
// Wait for the unloadProject to finish before loading the new project | ||
nextTick(() => { | ||
if (!isLoaded.value) { | ||
loadProject(result, fileURL); | ||
toggleProjectMenu(false); | ||
} | ||
}); | ||
} | ||
isLoading.value = false; | ||
} | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@import '~/assets/css/bootstrap/config'; | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export type ViewerProject = { | ||
remoteFileUrl: string; | ||
title: string; | ||
}; | ||
|
||
export type ViewerProjectList = { | ||
items: ViewerProject[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters