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>
<div>
<v-card v-if="projectInfo">
<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>
</div>
<v-row>
<v-col class="col-6">
<p>Stream details</p>
<v-card outlined>
<v-card-title>
{{ stream.name }}
<v-btn outlined text small class="ml-3" :href="serverUrl+'/streams/'+stream.id">View in server</v-btn>
</v-card-title>
<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>
<script>
@ -16,10 +39,11 @@ import {getStreamObject} from "@/speckleUtils";
export default {
name: "RevitProjectInfo",
components: {},
props: ["info"],
data(){
props: ["info", "stream"],
data() {
return {
projectInfo: null
projectInfo: null,
serverUrl: process.env.VUE_APP_SERVER_URL
}
},
watch: {
@ -27,8 +51,8 @@ export default {
deep: true,
immediate: true,
handler: async function (val, oldVal) {
if(!val) return
var id = this.$store.state.currentStream.id
if (!val) return
var id = this.$route.params.id
var res = await getStreamObject(id, this.info[0].referencedId)
console.log(res)
this.projectInfo = res

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

@ -1,19 +1,9 @@
<template>
<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-row>
<v-col>
<revit-project-info :info="refObj['@Project Information']"/>
<revit-project-info :info="refObj['@Project Information']" :stream="stream"/>
</v-col>
</v-row>
<v-row>
@ -40,7 +30,6 @@ import ObjectLoaderTest from "@/components/ObjectLoaderTest";
export default {
name: "RevitStream",
components: {ObjectLoaderTest, RevitCategories, RevitProjectInfo},
props: [ "streamId" ],
data(){
return {
stream: null,
@ -55,6 +44,7 @@ export default {
}
},
computed: {
streamId(){ return this.$route.params.id },
isRevitCommit() { return this.selectedCommit?.sourceApplication?.startsWith("Revit")}
},
methods: {
@ -64,9 +54,11 @@ export default {
this.refObj = null
this.selectedCommit = null
},
async getStream(){
console.log(this.streamId)
var res = await getStreamCommits(this.streamId,1,null)
console.log(res)
console.log("commits", res.data.stream.commits.items)
this.selectedCommit = res.data.stream.commits.items[0]
this.stream = res.data.stream

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

@ -3,6 +3,7 @@ import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import store from '../store/index.js'
import WelcomeView from "@/components/WelcomeView";
import RevitStream from "@/components/RevitStream";
Vue.use(VueRouter)
@ -12,13 +13,24 @@ const routes = [
name: 'Home',
component: Home,
meta: {
isProtected: true
requiresAuth: true
}
},
{
path: '/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
})
router.beforeEach( async (to, from, next) => {
if(to.query.access_code){
router.beforeEach(async (to, from, next) => {
if (to.query.access_code) {
// If the route contains an access code, exchange it
try {
await store.dispatch('exchangeAccessCode', to.query.access_code)
} catch (err){
} catch (err) {
console.warn("exchange failed", err);
}
// Whatever happens, go home.
next("/")
}
else if(to.meta.isProtected){
await store.dispatch("getUser")
var isAuth = store.getters.isAuthenticated
if(!isAuth) next("/login")
else next()
}
else {
next()
return 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

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

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