Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Tipee Reflect Plugin #173

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,721 changes: 2,425 additions & 1,296 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/plugins/excelExport/dist/excelExport.plugin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/plugins/gltfExtractor/dist/gltfExtractor.plugin.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/plugins/iframeShare/dist/iframeShare.plugin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/plugins/iot/dist/iot.plugin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/plugins/iotEquipment/dist/iotEquipment.plugin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/plugins/kroqiBcfService/dist/kroqiBcfService.plugin.js

Large diffs are not rendered by default.

Binary file added src/plugins/reflect/assets/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/plugins/reflect/assets/reflect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/plugins/reflect/assets/rivp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/plugins/reflect/assets/tipee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions src/plugins/reflect/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "viewer-plugin-reflect",
"version": "0.1.1",
"description": "Reflect BIMData Viewer Plugin",
"scripts": {
"build": "rollup -c --environment BUILD:production",
"watch": "rollup --watch -c",
"prepublishOnly": "npm run build"
},
"main": "dist/reflect.plugin.js",
"files": [
"dist"
],
"keywords": [
"BIMData",
"Viewer",
"Plugin",
"reflect"
],
"dependencies": {
"@bimdata/design-system": "^2.1.1-rc.2",
"async": "^3.2.4",
"exceljs": "^4.3.0",
"file-saver": "^2.0.5"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-url": "^6.1.0",
"rollup": "^2.79.1",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-scss": "^3.0.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-vue": "^5.1.9",
"sass": "^1.57.1"
}
}
38 changes: 38 additions & 0 deletions src/plugins/reflect/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import VuePlugin from 'rollup-plugin-vue';
import scssPlugin from 'rollup-plugin-scss';
import url from '@rollup/plugin-url';
import { terser } from 'rollup-plugin-terser';
import commonjs from 'rollup-plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';

const isProduction = (process.env.BUILD === 'production');

const plugins = [
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
}),
VuePlugin(),
scssPlugin(),
commonjs(),
nodeResolve(),
url({
limit: 100 * 1024 *1024,
include: ['assets/*']
}),
];

if (isProduction) {
plugins.push(terser());
}

export default {
input: 'src/reflect.plugin.js',
output: {
file: 'dist/reflect.plugin.js',
format: 'esm',
sourcemap: !isProduction,
},
plugins
};
186 changes: 186 additions & 0 deletions src/plugins/reflect/src/.archived/AddRuleReflect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<template>
<div style="">
<BIMDataInput v-model="projectName" placeholder="Name" />
<BIMDataTextarea
label="projectDescription"
name="example"
v-model="projectDescription"
resizable
/>

<BIMDataButton
width="100%"
icon
v-on:click="addProject"
class="bimdata-btn__fill bimdata-btn__fill--primary bimdata-btn__radius m-y-12 p-x-24"
>
<BIMDataIcon name="plus" size="xxxs" margin="0 12px 0 0" />
Add project
</BIMDataButton>

<BIMDataButton
width="100%"
color="high"
fill
square
icon
v-on:click="cancel"
class="bimdata-btn__fill bimdata-btn__fill--secondary bimdata-btn__radius m-y-12 p-x-24"
>
<BIMDataIcon name="chevron" size="xxxs" margin="0 12px 0 0" />
Cancel
</BIMDataButton>
</div>
</template>

<script>
import {
BIMDataIcon,
BIMDataTextarea,
BIMDataInput,
BIMDataButton,
} from "@bimdata/design-system";
import func from "../func.js";

export default {
name: "AddProjectReflect",
components: {
BIMDataButton,
BIMDataInput,
BIMDataTextarea,
BIMDataIcon,
},
props: {
access_token: {
type: String,
required: true,
},
},
data() {
return {
loadedIfc: null,
exportStructure: true,
projectName: "",
projectDescription: "",
projectCreated: false,
};
},
computed: {
reflect_url() {
return "https://smarty.plateforme-tipee.com";
},
},
created() {
// Set default fileName
const parts = this.$viewer.state.models[0].document.file_name.split(".");
parts.pop(); // Remove extension
const name = parts.join("."); // rebuild name without extension
const date = new Date();
const created_at =
date.toLocaleDateString(this.$i18n.locale).replace(/\//g, "-") +
"-" +
date.getHours() +
"-" +
date.getMinutes();
this.projectName = "Reflect_" + name + "-" + created_at;
this.projectDescription = "";
},

methods: {
async loadIfcBimData(url, filename) {
let response = await fetch(url);
let data = await response.text();
console.log("data:", data);
let metadata = {
type: "application/ifc",
};
let file = new File([data], filename, metadata);
return file;
},

get_access_token() {
return this.access_token;
},

getInfoIfcFile() {
const models = this.$viewer.state.models;
console.log("loadedIfcs", models);
console.log("this.$viewer.state", this.$viewer.state);
this.loadedIfc = models[0];
return {
url: this.loadedIfc.document.file,
filename: this.loadedIfc.document.name,
};
},

headers(token) {
return {
Authorization: "Bearer " + token,
"Content-Type": "application/json;charset=UTF-8",
};
},
cancel() {
this.projectCreated = true;
this.$emit("project-method", this.projectCreated);
},

async addProject() {
const res = await fetch(`${this.reflect_url}/reflect/project`, {
headers: this.headers(this.access_token),
body: JSON.stringify({
name: this.projectName,
description: this.projectDescription,
}),
method: "POST",
});
const json = await res.json();
const id_current_project = json.project_id;

const info = this.getInfoIfcFile();
const url = info.url;
const filename = info.filename;

console.log("this.get_access_token()", this.get_access_token());

// async function createFile2(url,access_token, fn) {
// let request = new XMLHttpRequest();
// let file1;
// request.open("GET", url, true);
// request.responseType = 'text';
// request.onload = function () {
// file1 = new File([request.response], "filename.ifc", {
// type: "application/ifc",
// });
// fn({file:file1, access_token:access_token});
// };
// request.send();
// }
// const rere = await createFile2(url,this.access_token, function (data) {
// const formData = new FormData();
// formData.append("file", data.file);
// func.addIfc(formData, id_current_project,data.access_token);
// return "fde";
// }).then(res => {
// console.log("res:", res);
// });

const ifc_bimdata = await this.loadIfcBimData(url, filename);
const formData = new FormData();

console.log("ifc_bimdata", ifc_bimdata);
formData.append("file", ifc_bimdata);
func.addIfc(formData, id_current_project, this.access_token);

if (id_current_project) {
this.projectCreated = true;
this.$emit("project-method", this.projectCreated);
this.$emit("reflect-connected-method", "");
}
},
},
};
</script>

<style lang="scss" scoped>
@import "~@bimdata/design-system/dist/scss/BIMDataUtilities.scss";
</style>
Loading