Compare commits

...

4 Commits

Author SHA1 Message Date
oguzhankoral 18caf16621 WIP 2024-02-12 18:09:31 +03:00
oguzhankoral c781534950 Trigger sketchup only saved stream not exists 2024-02-12 11:52:18 +03:00
oguzhankoral 886ede61e1 Enrich selected account info and fix same user id issue 2024-02-12 11:31:02 +03:00
oguzhankoral 5a42ea39ce Disable reload 2024-02-12 11:30:39 +03:00
6 changed files with 141 additions and 95 deletions
+19 -9
View File
@@ -48,21 +48,25 @@
<v-img v-if="user.avatar" :src="user.avatar" /> <v-img v-if="user.avatar" :src="user.avatar" />
<v-img v-else :src="`https://robohash.org/` + user.id + `.png?size=40x40`" /> <v-img v-else :src="`https://robohash.org/` + user.id + `.png?size=40x40`" />
</v-avatar> </v-avatar>
<div>
<b>{{ user.name }}</b>
</div>
<div class="caption"> <div class="caption">
{{ user.company }} {{ user.company }}
<br /> <br />
{{ user.bio ? 'Bio: ' + user.bio : '' }} {{ user.bio ? 'Bio: ' + user.bio : '' }}
</div> </div>
<div>
<b>{{ user.name }}</b>
<br />
<b>{{ user.email }}</b>
</div>
<div class="caption">
<b>{{ serverInfo.canonicalUrl }}</b>
</div>
</v-card-text> </v-card-text>
<v-card-text v-if="accounts()"> <v-card-text v-if="accounts()">
<v-divider class="my-3" /> <v-divider class="my-3" />
<div v-for="account in accounts()" :key="account.id"> <div v-for="account in accounts()" :key="account.id">
<v-btn <v-btn
v-if="account.userInfo.id != user.id" v-if="account.id != activeAccount().id"
rounded rounded
large large
class="my-1 elevation-0" class="my-1 elevation-0"
@@ -128,6 +132,7 @@
/*global sketchup*/ /*global sketchup*/
import { bus } from './main' import { bus } from './main'
import userQuery from './graphql/user.gql' import userQuery from './graphql/user.gql'
import serverInfoQuery from './graphql/serverInfo.gql'
import { onLogin } from './vue-apollo' import { onLogin } from './vue-apollo'
import Login from "@/views/Login"; import Login from "@/views/Login";
@@ -205,6 +210,9 @@ export default {
apollo: { apollo: {
user: { user: {
query: userQuery query: userQuery
},
serverInfo: {
query: serverInfoQuery
} }
}, },
mounted() { mounted() {
@@ -249,10 +257,12 @@ export default {
global.setSelectedAccount(account) global.setSelectedAccount(account)
// Force pushes to reload page to create ApolloClient from scratch // Force pushes to reload page to create ApolloClient from scratch
setTimeout(() => { // setTimeout(() => {
// timeout to wait a bit for potential sketchup.exec in the mean time calls // // timeout to wait a bit for potential sketchup.exec in the mean time calls
location.reload() // location.reload()
}, 200); // }, 200);
this.$apollo.queries.user.refetch()
this.$apollo.queries.serverInfo.refetch()
}, },
requestRefresh() { requestRefresh() {
sketchup.exec({name: 'reload_accounts', data: {}}) sketchup.exec({name: 'reload_accounts', data: {}})
+90 -82
View File
@@ -1,10 +1,6 @@
<template> <template>
<v-card <v-card v-if="stream" :class="`mb-3 rounded-lg grey ${$vuetify.theme.dark ? 'darken-4' : 'lighten-4'}`"
v-if="stream" @mouseenter="hover = true" @mouseleave="hover = false">
:class="`mb-3 rounded-lg grey ${$vuetify.theme.dark ? 'darken-4' : 'lighten-4'}`"
@mouseenter="hover = true"
@mouseleave="hover = false"
>
<v-toolbar flat height="70" :color="getColor(invalid)"> <v-toolbar flat height="70" :color="getColor(invalid)">
<v-btn v-tooptip="''" icon small outlined class="delta-btn" v-if="invalid" @click="activateDiffing"> <v-btn v-tooptip="''" icon small outlined class="delta-btn" v-if="invalid" @click="activateDiffing">
<v-icon v-if="!diffing" class="toggleUpDown" :class='{ "rotate": diffing }' small>mdi-eye-off-outline</v-icon> <v-icon v-if="!diffing" class="toggleUpDown" :class='{ "rotate": diffing }' small>mdi-eye-off-outline</v-icon>
@@ -12,12 +8,8 @@
</v-btn> </v-btn>
<v-toolbar-title class="ml-0" style="position: relative; left: -10px"> <v-toolbar-title class="ml-0" style="position: relative; left: -10px">
<!-- Uncomment when pinning is in place and add style="position: relative; left: -10px" to the element above :) --> <!-- Uncomment when pinning is in place and add style="position: relative; left: -10px" to the element above :) -->
<v-btn <v-btn v-tooltip="`Pin this ${streamText.toLowerCase()} - it will be saved to this file.`" icon x-small
v-tooltip="`Pin this ${streamText.toLowerCase()} - it will be saved to this file.`" @click="toggleSavedStream">
icon
x-small
@click="toggleSavedStream"
>
<v-icon v-if="saved" x-small>mdi-pin</v-icon> <v-icon v-if="saved" x-small>mdi-pin</v-icon>
<v-icon v-else x-small>mdi-pin-outline</v-icon> <v-icon v-else x-small>mdi-pin-outline</v-icon>
</v-btn> </v-btn>
@@ -29,24 +21,12 @@
<v-btn v-tooltip="'View online'" icon small class="mr-3" @click="openInWeb"> <v-btn v-tooltip="'View online'" icon small class="mr-3" @click="openInWeb">
<v-icon small>mdi-open-in-new</v-icon> <v-icon small>mdi-open-in-new</v-icon>
</v-btn> </v-btn>
<v-btn <v-btn v-tooltip="'Send'" icon class="mr-3 elevation-2" :loading="loadingSend" @click="send">
v-tooltip="'Send'"
icon
class="mr-3 elevation-2"
:loading="loadingSend"
@click="send"
>
<!-- <v-icon>mdi-upload</v-icon> --> <!-- <v-icon>mdi-upload</v-icon> -->
<v-img v-if="$vuetify.theme.dark" src="@/assets/SenderWhite.png" max-width="30" /> <v-img v-if="$vuetify.theme.dark" src="@/assets/SenderWhite.png" max-width="30" />
<v-img v-else src="@/assets/Sender.png" max-width="30" /> <v-img v-else src="@/assets/Sender.png" max-width="30" />
</v-btn> </v-btn>
<v-btn <v-btn v-tooltip="'Receive'" icon class="elevation-2" :loading="loadingReceive" @click="receive">
v-tooltip="'Receive'"
icon
class="elevation-2"
:loading="loadingReceive"
@click="receive"
>
<!-- <v-icon>mdi-download</v-icon> --> <!-- <v-icon>mdi-download</v-icon> -->
<v-img v-if="$vuetify.theme.dark" src="@/assets/ReceiverWhite.png" max-width="30" /> <v-img v-if="$vuetify.theme.dark" src="@/assets/ReceiverWhite.png" max-width="30" />
<v-img v-else src="@/assets/Receiver.png" max-width="30" /> <v-img v-else src="@/assets/Receiver.png" max-width="30" />
@@ -66,11 +46,8 @@
<template #activator="{ on, attrs }"> <template #activator="{ on, attrs }">
<v-slide-x-transition> <v-slide-x-transition>
<div v-show="hover"> <div v-show="hover">
<create-branch-dialog <create-branch-dialog :is-f-e2="preferences && preferences.user && preferences.user.fe2"
:is-f-e2="preferences && preferences.user && preferences.user.fe2" :stream-name="stream.name" :stream-id="streamId" />
:stream-name="stream.name"
:stream-id="streamId"
/>
</div> </div>
</v-slide-x-transition> </v-slide-x-transition>
<v-chip v-if="stream.branches" small v-bind="attrs" class="mr-1" v-on="on"> <v-chip v-if="stream.branches" small v-bind="attrs" class="mr-1" v-on="on">
@@ -80,12 +57,8 @@
</template> </template>
<!-- Branch list --> <!-- Branch list -->
<v-list dense> <v-list dense>
<v-list-item <v-list-item v-for="(branch, index) in stream.branches.items" :key="index" link
v-for="(branch, index) in stream.branches.items" @click="switchBranch(branch.name)">
:key="index"
link
@click="switchBranch(branch.name)"
>
<v-list-item-title class="text-caption font-weight-regular"> <v-list-item-title class="text-caption font-weight-regular">
<v-icon v-if="branch.name === branchName" small class="mr-1 float-left"> <v-icon v-if="branch.name === branchName" small class="mr-1 float-left">
mdi-check mdi-check
@@ -100,22 +73,14 @@
<template #activator="{ on, attrs }"> <template #activator="{ on, attrs }">
<v-chip v-if="stream && stream.commits" small v-bind="attrs" v-on="on"> <v-chip v-if="stream && stream.commits" small v-bind="attrs" v-on="on">
<v-icon small class="mr-1 float-left">mdi-source-commit</v-icon> <v-icon small class="mr-1 float-left">mdi-source-commit</v-icon>
{{ selectedBranch.commits.items.length ? commitId : 'no commits' }} {{ selectedBranch.commits.items.length ? commitId : 'no commits' }}
</v-chip> </v-chip>
</template> </template>
<v-list v-if="selectedBranch && selectedBranch.commits" dense> <v-list v-if="selectedBranch && selectedBranch.commits" dense>
<v-list-item <v-list-item v-for="(commit, index) in selectedBranch.commits.items" :key="index" link
v-for="(commit, index) in selectedBranch.commits.items" @click="switchCommit(commit.id)">
:key="index"
link
@click="switchCommit(commit.id)"
>
<v-list-item-title class="text-caption font-weight-regular"> <v-list-item-title class="text-caption font-weight-regular">
<v-icon <v-icon v-if="(commitId == 'latest' && index == 0) || commit.id == commitId" small class="mr-1 float-left">
v-if="(commitId == 'latest' && index == 0) || commit.id == commitId"
small
class="mr-1 float-left"
>
mdi-check mdi-check
</v-icon> </v-icon>
<v-icon v-else small class="mr-1 float-left">mdi-source-commit</v-icon> <v-icon v-else small class="mr-1 float-left">mdi-source-commit</v-icon>
@@ -131,24 +96,14 @@
<div class="flex-grow-1 px-4"> <div class="flex-grow-1 px-4">
<v-slide-y-transition> <v-slide-y-transition>
<div v-show="hover"> <div v-show="hover">
<v-text-field <v-text-field v-model="commitMessage" xxxclass="small-text-field" hide-details dense flat
v-model="commitMessage" :placeholder="`Write your ${commitText.toLowerCase()} message here`" />
xxxclass="small-text-field"
hide-details
dense
flat
:placeholder="`Write your ${commitText.toLowerCase()} message here`"
/>
</div> </div>
</v-slide-y-transition> </v-slide-y-transition>
</div> </div>
</v-card-text> </v-card-text>
<v-progress-linear <v-progress-linear v-if="(loadingSend || loadingReceive) && loadingStage" key="progress-bar" height="14"
v-if="(loadingSend || loadingReceive) && loadingStage" indeterminate>
key="progress-bar"
height="14"
indeterminate
>
<div class="text-caption"> <div class="text-caption">
{{ loadingStage }} {{ loadingStage }}
</div> </div>
@@ -164,8 +119,9 @@
import gql from 'graphql-tag' import gql from 'graphql-tag'
import { bus } from '../main' import { bus } from '../main'
import streamQuery from '../graphql/stream.gql' import streamQuery from '../graphql/stream.gql'
import projectQuery from '../graphql/project.gql'
import ObjectLoader from '@speckle/objectloader' import ObjectLoader from '@speckle/objectloader'
import {HostApplications} from '@/utils/hostApplications' import { HostApplications } from '@/utils/hostApplications'
global.convertedFromSketchup = function (streamId, batches, commitId, totalChildrenCount) { global.convertedFromSketchup = function (streamId, batches, commitId, totalChildrenCount) {
bus.$emit(`sketchup-objects-${streamId}`, batches, commitId, totalChildrenCount) bus.$emit(`sketchup-objects-${streamId}`, batches, commitId, totalChildrenCount)
@@ -212,7 +168,8 @@ export default {
streamText: '', streamText: '',
branchText: '', branchText: '',
commitText: '', commitText: '',
preferences: {} preferences: {},
filterBranchIds: []
} }
}, },
apollo: { apollo: {
@@ -225,6 +182,18 @@ export default {
} }
} }
}, },
project: {
prefetch: true,
query: projectQuery,
variables() {
return {
projectId: this.streamId,
filter: {
ids: this.filterBranchIds
}
}
}
},
$subscribe: { $subscribe: {
commitCreated: { commitCreated: {
query: gql` query: gql`
@@ -302,7 +271,39 @@ export default {
this.commitText = pref.user.fe2 ? 'Version' : 'Commit' this.commitText = pref.user.fe2 ? 'Version' : 'Commit'
}) })
// Collect preferences to render UI according to it // Collect preferences to render UI according to it
sketchup.exec({name: "collect_preferences", data: {}}) sketchup.exec({ name: "collect_preferences", data: {} })
bus.$on(`set-stream-branch-commit-${this.streamId}`, async (branchId, commitId) => {
console.log(branchId, "branchId");
let res = await this.$apollo.query({
query: gql`
query Project($projectId: String!, $filter: ProjectModelsFilter) {
project(id: $projectId) {
id
name
models (filter: $filter) {
items {
id
name
versions {
items {
id
}
}
}
}
}
}
`,
variables: {
projectId: this.streamId,
filter: {
ids: [branchId]
}
}
})
console.log(res.data);
})
bus.$on(`deactivate-diffing-${this.streamId}`, () => { bus.$on(`deactivate-diffing-${this.streamId}`, () => {
this.diffing = false this.diffing = false
@@ -347,11 +348,11 @@ export default {
this.$mixpanel.track('Send', { method: 'OneClick' }) this.$mixpanel.track('Send', { method: 'OneClick' })
}) })
if (this.saved) sketchup.exec({name: "notify_connected", data: {stream_id: this.streamId}}) if (this.saved) sketchup.exec({ name: "notify_connected", data: { stream_id: this.streamId } })
}, },
methods: { methods: {
getColor(invalid){ getColor(invalid) {
if(invalid){ if (invalid) {
return "#ffdfdf" return "#ffdfdf"
} else { } else {
return "" return ""
@@ -375,22 +376,22 @@ export default {
this.$mixpanel.track('Connector Action', { name: 'Commit Switch' }) this.$mixpanel.track('Connector Action', { name: 'Commit Switch' })
this.commitId = commitId this.commitId = commitId
}, },
activateDiffing(){ activateDiffing() {
if (this.diffing){ if (this.diffing) {
this.diffing = false this.diffing = false
sketchup.exec({name: "deactivate_diffing", data: {}}) sketchup.exec({ name: "deactivate_diffing", data: {} })
return return
} }
this.diffing = true this.diffing = true
bus.$emit("deactivate-diffing-except", (this.streamId)) bus.$emit("deactivate-diffing-except", (this.streamId))
sketchup.exec({name: "activate_diffing", data: {stream_id: this.streamId}}) sketchup.exec({ name: "activate_diffing", data: { stream_id: this.streamId } })
}, },
toggleSavedStream() { toggleSavedStream() {
if (this.saved) { if (this.saved) {
sketchup.exec({name: "remove_stream", data: {stream_id: this.streamId}}) sketchup.exec({ name: "remove_stream", data: { stream_id: this.streamId } })
this.$mixpanel.track('Connector Action', { name: 'Stream Remove' }) this.$mixpanel.track('Connector Action', { name: 'Stream Remove' })
} else { } else {
sketchup.exec({name: "save_stream", data: {stream_id: this.streamId}}) sketchup.exec({ name: "save_stream", data: { stream_id: this.streamId } })
this.$mixpanel.track('Connector Action', { name: 'Stream Save' }) this.$mixpanel.track('Connector Action', { name: 'Stream Save' })
} }
}, },
@@ -401,7 +402,7 @@ export default {
const isMultiplayer = this.selectedCommit.authorId !== selectedAccount['userInfo']['id'] const isMultiplayer = this.selectedCommit.authorId !== selectedAccount['userInfo']['id']
const sourceApp = this.selectedCommit.sourceApplication const sourceApp = this.selectedCommit.sourceApplication
const sourceAppSlug = HostApplications.GetHostAppFromString(sourceApp).slug const sourceAppSlug = HostApplications.GetHostAppFromString(sourceApp).slug
this.$mixpanel.track('Receive', { isMultiplayer: isMultiplayer, sourceHostApp: sourceAppSlug, sourceHostAppVersion: sourceApp}) this.$mixpanel.track('Receive', { isMultiplayer: isMultiplayer, sourceHostApp: sourceAppSlug, sourceHostAppVersion: sourceApp })
const refId = this.selectedCommit?.referencedObject const refId = this.selectedCommit?.referencedObject
if (!refId) { if (!refId) {
this.loadingReceive = false this.loadingReceive = false
@@ -418,14 +419,16 @@ export default {
let rootObj = await loader.getAndConstructObject(this.updateLoadingStage) let rootObj = await loader.getAndConstructObject(this.updateLoadingStage)
sketchup.exec({name:"receive_objects" , data: { sketchup.exec({
name: "receive_objects", data: {
base: rootObj, base: rootObj,
stream_name: this.stream.name, stream_name: this.stream.name,
stream_id: this.streamId, stream_id: this.streamId,
branch_name: this.selectedCommit.branchName, branch_name: this.selectedCommit.branchName,
branch_id: this.selectedCommit.id, branch_id: this.selectedCommit.id,
source_app: this.selectedCommit.sourceApplication source_app: this.selectedCommit.sourceApplication
}}) }
})
await this.$apollo.mutate({ await this.$apollo.mutate({
mutation: gql` mutation: gql`
@@ -451,7 +454,7 @@ export default {
this.loadingStage = 'converting' this.loadingStage = 'converting'
this.loadingSend = true this.loadingSend = true
this.$mixpanel.track('Send') this.$mixpanel.track('Send')
sketchup.exec({name:"send_selection" , data: {stream_id: this.streamId}}) sketchup.exec({ name: "send_selection", data: { stream_id: this.streamId } })
console.log('>>> SpeckleSketchUp: Objects requested from SketchUp') console.log('>>> SpeckleSketchUp: Objects requested from SketchUp')
await this.sleep(2000) await this.sleep(2000)
}, },
@@ -481,7 +484,7 @@ export default {
} }
const t1 = Date.now() const t1 = Date.now()
const elapsedTime = (t1-t0) / 1000 const elapsedTime = (t1 - t0) / 1000
console.log(`Upload time: ${elapsedTime} second`) console.log(`Upload time: ${elapsedTime} second`)
let commit = { let commit = {
@@ -556,6 +559,7 @@ export default {
.fade-leave-active { .fade-leave-active {
transition: opacity 0.2s ease-in; transition: opacity 0.2s ease-in;
} }
.fade-enter, .fade-enter,
.fade-leave-to { .fade-leave-to {
opacity: 0; opacity: 0;
@@ -566,27 +570,31 @@ export default {
max-height: 1200px; max-height: 1200px;
overflow: hidden; overflow: hidden;
} }
.expand-leave-active { .expand-leave-active {
transition: all 0.3s ease; transition: all 0.3s ease;
max-height: 1200px; max-height: 1200px;
overflow: hidden; overflow: hidden;
} }
.expand-enter, .expand-enter,
.expand-leave-to { .expand-leave-to {
max-height: 0; max-height: 0;
opacity: 0; opacity: 0;
} }
.v-text-field >>> input { .v-text-field>>>input {
font-size: 0.9em; font-size: 0.9em;
} }
.v-text-field >>> label {
.v-text-field>>>label {
font-size: 0.9em; font-size: 0.9em;
} }
.btn-fix:focus::before { .btn-fix:focus::before {
opacity: 0 !important; opacity: 0 !important;
} }
.btn-fix:hover::before { .btn-fix:hover::before {
opacity: 0.08 !important; opacity: 0.08 !important;
} }
@@ -250,7 +250,9 @@ export default {
this.$eventHub.$emit('notification', { this.$eventHub.$emit('notification', {
text: 'Stream Added by URL!\n', text: 'Stream Added by URL!\n',
}) })
bus.$emit('stream-added-by-id-or-url', stream.id) console.log(streamWrapper);
console.log(streamWrapper.branchName.slice(0, -1), "stream-added-by-id-or-url");
await bus.$emit('stream-added-by-id-or-url', stream.id, streamWrapper.branchName.slice(0, -1), streamWrapper.commitId)
this.$mixpanel.track('Connector Action', { name: 'Stream Add From URL' }) this.$mixpanel.track('Connector Action', { name: 'Stream Add From URL' })
} }
catch (e){ catch (e){
+17
View File
@@ -0,0 +1,17 @@
query Project($projectId: String!, $filter: ProjectModelsFilter) {
project(id: $projectId) {
id
name
models (filter: $filter) {
items {
id
name
versions {
items {
id
}
}
}
}
}
}
+6
View File
@@ -0,0 +1,6 @@
query{
serverInfo {
name
canonicalUrl
}
}
+5 -2
View File
@@ -120,16 +120,19 @@ export default {
bus.$on('set-saved-streams', (streamIds) => { bus.$on('set-saved-streams', (streamIds) => {
this.savedStreams = streamIds this.savedStreams = streamIds
}) })
bus.$on('stream-added-by-id-or-url', (streamId) => { bus.$on('stream-added-by-id-or-url', async(streamId, branchId, commitId) => {
if (!this.savedStreams){ if (!this.savedStreams){
this.savedStreams = [] this.savedStreams = []
this.savedStreams.push(streamId) this.savedStreams.push(streamId)
sketchup.exec({name: "save_stream", data: {stream_id: streamId}})
} else { } else {
if (!this.savedStreams.includes(streamId)){ if (!this.savedStreams.includes(streamId)){
this.savedStreams.push(streamId) this.savedStreams.push(streamId)
sketchup.exec({name: "save_stream", data: {stream_id: streamId}})
} }
} }
sketchup.exec({name: "save_stream", data: {stream_id: streamId}}) await bus.$emit(`set-stream-branch-commit-${streamId}`, branchId, commitId)
}) })
sketchup.exec({name: "load_saved_streams", data: {}}) sketchup.exec({name: "load_saved_streams", data: {}})
console.log('LAUNCHED') console.log('LAUNCHED')