Compare commits

..

4 Commits

Author SHA1 Message Date
oguzhankoral 9d2ef1e26e Fix activeAccount 2024-02-12 18:44:04 +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
9 changed files with 30 additions and 37 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::Edge => INCLUDE_EDGE_ENTITY_ATTRIBUTES
Sketchup::Face => 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[:model])
.attribute_dictionaries_to_speckle(component_instance, preferences)
att = dictionaries.any? ? { dictionaries: dictionaries } : {}
speckle_schema = SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler
.speckle_schema_to_speckle(component_instance)
+17 -16
View File
@@ -104,12 +104,12 @@
/>
</v-container>
<create-stream-dialog
v-if="accounts() && accounts().length !== 0"
v-if="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() && accounts().length !== 0" fluid>
<v-container v-if="accounts().length !== 0" fluid>
<router-view :stream-search-query="streamSearchQuery"/>
</v-container>
<v-container v-else>
@@ -149,16 +149,16 @@ global.collectVersions = function (versions) {
global.loadAccounts = function (accounts) {
console.log('>>> SpeckleSketchup: Loading accounts', accounts)
localStorage.setItem('localAccounts', JSON.stringify(accounts))
let selectedAccountId = localStorage.getItem('selectedAccountId')
let uuid = localStorage.getItem('uuid')
if (accounts.length !== 0){
if (selectedAccountId) {
var account = accounts.find((acct) => acct['id'] === selectedAccountId)
if (uuid) {
var account = accounts.find((acct) => acct['userInfo']['id'] === uuid)
if (account){
global.setSelectedAccount(account)
return
}
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
}
global.setSelectedAccount(accounts.find((acct) => acct['isDefault']))
}
}
@@ -166,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('selectedAccountId', account['id'])
localStorage.setItem('uuid', account['userInfo']['id'])
localStorage.setItem('frontend2', account['serverInfo']['frontend2'])
bus.$emit('selected-account-reloaded')
}
@@ -213,14 +213,6 @@ export default {
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)
@@ -241,12 +233,21 @@ 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() {
activeAccount(){
return JSON.parse(localStorage.getItem('selectedAccount'))
},
switchAccount(account) {
+1 -2
View File
@@ -145,8 +145,7 @@ export default {
prefetch: true,
variables() {
return {
id: this.sourceStreamId,
limit: 100
id: this.sourceStreamId
}
},
skip() {
+1 -2
View File
@@ -221,8 +221,7 @@ export default {
query: streamQuery,
variables() {
return {
id: this.streamId,
limit: 100
id: this.streamId
}
}
},
@@ -205,7 +205,7 @@ export default {
},
async getStream(){
try {
const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl)
const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl, localStorage.getItem('frontend2') === 'true')
let res = await this.$apollo.query({
query: gql`
query Stream($id: String!){
+2 -2
View File
@@ -1,4 +1,4 @@
query Stream($id: String!, $limit: Int!) {
query Stream($id: String!) {
stream(id: $id) {
id
name
@@ -27,7 +27,7 @@ query Stream($id: String!, $limit: Int!) {
referencedObject
}
}
branches (limit: $limit) {
branches {
totalCount
items {
id
+3 -9
View File
@@ -1,12 +1,12 @@
require('url')
export class StreamWrapper {
constructor(streamIdOrUrl, accountId, serverUrl) {
this.isFE2 = this.checkIsFE2(streamIdOrUrl)
constructor(streamIdOrUrl, accountId, serverUrl, isFE2) {
this.isFE2 = isFE2
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,12 +17,6 @@ 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 + '/')
+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://app.speckle.systems')
localStorage.setItem('serverUrl', 'https://speckle.xyz')
}
const authLink = setContext((_, { headers }) => {
@@ -34,7 +34,7 @@ const defaultOptions = {
return (
(localStorage.getItem('serverUrl').includes('http')
? localStorage.getItem('serverUrl')
: 'https://app.speckle.systems') + '/graphql'
: 'https://speckle.xyz') + '/graphql'
)
},
@@ -43,7 +43,7 @@ const defaultOptions = {
wsEndpoint: (
(localStorage.getItem('serverUrl').includes('http')
? localStorage.getItem('serverUrl')
: 'https://app.speckle.systems') + '/graphql'
: 'https://speckle.xyz') + '/graphql'
).replace('http', 'ws'),
// LocalStorage token