Compare commits

...

5 Commits

Author SHA1 Message Date
oguzhankoral 462eb229a5 Use account id instead uuid to get selected account before 2024-02-16 17:46:34 +03:00
oguzhankoral 9d37d126cb Change default to app.speckle.systems 2024-02-16 17:04:27 +03:00
oguzhankoral 6372bea9fc Call sketchup functions before mount 2024-02-16 17:04:11 +03:00
Oğuzhan Koral 060b1b8f41 Fix (Attributes): Fix typos 2024-02-15 16:43:32 +03:00
Oğuzhan Koral da2e228293 Fix (FE2): CNX-8877 bug access error by fe2 model url (#321)
* Disable reload

* Enrich selected account info and fix same user id issue

* Trigger sketchup only saved stream not exists

* Fix activeAccount

* Increase number of branches limit to 100

* Check regex match
2024-02-13 16:36:35 +03:00
11 changed files with 65 additions and 45 deletions
@@ -15,7 +15,7 @@ module SpeckleConnector
Sketchup::ComponentInstance => INCLUDE_COMPONENT_ENTITY_ATTRIBUTES,
Sketchup::Group => INCLUDE_GROUP_ENTITY_ATTRIBUTES,
Sketchup::Face => INCLUDE_FACE_ENTITY_ATTRIBUTES,
Sketchup::Face => INCLUDE_EDGE_ENTITY_ATTRIBUTES
Sketchup::Edge => INCLUDE_EDGE_ENTITY_ATTRIBUTES
}.freeze
LEVEL_SHIFT_VALUE = SpeckleObjects::Geometry.length_to_native(1.5, 'm')
@@ -84,7 +84,7 @@ module SpeckleConnector
speckle_state = new_speckle_state
dictionaries = SketchupModel::Dictionary::BaseDictionaryHandler
.attribute_dictionaries_to_speckle(component_instance, preferences)
.attribute_dictionaries_to_speckle(component_instance, preferences[:model])
att = dictionaries.any? ? { dictionaries: dictionaries } : {}
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler
.speckle_schema_to_speckle(component_instance)
+36 -31
View File
@@ -48,21 +48,25 @@
<v-img v-if="user.avatar" :src="user.avatar" />
<v-img v-else :src="`https://robohash.org/` + user.id + `.png?size=40x40`" />
</v-avatar>
<div>
<b>{{ user.name }}</b>
</div>
<div class="caption">
{{ user.company }}
<br />
{{ user.bio ? 'Bio: ' + user.bio : '' }}
</div>
<div>
<b>{{ user.name }}</b>
<br />
<b>{{ user.email }}</b>
</div>
<div class="caption">
<b>{{ activeAccount().serverInfo.url }}</b>
</div>
</v-card-text>
<v-card-text v-if="accounts()">
<v-divider class="my-3" />
<div v-for="account in accounts()" :key="account.id">
<v-btn
v-if="account.userInfo.id != user.id"
v-if="account.id != activeAccount().id"
rounded
large
class="my-1 elevation-0"
@@ -100,12 +104,12 @@
/>
</v-container>
<create-stream-dialog
v-if="accounts().length !== 0"
v-if="accounts() && accounts().length !== 0"
:is-f-e2-terms="preferences && preferences.user && preferences.user.fe2"
:account-id="activeAccount().userInfo.id"
:server-url="activeAccount().serverInfo.url"
/>
<v-container v-if="accounts().length !== 0" fluid>
<v-container v-if="accounts() && accounts().length !== 0" fluid>
<router-view :stream-search-query="streamSearchQuery"/>
</v-container>
<v-container v-else>
@@ -128,6 +132,7 @@
/*global sketchup*/
import { bus } from './main'
import userQuery from './graphql/user.gql'
import serverInfoQuery from './graphql/serverInfo.gql'
import { onLogin } from './vue-apollo'
import Login from "@/views/Login";
@@ -144,18 +149,16 @@ global.collectVersions = function (versions) {
global.loadAccounts = function (accounts) {
console.log('>>> SpeckleSketchup: Loading accounts', accounts)
localStorage.setItem('localAccounts', JSON.stringify(accounts))
let uuid = localStorage.getItem('uuid')
let selectedAccountId = localStorage.getItem('selectedAccountId')
if (accounts.length !== 0){
if (uuid) {
var account = accounts.find((acct) => acct['userInfo']['id'] === uuid)
if (selectedAccountId) {
var account = accounts.find((acct) => acct['id'] === selectedAccountId)
if (account){
global.setSelectedAccount(account)
}else{
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
return
}
} else {
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
}
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
}
}
@@ -163,7 +166,7 @@ global.setSelectedAccount = function (account) {
localStorage.setItem('selectedAccount', JSON.stringify(account))
localStorage.setItem('serverUrl', account['serverInfo']['url'])
localStorage.setItem('SpeckleSketchup.AuthToken', account['token'])
localStorage.setItem('uuid', account['userInfo']['id'])
localStorage.setItem('selectedAccountId', account['id'])
localStorage.setItem('frontend2', account['serverInfo']['frontend2'])
bus.$emit('selected-account-reloaded')
}
@@ -205,8 +208,19 @@ export default {
apollo: {
user: {
query: userQuery
},
serverInfo: {
query: serverInfoQuery
}
},
beforeMount() {
// Collect accounts from 'Accounts.db' by ruby sqlite3
sketchup.exec({name: "init_local_accounts", data: {}})
// Collect preferences to render UI according to it
sketchup.exec({name: "collect_preferences", data: {}})
// Collect versions to inform mixpanel
sketchup.exec({name: "collect_versions", data: {}})
},
mounted() {
bus.$on('selected-account-reloaded', async () => {
await onLogin(this.$apollo.provider.defaultClient)
@@ -227,32 +241,23 @@ export default {
this.branchText = this.preferences.user.fe2 ? 'Model' : 'Branch'
this.$vuetify.theme.dark = this.preferences.user.dark_theme
})
// Collect versions to inform mixpanel
sketchup.exec({name: "collect_versions", data: {}})
// Collect preferences to render UI according to it
sketchup.exec({name: "collect_preferences", data: {}})
// Collect accounts from 'Accounts.db' by ruby sqlite3
sketchup.exec({name: "init_local_accounts", data: {}})
},
methods: {
accounts() {
return JSON.parse(localStorage.getItem('localAccounts'))
},
activeAccount(){
return this.accounts().find((account) => account['isDefault'])
activeAccount() {
return JSON.parse(localStorage.getItem('selectedAccount'))
},
switchAccount(account) {
this.$mixpanel.track('Connector Action', { name: 'Account Select' })
global.setSelectedAccount(account)
// Force pushes to reload page to create ApolloClient from scratch
setTimeout(() => {
// timeout to wait a bit for potential sketchup.exec in the mean time calls
location.reload()
}, 200);
// setTimeout(() => {
// // timeout to wait a bit for potential sketchup.exec in the mean time calls
// location.reload()
// }, 200);
},
requestRefresh() {
sketchup.exec({name: 'reload_accounts', data: {}})
+2 -1
View File
@@ -145,7 +145,8 @@ export default {
prefetch: true,
variables() {
return {
id: this.sourceStreamId
id: this.sourceStreamId,
limit: 100
}
},
skip() {
+2 -1
View File
@@ -221,7 +221,8 @@ export default {
query: streamQuery,
variables() {
return {
id: this.streamId
id: this.streamId,
limit: 100
}
}
},
@@ -205,7 +205,7 @@ export default {
},
async getStream(){
try {
const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl, localStorage.getItem('frontend2') === 'true')
const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl)
let res = await this.$apollo.query({
query: gql`
query Stream($id: String!){
+6
View File
@@ -0,0 +1,6 @@
query{
serverInfo {
name
canonicalUrl
}
}
+2 -2
View File
@@ -1,4 +1,4 @@
query Stream($id: String!) {
query Stream($id: String!, $limit: Int!) {
stream(id: $id) {
id
name
@@ -27,7 +27,7 @@ query Stream($id: String!) {
referencedObject
}
}
branches {
branches (limit: $limit) {
totalCount
items {
id
+9 -3
View File
@@ -1,12 +1,12 @@
require('url')
export class StreamWrapper {
constructor(streamIdOrUrl, accountId, serverUrl, isFE2) {
this.isFE2 = isFE2
constructor(streamIdOrUrl, accountId, serverUrl) {
this.isFE2 = this.checkIsFE2(streamIdOrUrl)
this.streamsKey = this.isFE2 ? 'projects/': 'streams/'
this.branchesKey = this.isFE2 ? 'models/': 'branches/'
this.commitsKey = this.isFE2 ? 'versions/': 'commits/'
this.originalOutput = streamIdOrUrl
this.originalOutput = streamIdOrUrl
try {
this.streamWrapperFromUrl(streamIdOrUrl)
}
@@ -17,6 +17,12 @@ export class StreamWrapper {
}
}
checkIsFE2(streamUrl){
const fe2UrlRegex = /\/projects\/(?<projectId>[\w\d]+)(?:\/models\/(?<model>[\w\d]+(?:@[\w\d]+)?)(?:,(?<additionalModels>[\w\d]+(?:@[\w\d]+)?))*)?/
const match = fe2UrlRegex.exec(streamUrl);
return match !== null;
}
streamWrapperFromUrl(streamUrl){
this.url = new URL(streamUrl)
this.segments = this.url.pathname.split('/').map((segment) => segment + '/')
+2 -1
View File
@@ -124,12 +124,13 @@ export default {
if (!this.savedStreams){
this.savedStreams = []
this.savedStreams.push(streamId)
sketchup.exec({name: "save_stream", data: {stream_id: streamId}})
} else {
if (!this.savedStreams.includes(streamId)){
this.savedStreams.push(streamId)
sketchup.exec({name: "save_stream", data: {stream_id: streamId}})
}
}
sketchup.exec({name: "save_stream", data: {stream_id: streamId}})
})
sketchup.exec({name: "load_saved_streams", data: {}})
console.log('LAUNCHED')
+3 -3
View File
@@ -12,7 +12,7 @@ if (process.env.NODE_ENV === 'development') {
localStorage.setItem(AUTH_TOKEN, process.env.VUE_APP_DEV_TOKEN)
localStorage.setItem('serverUrl', process.env.VUE_APP_DEFAULT_SERVER)
} else if (!localStorage.getItem('serverUrl')) {
localStorage.setItem('serverUrl', 'https://speckle.xyz')
localStorage.setItem('serverUrl', 'https://app.speckle.systems')
}
const authLink = setContext((_, { headers }) => {
@@ -34,7 +34,7 @@ const defaultOptions = {
return (
(localStorage.getItem('serverUrl').includes('http')
? localStorage.getItem('serverUrl')
: 'https://speckle.xyz') + '/graphql'
: 'https://app.speckle.systems') + '/graphql'
)
},
@@ -43,7 +43,7 @@ const defaultOptions = {
wsEndpoint: (
(localStorage.getItem('serverUrl').includes('http')
? localStorage.getItem('serverUrl')
: 'https://speckle.xyz') + '/graphql'
: 'https://app.speckle.systems') + '/graphql'
).replace('http', 'ws'),
// LocalStorage token