This commit is contained in:
Alan Rynne 2021-09-28 17:17:05 +02:00
Родитель e215ead6e6
Коммит 4f68c8ac8f
4 изменённых файлов: 70 добавлений и 43 удалений

Просмотреть файл

@ -1,13 +1,36 @@
<template> <template>
<div> <v-row>
<v-card v-if="projectInfo"> <v-col class="col-6">
<v-card-title>{{projectInfo.name}} {{projectInfo.number}}<span class="d-flex align-center text-body-2 grey--text border pl-2"> <v-icon size="medium" color="grey" class="pr-1">mdi-home-circle-outline</v-icon>{{projectInfo.address}}</span></v-card-title> <p>Stream details</p>
<v-card-subtitle class="d-flex aling-center"> <v-card outlined>
<v-icon size="small" class="pr-1">mdi-account-circle-outline</v-icon>{{projectInfo.author}} <v-card-title>
<v-icon size="small" class="pr-1 pl-2">mdi-calendar-check-outline</v-icon>{{projectInfo.status}} {{ stream.name }}
</v-card-subtitle> <v-btn outlined text small class="ml-3" :href="serverUrl+'/streams/'+stream.id">View in server</v-btn>
</v-card> </v-card-title>
</div> <v-card-subtitle>
</v-card-subtitle>
</v-card>
</v-col>
<v-col class="col-6">
<p>Project information</p>
<v-card v-if="projectInfo" outlined>
<v-card-title>{{ projectInfo.name }} {{ projectInfo.number }}<span
class="d-flex align-center text-body-2 grey--text border pl-2">
<v-icon size="medium" color="grey"
class="pr-1">mdi-home-circle-outline</v-icon>{{ projectInfo.address }}</span>
</v-card-title>
<v-card-subtitle class="d-flex aling-center">
<v-icon size="small" class="pr-1">mdi-account-circle-outline</v-icon>
{{ projectInfo.author }}
<v-icon size="small" class="pr-1 pl-2">mdi-calendar-check-outline</v-icon>
{{ projectInfo.status }}
</v-card-subtitle>
</v-card>
<v-card v-else>
<v-card-subtitle>No project info was sent on this commit</v-card-subtitle>
</v-card>
</v-col>
</v-row>
</template> </template>
<script> <script>
@ -16,10 +39,11 @@ import {getStreamObject} from "@/speckleUtils";
export default { export default {
name: "RevitProjectInfo", name: "RevitProjectInfo",
components: {}, components: {},
props: ["info"], props: ["info", "stream"],
data(){ data() {
return { return {
projectInfo: null projectInfo: null,
serverUrl: process.env.VUE_APP_SERVER_URL
} }
}, },
watch: { watch: {
@ -27,8 +51,8 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler: async function (val, oldVal) { handler: async function (val, oldVal) {
if(!val) return if (!val) return
var id = this.$store.state.currentStream.id var id = this.$route.params.id
var res = await getStreamObject(id, this.info[0].referencedId) var res = await getStreamObject(id, this.info[0].referencedId)
console.log(res) console.log(res)
this.projectInfo = res this.projectInfo = res

Просмотреть файл

@ -1,19 +1,9 @@
<template> <template>
<v-container id="revitStream" class="pa-6"> <v-container id="revitStream" class="pa-6">
<h2 class="pt-6 primary--text">
<span v-if="stream">
{{ stream.name }} {{ stream.id }}
<v-btn outlined text small class="ml-3" :href="serverUrl+'/streams/'+stream.id">View in server</v-btn>
<v-btn outlined text small class="ml-3" color="error" @click="clearSelection">Clear selection</v-btn>
</span>
<span v-else>
<em>No stream selected. Find one using the search bar 👆🏼</em>
</span>
</h2>
<v-container v-if="refObj"> <v-container v-if="refObj">
<v-row> <v-row>
<v-col> <v-col>
<revit-project-info :info="refObj['@Project Information']"/> <revit-project-info :info="refObj['@Project Information']" :stream="stream"/>
</v-col> </v-col>
</v-row> </v-row>
<v-row> <v-row>
@ -40,7 +30,6 @@ import ObjectLoaderTest from "@/components/ObjectLoaderTest";
export default { export default {
name: "RevitStream", name: "RevitStream",
components: {ObjectLoaderTest, RevitCategories, RevitProjectInfo}, components: {ObjectLoaderTest, RevitCategories, RevitProjectInfo},
props: [ "streamId" ],
data(){ data(){
return { return {
stream: null, stream: null,
@ -55,6 +44,7 @@ export default {
} }
}, },
computed: { computed: {
streamId(){ return this.$route.params.id },
isRevitCommit() { return this.selectedCommit?.sourceApplication?.startsWith("Revit")} isRevitCommit() { return this.selectedCommit?.sourceApplication?.startsWith("Revit")}
}, },
methods: { methods: {
@ -64,9 +54,11 @@ export default {
this.refObj = null this.refObj = null
this.selectedCommit = null this.selectedCommit = null
}, },
async getStream(){ async getStream(){
console.log(this.streamId) console.log(this.streamId)
var res = await getStreamCommits(this.streamId,1,null) var res = await getStreamCommits(this.streamId,1,null)
console.log(res)
console.log("commits", res.data.stream.commits.items) console.log("commits", res.data.stream.commits.items)
this.selectedCommit = res.data.stream.commits.items[0] this.selectedCommit = res.data.stream.commits.items[0]
this.stream = res.data.stream this.stream = res.data.stream

Просмотреть файл

@ -3,6 +3,7 @@ import VueRouter from 'vue-router'
import Home from '../views/Home.vue' import Home from '../views/Home.vue'
import store from '../store/index.js' import store from '../store/index.js'
import WelcomeView from "@/components/WelcomeView"; import WelcomeView from "@/components/WelcomeView";
import RevitStream from "@/components/RevitStream";
Vue.use(VueRouter) Vue.use(VueRouter)
@ -12,13 +13,24 @@ const routes = [
name: 'Home', name: 'Home',
component: Home, component: Home,
meta: { meta: {
isProtected: true requiresAuth: true
} }
}, },
{ {
path: '/login', path: '/login',
name: 'Login', name: 'Login',
component: WelcomeView component: WelcomeView,
meta: {
requiresNoAuth: true
}
},
{
path: '/streams/:id',
name: 'Streams',
component: RevitStream,
meta: {
requiresAuth: true
}
} }
] ]
@ -28,26 +40,26 @@ const router = new VueRouter({
routes routes
}) })
router.beforeEach( async (to, from, next) => { router.beforeEach(async (to, from, next) => {
if(to.query.access_code){ if (to.query.access_code) {
// If the route contains an access code, exchange it // If the route contains an access code, exchange it
try { try {
await store.dispatch('exchangeAccessCode', to.query.access_code) await store.dispatch('exchangeAccessCode', to.query.access_code)
} catch (err){ } catch (err) {
console.warn("exchange failed", err); console.warn("exchange failed", err);
} }
// Whatever happens, go home. // Whatever happens, go home.
next("/") return next("/")
}
else if(to.meta.isProtected){
await store.dispatch("getUser")
var isAuth = store.getters.isAuthenticated
if(!isAuth) next("/login")
else next()
}
else {
next()
} }
// Fetch if user is authenticated
await store.dispatch("getUser")
var isAuth = store.getters.isAuthenticated
if (to.meta.requiresAuth && !isAuth)
return next({name: "Login"})
else if (to.meta.requiresNoAuth && isAuth)
return next("/")
// Any other page
next()
}) })
export default router export default router

Просмотреть файл

@ -1,6 +1,6 @@
<template lang="html"> <template lang="html">
<v-container class="home pa-6"> <v-container class="home pa-6">
<revit-stream :stream-id="selectedStream ? selectedStream.id : null"/> HOME!!
</v-container> </v-container>
</template> </template>
@ -12,7 +12,6 @@ import RevitStream from "@/components/RevitStream"
export default { export default {
name: 'Home', name: 'Home',
components: {RevitStream},
data: () => { data: () => {
return { return {
serverUrl: process.env.VUE_APP_SERVER_URL, serverUrl: process.env.VUE_APP_SERVER_URL,