Skip to content

Commit

Permalink
feat(viewer): create model-viewer view (still empty for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichel committed Apr 14, 2021
1 parent 0980fdc commit d580137
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ViewerCard
:project="project"
:models="models"
@model-change="onModelChange"
@model-changed="onModelChange"
/>
<ModelLocation :project="project" :model="displayedModel" />
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
required: true
}
},
emits: ["model-change"],
emits: ["model-changed"],
setup(props, { emit }) {
const nbSlices = 15;
const container = ref(null);
Expand All @@ -94,7 +94,7 @@ export default {
watch(index, i => {
image.value = images.value[i];
emit("model-change", props.models[i]);
emit("model-changed", props.models[i]);
});
const previousImage = () => {
if (index.value > 0) index.value--;
Expand Down
42 changes: 33 additions & 9 deletions src/components/specific/models/viewer-card/ViewerCard.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<template>
<BIMDataCard class="viewer-card">
<template #left>
<BIMDataButton color="primary" fill radius @click="goToViewer">
<BIMDataButton color="primary" fill radius @click="goToModelViewer">
<BIMDataIcon name="show" size="xs" />
<span>{{ $t("ViewerCard.buttonOpen") }}</span>
</BIMDataButton>
</template>
<template #content>
<ViewerCardModelPreview
:models="models"
@model-change="$emit('model-change', $event)"
/>
<ViewerCardModelPreview :models="models" @model-changed="onModelChange" />
</template>
</BIMDataCard>
</template>

<script>
import { ref, watch } from "vue";
import { useRouter } from "vue-router";
import { routeNames } from "@/router";
// Components
import BIMDataButton from "@bimdata/design-system/dist/js/BIMDataComponents/vue3/BIMDataButton.js";
import BIMDataCard from "@bimdata/design-system/dist/js/BIMDataComponents/vue3/BIMDataCard.js";
Expand All @@ -39,12 +39,36 @@ export default {
required: true
}
},
emits: ["model-change"],
setup() {
const goToViewer = () => {};
emits: ["model-changed"],
setup(props, { emit }) {
const router = useRouter();
const currentModel = ref();
watch(
() => props.models,
() => (currentModel.value = props.models[0]),
{ immediate: true }
);
const onModelChange = model => {
currentModel.value = model;
emit("model-changed", model);
};
const goToModelViewer = () => {
router.push({
name: routeNames.modelViewer,
params: {
spaceID: props.project.cloud.id,
projectID: props.project.id,
modelID: currentModel.value.id
}
});
};
return {
goToViewer
goToModelViewer,
onModelChange
};
}
};
Expand Down
18 changes: 15 additions & 3 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ import { createRouter, createWebHistory } from "vue-router";
import { authGuard } from "./guards";
import {
dashboardResolver,
modelViewerResolver,
projectBoardResolver,
userProjectsResolver,
rootResolver,
spaceBoardResolver,
userProjectsResolver,
userSpacesResolver
} from "./resolvers";
// Components
import Layout from "@/Layout";
import Dashboard from "@/views/dashboard/Dashboard";
import ModelViewer from "@/views/model-viewer/ModelViewer";
import OidcCallback from "@/views/oidc-callback/OidcCallback";
import OidcCallbackError from "@/views/oidc-callback-error/OidcCallbackError";
import ProjectBoard from "@/views/project-board/ProjectBoard";
import UserProjects from "@/views/user-projects/UserProjects";
import SpaceBoard from "@/views/space-board/SpaceBoard";
import UserProjects from "@/views/user-projects/UserProjects";
import UserSpaces from "@/views/user-spaces/UserSpaces";

const routeNames = Object.freeze({
Expand All @@ -26,7 +28,8 @@ const routeNames = Object.freeze({
userSpaces: "user-spaces",
spaceBoard: "space-board",
userProjects: "user-projects",
projectBoard: "project-board"
projectBoard: "project-board",
modelViewer: "model-viewer"
});

const routes = [
Expand Down Expand Up @@ -81,6 +84,15 @@ const routes = [
resolver: projectBoardResolver,
breadcrumb: "BreadcrumbProjectSelector"
}
},
{
path:
"/spaces/:spaceID(\\d+)/projects/:projectID(\\d+)/viewer/:modelID(\\d+)",
name: routeNames.modelViewer,
component: ModelViewer,
meta: {
resolver: modelViewerResolver
}
}
]
},
Expand Down
82 changes: 46 additions & 36 deletions src/router/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const createViewResolver = resolve => {
loading.value = true;
await resolve(route);
loading.value = false;
return;
};
};

Expand Down Expand Up @@ -47,48 +46,58 @@ const userProjectsResolver = createViewResolver(async () => {
});

const spaceBoardResolver = createViewResolver(async route => {
const {
currentSpace,
loadUserSpaces,
loadSpaceUsers,
loadSpaceInvitations,
selectSpace
} = useSpaces();
const { loadUserProjects, loadSpaceProjects } = useProjects();
const spaces = useSpaces();
const projects = useProjects();

await loadUserSpaces();
await loadUserProjects();
await selectSpace(+route.params.spaceID);
loadSpaceProjects(currentSpace.value);
if (currentSpace.value.isAdmin) {
await loadSpaceUsers(currentSpace.value);
await loadSpaceInvitations(currentSpace.value);
await spaces.loadUserSpaces();
await projects.loadUserProjects();

spaces.selectSpace(+route.params.spaceID);
projects.loadSpaceProjects(spaces.currentSpace.value);

if (spaces.currentSpace.value.isAdmin) {
await spaces.loadSpaceUsers(spaces.currentSpace.value);
await spaces.loadSpaceInvitations(spaces.currentSpace.value);
}
return;
});

const projectBoardResolver = createViewResolver(async route => {
const { currentSpace, loadUserSpaces, selectSpace } = useSpaces();
const {
currentProject,
loadUserProjects,
loadSpaceProjects,
loadProjectUsers,
loadProjectInvitations,
selectProject
} = useProjects();
const { loadProjectModels } = useModels();
const spaces = useSpaces();
const projects = useProjects();
const models = useModels();

await loadUserSpaces();
await loadUserProjects();
await selectSpace(+route.params.spaceID);
loadSpaceProjects(currentSpace.value);
await selectProject(+route.params.projectID);
if (currentProject.value.isAdmin) {
await loadProjectUsers(currentProject.value);
await loadProjectInvitations(currentProject.value);
await spaces.loadUserSpaces();
await projects.loadUserProjects();

spaces.selectSpace(+route.params.spaceID);
projects.loadSpaceProjects(spaces.currentSpace.value);

projects.selectProject(+route.params.projectID);
await models.loadProjectModels(projects.currentProject.value);

if (projects.currentProject.value.isAdmin) {
await projects.loadProjectUsers(projects.currentProject.value);
await projects.loadProjectInvitations(projects.currentProject.value);
}
await loadProjectModels(currentProject.value);
return;
});

const modelViewerResolver = createViewResolver(async route => {
const spaces = useSpaces();
const projects = useProjects();
const models = useModels();

await spaces.loadUserSpaces();
await projects.loadUserProjects();

spaces.selectSpace(+route.params.spaceID);
projects.loadSpaceProjects(spaces.currentSpace.value);

projects.selectProject(+route.params.projectID);
await models.loadProjectModels(projects.currentProject.value);

// models.selectModel(+route.params.modelID); ???
return;
});

Expand All @@ -98,5 +107,6 @@ export {
userSpacesResolver,
userProjectsResolver,
spaceBoardResolver,
projectBoardResolver
projectBoardResolver,
modelViewerResolver
};
11 changes: 11 additions & 0 deletions src/views/model-viewer/ModelViewer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.model-viewer-view {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;

display: flex;
justify-content: center;
align-items: center;
}
16 changes: 16 additions & 0 deletions src/views/model-viewer/ModelViewer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<div class="model-viewer-view">
<!-- TODO -->
BIMData Viewer
</div>
</template>

<script>
export default {
setup() {
// TODO
}
};
</script>

<style scoped lang="scss" src="./ModelViewer.scss"></style>

0 comments on commit d580137

Please sign in to comment.