Skip to content

Commit

Permalink
feat(photosphere): add photosphere and photosphere building support
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasRichel committed Sep 2, 2024
1 parent 714b16f commit 74f5815
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@
:file="file"
:loading="loadingFileIds.includes(file.id)"
@create-model="$emit('create-model', file)"
@create-photosphere="$emit('create-photosphere', file)"
@delete="$emit('delete', file)"
@download="$emit('download', file)"
@file-clicked="$emit('file-clicked', file)"
Expand Down Expand Up @@ -283,6 +284,7 @@ export default {
},
emits: [
"create-model",
"create-photosphere",
"delete",
"download",
"file-clicked",
Expand Down
15 changes: 12 additions & 3 deletions src/components/specific/files/files-manager/FilesManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
:foldersToUpload="foldersToUpload"
@back-parent-folder="backToParent"
@create-model="createModelFromFile"
@create-photosphere="createModelFromFile($event, MODEL_TYPE.PHOTOSPHERE)"
@delete="openFileDeleteModal([$event])"
@download="downloadFiles([$event])"
@dragover.prevent="() => {}"
Expand All @@ -100,6 +101,7 @@
:loadingFileIds="loadingFileIds"
:files="displayedFiles"
@create-model="createModelFromFile"
@create-photosphere="createModelFromFile($event, MODEL_TYPE.PHOTOSPHERE)"
@delete="openFileDeleteModal([$event])"
@download="downloadFiles([$event])"
@file-clicked="onFileSelected"
Expand Down Expand Up @@ -191,6 +193,7 @@ import { useAppSidePanel } from "../../app/app-side-panel/app-side-panel.js";
import { useSession } from "../../../../composables/session.js";
import { useListFilter } from "../../../../composables/list-filter.js";
import { useStandardBreakpoints } from "../../../../composables/responsive.js";
import { MODEL_TYPE } from "../../../../config/models.js";
import { VISA_STATUS } from "../../../../config/visa.js";
import FileService from "../../../../services/FileService.js";
import TagService from "../../../../services/TagService";
Expand Down Expand Up @@ -271,7 +274,7 @@ export default {
moveFiles: move,
downloadFiles: download,
} = useFiles();
const { createModel, deleteModels } = useModels();
const { createModel, createPhotosphere, deleteModels } = useModels();
const { fetchToValidateVisas, fetchCreatedVisas } = useVisa();
Expand Down Expand Up @@ -391,10 +394,15 @@ export default {
const loadingFileIds = ref([]);
const createModelFromFile = async (file) => {
const createModelFromFile = async (file, type) => {
try {
loadingFileIds.value.push(file.id);
const model = await createModel(props.project, file);
let model;
if (type === MODEL_TYPE.PHOTOSPHERE) {
model = await createPhotosphere(props.project, file);
} else {
model = await createModel(props.project, file);
}
emit("model-created", model);
pushNotification({
type: "success",
Expand Down Expand Up @@ -758,6 +766,7 @@ export default {
folderToManage,
importFromOtherProjectsActions,
loadingFileIds,
MODEL_TYPE,
searchText,
selectedFileTab,
selection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default {
},
emits: [
"create-model",
"create-photosphere",
"delete",
"download",
"file-clicked",
Expand Down Expand Up @@ -139,6 +140,18 @@ export default {
}
}
if (!isFolder(props.file) && isConvertibleToPhotosphere(props.file)) {
if (!isModel(props.file)) {
menuItems.value.push({
key: 3,
iconComponent: SetAsModelIcon,
text: "FileActionsCell.createPhotosphereButtonText",
disabled: !hasAdminPerm(props.project, props.file),
action: () => onClick("create-photosphere")
});
}
}
menuItems.value.push({
key: 5,
icon: "edit",
Expand Down
2 changes: 2 additions & 0 deletions src/components/specific/files/folder-table/FoldersTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
:file="file"
:loading="loadingFileIds.includes(file.id)"
@create-model="$emit('create-model', file)"
@create-photosphere="$emit('create-photosphere', file)"
@delete="$emit('delete', file)"
@download="$emit('download', file)"
@file-clicked="$emit('file-clicked', file)"
Expand Down Expand Up @@ -165,6 +166,7 @@ export default {
emits: [
"back-parent-folder",
"create-model",
"create-photosphere",
"delete",
"download",
"file-clicked",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ import IFCManager from "./ifc-manager/IFCManager.vue";
import PDFManager from "./pdf-manager/PDFManager.vue";
import PointCloudManager from "./point-cloud-manager/PointCloudManager.vue";
const { DWG, DXF, IFC, JPEG, META_BUILDING, PDF, PHOTOSPHERE, PNG, POINT_CLOUD } =
const { DWG, DXF, IFC, META_BUILDING, PDF, PHOTOSPHERE, PHOTOSPHERE_BUILDING, POINT_CLOUD } =
MODEL_TYPE;
const tabsDef = [
Expand Down Expand Up @@ -132,7 +132,7 @@ const tabsDef = [
id: "photos",
text: "Photos",
icon: "fileImagePolychrome",
modelTypes: [JPEG, PHOTOSPHERE, PNG],
modelTypes: [PHOTOSPHERE, PHOTOSPHERE_BUILDING],
component: "DWGManager"
}
];
Expand Down
6 changes: 6 additions & 0 deletions src/config/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const MODEL_TYPE = Object.freeze({
OBJ: "OBJ",
PDF: "PDF",
PHOTOSPHERE: "PHOTOSPHERE",
PHOTOSPHERE_BUILDING: "PHOTOSPHERE_BUILDING",
PNG: "PNG",
POINT_CLOUD: "POINT_CLOUD",
});
Expand Down Expand Up @@ -121,6 +122,11 @@ const MODEL_CONFIG = Object.freeze({
window: WINDOWS.PHOTOSPHERE,
icon: "fileImagePolychrome",
},
[MODEL_TYPE.PHOTOSPHERE_BUILDING]: {
ext: [],
window: WINDOWS.PHOTOSPHERE,
icon: "fileImagePolychrome",
},
[MODEL_TYPE.PNG]: {
ext: [MODEL_EXTENSIONS.PNG],
window: WINDOWS.PLAN,
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"addTagsButtonText": "Ajouter des tags",
"addVersionButtonText": "Ajouter une version",
"createModelButtonText": "Définir comme modèle",
"createPhotosphereButtonText": "Définir comme photosphère",
"manageAccessButtonText": "Gérer les accès",
"openViewerButtonText": "Ouvrir",
"previewModelButtonText": "Prévisualiser",
Expand All @@ -134,6 +135,7 @@
"FilesManager": {
"title": "Documents du projet",
"createModelNotification": "Modèle créé avec succès",
"createPhotosphereNotification": "Photosphère créée avec succès",
"structureImport": "Importer une structure GED",
"gedDownload": "Télécharger la GED",
"folderImport": "Importer un dossier"
Expand Down
19 changes: 19 additions & 0 deletions src/services/ModelService.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ class ModelService {
}
}

async createPhotosphere(project, file) {
try {
return await fetch(
`${ENV.VUE_APP_API_BASE_URL}/cloud/${project.cloud.id}/project/${project.id}/model/create-photosphere`,
{
method: "POST",
credentials: "include",
headers: {
...apiClient.authHeader,
"Content-Type": "application/json;charset=UTF-8",
},
body: JSON.stringify({ document_id: file.id })
}
).then(res => res.json());
} catch (error) {
throw new RuntimeError(ERRORS.MODEL_CREATE_ERROR, error);
}
}

async updateModels(project, models) {
try {
return await Promise.all(
Expand Down
6 changes: 6 additions & 0 deletions src/state/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const createModel = async (project, file) => {
return newModel;
};

const createPhotosphere = async (project, file) => {
const newModel = await ModelService.createPhotosphere(project, file);
return newModel;
};

const updateModels = async (project, models) => {
const newModels = await ModelService.updateModels(project, models);
await loadProjectModels(project);
Expand Down Expand Up @@ -171,6 +176,7 @@ export function useModels() {
loadProjectModels,
fetchModelByID,
createModel,
createPhotosphere,
updateModels,
updateModelName,
mergeModels,
Expand Down
8 changes: 8 additions & 0 deletions src/utils/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ function isConvertible(document) {
);
}

function isConvertibleToPhotosphere(document) {
const { JPEG, JPG } = MODEL_EXTENSIONS;
return [JPEG, JPG].includes(
fileExtension(document.file_name).toLowerCase()
);
}

function openInViewer(router, project, model) {
router.push({
name: routeNames.modelViewer,
Expand All @@ -94,6 +101,7 @@ function openInViewer(router, project, model) {

export {
isConvertible,
isConvertibleToPhotosphere,
isIFC,
isModel,
isPDF,
Expand Down

0 comments on commit 74f5815

Please sign in to comment.