Compare commits

...

180 Commits

Author SHA1 Message Date
Dogukan Karatas 2da1602986 Merge pull request #146 from specklesystems/dogukan/cnx-1502-merge-tables-of-federated-models
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
feat: federated models
2025-04-30 16:18:44 +02:00
Dogukan Karatas a0372e1970 Merge pull request #149 from specklesystems/alex/no-more-legacy-viewer
Alex/no more legacy viewer
2025-04-30 16:17:39 +02:00
oguzhankoral 98f10bb344 Sort the new viewer after Alex and compression for federated models 2025-04-29 17:08:27 +03:00
oguzhankoral ee11e47af3 Merge remote-tracking branch 'origin/alex/no-more-legacy-viewer' into dogukan/cnx-1502-merge-tables-of-federated-models 2025-04-29 14:25:04 +03:00
AlexandruPopovici f57697d929 Got rid of LegacyViewer and adjusted the wrapper accordingly. Blindly 2025-04-29 10:25:07 +03:00
Jedd Morgan ac0db18d24 refactor(ci): Update workflow to use new consolidated deployment workflow (#148)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
* Update workflow

* target main
2025-04-24 15:09:32 +02:00
Dogukan Karatas 24d26dc49f adds support for federated models 2025-03-27 14:02:20 +01:00
Oğuzhan Koral 1fff59de85 Add flag for anonymous (#145)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
2025-03-26 15:34:56 +03:00
Dogukan Karatas 771e34f6b5 null checks for anon user (#144) 2025-03-26 15:15:48 +03:00
Oğuzhan Koral f0b072d210 Feat(visual): persistent camera position (#143)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
* Subscribe the camera position

* Remember the last camera position

* Add email to mixpanel track

* Add custom views
2025-03-21 18:22:38 +03:00
Oğuzhan Koral 97a72c966a Feat(visual): select default view to load in powerbi (#141)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
* Add view modes and persist all camera settings into file

* Adjust z index

* sizing
2025-03-21 02:47:51 +03:00
Oğuzhan Koral 058c846770 Feat(visual): cleanup data (#140)
* cleanup data before loading to viewer

* only cleanup to properties and closures, good enough
2025-03-21 01:29:06 +03:00
Dogukan Karatas 3bb69f7aa8 removes beta flag (#139) 2025-03-19 14:59:37 +03:00
Dogukan Karatas c1dac7e663 Merge pull request #138 from specklesystems/dogukan/update-object-filtering
fix (data connector): object filtering logic
2025-03-19 10:39:35 +01:00
Dogukan Karatas 056815dad8 updated logic for filtering 2025-03-19 10:37:50 +01:00
Dogukan Karatas 929f06dbb7 update object filtering 2025-03-18 15:05:44 +01:00
Jedd Morgan 8cdfa97f41 Update build_powerbi.yml (#137) 2025-03-14 12:44:50 +03:00
Dogukan Karatas 28e9c43e5e fixes sourceApplication record (#136) 2025-03-03 20:30:31 +03:00
Oğuzhan Koral 380c60281b add ui property to track (#135)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
2025-02-27 19:25:58 +03:00
Dogukan Karatas c4f7c6082e adds helper functions (#131)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
2025-02-26 17:14:03 +00:00
Oğuzhan Koral 51a5261f1d more states.... (#134) 2025-02-26 16:53:28 +03:00
Oğuzhan Koral 5f6a032bf8 Fix: aligning colors across visuals (#133)
* Group by child value

* remove unused code
2025-02-26 15:04:05 +03:00
Jedd Morgan 8e1fe78af3 Remove desktop service from powerbi CI (#132) 2025-02-25 12:35:04 +00:00
Oğuzhan Koral 6dffa7dfa3 Feat(mixpanel): get user info from service (#130)
* get receive info from service

* rename userInfo to receiveInfo

* hijack download with more data

* gets email and token

* note for private project tests

---------

Co-authored-by: Dogukan Karatas <karatasdogukan@gmail.com>
2025-02-24 14:37:00 +03:00
Dogukan Karatas f61fae4284 feat (data): send user info to the service (#123)
* sends user info the service

* adds root object id

* fix port and casing

---------

Co-authored-by: oguzhankoral <oguzhankoral@gmail.com>
2025-02-21 16:14:13 +03:00
Oğuzhan Koral f97946a426 Update build_powerbi.yml (#129)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
2025-02-19 23:26:20 +03:00
Dogukan Karatas 8949917f21 fix(visual): update viewer version (#128)
* updates viewer version

* make it consistent
2025-02-19 23:03:34 +03:00
Oğuzhan Koral 0a0abd70df Chore: update ports (#127)
* update port

* update port +1
2025-02-19 12:51:02 +03:00
Oğuzhan Koral 19c9252a4a Update build_powerbi.yml (#126)
* Update build_powerbi.yml

* bump version
2025-02-19 12:50:44 +03:00
Oğuzhan Koral e50b04b305 Feat(visual): UI fine tuning (#125)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
* home view

* Update logo on viewer view

* progress bar while data is loading from bg service

* make home view speckle icon smaller

* put more gap between logo and speckle text
2025-02-17 22:19:02 +03:00
Dogukan Karatas 5cd0fe2b12 Merge pull request #124 from specklesystems/dogukan/visual-input-field-update
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
fix: rename the input field
2025-02-17 15:51:35 +01:00
Dogukan Karatas 59dd7ee9fc updates input field name 2025-02-17 15:36:47 +01:00
Jedd Morgan a6e7ed86d9 please work (#122)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
2025-02-14 14:15:25 +00:00
Jedd Morgan 573e70df02 Single line command (#121)
* Add quotes

* cmd uses carets

* I hate windows
2025-02-14 14:12:44 +00:00
Jedd Morgan 52f406f3ac Fix CI multi-line command (#120)
* Add quotes

* cmd uses carets
2025-02-14 14:07:40 +00:00
Jedd Morgan fbe34d43b1 Add quotes (#119) 2025-02-14 13:59:26 +00:00
Dogukan Karatas 5ad8139a4c Merge pull request #118 from specklesystems/jedd/cxpla-125-sign-the-power-bi-installer
Jedd/cxpla 125 sign the power bi installer
2025-02-14 14:53:40 +01:00
Jedd Morgan ba43724443 Self sign connector 2025-02-14 13:51:12 +00:00
Dogukan Karatas 8a34685b00 Merge pull request #117 from specklesystems/dogukankaratas-patch-1
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
Update build_powerbi.yml
2025-02-14 13:51:00 +01:00
Dogukan Karatas e9c2293736 Update build_powerbi.yml 2025-02-14 13:49:11 +01:00
Dogukan Karatas d27adb243f Merge pull request #116 from specklesystems/oguzhan/streaming-data-poc
Feat(visual): streaming data
2025-02-14 13:27:07 +01:00
Dogukan Karatas e55a382d73 updates input field name 2025-02-14 13:24:23 +01:00
oguzhankoral 00af5b5abb compress data to write read 2025-02-14 03:09:03 +03:00
oguzhankoral cba5ccf254 handle ndjson streamed data 2025-02-13 20:29:40 +03:00
oguzhankoral ae3c480f02 bump only viewer 2025-02-13 15:27:25 +03:00
oguzhankoral 0b716eb2cd Merge remote-tracking branch 'origin/dev' into oguzhan/streaming-data-poc 2025-02-13 14:52:23 +03:00
oguzhankoral a88f3323b1 bump speckle packages 2025-02-13 14:47:40 +03:00
Dogukan Karatas 7b06aef1f8 feature (data connector): server integration (#115)
* adds version parsing in data connector

* integrate with server

* adds data cleaning
2025-02-13 13:50:55 +03:00
oguzhankoral a45a67ed38 Cleanup 2025-02-13 13:23:14 +03:00
oguzhankoral efd07d4ffb streaming data + progress 2025-02-12 22:23:27 +03:00
Jedd Morgan 33116083e8 bump-version
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
2025-02-07 11:03:47 +00:00
Dogukan Karatas 12f548bd76 Merge pull request #113 from specklesystems/oguzhan/post-with-id-param
Feat: post with id param
2025-02-07 10:42:44 +01:00
oguzhankoral 8b9c4b1cf2 pass root id as param to send 2025-02-05 13:06:09 +00:00
Dogukan Karatas deb34e9262 adds the root id to key (#112) 2025-02-05 10:11:11 +00:00
Oğuzhan Koral 4a4a7d70c0 Rename the event to Receive (#111) 2025-02-04 19:38:20 +00:00
Jedd Morgan 4e1ce9ce71 bump service to 0.4.0 (#110) 2025-02-04 18:26:53 +00:00
Dogukan Karatas c9c1820e4d fix (data connector): adds caching to data connector (#109)
* adds caching to data connector

* endpoint updated
2025-02-04 18:26:33 +00:00
Oğuzhan Koral 62110739fb bump service version to 0.3.0 (#108)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
2025-02-02 21:33:53 +03:00
Oğuzhan Koral d5527c79b1 bump service tag (#107)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
2025-01-31 12:27:54 +03:00
Dogukan Karatas 79ba5cd365 Merge pull request #106 from specklesystems/dogukan/get-user-info
feat: send to local server
2025-01-31 10:26:13 +01:00
Jedd Morgan 17c857d138 Pass service as artifact (#105) 2025-01-31 10:50:16 +03:00
oguzhankoral f0538c94c3 Proper mixpanel track 2025-01-29 22:27:43 +03:00
Dogukan Karatas b1f2c741ad gets user info 2025-01-29 18:57:58 +01:00
Oğuzhan Koral 64dc73411a Feat(service): viewer data from local server (#104)
* Join strings

* Join strings

* POC from local viewer data

* WIP

* more WIP

* Align states

* aligns with new visual

* sends json to server

* Remove unused references

* POC

* local server data added

* updated nav table

* status updated

* added root object id

* status hidden

* Have rootObjectId as field

* Extract writeObjectsToFile

* Working state of interactivity

* Fix load from file vs. from local server

* TODO note

* Enable camera views

* sendStatus added

* cleaner structure

* Align port number with service

* Remove handle file change input

* Remove unused function in viewer

* Update capabilities for port

---------

Co-authored-by: Dogukan Karatas <karatasdogukan@gmail.com>
2025-01-29 18:02:24 +03:00
Oğuzhan Koral 8816430f51 Remove menu buttons from viewer (#102)
build_powerbi / build-connector (push) Has been cancelled
build_powerbi / build-visual (push) Has been cancelled
build_powerbi / deploy-installers (push) Has been cancelled
2025-01-16 20:18:33 +03:00
Oğuzhan Koral d5e8cd8a90 Fix: opening a file that has a visual with tooltip (#101)
* WIP

* Remove speckle server urls from webaccess

* Offline support identifier for mixpanel tracks

* Do not select if null

* Remove throttle

* Simplfy logic

* Increase row limit to 150000 for pro users
2025-01-15 14:34:01 +03:00
Dogukan Karatas 3bc82f6b9e updates build yaml file (#100) 2025-01-14 18:51:24 +03:00
Dogukan Karatas dc4f4c19f4 Merge pull request #99 from specklesystems/dogukan/labeling-releases
fix: update version label
2025-01-10 10:25:58 +01:00
Dogukan Karatas 15ebfab50b update gitversion.yml 2025-01-10 10:18:53 +01:00
Dogukan Karatas 10cc50a5b8 creates gitversion.yml (#98) 2025-01-09 18:33:43 +03:00
Dogukan Karatas 049fab417f feat: github action installer (#97)
* rename data column

* create yaml

* update yaml

* gives directory to action

* adds connector to yml

* update yml

* update yml again

* update version

* changes the ref

* adds shell

* fixes typo

* zip the artifacts

* updates version

* adds fetch depth

* updates yml branch

* adds tags
2025-01-09 17:53:15 +03:00
Oğuzhan Koral efe1c7ea0f Capture hits for isolated objects (#96) 2025-01-08 21:32:55 +03:00
Dogukan Karatas 7d7f3b04c5 rename data column (#95) 2025-01-08 18:40:57 +03:00
Dogukan Karatas 8e03d4464e fix: align column and input names (#94)
* rename columns

* updates query
2025-01-08 17:10:27 +03:00
Oğuzhan Koral 41161a8739 Feat(colors): CNX-964 coloring by in power bi visual (#93)
* Group objects by color and with their id

* Have colors back

* Fix color by
2025-01-08 16:23:42 +03:00
Oğuzhan Koral 436d13475d Fix(camera): CNX-969 camera resets when tooltip input is setunset (#92)
* Fix reseting camera on set/unset toolip

* Remove console log

* Remove unnecessary store props methods
2025-01-06 23:43:27 +03:00
Dogukan Karatas 6618e5654b fixes the structure of data connector (#91) 2025-01-06 18:10:49 +03:00
Oğuzhan Koral ca34cd3adc Fix(selection): CNX-963 deselecting does not work (#90)
* Clear selection if no hit

* Remove console log
2025-01-06 17:44:56 +03:00
Oğuzhan Koral 5168516109 Unload objects whenever we load new model (#89) 2025-01-06 14:47:18 +03:00
Dogukan Karatas 2fa69873d1 feat: new data model (#88)
* gets user info

* gets structured data

* gets by url

* publish the function

* cleanup the fields

* creates navigation table

* improves publishing

* builds relation between two table

* expands records dynamically

* folder structure reorder

* adds ordered chunks

* viewer data alternatives

* adds model name to the table name

* adds support for versioned urls

* adds relationship
2024-12-19 12:37:37 +03:00
Oğuzhan Koral 4f15db5d9c Feat: offline support (#87)
* disable redundant steps for POC

* Fixed the getInstances issue. Changed the webpack devsserver port so  it doesn't conflict with the pbviz process

* speckle offline loader tests

* gets user info

* gets structured data

* gets by url

* publish the function

* cleanup the fields

* creates navigation table

* improves publishing

* builds relation between two table

* wip

* some log cleanup and notes

* get sorted data from powerbi

* aling R_ raw data

* WIP

* WIP

* Handle row raw data per object

* introduce pinia

* bump speckle libraries to 2.23.2

* Cleanup on injections

* remove vuex dependency

* extract out button classes

* Revamp store and viewer handler

* Detect reload needed

* Bump the version to 3

* Bump node project to 3

* prettier settings on save and co

* comments

* Enable zoom extends

* Node packages version bumps and selection handler saga

* Cleanup viewer wrapper as MVP

* bump viewer version for offline loader

* correct warning logs

---------

Co-authored-by: AlexandruPopovici <alexandrupopoviciioan@gmail.com>
Co-authored-by: Dogukan Karatas <karatasdogukan@gmail.com>
2024-12-19 12:27:34 +03:00
Kristaps Fabians Geikins e233aec607 chore: add extra instructions for straight up windows (#86) 2024-12-04 15:44:25 +03:00
Kristaps Fabians Geikins 52f4325619 chore: various DX improvements like working source maps (#85)
* init changes

* sourcemaps work

* eff off pbiviz

* more fixes

* moar fixes

* prod build fix

* remove yarn field

* minor scripts change

* moar readme stuff
2024-12-03 22:35:18 +03:00
Alan Rynne 6e92c857a7 Merge pull request #84 from specklesystems/dev
Update `main` with changes from `dev`
2024-11-05 11:53:21 +01:00
Alan Rynne 8edc01b7d6 fix: Update viewer to version 2.21.0 (#82) 2024-11-05 11:26:09 +01:00
Claire Kuang 6d5f638895 Merge pull request #83 from specklesystems/claire/cnx-699-update-github-links-to-point-to-v3
Update README.md to align with main github page
2024-11-01 18:51:47 +00:00
Claire Kuang ccecf7cb2b Update README.md to align with main github page 2024-11-01 18:49:03 +00:00
Mucahit Bilal GOKER 156c3a5c3a return model id instead of name (#81) 2024-10-01 18:02:00 +02:00
Alan Rynne 887dbb2344 Merge branch 'main' into dev 2024-09-09 16:19:13 +02:00
Mucahit Bilal GOKER 556196a45f fixed extension path (#79) 2024-09-05 15:38:02 +02:00
Jedd Morgan 1bf6e76252 Merge pull request #78 from specklesystems/dev
Merge dev -> main
2024-08-08 14:41:41 +01:00
Mucahit Bilal GOKER b26801ef8a Update README.md (#76) 2024-08-08 14:40:35 +01:00
Iain Sproat 74ab91be3b chore(domains): update speckle.xyz to app.speckle.systems (#77)
- remove reference to DO 1-click as this is deprecated
2024-08-08 14:39:07 +01:00
Alan Rynne 920b346175 Merge branch 'main' into dev 2024-06-30 23:24:53 +02:00
Mucahit Bilal GOKER 9c42f06ea4 Merge pull request #75 from specklesystems/bimgeek-patch-1
Update README.md
2024-06-04 17:03:09 +03:00
Mucahit Bilal GOKER 6af64d8499 Update README.md 2024-06-04 17:02:58 +03:00
Alan Rynne 46ff9acd64 fix(visual): Give user facing pbiviz a better name 2024-05-30 11:03:10 +02:00
Alan Rynne 8031c7da4f feat: CNX-9628 Add visual to installer and CI script (#74)
* feat: Add visual to installer and CI script (attempt 1)

* fix(ci): Working directory set incorrectly

* fix(ci): Run build before pack and set data connector path correctly

* Install visual tools into dev dependencies

* fix(ci): Try fix MakePQX not found

* fix(ci): MakePQX args need correct subfolder

* fix(visual): Rename visual to not have guid

* feat(ci): Set default version to 2.0.0 everywhere, and overwrite on CI jobs

* fix(ci): Missed one version location

* fix(visual): Always use package.json version

This allows us to `npm version` instead of doing some weirder logic

* fix(visual): Allow same version when bumping
2024-05-29 22:34:03 +02:00
Alan Rynne 08554fc864 Merge branch 'main' into dev 2024-05-29 18:20:16 +02:00
Alan Rynne 9168174747 feat: CNX-9627 Merge data connector and visual into the same repo (#73)
* chore: Moved data connector into nested `src/powerbi-data-connector` folder

* feat(visual): Moved powerbi visual from speckle-powerbi-visuals repo

Copied from 2.19 tagged commit 0f034c17d04acd3fa5130a91779576efde7793a9

* chore: Created vscode workspace and unified settings

* fix: Update iss file and CI scripts

+ added workspace settings

* ci: Minor path fixes

* ci: And some extra tweaks

* ci: Typo in powerbi.iss
2024-05-29 12:16:40 +02:00
Alan Rynne fd9054a387 fix: Ensure old .mez connector is removed upon installation (#72) 2024-05-23 00:00:42 +02:00
Alan Rynne 84efce792b Merge pull request #71 from specklesystems/dev
Update `main` with changes from `dev`
2024-05-14 17:20:43 +02:00
Alan Rynne 0bc4da1864 fix: User Shell constant from Innosetup instead of ENV var from system (#70)
Lower admin rights to minimum as we don't need any more.
2024-05-13 16:28:49 +02:00
Alan Rynne d7ea4f217f fix: Installer doesn't need admin rights unless we sign the PQX (currently blocked) (#69) 2024-04-29 12:17:35 +02:00
Alan Rynne 3971adafd6 Merge pull request #68 from specklesystems/dev
Update main with changes from dev
2024-04-09 22:06:30 +02:00
Alan Rynne 1392070b31 CNX-9189 Installer for PowerBI Data Connector (without signing PQX) (#67)
* feat: Added logic to add thumbprint to registry

As well as delete it on uninstall, without compromising the rest of the values that other connectors may have added.

* fix: Re-enable pqx

* fix: Minor edits to install logic

* feat: CI config with conditional signing

* fix: Set versions correctly

* fix: Disable github release upload

* fix: Missing SSM env var and fast exit if external pr

* fix: Set version env vars correctly

* just a test

* another test 🧪

* with AI help

* circleCI wth

* 🤔🤕

* Why does it refuse to work!?!?!

* Onelining

* Onelining real command

* too fast :D

* 🤞🏼

* final touch?

* I really hope this does it

* 🥲

* 💥

* Revert "💥"

This reverts commit ac570614a9.

* Jonathon's magic 🪄

* Jonathon's magic v2

* starts to seem less magical

* maybe PEBKAC

* 🤞🏼

* just one loop?

* try escape \

* no double %%

* try escape with ""

* try bat file

* try bat file differently

* 🤦🏼‍♂️

* double %% in bat file

* try relative path

* fix code-signing error

* move includes

* 🚀

* fix: Do not sign PQX but do sign installers

* fix: Use actual tagname 🙇🏼‍♂️🤦🏼‍♂️

* ci: Minor tweaks

* ci: Push to real feed

* fix: Use exe not pqx to upload installer 🤦🏼‍♂️
2024-04-08 12:06:44 +02:00
Alan Rynne 85b9e88fc1 Merge pull request #65 from specklesystems/dev
Update `dev` with changes from `main`
2024-03-14 11:40:48 +01:00
Alan Rynne 92fc894d4b fix: Throw error when multi-model URL is input (#64) 2024-02-26 18:21:23 +01:00
Alan Rynne b033cfa82b CNX-9076: first round of new web app terminology rename (#63)
* fix: first round of new web app terminology rename

* fix: Last refs to commit/branch/stream gone

* fix: Table headers

* ci: Removed unnecessary step and bumped ci ghr image

* Modified publicly visible names on resource file
2024-02-26 17:03:20 +01:00
KatKatKateryna 86cba3ce2b Update README.md (#62)
Updated install instructions as here: https://learn.microsoft.com/en-gb/power-bi/connect-data/desktop-connector-extensibility#certified-connectors
2024-02-26 10:44:10 +01:00
Alan Rynne c752487f9f fix: CNX-7606 Fixes missing Data column error (#61)
* fix: Result will now include parent commit object and no longer assume it will have children

* fix: Keep metadata in joined table
2024-01-12 13:29:42 +01:00
Alan Rynne 95f51b0d32 fix(CNX-8322): Separated completely frontend2 parsing (#59)
* fix: Separated completely frontend2 parsing

This prevents logic from Fe2 leaking into Fe1 and viceversa, which could cause `null` exceptions in some cases.

* CNX-8322 Track in Jira
2023-11-30 10:26:53 +01:00
Alan Rynne 9a5c1283ce Adds Frontend2 URL Support for single model urls (#58)
* feat: Adds FE2 Url support for single model urls

* fix: Minor formatting changes
2023-11-09 16:48:36 +01:00
Alan Rynne da1f0c7b7e feat: Added extensions.json (#57) 2023-10-30 10:58:17 +01:00
Alan Rynne 0bb72f0d9d fix: Get back metrics by using old specific Receive log method (#56) 2023-10-30 10:56:04 +01:00
Ryan Haunfelder 19e64fd4b2 Parses the stream URL in a slightly more robust way. (#55) 2023-10-25 11:26:46 +02:00
Alan Rynne 63f286cd0b bump: 2.15.0-rc 2023-07-07 14:54:01 +02:00
Alan Rynne e89ccbbe1a feat: Adds new ToNameValueRecord function for revit params and DynamicExpand for table columns (#49) 2023-07-07 10:35:38 +02:00
garylzimmer f77e315623 Update README.md (#47)
added note about expected use case and link to relevant github
2023-06-14 13:11:13 +02:00
Alan Rynne 9db161b3f2 Update main with changes in dev (#42)
* feat: Added isMultiplayer to receive log

* Adds universal OAuth, preliminary connector installer and new column in GetByURL table (#41)

* ci: Added step to sign MEZ file

* ci: Fix output dir

* ci: Added innosetup installer test

* ci: Fix path

* ci: Fix sign tool path 🤦🏼‍♂️

* ci: Don't sign

* feat: Added parent object column to GetByUrl result

* feat: Universal OAuth login

* fix: Installer function fail, non-critical. Reverted to simple implementation
2023-05-11 12:37:20 +02:00
Alan Rynne 83ec9a7888 ci: Updated issue automation 2023-01-09 20:26:28 +01:00
Alan Rynne 6128b4293f fix: Use filename with no . 2023-01-09 17:15:36 +01:00
Alan Rynne 6f68ec9c29 revert no branch change 2023-01-09 17:12:48 +01:00
Alan Rynne 10c1009430 fix: Try with no branch 2023-01-09 17:12:20 +01:00
Alan Rynne c635995bf6 fix: Add reopen event 2023-01-09 17:09:43 +01:00
Alan Rynne 1198450ea4 fix: Use non-nested path 2023-01-09 17:08:22 +01:00
Alan Rynne 3d4545be64 fix: Use correct location 2023-01-09 17:04:52 +01:00
Alan Rynne 363c389928 test: Use reusable workflow for issue open event 2023-01-09 17:02:02 +01:00
Alan Rynne addc3f9d86 feat: using contexts in CI config (#36)
* feat: using contexts in CI config

* fix: Wrong context in the wrong place
2023-01-09 11:55:40 +01:00
Alan Rynne 44fc99ecb7 fix(ci): Version setting on CI now picks up correct version 2023-01-02 11:08:35 +01:00
Alan Rynne f52d6c46cb Changes login from latest to XYZ (#35)
* feat: Adds XYZ login instead + minor cleanup

* fix: Added tracking to both exposed functions
2022-12-20 19:00:02 +01:00
Alan Rynne f558d5dce3 Adds support for REST endpoint to get objects (#34)
* feat: Working REST endpoint to fetch objects instead of GraphQL

* hack: Temporarily exposed rest function

* feat: Added OAuth test login

* chore: Cleanup for release
2022-12-15 12:06:19 +01:00
Alan Rynne f9093a34e5 fixes #33 2022-12-06 12:06:42 +01:00
Alan Rynne 23cb40c4ab Fixes slow behaviour in Speckle.GetByUrl (#31)
* fix: Swapped slow RemoveItems for faster Select

* feat: Added `select` input to `GetObjectChildren` function

* fix: Increased pagination to 1000
2022-12-05 22:53:56 +01:00
Alan Rynne 9bd6140065 CI: Adds build and deploy configs (#30)
* Add .circleci/config.yml

* First attempt

* fix: Missing win orb

* fix: Wrong persist path

* ci: Added version updating step

* ci: Fixed artifacts paths

* ci: Added publish to github release step

* Fixing ci paths to persist

* fix: Artifacts path

* ci: Fix deploy dependency order

* ci: Adds tags to ghr inputs
2022-12-05 17:59:20 +01:00
Alan Rynne a14bb06d4e Merge pull request #29 from specklesystems/unit-testing
General improvements in DataConnector
2022-12-05 13:51:11 +01:00
Alan Rynne 01576e77df chore: Reorganised tests 2022-12-05 10:19:32 +01:00
Alan Rynne f1e16e9d55 feat: More refactoring, tests and new exposed functions 2022-12-04 22:50:42 +01:00
Alan Rynne 4f210dae04 feat: Refactor of helper methods 2022-12-02 00:00:04 +01:00
Alan Rynne 8669cf59f8 fix: Minor fixes in imports + test.query.pq file 2022-12-01 17:03:15 +01:00
Alan Rynne 6e6402cb38 Merge pull request #18 from specklesystems/refactor/vs-code-extension
Refactor: Use new VSCode Extension + Modularise data connector
2022-11-29 12:34:08 +01:00
Alan Rynne 7b62630fd1 fix: MIssing getUser function in LogEvent 2022-11-29 12:28:24 +01:00
Alan Rynne eee4f0f8c2 feat: Added utility functions from powerquery docs 2022-11-28 23:05:41 +01:00
Alan Rynne 23fa79bdd9 fix: Renamed commitReceived function 2022-11-28 22:53:23 +01:00
Alan Rynne edc9917a20 feat: Split down into modules 2022-11-28 22:38:59 +01:00
Alan Rynne 99cffeba8c feat: Working with new VSCode extension 2022-11-28 20:47:28 +01:00
Alan Rynne 7e92e7a2aa Fixes #16 2022-11-25 13:48:06 +01:00
Alan Rynne 15aa627d7f fix: Failed receive on public streams due to read receipts (fixes #15) 2022-10-27 23:23:37 +02:00
Alan Rynne 8844f1837e feat: Updated mixpanel logging with sourceApp variables 2022-10-07 12:58:35 +02:00
Alan Rynne 6d1b85a14f Revert "fix: Read receipt was using hardcoded token? "
This reverts commit b2d6568b66.
2022-09-01 10:39:01 +02:00
Alan Rynne b2d6568b66 fix: Read receipt was using hardcoded token? 2022-09-01 10:33:05 +02:00
Alan Rynne 72f455393b fix: Prevent read receipt when no credentials are found 2022-09-01 10:13:20 +02:00
Alan Rynne bd3fe6a47c feat: Refactored output table for viewer compatibility 2022-08-31 11:25:46 +02:00
Alan Rynne e7710f0f8e fix: Remove null row at the end or result table 2022-08-25 11:08:09 +02:00
Alan Rynne e9034027eb feat: Added columns to FetchByUrl result table for plug-and-play with the viewer 2022-08-25 10:42:03 +02:00
Alan Rynne 685384b147 feat: Added mixpanel user and server hashed 2022-04-07 15:37:52 +02:00
Alan Rynne 5973aaea10 feat: Added user fetch function 2022-04-07 12:17:17 +02:00
Alan Rynne 639287f69c feat: Added mixpanel tracking 2022-04-06 12:55:49 +02:00
Alan Rynne a43decd473 Merge pull request #12 from specklesystems/fix/branch-special-chars
Fix: Uses powerquery `buildQueryString` method to ensure branch name is url safe first
2021-12-03 12:18:19 +01:00
Alan Rynne a532061879 Fix: Uses powerquery buildQueryString method to ensure branch name is url safe first 2021-12-03 12:16:50 +01:00
Alan Rynne 15ac7c041e Merge pull request #10 from specklesystems/hotfix/url-parsing
fix: Fixes wrong implementation assignment and optional input removal
2021-12-02 12:17:03 +01:00
Alan Rynne 770d45f981 fix: Fixes wrong implementation assignment and optional input removal 2021-12-02 12:15:58 +01:00
Alan Rynne 50b59a88c3 Merge pull request #9 from specklesystems/alan/error-reporting
Stable release final touches 🪄
2021-11-29 12:41:06 +01:00
Alan Rynne 0bad9914c8 fix: Removed shared tag from API function 2021-11-29 12:40:54 +01:00
Alan Rynne aee00f3f21 fix: Removed __closure and totalChildrenCount fields. 2021-11-29 12:31:45 +01:00
Alan Rynne 2abdd4b645 fix: Removed duplicated icons and fixed folder path 2021-11-29 12:31:19 +01:00
Alan Rynne 71ef1acd8b feat: Final polish!! 2021-11-29 11:39:39 +01:00
Alan Rynne 23114a2912 chore: Pending file deletion 2021-11-25 10:02:42 +01:00
Alan Rynne ee989f927d feat: Better error handling and initial function documentation 2021-11-25 10:01:09 +01:00
Alan Rynne 1ff15c7b44 chore: Moved logos into subfolder 2021-11-25 10:00:45 +01:00
Alan Rynne 6e9fb590a0 chore: Removed duplicated api call 2021-11-24 18:58:53 +01:00
Alan Rynne 9700865934 Merge pull request #7 from specklesystems/alan/table-pagination
Adds pagination to object queries
2021-11-24 10:58:48 +01:00
Alan Rynne cf9e5a70b6 chore: Reordering of methods for clarity 2021-11-24 09:52:04 +01:00
Alan Rynne 50c360ae79 feat: Pagination works!! Plus query formating 2021-11-24 09:31:39 +01:00
Alan Rynne b671945fa7 feat: More re-structuring + pagination boilerplate 2021-11-24 09:05:52 +01:00
Alan Rynne eb4787ddfa fix: Removed redundant implementation 2021-11-23 16:40:31 +01:00
Alan Rynne 3ffd6c63e0 feat: Fetch refactoring 2021-11-23 16:33:08 +01:00
Alan Rynne a5a8316ee0 Merge pull request #6 from specklesystems/alan/receive-receipts
feat: Added receive receipts to PowerBI and branch URL support
2021-11-19 15:21:13 +01:00
Alan Rynne 17083c9474 feat: Branch url support! + minor mismatch in auth 2021-11-19 12:07:12 +01:00
Alan Rynne 3e6f9988d6 feat: Added receive receipts to PowerBI 2021-11-18 13:51:10 +01:00
144 changed files with 32592 additions and 614 deletions
+3
View File
@@ -0,0 +1,3 @@
for /f "tokens=1 delims=-" %%i in ("%CIRCLE_TAG%") do set "TAG=%%i.%WORKFLOW_NUM%"
for /f "tokens=1 delims=/" %%j in ("%CIRCLE_TAG%") do set "SEMVER=%%j"
tools\InnoSetup\ISCC.exe tools\powerbi.iss /Sbyparam=$p /DINFO_VERSION=%TAG% /DVERSION=%SEMVER% %*
+171
View File
@@ -0,0 +1,171 @@
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
orbs:
win: circleci/windows@5.0
commands:
setup_digicert:
description: Set up Digicert Keylocker certificate for code-signing
steps:
- run:
name: "Digicert Signing Manager Setup"
command: |
cd C:\
curl.exe -X GET https://one.digicert.com/signingmanager/api-ui/v1/releases/smtools-windows-x64.msi/download -H "x-api-key:$env:SM_API_KEY" -o smtools-windows-x64.msi
msiexec.exe /i smtools-windows-x64.msi /quiet /qn | Wait-Process
- run:
name: Setup Digicert ONE Client Cert
command: |
cd C:\
echo $env:SM_CLIENT_CERT_FILE_B64 > certificate.txt
certutil -decode certificate.txt certificate.p12
- run:
name: Sync Certs
command: |
& $env:SSM\smksp_cert_sync.exe
jobs:
build-visual:
docker:
- image: cimg/node:18.20.3
steps:
- checkout
- run: node --version
- run:
name: "npm install"
command: "npm i"
working_directory: src/powerbi-visual
- run:
name: Set version
command: |
npm version ${CIRCLE_TAG:-2.0.0} --allow-same-version
working_directory: src/powerbi-visual
- run:
name: "npm run build"
command: "npm run build"
working_directory: src/powerbi-visual
- store_artifacts:
path: dist/*.pbiviz
- persist_to_workspace:
root: ./
paths:
- src/powerbi-visual/dist/*.pbiviz
build-connector:
executor:
name: win/default
shell: powershell.exe
environment:
SSM: 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools'
steps:
- checkout
- run:
name: "Set connector internal version"
command: |
$env:VERSION = if([string]::IsNullOrEmpty($env:CIRCLE_TAG)) { "2.0.0" } else { $env:CIRCLE_TAG }
(Get-Content ./Speckle.pq).replace('[Version = "2.0.0"]', '[Version = "'+$($env:VERSION)+'"]') | Set-Content ./Speckle.pq
working_directory: src/powerbi-data-connector
- run:
name: "Build Data Connector"
command: "msbuild Speckle.proj /restore /consoleloggerparameters:NoSummary /property:GenerateFullPaths=true"
working_directory: src/powerbi-data-connector
- run:
name: Create PQX file
command: .\tools\MakePQX\MakePQX.exe pack -mz src/powerbi-data-connector/bin/Speckle.mez -t src/powerbi-data-connector/bin/Speckle.pqx
- persist_to_workspace:
root: ./
paths:
- src/powerbi-data-connector/bin/Speckle.pqx
build-installer:
executor:
name: win/default
shell: powershell.exe
environment:
SSM: 'C:\Program Files\DigiCert\DigiCert One Signing Manager Tools'
steps:
- checkout
- attach_workspace:
at: ./
- unless: # Build installers unsigned on non-tagged builds
condition: << pipeline.git.tag >>
steps:
- run:
name: Build Installer
shell: cmd.exe #does not work in powershell
environment:
WORKFLOW_NUM: << pipeline.number >>
CIRCLE_TAG: 2.0.0
command: .circleci\build-installer.bat
- when: # Setup certificates and build installers signed for tagged builds
condition: << pipeline.git.tag >>
steps:
- setup_digicert
- run:
name: Build Installer
shell: cmd.exe #does not work in powershell
environment:
WORKFLOW_NUM: << pipeline.number >>
command: .circleci\build-installer.bat /DSIGN_INSTALLER /DCODE_SIGNING_CERT_FINGERPRINT=%SM_CODE_SIGNING_CERT_SHA1_HASH%
- store_artifacts:
path: ./installer
- persist_to_workspace:
root: ./
paths:
- installer/*.exe
deploy-connector-to-feed:
docker:
- image: mcr.microsoft.com/dotnet/sdk:6.0
steps:
- attach_workspace:
at: ./
- run:
name: Install Manager Feed CLI
command: dotnet tool install --global Speckle.Manager.Feed
- run:
name: Upload new version
command: |
TAG=$(if [ "${CIRCLE_TAG}" ]; then echo $CIRCLE_TAG; else echo "2.0.0"; fi;)
SEMVER=$(echo "$TAG" | sed -e 's/\/[a-zA-Z-]*//')
VER=$(echo "$SEMVER" | sed -e 's/-.*//')
VERSION=$(echo $VER.$WORKFLOW_NUM)
/root/.dotnet/tools/Speckle.Manager.Feed deploy -s powerbi -v ${SEMVER} -u https://releases.speckle.dev/installers/powerbi/powerbi-${SEMVER}.exe -o Win -a Any -f ./installer/powerbi-${SEMVER}.exe
environment:
WORKFLOW_NUM: << pipeline.number >>
workflows:
build:
jobs:
- build-connector:
context: digicert-keylocker
- build-visual
- build-installer:
context: digicert-keylocker
requires:
- build-connector
- build-visual
deploy:
jobs:
- build-connector:
filters: &deploy_filter
branches:
ignore: /.*/
tags:
only: /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-\w{1,10})?$/
context: digicert-keylocker
- build-visual:
filters: *deploy_filter
- build-installer:
filters: *deploy_filter
context: digicert-keylocker
requires:
- build-connector
- build-visual
- deploy-connector-to-feed:
filters: *deploy_filter
requires:
- build-installer
context: do-spaces-speckle-releases
+145
View File
@@ -0,0 +1,145 @@
name: build_powerbi
on:
push:
branches: ["installer-test/**"]
tags: ["v3.*.*"] # Manual delivery on every 3.x tag
jobs:
build-connector:
runs-on: windows-latest
outputs:
semver: ${{ steps.set-version.outputs.semver }}
file-version: ${{ steps.set-info-version.outputs.file-version }}
env:
CertFile: "./speckle.pfx"
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: 6.0.5 # github actions doesnt like 6.1.0 onwards https://github.com/GitTools/actions/blob/main/docs/versions.md
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v3.0.0
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Build Data Connector
working-directory: src/powerbi-data-connector
run: |
msbuild Speckle.proj /restore /consoleloggerparameters:NoSummary /property:GenerateFullPaths=true
- name: Setup Self-sign certificate
run: |
echo "${{ secrets.SELF_CERT_FILE_B64 }}" > "certificate.txt"
certutil -decode certificate.txt ${{ env.CertFile }}
- name: Create PQX file
run: |
.\tools\MakePQX\MakePQX.exe pack --mez src/powerbi-data-connector/bin/Speckle.mez --target src/powerbi-data-connector/bin/Speckle.pqx --certificate ${{env.CertFile}} --password ${{secrets.SELF_CERT_PASSWORD}}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: powerbi-connector
path: src/powerbi-data-connector/bin/Speckle.pqx
if-no-files-found: error
retention-days: 1
- id: set-version
name: Set version to output
run: echo "semver=${{steps.gitversion.outputs.semVer}}" >> "$GITHUB_OUTPUT"
shell: bash
- id: set-info-version
name: Set version to output
run: echo "file-version=${{steps.gitversion.outputs.AssemblySemVer}}" >> "$GITHUB_OUTPUT"
shell: bash
build-visual:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v3.0.0
with:
versionSpec: 6.0.5 # github actions doesnt like 6.1.0 onwards https://github.com/GitTools/actions/blob/main/docs/versions.md
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v3.0.0
- run: npm ci
working-directory: src/powerbi-visual
- run: npm version ${{steps.gitversion.outputs.semVer}} --allow-same-version
working-directory: src/powerbi-visual
- run: npm run build
working-directory: src/powerbi-visual
- uses: actions/upload-artifact@v4
with:
name: powerbi-visual
path: src/powerbi-visual/dist/*.pbiviz
if-no-files-found: error
retention-days: 1
deploy-installers:
runs-on: ubuntu-latest
needs:
- build-connector
- build-visual
env:
IS_TAG_BUILD: ${{ github.ref_type == 'tag' }}
steps:
- name: download artifacts
uses: actions/download-artifact@v4
with:
name: powerbi-connector
path: artifacts/
- name: download artifacts visual
uses: actions/download-artifact@v4
with:
name: powerbi-visual
path: artifacts/
- name: Zip artifacts
run: |
cd artifacts && zip -r ../powerbi.zip .
- name: upload artifacts
uses: actions/upload-artifact@v4
with:
name: output-${{needs.build-connector.outputs.semver}}
path: powerbi.zip
if-no-files-found: error
retention-days: 1
- name: 🔫 Trigger Build Installer(s)
uses: the-actions-org/workflow-dispatch@v4.0.0
with:
workflow: Build Installers
repo: specklesystems/connector-installers
token: ${{ secrets.CONNECTORS_GH_TOKEN }}
inputs: '{
"run_id": "${{ github.run_id }}",
"semver": "${{ needs.build-connector.outputs.semver }}",
"file_version": "${{ needs.build-connector.outputs.file-version }}",
"repo": "${{ github.repository }}",
"is_public_release": ${{ env.IS_TAG_BUILD }}
}'
ref: main
wait-for-completion: true
wait-for-completion-interval: 10s
wait-for-completion-timeout: 10m
display-workflow-run-url: true
display-workflow-run-url-interval: 10s
- uses: geekyeggo/delete-artifact@v5
with:
name: output-*
-78
View File
@@ -1,78 +0,0 @@
name: Update issue Status
on:
issues:
types: [closed]
jobs:
update_issue:
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ORGANIZATION: specklesystems
PROJECT_NUMBER: 9
run: |
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectNext(number: $number) {
id
fields(first:20) {
nodes {
id
name
settings
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
echo "$PROJECT_ID"
echo "$STATUS_FIELD_ID"
echo 'DONE_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .settings | fromjson | .options[] | select(.name== "Done") | .id' project_data.json) >> $GITHUB_ENV
echo "$DONE_ID"
- name: Add Issue to project #it's already in the project, but we do this to get its node id!
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
item_id="$( gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
mutation($project:ID!, $id:ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $id}) {
projectNextItem {
id
}
}
}' -f project=$PROJECT_ID -f id=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
- name: Update Status
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
mutation($project:ID!, $status:ID!, $id:ID!, $value:String!) {
set_status: updateProjectNextItemField(
input: {
projectId: $project
itemId: $id
fieldId: $status
value: $value
}
) {
projectNextItem {
id
}
}
}' -f project=$PROJECT_ID -f status=$STATUS_FIELD_ID -f id=$ITEM_ID -f value=${{ env.DONE_ID }}
-50
View File
@@ -1,50 +0,0 @@
name: Move new issues into Project
on:
issues:
types: [opened]
jobs:
track_issue:
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ORGANIZATION: specklesystems
PROJECT_NUMBER: 9
run: |
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectNext(number: $number) {
id
fields(first:20) {
nodes {
id
name
settings
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
- name: Add Issue to project
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
item_id="$( gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
mutation($project:ID!, $id:ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $id}) {
projectNextItem {
id
}
}
}' -f project=$PROJECT_ID -f id=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
+10
View File
@@ -334,3 +334,13 @@ ASALocalRun/
.localhistory/
**/.DS_Store
**/dist/
**/.tmp/
**/webpack.statistics.*.html
**/webpack.statistics.html
**/Thumbs.db
installer/
localhost.pem
localhost-key.pem
+11
View File
@@ -0,0 +1,11 @@
workflow: GitFlow/v1
next-version: 3.0.0
mode: ManualDeployment
branches:
main:
label: rc
develop:
regex: ^dev$
label: beta
unknown:
increment: None
+68 -61
View File
@@ -1,14 +1,74 @@
<h1 align="center">
<<h1 align="center">
<img src="https://user-images.githubusercontent.com/2679513/131189167-18ea5fe1-c578-47f6-9785-3748178e4312.png" width="150px"/><br/>
Speckle | PowerBI
Speckle | Power BI
</h1>
<h3 align="center">
Data Connector for Microsoft's PowerBI platform
</h3>
<p align="center"><b>Speckle</b> is the data infrastructure for the AEC industry.</p><br/>
<p align="center"><a href="https://twitter.com/SpeckleSystems"><img src="https://img.shields.io/twitter/follow/SpeckleSystems?style=social" alt="Twitter Follow"></a> <a href="https://speckle.community"><img src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fspeckle.community&amp;style=flat-square&amp;logo=discourse&amp;logoColor=white" alt="Community forum users"></a> <a href="https://speckle.systems"><img src="https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square" alt="website"></a> <a href="https://speckle.guide/dev/"><img src="https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&amp;logo=read-the-docs&amp;logoColor=white" alt="docs"></a></p>
<p align="center"></p>
> Speckle is the first AEC data hub that connects with your favorite AEC tools. Speckle exists to overcome the challenges of working in a fragmented industry where communication, creative workflows, and the exchange of data are often hindered by siloed software and processes. It is here to make the industry better.
<h3 align="center">
Speckle Connector and 3D Viewer Visual for Power BI
</h3>
# Features
Speckle Power BI Data Connector lets you easily get data from Speckle into Power BI reports and visualizations. You can access and analyze data from various AEC apps (like Revit, Archicad, Grasshopper, and more) and open-source files (IFC, STL, OBJ, etc.) into Power BI with ease.
Speckles connection to Power BI consists of two parts:
- **Data Connector** fetches the data you uploaded from AEC apps to Speckle.
- **3D Visual** allows you to see those models in 3D within Power BI.
![Desktop - 1 (1)](https://github.com/specklesystems/speckle-powerbi/assets/51519350/6d2c5224-965f-4eae-b869-be26cb48c6b2)
# Repo Structure
This repo is home to our Power BI connector. The Speckle Server provides all the web-facing functionality and can be found [here](https://github.com/specklesystems/Server).
`src/powerbi-data-connector` contains all the code for the Data connector.
`src/powerbi-visual` contains all the code for 3D Visual.
# Installation
Speckle connector can be installed directly from [Manager for Speckle](https://speckle.systems/download/). Full instructions for [installation](https://speckle.guide/user/powerbi/installation.html) and [configuration](https://speckle.guide/user/powerbi/configuration.html) can be found on our docs.
# Using 3D Visual
3D Visual can be imported as any other Power BI custom visual.
1. Navigate to the Visualization Pane.
2. Click the three dots (…) and select “Import a visual from a file”.
3. Go to `Documents/Power BI Desktop/Custom Visuals` and import `Speckle 3D Visual.pbiviz` file.
4. Speckle cube will appear in the Visualization pane.
For more on how to use the visual, [check our docs](https://speckle.guide/user/powerbi-visual/introduction.html).
# Usage
To get started with Power BI connectors, please take a look at the [documentation](https://speckle.guide/user/powerbi/introduction.html) and extensive [tutorials](https://www.youtube.com/playlist?list=PLlI5Dyt2HaEsZHG2WJ75WIM0Brx6VHT2S) published.
# **Developing & Debugging**
We encourage everyone interested to debug/hack/contribute/give feedback to this project.
## **Setup**
### **Install PowerQuery SDK**
Follow the instructions from the [official docs](https://docs.microsoft.com/en-us/power-query/installingsdk)
### **Build with Visual Studio**
Every time you build the connector, VisualStudio will copy the latest `.mez` connector file to the appropriate location. Just restart PowerBI to see the latest changes.
### **Debug**
You can start the PowerQuery connector in VisualStudio, this will open a standalone connector you can use for testing purposes.
We don't know of a way to debug the connector live in PowerBI, but we'd be happy to hear about it.
# About Speckle
@@ -31,8 +91,7 @@ What is Speckle? Check our ![YouTube Video Views](https://img.shields.io/youtube
Give Speckle a try in no time by:
- [![speckle XYZ](https://img.shields.io/badge/https://-speckle.xyz-0069ff?style=flat-square&logo=hackthebox&logoColor=white)](https://speckle.xyz) ⇒ creating an account at our public server
- [![create a droplet](https://img.shields.io/badge/Create%20a%20Droplet-0069ff?style=flat-square&logo=digitalocean&logoColor=white)](https://marketplace.digitalocean.com/apps/speckle-server?refcode=947a2b5d7dc1) ⇒ deploying an instance in 1 click
- [![app.speckle.systems](https://img.shields.io/badge/https://-speckle.xyz-0069ff?style=flat-square&logo=hackthebox&logoColor=white)](https://app.speckle.systems) ⇒ creating an account at our public server
### Resources
@@ -41,55 +100,3 @@ Give Speckle a try in no time by:
- [![docs](https://img.shields.io/badge/docs-speckle.guide-orange?style=for-the-badge&logo=read-the-docs&logoColor=white)](https://speckle.guide/dev/) reference on almost any end-user and developer functionality
![Untitled](https://user-images.githubusercontent.com/2679513/132021739-15140299-624d-4410-98dc-b6ae6d9027ab.png)
# Repo structure
This repo is the home to our Speckle 2.0 PowerBI project. The [Speckle Server](https://github.com/specklesystems/Server) is providing all the web-facing functionality and can be found [here](https://github.com/specklesystems/Server).
## Install
Go to the [Releases](https://github.com/specklesystems/speckle-powerbi/releases) page, downlad the `.mez` file of the latest release and copy it into the following folder in your computer:
```
YOUR_USER_FOLDER\Documents\Power BI Desktop\Custom Connectors\
```
### Allow custom extensions to run
Go to `Settings -> Security -> Data Extensions` and activate the following option:
![Allow extensions to run](https://user-images.githubusercontent.com/2316535/130931149-074cf6a8-1910-41f1-99c7-b8b08168f473.png)
### Checking the connector is loaded
Now open PowerBI and you should see `Speckle (beta)` appear in the data source.
![PowerBI](https://user-images.githubusercontent.com/2316535/129580913-02e5e662-f344-419c-9894-e97055930c58.png)
## Usage
> More detailed instructions on how to use the connector will be added shortly!
### Current limitations
Chunked data currently is not automatically de-chunked when received, we are aware of this limitation and are working to resolve it!
## Developing & Debugging
We encourage everyone interested to debug / hack / contribute / give feedback to this project.
### Setup
#### Install PowerQuery SDK
Follow the instructions from the [official docs](https://docs.microsoft.com/en-us/power-query/installingsdk)
#### Build with Visual Studio
Every time you build the connector, VisualStudio will copy the latest `.mez` connector file to the appropriate location. Just restart PowerBI to see the latest changes.
#### Debug
You can start the PowerQuery connector in VisualStudio, this will open a standalone connector you can use for testing purposes.
We don't know of a way to debug the connector live in PowerBI, but we'd be happy to hear about it.
-25
View File
@@ -1,25 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{4DF76451-A46A-4C0B-BE03-459FAAFA07E6}") = "Speckle", "Speckle\Speckle.mproj", "{D61F9470-E614-45C7-8047-E354FF219408}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D61F9470-E614-45C7-8047-E354FF219408}.Debug|x86.ActiveCfg = Debug|x86
{D61F9470-E614-45C7-8047-E354FF219408}.Debug|x86.Build.0 = Debug|x86
{D61F9470-E614-45C7-8047-E354FF219408}.Release|x86.ActiveCfg = Release|x86
{D61F9470-E614-45C7-8047-E354FF219408}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {765772BB-45FA-4661-9573-F0F182FEB7C1}
EndGlobalSection
EndGlobal
-121
View File
@@ -1,121 +0,0 @@
<Project DefaultTargets="BuildExtension" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0b5fe03d-aad9-4bc4-9edf-b543d5e50d29}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>MyRootNamespace</RootNamespace>
<AssemblyName>MyAssemblyName</AssemblyName>
<EnableUnmanagedDebugging>False</EnableUnmanagedDebugging>
<AllowNativeQuery>False</AllowNativeQuery>
<AsAction>False</AsAction>
<FastCombine>False</FastCombine>
<ClearLog>False</ClearLog>
<ShowEngineTraces>False</ShowEngineTraces>
<ShowUserTraces>False</ShowUserTraces>
<LegacyRedirects>False</LegacyRedirects>
<SuppressRowErrors>False</SuppressRowErrors>
<SuppressCellErrors>False</SuppressCellErrors>
<MaxRows>1000</MaxRows>
<ExtensionProject>Yes</ExtensionProject>
<Name>Speckle</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>false</DebugSymbols>
<!--Should be true, fix this when the debugger is implemented -->
<OutputPath>bin\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>false</DebugSymbols>
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Speckle.pq">
<SubType>Code</SubType>
</Compile>
<Compile Include="SpeckleLogo16.png">
<SubType>Code</SubType>
</Compile>
<Compile Include="SpeckleLogo20.png">
<SubType>Code</SubType>
</Compile>
<Compile Include="SpeckleLogo24.png">
<SubType>Code</SubType>
</Compile>
<Compile Include="SpeckleLogo32.png">
<SubType>Code</SubType>
</Compile>
<Compile Include="SpeckleLogo40.png">
<SubType>Code</SubType>
</Compile>
<Compile Include="SpeckleLogo48.png">
<SubType>Code</SubType>
</Compile>
<Compile Include="SpeckleLogo64.png">
<SubType>Code</SubType>
</Compile>
<Compile Include="SpeckleLogo80.png">
<SubType>Code</SubType>
</Compile>
<Compile Include="resources.resx">
<SubType>Code</SubType>
</Compile>
<Content Include="Speckle.query.pq">
<SubType>Code</SubType>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<UsingTask TaskName="BuildExtension" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<InputDirectory ParameterType="System.String" Required="true" />
<OutputFile ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Using Namespace="System.Globalization" />
<Using Namespace="System.IO.Compression " />
<Code Type="Fragment" Language="cs"><![CDATA[
using(FileStream fileStream = File.Create(OutputFile))
using(ZipArchive archiveOut = new ZipArchive(fileStream, ZipArchiveMode.Create, false))
{
foreach(string fullPath in Directory.EnumerateFiles(InputDirectory))
{
string filename = Path.GetFileName(fullPath);
archiveOut.CreateEntryFromFile(fullPath, filename, CompressionLevel.Optimal);
}
}
]]></Code>
</Task>
</UsingTask>
<Target Name="BuildExtension" DependsOnTargets="ExtensionClean">
<ItemGroup>
<PQFiles Include="@(Compile)" Condition="'%(Extension)' == '.pq'" />
</ItemGroup>
<ItemGroup>
<NonPQFiles Include="@(Compile)" Condition="'%(Extension)' != '.pq'" />
</ItemGroup>
<MakeDir Directories="$(IntermediateOutputPath)" />
<MakeDir Directories="$(OutputPath)" />
<Copy SourceFiles="@(NonPQFiles)" DestinationFolder="$(IntermediateOutputPath)" />
<Copy SourceFiles="@(PQFiles)" DestinationFiles="@(PQFiles->'$(IntermediateOutputPath)%(RecursiveDir)%(FileName).m')" />
<BuildExtension InputDirectory="$(IntermediateOutputPath)" OutputFile="$(OutputPath)\$(ProjectName).mez" />
<Message Text="Copying .mez file to: $(UserProfile)\Documents\Power BI Desktop\Custom Connectors" Importance="High" />
<MakeDir Directories="$(UserProfile)\Documents\Power BI Desktop\Custom Connectors\" />
<Copy SourceFiles="$(OutputPath)\$(ProjectName).mez" DestinationFolder="$(UserProfile)\Documents\Power BI Desktop\Custom Connectors">
</Copy>
</Target>
<Target Name="ExtensionClean">
<!-- Remove obj folder -->
<RemoveDir Directories="$(BaseIntermediateOutputPath)" />
<!-- Remove bin folder -->
<RemoveDir Directories="$(OutputPath)" />
</Target>
</Project>
-260
View File
@@ -1,260 +0,0 @@
section Speckle;
/* This is an additional nav bar that can display branches of a stream: not using this for now
[DataSource.Kind="Speckle", Publish="Speckle.Publish"]
shared Speckle.Contents = Value.ReplaceType(NavigationTable.Simple, type function (url as Uri.Type) as any);
// set up nav table
shared NavigationTable.Simple = (url) as table =>
let
baseUrl = Uri.Parts(url)[Host] as text,
streamId = Text.Split(Uri.Parts(url)[Path], "/"){2},
objects = Speckle.GetBranches(baseUrl, streamId),
table = #table(
{"Name", "Key", "Data", "ItemKind", "ItemName", "IsLeaf"},
List.InsertRange(objects, List.Count(objects), {{"GetCommit", "GetCommit", Speckle.GetObjectFromObject(baseUrl, streamId), "Function", "Function", true}})
),
NavTable = Table.ToNavigationTable(table, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
in
NavTable;
Speckle.GetBranches = (url, id) =>
let
Source = Web.Contents(
Text.Combine({"https:/", url, "graphql"}, "/"),
[
Headers=[
#"Method"="POST",
#"Content-Type"="application/json"
],
Content=Text.ToBinary("{""query"": ""query { stream( id: \"""&id&"\"" ) { branches { items { name commits { items { id message sourceApplication authorName createdAt } } } } } }""}")
]
),
#"JSON" = Json.Document(Source),
branches = #"JSON"[data][stream][branches][items],
branchList = List.Generate(
() => [x = 0, y = Speckle.GetBranchAsList(branches{x})],
each [x] < List.Count(branches),
each [x = [x] + 1, y = Speckle.GetBranchAsList(branches{x})],
each [y]
)
in
branchList;
Speckle.GetBranchAsList = (branchRecord) =>
let
commits = Table.FromRecords(branchRecord[commits][items]),
list = {branchRecord[name], branchRecord[name], commits, "Table", "Table", true}
in
list;
*/
[DataSource.Kind="Speckle", Publish="Speckle.Publish"]
shared Speckle.Contents = Value.ReplaceType(CommitTable, type function (StreamUrl as Uri.Type) as any);
/* INFO: Variables will not be instantiated (or any code run) until they are used */
shared CommitTable = (url) as table =>
let
// Get server and streamId, and branchName / commitId / objectid from the input url
s = Text.Combine({"https://", Uri.Parts(url)[Host]}),
server = Speckle.LogToMatomo(s),
segments = Text.Split(Text.AfterDelimiter(Uri.Parts(url)[Path], "/", 0), "/"),
streamId = segments{1},
branchName = if( List.Count(segments) = 4 and segments{2} = "branches" ) then segments{3} else null,
commitId = if (List.Count(segments) = 4 and segments{2} = "commits" ) then segments{3} else null,
objectId = if (List.Count(segments) = 4 and segments{2} = "objects" ) then segments{3} else null,
commitTable = if (commitId <> null) then Speckle.GetObjectFromCommit(server, streamId, commitId)
else if (objectId <> null) then Speckle.GetObjectFromObject(server, streamId, objectId, false)
else if (branchName <> null) then #table( { "Error" }, { { "Invalid URL, use a stream or commit or object url" } } ) // currently not implemented, see reason below
else Speckle.GetObjectFromStream(server, streamId)
in
commitTable;
/* Since everything is lazily evaluated, we must join and split the result of the matomo call with the server, and spit back the server url for PowerBI to actually log the calls to Matomo */
Speckle.LogToMatomo = (server) =>
let
matomoUrl = "https://speckle.matomo.cloud/matomo.php",
action = "receive/manual",
appName = "Power BI",
userId = "powerBIuser",
params = [
idsite = "2",
rec = "1",
apiv = "1",
uid = userId,
action_name = action,
url = Text.Combine({"http://connectors/PowerBI/", action}),
urlref = Text.Combine({"http://connectors/PowerBI/", action}),
_cvar = Text.FromBinary(Json.FromValue([hostApplication = appName]))
],
visitQuery = Uri.BuildQueryString(params),
visitRes = Web.Contents(Text.Combine({matomoUrl, "?", visitQuery}),
[
Headers=[
#"Method"="POST"
],
Content=Text.ToBinary(server)
]),
eventParams = [
idsite = "2",
rec = "1",
apiv = "1",
uid = userId,
_cvar = Text.FromBinary(Json.FromValue([hostApplication = appName])),
e_c = appName,
e_a = action
],
eventQuery = Uri.BuildQueryString(eventParams),
eventRes = Web.Contents(Text.Combine({ matomoUrl, "?", eventQuery}),
[
Headers=[
#"Method"="POST"
],
Content=Text.ToBinary(server)
]),
Result = Text.FromBinary(visitRes) & Text.FromBinary(eventRes),
Combined = Text.Combine({server,Result},"___"),
Split = Text.Split(Combined,"___"){0}
in
Split;
Speckle.GetObjectFromStream = (server, streamId) =>
let
branchName = "main",
Source = Web.Contents(
Text.Combine({server, "graphql"}, "/"),
[
Headers=[
#"Method"="POST",
#"Content-Type"="application/json"
],
Content=Text.ToBinary("{""query"": ""query { stream( id: \"""&streamId&"\"" ) { branch (name: \"""&branchName&"\""){ commits (limit: 1) { items { referencedObject } } } } }""}")
]
),
#"JSON" = Json.Document(Source),
objectId = #"JSON"[data][stream][branch][commits][items]{0}[referencedObject],
objectsTable = Speckle.GetObjectFromObject(server, streamId, objectId, true)
in
objectsTable;
/* Not implemented since power query M uri does not have a decode method...def not manually writing a method to handle special chars and emojis
Speckle.GetObjectFromBranch = (server, streamId, branchName) =>
let
Source = Web.Contents(
Text.Combine({server, "graphql"}, "/"),
[
Headers=[
#"Method"="POST",
#"Content-Type"="application/json"
],
Content=Text.ToBinary("{""query"": ""query { stream( id: \"""&streamId&"\"" ) { branch (name: \"""&branchName&"\""){ commits (limit: 1) { items { referencedObject } } } } }""}")
]
),
#"JSON" = Json.Document(Source),
objectId = #"JSON"[data][stream][branch][commits][items]{0}[referencedObject],
objectsTable = Speckle.GetObjectFromObject(server, streamId, objectId)
in
objectsTable;
*/
shared Speckle.GetObjectFromCommit = (server, streamId, commitId) =>
let
Source = Web.Contents(
Text.Combine({server, "graphql"}, "/"),
[
Headers=[
#"Method"="POST",
#"Content-Type"="application/json"
],
Content=Text.ToBinary("{""query"": ""query { stream( id: \"""&streamId&"\"" ) { commit (id: \"""&commitId&"\""){ referencedObject } } }""}")
]
),
#"JSON" = Json.Document(Source),
objectId = #"JSON"[data][stream][commit][referencedObject],
objectsTable = Speckle.GetObjectFromObject(server, streamId, objectId, true)
in
objectsTable;
Speckle.GetObjectFromObject = (server, streamId, objectId, IsCommitObject) =>
let
query = if (IsCommitObject) then "{""query"": ""query { stream( id: \"""&streamId&"\"" ) { object (id: \"""&objectId&"\"") { children { objects { data } } } } }""}"
else "{""query"": ""query { stream( id: \"""&streamId&"\"" ) { object (id: \"""&objectId&"\"") { data } } }""}",
Source = Web.Contents(
Text.Combine({server, "graphql"}, "/"),
[
Headers=[
#"Method"="POST",
#"Content-Type"="application/json"
],
Content=Text.ToBinary(query)
]
),
#"JSON" = Json.Document(Source),
objects = if (IsCommitObject) then #"JSON"[data][stream][object][children][objects]
else {#"JSON"[data][stream][object][data]},
// remove closures from records, and remove DataChunk records
removeClosureField = List.Transform(objects, each Record.RemoveFields(_, "__closure", MissingField.Ignore)),
removeDatachunkRecords = List.RemoveItems(removeClosureField, List.FindText(removeClosureField, "Speckle.Core.Models.DataChunk")),
objectsTable = Table.FromRecords(removeDatachunkRecords)
in
objectsTable;
// Data Source Kind description
Speckle = [
Authentication = [
Key = [
KeyLabel="Personal Access Token",
Label = "Private stream"
],
Implicit = [
Label = "Public stream"
]
],
Label = Extension.LoadString("Speckle Connector")
];
// Data Source UI publishing description
Speckle.Publish = [
Beta = true,
Category = "Other",
ButtonText = { Extension.LoadString("ButtonTitle"), Extension.LoadString("ButtonHelp") },
LearnMoreUrl = "https://speckle.guide",
SourceImage = Speckle.Icons,
SourceTypeImage = Speckle.Icons
];
Speckle.Icons = [
Icon16 = { Extension.Contents("SpeckleLogo16.png"), Extension.Contents("SpeckleLogo20.png"), Extension.Contents("SpeckleLogo24.png"), Extension.Contents("SpeckleLogo32.png") },
Icon32 = { Extension.Contents("SpeckleLogo32.png"), Extension.Contents("SpeckleLogo40.png"), Extension.Contents("SpeckleLogo48.png"), Extension.Contents("SpeckleLogo64.png") }
];
// copy and pasted function from microsoft docs since it's not included yet in M standard lib
Table.ToNavigationTable = (
table as table,
keyColumns as list,
nameColumn as text,
dataColumn as text,
itemKindColumn as text,
itemNameColumn as text,
isLeafColumn as text
) as table =>
let
tableType = Value.Type(table),
newTableType = Type.AddTableKey(tableType, keyColumns, true) meta
[
NavigationTable.NameColumn = nameColumn,
NavigationTable.DataColumn = dataColumn,
NavigationTable.ItemKindColumn = itemKindColumn,
Preview.DelayColumn = itemNameColumn,
NavigationTable.IsLeafColumn = isLeafColumn
],
navigationTable = Value.ReplaceType(table, newTableType)
in
navigationTable;
-5
View File
@@ -1,5 +0,0 @@
// Use this file to write queries to test your data connector
let
result = Speckle.Contents("https://speckle.xyz/streams/5b97b37b8b")
in
result
+6
View File
@@ -0,0 +1,6 @@
{
"name": "speckle-powerbi",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}
+63
View File
@@ -0,0 +1,63 @@
{
"folders": [
{
"name": "🏠 root",
"path": "."
},
{
"name": "➡️ powerbi-data-connector",
"path": "src/powerbi-data-connector"
},
{
"name": "👀 powerbi-visual",
"path": "src/powerbi-visual"
}
],
"settings": {
"powerquery.general.mode": "SDK",
"powerquery.sdk.defaultQueryFile": "${workspaceFolder}\\src\\powerbi-data-connector\\Speckle.query.pq",
"powerquery.sdk.defaultExtension": "${workspaceFolder}\\src\\powerbi-data-connector\\bin\\Speckle.mez",
"files.eol": "\n",
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true,
".tmp": true
},
"editor.formatOnPaste": true,
"editor.multiCursorModifier": "ctrlCmd",
"editor.snippetSuggestions": "top",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"search.exclude": {
".tmp": true,
"typings": true,
"dist": true,
"wepbpack.statistics.dev.html": true,
"wepbpack.statistics.html": true
},
"json.schemas": [
{
"fileMatch": ["/pbiviz.json"],
"url": "./src/powerbi-visual/node_modules/powerbi-visuals-api/schema.pbiviz.json"
},
{
"fileMatch": ["/capabilities.json"],
"url": "./src/powerbi-visual/node_modules/powerbi-visuals-api/schema.capabilities.json"
},
{
"fileMatch": ["/dependencies.json"],
"url": "./src/powerbi-visual/node_modules/powerbi-visuals-api/schema.dependencies.json"
}
]
},
"extensions": {
"recommendations": [
"esbenp.prettier-vscode",
"ms-dotnettools.csharp",
"powerquery.vscode-powerquery-sdk"
]
}
}
+12
View File
@@ -0,0 +1,12 @@
{
"configurations": [
{
"type": "powerquery",
"request": "launch",
"name": "Test powerquery file",
"program": "${workspaceFolder}/${command:AskForPowerQueryFileName}",
"additionalArgs": ["--logMashupEngineTraces", "user"],
"preLaunchTask": "build"
}
]
}
+32
View File
@@ -0,0 +1,32 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "powerquery",
"operation": "msbuild",
"additionalArgs": [
"/restore",
"/consoleloggerparameters:NoSummary",
"/property:GenerateFullPaths=true"
],
"problemMatcher": ["$msCompile"],
"group": "build",
"label": "build"
},
{
"type": "shell",
"label": "tests",
"command": "${config:powerquery.sdk.tools.location}\\PQTest.exe",
"args": [
"run-test",
"--extension",
"${config:powerquery.sdk.defaultExtension}",
"--queryFile",
"${workspaceFolder}\\tests",
"--prettyPrint"
],
"problemMatcher": [],
"dependsOn": ["build"]
}
]
}
+204
View File
@@ -0,0 +1,204 @@
[Version = "3.0.0"]
section Speckle;
AuthAppId = "spklpwerbi";
AuthAppSecret = "spklpwerbi";
// function to load `pqm` files - this is essential and must be kept
shared Speckle.LoadFunction = (fileName as text) =>
let
binary = Extension.Contents(fileName),
asText = Text.FromBinary(binary)
in
try
Expression.Evaluate(asText, #shared)
catch (e) =>
error
[
Reason = "Speckle.LoadFunction Failure",
Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'",
Message.Parameters = {fileName, e[Reason], e[Message]},
Detail = [File = fileName, Error = e]
];
// here we register the functions to expose them globally
[DataSource.Kind = "Speckle"]
shared Speckle.Parser = Value.ReplaceType(
Speckle.LoadFunction("Parser.pqm"),
type function (url as Uri.Type) as record
);
[DataSource.Kind = "Speckle"]
shared Speckle.Api.Fetch = Value.ReplaceType(
Speckle.LoadFunction("Api.Fetch.pqm"),
type function (url as Uri.Type, optional query as text, optional variables as record) as record
);
[DataSource.Kind = "Speckle"]
shared Speckle.GetUser = Value.ReplaceType(
Speckle.LoadFunction("GetUser.pqm"),
type function (url as Uri.Type) as record
);
[DataSource.Kind = "Speckle"]
shared Speckle.GetModel = Value.ReplaceType(
Speckle.LoadFunction("GetModel.pqm"),
type function (url as Uri.Type) as record
);
[DataSource.Kind = "Speckle"]
shared Speckle.GetStructuredData = Value.ReplaceType(
Speckle.LoadFunction("GetStructuredData.pqm"),
type function (url as Uri.Type) as table
);
[DataSource.Kind = "Speckle"]
shared Speckle.SendToServer = Value.ReplaceType(
Speckle.LoadFunction("SendToServer.pqm"),
type function (url as Uri.Type) as table
);
[DataSource.Kind = "Speckle", Publish="GetByUrl.Publish"]
shared Speckle.GetByUrl = Value.ReplaceType(
Speckle.LoadFunction("GetByUrl.pqm"),
type function (
url as (
Uri.Type meta [
Documentation.FieldCaption = "Speckle Model URL",
Documentation.FieldDescription = "The URL of a model in a Speckle server project. You can copy it directly from your browser.",
Documentation.SampleValues = {"https://app.speckle.systems/projects/7902de1f57/models/7f890a65df"}
]
)
) as table meta [
Documentation.Name = "Speckle - Get Data by URL",
Documentation.DisplayName = "Speckle - Get Data by URL",
Documentation.LongDescription = "Returns structured data from a Speckle model URL.#(lf)
Supports the following URL formats:#(lf)
- Model URL: Gets the latest version of the specified model#(lf)
(e.g., 'https://app.speckle.systems/projects/PROJECT_ID/models/MODEL_ID')#(lf)
- Version URL: Gets a specific version from the project#(lf)
(e.g., 'https://app.speckle.systems/projects/PROJECT_ID/models/MODEL_ID@VERSION_ID')"
]
);
shared Speckle.Revit.Parameters.ToNameValueRecord = (r as record, optional exclude as list) as record =>
let
defaultExclude = {"id", "speckle_type", "applicationId", "totalChildrenCount"},
fullExclusion = if exclude = null then defaultExclude else List.Union(defaultExclude, exclude),
clean = Record.RemoveFields(r, fullExclusion, MissingField.Ignore),
recTable = Record.ToTable(clean),
cleanTable = Table.RemoveColumns(recTable, "Name"),
expanded = Table.ExpandRecordColumn(
cleanTable, "Value", {"name", "value", "applicationInternalName"}, {"Name", "Value", "UID"}
),
joined = Table.AddColumn(expanded, "Combo", each [Name] & " [" & [UID] & "]"),
renamed = Table.RenameColumns(joined, {{"Name", "x"}, {"Combo", "Name"}}),
result = Record.FromTable(renamed)
in
result;
// here we register the GetByUrl function to power bi ui
GetByUrl.Publish = [
Cateogry = "Other",
ButtonText = {"Connect to Speckle"},
LearnMoreUrl = "https://speckle.guide/user/powerbi/introduction.html",
SourceImage = GetByUrl.Icons,
SourceTypeImage = GetByUrl.Icons
];
GetByUrl.Icons = [
Icon16 = { Extension.Contents("SpeckleLogo16.png"), Extension.Contents("SpeckleLogo20.png"), Extension.Contents("SpeckleLogo24.png"), Extension.Contents("SpeckleLogo32.png") },
Icon32 = { Extension.Contents("SpeckleLogo32.png"), Extension.Contents("SpeckleLogo40.png"), Extension.Contents("SpeckleLogo48.png"), Extension.Contents("SpeckleLogo64.png") }
];
// The data source definition
Speckle = [
// This is used when running the connector on an on-premises data gateway
TestConnection = (path) => {"Speckle.GetUser", path},
// Authentication strategy
Authentication = [
OAuth = [
Label = "Speckle Account",
StartLogin = (clientApplication, dataSourcePath, state, display) =>
let
server = Text.Combine(
{Uri.Parts(dataSourcePath)[Scheme], "://", Uri.Parts(dataSourcePath)[Host]}
)
in
[
LoginUri = Text.Combine({server, "authn", "verify", AuthAppId, state}, "/"),
CallbackUri = "https://oauth.powerbi.com/views/oauthredirect.html",
WindowHeight = 800,
WindowWidth = 600,
Context = null
],
FinishLogin = (clientApplication, dataSourcePath, context, callbackUri, state) =>
let
server = Text.Combine(
{Uri.Parts(dataSourcePath)[Scheme], "://", Uri.Parts(dataSourcePath)[Host]}
),
Parts = Uri.Parts(callbackUri)[Query],
Source = Web.Contents(
Text.Combine({server, "auth", "token"}, "/"),
[
Headers = [
#"Content-Type" = "application/json"
],
Content = Json.FromValue(
[
accessCode = Parts[access_code],
appId = AuthAppId,
appSecret = AuthAppSecret,
challenge = state
]
)
]
),
json = Json.Document(Source)
in
[
access_token = json[token],
scope = null,
token_type = "bearer",
refresh_token = json[refreshToken]
],
Refresh = (dataSourcePath, refreshToken) =>
let
server = Text.Combine(
{Uri.Parts(dataSourcePath)[Scheme], "://", Uri.Parts(dataSourcePath)[Host]}
),
Source = Web.Contents(
Text.Combine({server, "auth", "token"}, "/"),
[
Headers = [
#"Content-Type" = "application/json"
],
Content = Json.FromValue(
[
refreshToken = refreshToken,
appId = AuthAppId,
appSecret = AuthAppSecret
]
)
]
),
json = Json.Document(Source)
in
[
access_token = json[token],
scope = null,
token_type = "bearer",
refresh_token = json[refreshToken]
]
],
Key = [
KeyLabel = "Personal Access Token",
Label = "Private Project"
],
Implicit = [
Label = "Public Project"
]
],
Label = "Speckle"
];
+46
View File
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="BuildMez">
<PropertyGroup>
<Version Condition="'$(Version)' == ''">2.0.0-wip</Version>
<OutputPath Condition="'$(OutputPath)' == ''">$(MSBuildProjectDirectory)\bin\</OutputPath>
<IntermediateOutputPath Condition="'$(IntermediateOutputPath)' == ''">
$(MSBuildProjectDirectory)\obj\</IntermediateOutputPath>
<MezIntermediatePath>$(IntermediateOutputPath)MEZ\</MezIntermediatePath>
<MezOutputPath>$(OutputPath)$(MsBuildProjectName).mez</MezOutputPath>
<IsContinuousIntegrationBuild>false</IsContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup>
<MezContent Include="Speckle.pq" />
<MezContent Include="speckle\**\*.pqm" />
<MezContent Include="assets\SpeckleLogo16.png" />
<MezContent Include="assets\SpeckleLogo20.png" />
<MezContent Include="assets\SpeckleLogo24.png" />
<MezContent Include="assets\SpeckleLogo32.png" />
<MezContent Include="assets\SpeckleLogo40.png" />
<MezContent Include="assets\SpeckleLogo48.png" />
<MezContent Include="assets\SpeckleLogo64.png" />
<MezContent Include="assets\SpeckleLogo80.png" />
<MezContent Include="assets\resources.resx" />
</ItemGroup>
<Target Name="BuildMez" AfterTargets="Build" Inputs="@(MezContent)" Outputs="$(MezOutputPath)">
<RemoveDir Directories="$(MezIntermediatePath)" />
<Copy SourceFiles="@(MezContent)" DestinationFolder="$(MezIntermediatePath)" />
<MakeDir Directories="$(OutputPath)" Condition="!Exists('$(OutputPath)')" />
<ZipDirectory SourceDirectory="$(MezIntermediatePath)" DestinationFile="$(MezOutputPath)"
Overwrite="true" />
</Target>
<Target Name="CopyToConnectors" AfterTargets="BuildMez"
Condition="$(IsContinuousIntegrationBuild) == 'false'">
<Message
Text="Copying .mez file to: $(UserProfile)\Documents\Power BI Desktop\Custom Connectors"
Importance="High" />
<MakeDir Directories="$(UserProfile)\Documents\Power BI Desktop\Custom Connectors\" />
<Copy SourceFiles="$(MezOutputPath)"
DestinationFolder="$(UserProfile)\Documents\Power BI Desktop\Custom Connectors\" />
</Target>
<Target Name="Clean">
<RemoveDir Directories="$(MezIntermediatePath)" />
<Delete Files="$(MezOutputPath)" />
</Target>
</Project>
@@ -0,0 +1,9 @@
// use this file to write queries to test your data connector
// NOTE! for tests, be make sure you put here a model that in private project to make sure all good.
let
result = Speckle.GetByUrl(
"https://latest.speckle.systems/projects/126cd4b7bb/models/85c44d39c6"
)
in
result

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

@@ -22,8 +22,10 @@
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing"
mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework
object]</value>
<comment>This is a comment</comment>
</data>
@@ -59,7 +61,8 @@
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
@@ -112,18 +115,65 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ButtonHelp" xml:space="preserve">
<value>Connect to Speckle</value>
</data>
<data name="ButtonTitle" xml:space="preserve">
<value>Speckle</value>
</data>
<data name="DataSourceLabel" xml:space="preserve">
<value>Speckle</value>
</data>
<data name="GetByUrl.Help" xml:space="preserve">
<value>Connect to Speckle by Model URL</value>
</data>
<data name="GetByUrl.Label" xml:space="preserve">
<value>Speckle</value>
</data>
<data name="GetByUrl.Title" xml:space="preserve">
<value>Speckle - Get Model by URL</value>
</data>
<data name="GetObjFromBranch.Help" xml:space="preserve">
<value>Connect to Speckle by server URL, stream ID and branch name</value>
</data>
<data name="GetObjFromBranch.Label" xml:space="preserve">
<value>Get the latest commit from a stream's branch</value>
</data>
<data name="GetObjFromBranch.Title" xml:space="preserve">
<value>Speckle - Get Stream branch</value>
</data>
<data name="GetObjFromCommit.Help" xml:space="preserve">
<value>Connect to Speckle by server URL, stream ID and commit ID</value>
</data>
<data name="GetObjFromCommit.Label" xml:space="preserve">
<value>A label</value>
</data>
<data name="GetObjFromCommit.Title" xml:space="preserve">
<value>Speckle - Get Stream commit</value>
</data>
<data name="GetStream.Help" xml:space="preserve">
<value>Connect to Speckle by server URL and stream ID</value>
</data>
<data name="GetStream.Label" xml:space="preserve">
<value>Speckle</value>
</data>
<data name="GetStream.Title" xml:space="preserve">
<value>Speckle - Get Model by URL [Structured]</value>
</data>
<data name="GetObjectAsNavTable.Title" xml:space="preserve">
<value>Speckle - Get Object as NavTable</value>
</data>
<data name="GetObjectAsNavTable.Label" xml:space="preserve">
<value>Speckle</value>
</data>
<data name="GetObjectAsNavTable.Help" xml:space="preserve">
<value>Returns a navigation table for a given object</value>
</data>
<data name="Traverse.Title" xml:space="preserve">
<value>Traverse an object and populate refs</value>
</data>
<data name="Traverse.Label" xml:space="preserve">
<value>Traverse</value>
</data>
<data name="Traverse.Help" xml:space="preserve">
<value>Traverse help</value>
</data>
</root>
@@ -0,0 +1,112 @@
(url as text) as table =>
let
// import required functions
GetStructuredData = Extension.LoadFunction("GetStructuredData.pqm"),
SendToServer = Extension.LoadFunction("SendToServer.pqm"),
GetModel = Extension.LoadFunction("GetModel.pqm"),
Parser = Extension.LoadFunction("Parser.pqm"),
// the logic for importing functions from other files
Extension.LoadFunction = (fileName as text) =>
let
binary = Extension.Contents(fileName),
asText = Text.FromBinary(binary)
in
try
Expression.Evaluate(asText, #shared)
catch (e) =>
error
[
Reason = "Extension.LoadFunction Failure",
Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'",
Message.Parameters = {fileName, e[Reason], e[Message]},
Detail = [File = fileName, Error = e]
],
// parse the URL to determine if it's a federated model
parsedUrl = Parser(url),
// function to process a single model and get its data
ProcessSingleModel = (baseUrl, projectId, modelId, versionId) =>
let
// construct a standard URL for the model
singleModelUrl = Text.Combine({
baseUrl,
"/projects/",
projectId,
"/models/",
modelId,
if versionId <> null then Text.Combine({"@", versionId}) else ""
}),
// get model info
modelInfo = GetModel(singleModelUrl),
rootObjectId = modelInfo[rootObjectId],
modelName = modelInfo[modelName],
// get structured data
structuredData = GetStructuredData(singleModelUrl),
// add the model name as context
result = Table.AddColumn(
structuredData,
"Source Model",
each modelName,
type text
)
in
[
Data = result,
RootObjectId = rootObjectId
],
// check if this is a federated model
results = if parsedUrl[isFederated] = true then
// process each model in the federation
let
modelsData = List.Transform(
parsedUrl[federatedModels],
each ProcessSingleModel(
parsedUrl[baseUrl],
parsedUrl[projectId],
[modelId],
[versionId]
)
),
// extract all data tables
allTables = List.Transform(modelsData, each [Data]),
// extract all root object IDs
allRootIds = List.Transform(modelsData, each [RootObjectId]),
// combine all root object IDs into a comma-separated string
combinedRootIds = Text.Combine(allRootIds, ","),
// combine all data tables
combinedData = Table.Combine(allTables),
// replace the "Version Object ID" column with the combined root IDs
finalData = Table.TransformColumns(
combinedData,
{"Version Object ID", each combinedRootIds}
)
in
finalData
else
// use existing functionality for single models
let
// get model name
modelInfo = GetModel(url),
modelName = modelInfo[modelName],
// get structured data
structuredData = GetStructuredData(url),
// rename column based on send status
newColumnName = "Version Object ID",
result = Table.RenameColumns(structuredData, {{"Version Object ID", newColumnName}})
in
result
in
results
@@ -0,0 +1,33 @@
(server as text, optional query as text, optional variables as record) as record =>
let
apiKey = try Extension.CurrentCredential()[Key] otherwise null,
defaultQuery = "query {
activeUser {
email
name
}
serverInfo {
name
company
version
}
}",
Source = Web.Contents(
Text.Combine({server, "graphql"}, "/"),
[
Headers = [
#"Method" = "POST",
#"Content-Type" = "application/json",
#"Authorization" = if apiKey = null then "" else Text.Format("Bearer #{0}", {apiKey})
],
ManualStatusHandling = {400},
Content = Json.FromValue([query = Text.From(query ?? defaultQuery), variables = variables])
]
),
#"JSON" = Json.Document(Source)
in
// Check if response contains errors, if so, return first error.
if Record.HasFields(#"JSON", {"errors"}) then
error #"JSON"[errors]{0}[message]
else
#"JSON"[data]
@@ -0,0 +1,122 @@
// function for getting model information through graphql query
(url as text) as record =>
let
// import the parser function
Parser = Extension.LoadFunction("Parser.pqm"),
// the logic for importing functions from other files
Extension.LoadFunction = (fileName as text) =>
let
binary = Extension.Contents(fileName),
asText = Text.FromBinary(binary)
in
try
Expression.Evaluate(asText, #shared)
catch (e) =>
error
[
Reason = "Extension.LoadFunction Failure",
Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'",
Message.Parameters = {fileName, e[Reason], e[Message]},
Detail = [File = fileName, Error = e]
],
// parse the url and get necessary fields
parsedUrl = Parser(url),
server = parsedUrl[baseUrl],
projectId = parsedUrl[projectId],
modelId = parsedUrl[modelId],
versionId = parsedUrl[versionId],
// get API key if available
apiKey = try Extension.CurrentCredential()[Key] otherwise null,
// graphql query to get model info including root object id
// includes specific version if provided
query = if versionId = null then
"query ($projectId: String!, $modelId: String!) {
project(id: $projectId) {
model(id: $modelId) {
id
name
versions {
items {
id
referencedObject
sourceApplication
}
}
}
}
}"
else
"query ($projectId: String!, $modelId: String!, $versionId: String!) {
project(id: $projectId) {
model(id: $modelId) {
id
name
version(id: $versionId) {
id
referencedObject
sourceApplication
}
}
}
}",
// include versionId in variables if it exists
variables = if versionId = null then
[
projectId = projectId,
modelId = modelId
]
else
[
projectId = projectId,
modelId = modelId,
versionId = versionId
],
// make the api request
Source = Web.Contents(
Text.Combine({server, "graphql"}, "/"),
[
Headers = [
#"Method" = "POST",
#"Content-Type" = "application/json",
#"Authorization" = if apiKey = null then "" else Text.Format("Bearer #{0}", {apiKey})
],
ManualStatusHandling = {400, 401, 403},
Content = Json.FromValue([
query = query,
variables = variables
])
]
),
// parse the response
JsonResponse = Json.Document(Source),
// extract needed information, now handling both version-specific and latest version cases
result = if Record.HasFields(JsonResponse, {"errors"}) then
error JsonResponse[errors]{0}[message]
else if JsonResponse[data]?[project]?[model] = null then
error "Model not found or access denied. Please check your authentication and model ID."
else if versionId = null then
[
modelId = JsonResponse[data][project][model][id],
modelName = JsonResponse[data][project][model][name],
versionId = JsonResponse[data][project][model][versions][items]{0}[id],
rootObjectId = JsonResponse[data][project][model][versions][items]{0}[referencedObject],
sourceApplication = JsonResponse[data][project][model][versions][items]{0}[sourceApplication]
]
else
[
modelId = JsonResponse[data][project][model][id],
modelName = JsonResponse[data][project][model][name],
versionId = JsonResponse[data][project][model][version][id],
rootObjectId = JsonResponse[data][project][model][version][referencedObject],
sourceApplication = JsonResponse[data][project][model][version][sourceApplication]
]
in
result
@@ -0,0 +1,74 @@
// function for getting structured object data
(url as text) as table =>
let
// import the required functions
GetModel = Extension.LoadFunction("GetModel.pqm"),
SendToServer = Extension.LoadFunction("SendToServer.pqm"),
// the logic for importing functions from other files
Extension.LoadFunction = (fileName as text) =>
let
binary = Extension.Contents(fileName),
asText = Text.FromBinary(binary)
in
try
Expression.Evaluate(asText, #shared)
catch (e) =>
error
[
Reason = "Extension.LoadFunction Failure",
Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'",
Message.Parameters = {fileName, e[Reason], e[Message]},
Detail = [File = fileName, Error = e]
],
// get model info and server data
modelInfo = GetModel(url),
rootId = modelInfo[rootObjectId],
// Get the data from SendToServer - this is already a response from the service
JsonResponse = SendToServer(url),
// convert list to table with all columns expanded
TableFromList = Table.FromList(
JsonResponse,
Splitter.SplitByNothing(),
null,
null,
ExtraValues.Error
),
// fields to remove from data record
FieldsToRemove = {"__closure", "totalChildrenCount", "renderMaterialProxies"},
// create the final table with cleaned data records
FinalTable = Table.FromRecords(
List.Transform(
TableFromList[Column1],
each let
record = _,
fieldsToRemoveForThisRecord = List.Select(
FieldsToRemove,
each Record.HasFields(record, {_})
)
in
[
#"Object IDs" = record[id], // Object IDs
#"Speckle Type" = record[speckle_type], // Speckle Type
#"Version Object ID" = rootId,
data = Record.RemoveFields(record, fieldsToRemoveForThisRecord) // Data
]
)
),
// Filtering logic here
// If, model data contains any DataObject -> fetch only data objects
// If there are no data objects in the data -> fetch everything but DataChunks
HasDataObjects = Table.RowCount(
Table.SelectRows(FinalTable, each Text.Contains(Record.FieldOrDefault([data], "speckle_type", ""), "DataObject"))
) > 0,
FilteredTable = if HasDataObjects then
Table.SelectRows(FinalTable, each Text.Contains(Record.FieldOrDefault([data], "speckle_type", ""), "DataObject"))
else
Table.SelectRows(FinalTable, each Record.FieldOrDefault([data], "speckle_type", "") <> "Speckle.Core.Models.DataChunk")
in
FilteredTable
@@ -0,0 +1,66 @@
// function for getting the user info with graphql query
let
// import the parser function from Parser.pqm file
Parser = Extension.LoadFunction("Parser.pqm"),
// the logic for importing functions from other files
Extension.LoadFunction = (fileName as text) =>
let
binary = Extension.Contents(fileName),
asText = Text.FromBinary(binary)
in
try
Expression.Evaluate(asText, #shared)
catch (e) =>
error
[
Reason = "Extension.LoadFunction Failure",
Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'",
Message.Parameters = {fileName, e[Reason], e[Message]},
Detail = [File = fileName, Error = e]
]
in
(url as text) as record =>
let
// get base server URL using the imported function
parsedUrl = Parser(url),
server = parsedUrl[baseUrl],
apiKey = try Extension.CurrentCredential()[Key] otherwise "",
query = "query {
activeUser {
email
name
}
serverInfo {
name
company
version
}
}",
Source = Web.Contents(
Text.Combine({server, "graphql"}, "/"),
[
Headers = [
#"Method" = "POST",
#"Content-Type" = "application/json",
#"Authorization" = if apiKey = "" then "" else Text.Format("Bearer #{0}", {apiKey})
],
ManualStatusHandling = {400},
Content = Json.FromValue([query = query])
]
),
JsonResponse = Json.Document(Source)
in
if Record.HasFields(JsonResponse, {"errors"}) then
error JsonResponse[errors]{0}[message]
else
[
UserEmail = try JsonResponse[data][activeUser][email] otherwise "",
UserName = try JsonResponse[data][activeUser][name] otherwise "",
ServerName = JsonResponse[data][serverInfo][name],
ServerCompany = JsonResponse[data][serverInfo][company],
ServerVersion = JsonResponse[data][serverInfo][version],
Token = if apiKey = "" then null else apiKey[access_token]
]
@@ -0,0 +1,58 @@
// function for parsing the url into base url, project id, model id and version id
(url as text) as record =>
let
urlParts = Uri.Parts(url),
baseUrl = Text.Combine({urlParts[Scheme], "://", urlParts[Host]}),
pathSegments = List.Select(Text.Split(urlParts[Path], "/"), each _ <> ""),
// extract project ID if it exists
projectId = if List.Count(pathSegments) >= 2 and pathSegments{0} = "projects"
then pathSegments{1} else null,
// extract model ID and version ID if they exist
rawModelSegment = if List.Count(pathSegments) >= 4 and pathSegments{2} = "models"
then pathSegments{3} else "",
// check if this is a federated model (contains commas)
isFederated = Text.Contains(rawModelSegment, ","),
// if federated, split by comma to get multiple model IDs
modelSegments = if isFederated
then Text.Split(rawModelSegment, ",")
else {rawModelSegment},
// process each model segment (could be modelID or modelID@versionID)
processedModels = List.Transform(
modelSegments,
each [
modelId = if Text.Contains(_, "@")
then Text.Split(_, "@"){0}
else _,
versionId = if Text.Contains(_, "@")
then Text.Split(_, "@"){1}
else null
]
),
// extract model IDs and version IDs into separate lists
modelIds = List.Transform(processedModels, each [modelId]),
versionIds = List.Transform(processedModels, each [versionId]),
// validate URL structure
isValid = projectId <> null and List.Count(modelIds) > 0 and List.First(modelIds) <> ""
in
if not isValid then
error [
Reason = "Invalid URL",
Message = "The URL must be in the format 'https://server/projects/PROJECT_ID/models/MODEL_ID' or 'https://server/projects/PROJECT_ID/models/MODEL_ID@VERSION_ID' or 'https://server/projects/PROJECT_ID/models/MODEL_ID1,MODEL_ID2'"
]
else
[
baseUrl = baseUrl,
projectId = projectId,
modelId = if isFederated then null else processedModels{0}[modelId],
versionId = if isFederated then null else processedModels{0}[versionId],
isFederated = isFederated,
federatedModels = if isFederated then processedModels else null
]
@@ -0,0 +1,63 @@
(url as text) as list =>
let
// Import required functions
GetModel = Extension.LoadFunction("GetModel.pqm"),
Parser = Extension.LoadFunction("Parser.pqm"),
GetUser = Extension.LoadFunction("GetUser.pqm"),
// the logic for importing functions from other files
Extension.LoadFunction = (fileName as text) =>
let
binary = Extension.Contents(fileName),
asText = Text.FromBinary(binary)
in
try
Expression.Evaluate(asText, #shared)
catch (e) =>
error
[
Reason = "Extension.LoadFunction Failure",
Message.Format = "Loading '#{0}' failed - '#{1}': '#{2}'",
Message.Parameters = {fileName, e[Reason], e[Message]},
Detail = [File = fileName, Error = e]
],
// Get model info and parsed URL
modelInfo = GetModel(url),
parsedUrl = Parser(url),
userInfo = GetUser(url),
// Get API key if available
apiKey = userInfo[Token],
// Get user email from credentials
userEmail = userInfo[UserEmail],
// Prepare request data
requestData = Json.FromValue([
Url = url,
Server = parsedUrl[baseUrl],
Email = userEmail,
ProjectId = parsedUrl[projectId],
ObjectId = modelInfo[rootObjectId],
SourceApplication = modelInfo[sourceApplication],
Token = apiKey
]),
// Send request to local server
Response = Web.Contents(
"http://127.0.0.1:29364/download",
[
Headers = [
#"Content-Type" = "application/json",
#"Method" = "POST"
],
Content = requestData,
ManualStatusHandling = {400, 401, 403, 404, 500}
]
),
// Parse response
JsonResponse = Json.Document(Response)
in
JsonResponse
+37
View File
@@ -0,0 +1,37 @@
/** @type {import("eslint").Linter.Config} */
const config = {
root: true,
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
requireConfigFile: false,
ecmaVersion: 2020,
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
extends: [
'eslint:recommended',
'plugin:vue/vue3-recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier'
],
env: {
node: true,
commonjs: true
},
ignorePatterns: [
'node_modules',
'dist',
'public',
'events.json',
'.*.{ts,js,vue,tsx,jsx}',
'generated/**/*'
],
rules: {
'no-var': 'off',
'@typescript-eslint/ban-ts-comment': 'warn'
}
}
module.exports = config
+76
View File
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at hello@speckle.systems. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
+50
View File
@@ -0,0 +1,50 @@
# Speckle Contribution Guidelines
## Introduction
Thank you for reading this! Speckle's a rather wide network of parts that depend on each other, either directly, indirectly or even just cosmetically.
> **Speckle** is a quite large ecosystem of moving parts. Any changes may have unintended effects, that can cause problems quickly for many people (and processes) that rely on Speckle.
This means that what might look like a simple quick change in one repo may have a big hidden cost that propagates around other parts of the project. We're all here to help each other, and this guide is meant to help you get started and promote a framework that can untangle all these dependecies through discussion!
## Bugs & Issues 🐞
### Found a new bug?
- First step is to check whether this is a new bug! We encourage you to search through the issues of the project in question **and** associated repos!
- If you come up with nothing, **open a new issue with a clear title and description**, as much relevant information as possible: system configuration, code samples & steps to reproduce the problem.
- Can't mention this often enough: tells us how to reproduce the problem! We will ignore or flag as such issues without reproduction steps.
- Try to reference & note all potentially affected projects.
### Sending a PR for Bug Fixes
You fixed something! Great! We hope you logged it first :) Make sure though that you've covered the lateral thinking needed for a bug report, as described above, also in your implementation! If there any tests, make sure they all pass. If there are none, it means they're missing - so add them!
## New Features 🎉
The golden rule is to Discuss First!
- Before embarking on adding a new feature, suggest it first as an issue with the `enhancement` label and/or title - this will allow relevant people to pitch in
- We'll now discuss your requirements and see how and if they fit within the Speckle ecosystem.
- The last step is to actually start writing code & submit a PR so we can follow along!
- All new features should, if and where possible, come with tests. We won't merge without!
> Many clients may potentially have overlapping scopes, some features might already be in dev somewhere else, or might have been postponed to the next major release due to api instability in that area. For example, adding a delete stream button in the accounts panel in rhino: this feature was planned for speckle admin, and the whole functionality of the accounts panel in rhino is to be greatly reduced!
## Cosmetic Patches ✨
Changes that are cosmetic in nature and do not add anything substantial to the stability or functionality of Speckle **will generally not be accepted**.
Why? However trivial the changes might seem, there might be subtle reasons for the original code to be as it is. Furthermore, there are a lot of potential hidden costs (that even maintainers themselves are not aware of fully!) and they eat up review time unncessarily.
> **Examples**: modifying the colour of an UI element in one client may have a big hidden cost and need propagation in several other clients that implement a similar ui element. Changing the default port or specifiying `localhost` instead of `0.0.0.0` breaks cross-vm debugging and developing.
## Wrap up
Don't worry if you get things wrong. We all do, including project owners: this document should've been here a long time ago. There's plenty of room for discussion on our community [forum](https://discourse.speckle.works).
🙌❤️💙💚💜🙌
+110
View File
@@ -0,0 +1,110 @@
---
name: Bug report
about: Help improve Speckle!
title: ''
labels: bug
assignees: ''
---
<!---
Provide a short summary in the Title above. Examples of good Issue titles:
* "Bug: Error from server when reticulating splines"
* "Bug: Revit crashes when installing connector"
-->
## Prerequisites
<!---
Please answer the following questions before submitting an issue.
-->
- [ ] I read the [contribution guidelines](https://github.com/specklesystems/speckle-server/blob/main/CONTRIBUTING.md)
- [ ] I checked the [documentation](https://speckle.guide/) and found no answer.
- [ ] I checked [existing issues](../issues?q=is%3Aissue) and found no similar issue. <!-- If you do find an existing issue, please show your support by liking it :+1: instead of creating a new issue -->
- [ ] I checked the [community forum](https://speckle.community/) for related discussions and found no answer.
- [ ] I'm reporting the issue to the correct repository (see also [speckle-server](https://github.com/specklesystems/speckle-server), [speckle-sharp](https://github.com/specklesystems/speckle-sharp), [specklepy](https://github.com/specklesystems/specklepy), [speckle-docs](https://github.com/specklesystems/speckle-docs), and [others](https://github.com/orgs/specklesystems/repositories))
## What package are you referring to?
<!---
Is it related to the server (backend) only, or does this bug relate to the frontend, viewer, objectloader or any other package?
-->
## Describe the bug
<!---
A clear and concise description of what the bug is.
-->
## To Reproduce
<!---
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
-->
## Expected behavior
<!---
A clear and concise description of what you expected to happen.
-->
## Screenshots
<!---
If applicable, add screenshots to help explain your problem.
-->
## System Info
If applicable, please fill in the below details - they help a lot!
### Desktop (please complete the following information):
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
### Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
## Failure Logs
<!---
Please include any relevant log snippets or files here, or upload as a file.
If including inline, please use markdown code block syntax. https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks
For example:
```
your log output here
```
-->
## Additional context
<!---
Add any other context about the problem here.
-->
## Proposed Solution (if any)
<!---
Let us know what how you would solve this.
-->
#### Optional: Affected Projects
<!---
Does this issue propagate to other dependencies or dependents? If so, list them here with links!
-->
@@ -0,0 +1,65 @@
---
name: Feature request
about: Suggest an idea for Speckle!
title: ''
labels: enhancement, question
assignees: ''
---
<!---
Provide a short summary in the Title above. Examples of good Issue titles:
* "Enhancement: Connector for Minecraft"
* "Enhancement: Web viewer should support tesseracts"
-->
## Prerequisites
<!---
Please answer the following questions before submitting an issue.
-->
- [ ] I read the [contribution guidelines](https://github.com/specklesystems/speckle-server/blob/main/CONTRIBUTING.md)
- [ ] I checked the [documentation](https://speckle.guide/) and found no answer.
- [ ] I checked [existing issues](../issues?q=is%3Aissue) and found no similar issue. <!-- If you do find an existing issue, please show your support by liking it :+1: instead of creating a new issue -->
- [ ] I checked the [community forum](https://speckle.community/) for related discussions and found no answer.
- [ ] I'm requesting the feature to the correct repository (see also [speckle-server](https://github.com/specklesystems/speckle-server), [speckle-sharp](https://github.com/specklesystems/speckle-sharp), [specklepy](https://github.com/specklesystems/specklepy), [speckle-docs](https://github.com/specklesystems/speckle-docs), and [others](https://github.com/orgs/specklesystems/repositories))
## What package are you referring to?
<!---
Is it related to the server (backend) only, or does this feature request relate to the frontend, viewer, objectloader or any other package?
-->
## Is your feature request related to a problem? Please describe.
<!---
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-->
## Describe the solution you'd like
<!---
A clear and concise description of what you want to happen.
-->
## Describe alternatives you've considered
<!---
A clear and concise description of any alternative solutions or features you've considered.
-->
## Additional context
<!---
Add any other context or screenshots about the feature request here.
Have you seen this feature implemented in any other software? Can you provide screenshots or links to video or documentation?
What works well about these existing features in other software? What doesn't work well?
-->
## Related issues or community discussions
<!---
Is this feature request related to (but sufficiently distinct from) any existing issues?
Does this feature request require other features to be available beforehand?
Has this feature been discussed in the community forum, please link here? https://speckle.community/
-->
@@ -0,0 +1,86 @@
<!---
Provide a short summary in the Title above. Examples of good PR titles:
* "Feature: adds metrics to component"
* "Fix: resolves duplication in comment thread"
* "Update: apollo v2.34.0"
-->
## Description & motivation
<!---
Describe your changes, and why you're making them. What benefit will this have to others?
Is this linked to an open Github issue, a thread in Speckle community,
or another pull request? Link it here.
If it is related to a Github issue, and resolves it, please link to the issue number, e.g.:
Fixes #85, Fixes #22, Fixes username/repo#123
Connects #123
-->
## Changes:
<!---
- Item 1
- Item 2
-->
## To-do before merge
<!---
(Optional -- remove this section if not needed)
Include any notes about things that need to happen before this PR is merged, e.g.:
- [ ] Change the base branch
- [ ] Ensure PR #56 is merged
-->
## Screenshots:
<!---
Include a screenshot the before and after. This can be a screenshot of a plugin, web frontend, or output in a terminal.
-->
## Validation of changes:
<!---
Describe what tests have been added or amended, and why these demonstrate it works and will prevent this feature being accidentally broken by future changes.
-->
## Checklist:
<!---
This checklist is mostly useful as a reminder of small things that can easily be
forgotten it is meant as a helpful tool rather than hoops to jump through.
Put an `x` in all the items that apply, make notes next to any that haven't been
addressed, and remove any items that are not relevant to this PR.
-->
- [ ] My pull request follows the guidelines in the [Contributing guide](https://github.com/specklesystems/speckle-server/blob/main/CONTRIBUTING.md)?
- [ ] My pull request does not duplicate any other open [Pull Requests](../../pulls) for the same update/change?
- [ ] My commits are related to the pull request and do not amend unrelated code or documentation.
- [ ] My code follows a similar style to existing code.
- [ ] I have added appropriate tests.
- [ ] I have updated or added relevant documentation.
+11
View File
@@ -0,0 +1,11 @@
{
"trailingComma": "none",
"tabWidth": 2,
"semi": false,
"endOfLine": "auto",
"bracketSpacing": true,
"vueIndentScriptAndStyle": false,
"htmlWhitespaceSensitivity": "ignore",
"printWidth": 100,
"singleQuote": true
}
+13
View File
@@ -0,0 +1,13 @@
{
"version": "0.1.0",
"configurations": [
{
"name": "Debugger",
"type": "chrome",
"request": "attach",
"port": 8080,
"sourceMaps": true,
"webRoot": "${cwd}/"
}
]
}
+33
View File
@@ -0,0 +1,33 @@
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"files.eol": "\n",
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true,
".tmp": true
},
"files.associations": {
"*.resjson": "json"
},
"editor.formatOnSave": true,
"search.exclude": {
".tmp": true,
"typings": true
},
"json.schemas": [
{
"fileMatch": ["/pbiviz.json"],
"url": "./node_modules/powerbi-visuals-api/schema.pbiviz.json"
},
{
"fileMatch": ["/capabilities.json"],
"url": "./node_modules/powerbi-visuals-api/schema.capabilities.json"
},
{
"fileMatch": ["/dependencies.json"],
"url": "./node_modules/powerbi-visuals-api/schema.dependencies.json"
}
],
"vue.codeActions.enabled": false
}
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2020 AEC Systems
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+112
View File
@@ -0,0 +1,112 @@
<h1 align="center">
<img src="https://user-images.githubusercontent.com/2679513/131189167-18ea5fe1-c578-47f6-9785-3748178e4312.png" width="150px"/><br/>
Speckle | PowerBI Visuals
</h1>
<h3 align="center">
3D Viewer for PowerBI and more...
Expected use case is that the visual displays data pulled from Speckle via the Speckle Data Connector for PowerBI (https://github.com/specklesystems/speckle-powerbi)
</h3>
> ⚠️ This repo is still in very early stages of development, use at your own risk!
<p align="center"><b>Speckle</b> is data infrastructure for the AEC industry.</p><br/>
<p align="center"><a href="https://twitter.com/SpeckleSystems"><img src="https://img.shields.io/twitter/follow/SpeckleSystems?style=social" alt="Twitter Follow"></a> <a href="https://speckle.community"><img src="https://img.shields.io/discourse/users?server=https%3A%2F%2Fspeckle.community&amp;style=flat-square&amp;logo=discourse&amp;logoColor=white" alt="Community forum users"></a> <a href="https://speckle.systems"><img src="https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square" alt="website"></a> <a href="https://speckle.guide/dev/"><img src="https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&amp;logo=read-the-docs&amp;logoColor=white" alt="docs"></a></p>
<p align="center"></p>
# About Speckle
What is Speckle? Check our ![YouTube Video Views](https://img.shields.io/youtube/views/B9humiSpHzM?label=Speckle%20in%201%20minute%20video&style=social)
### Features
- **Object-based:** say goodbye to files! Speckle is the first object based platform for the AEC industry
- **Version control:** Speckle is the Git & Hub for geometry and BIM data
- **Collaboration:** share your designs collaborate with others
- **3D Viewer:** see your CAD and BIM models online, share and embed them anywhere
- **Interoperability:** get your CAD and BIM models into other software without exporting or importing
- **Real time:** get real time updates and notifications and changes
- **GraphQL API:** get what you need anywhere you want it
- **Webhooks:** the base for a automation and next-gen pipelines
- **Built for developers:** we are building Speckle with developers in mind and got tools for every stack
- **Built for the AEC industry:** Speckle connectors are plugins for the most common software used in the industry such as Revit, Rhino, Grasshopper, AutoCAD, Civil 3D, Excel, Unreal Engine, Unity, QGIS, Blender and more!
### Try Speckle now!
Give Speckle a try in no time by:
- [![speckle](https://img.shields.io/badge/https://-app.speckle.systems-0069ff?style=flat-square&logo=hackthebox&logoColor=white)](https://app.speckle.systems) ⇒ creating an account
- [![create a droplet](https://img.shields.io/badge/Create%20a%20Droplet-0069ff?style=flat-square&logo=digitalocean&logoColor=white)](https://marketplace.digitalocean.com/apps/speckle-server?refcode=947a2b5d7dc1) ⇒ deploying an instance in 1 click
### Resources
- [![Community forum users](https://img.shields.io/badge/community-forum-green?style=for-the-badge&logo=discourse&logoColor=white)](https://speckle.community) for help, feature requests or just to hang with other speckle enthusiasts, check out our community forum!
- [![website](https://img.shields.io/badge/tutorials-speckle.systems-royalblue?style=for-the-badge&logo=youtube)](https://speckle.systems) our tutorials portal is full of resources to get you started using Speckle
- [![docs](https://img.shields.io/badge/docs-speckle.guide-orange?style=for-the-badge&logo=read-the-docs&logoColor=white)](https://speckle.guide/dev/) reference on almost any end-user and developer functionality
![Untitled](https://user-images.githubusercontent.com/2679513/132021739-15140299-624d-4410-98dc-b6ae6d9027ab.png)
# Repo structure
This repo follows the default structure of any Custom PowerBI Visual, generated by the `pbiviz` tool.
For now, it only contains a single visual -> The Speckle 3D Viewer
For more information about how a PowerBI visual is structured, you can check out the [official documentation](https://docs.microsoft.com/en-us/power-bi/developer/visuals/visual-project-structure)
### Other repos
Make sure to also check and ⭐️ these other Speckle repositories:
- [`speckle-server`](https://github.com/specklesystems/speckle-server): Server and Web packages
- [`specklepy`](https://github.com/specklesystems/specklepy): Python SDK 🐍
- [`speckle-excel`](https://github.com/specklesystems/speckle-excel): Excel connector
- [`speckle-unity`](https://github.com/specklesystems/speckle-unity): Unity 3D connector
- [`speckle-blender`](https://github.com/specklesystems/speckle-blender): Blender connector
- [`speckle-unreal`](https://github.com/specklesystems/speckle-unreal): Unreal Engine Connector
- [`speckle-qgis`](https://github.com/specklesystems/speckle-qgis): QGIS connectod
- [`speckle-powerbi`](https://github.com/specklesystems/speckle-powerbi): PowerBi connector
- and more [connectos & tooling](https://github.com/specklesystems/)!
## Developing and Debugging
There's a neat guide on setting up your environment for developing visuals [here](https://docs.microsoft.com/en-us/power-bi/developer/visuals/environment-setup)
You'll need to properly set up the certificate in order to be able to use the hot-reloading feature.
> Hot Reload will only work on PowerBI Web (**not** on Desktop).
### Local dev guide (for powerbi-visual)
1. Cd into `./src/powerbi-visual`
1. Run `npm install`
1. To ensure proper SSL cert usage
1. Ensure [mkcert](https://github.com/FiloSottile/mkcert) is installed
1. Run `npm run generate-certs`
1. If you're on Windows or WSL2, you'll need to copy over the root CA to the Windows side and install it there as a trusted root CA.
1. WSL2: Typically its in `~/.local/share/mkcert/rootCA.pem` on WSL2. From bash, `cd` to that folder and then do `explorer.exe .` to open it in Windows Explorer and then copy the pem file to someplace better accessible.
1. Windows: Typically its in `%LOCALAPPDATA%\mkcert\`.
1. Open `crtmgr` and install it into **Trusted Root Certification Authorities**. "Certificates - Current User" > "Trusted Root Certification Authorities" > "Certificates" > Right Click "All Tasks" > "Import" > "Local Machine" > "Place all certificates in the following store" > "Trusted Root Certification Authorities". You may have to set the cert filter to "All Files" to see the `.pem` file.
1. After the cert is installed you may have to restart your browser & dev server
1. Run `npm run dev`
1. PowerBI -> Home > New Report > Paste Or manually enter date > Auto-create > Create
1. In the report, click on 'Edit' to open edit mode, and add a "Developer Visual" visual
#### Source map issues
Make sure you're running the dev build (`npm run dev`) and in your browser's dev tools trigger "Clear source maps cache" and "Enable JavaScript source maps". When everything's working, you should be able to click on the "App mounted" console message's file reference link which will take you to the source-mapped source code in dev tools.
Its still a bit janky in that it maye show multiple files with the same name in the file tree,
but one of those is gonna be the real fully source mapped one.
### Contributing
Please make sure you read the [contribution guidelines](.github/CONTRIBUTING.md) for an overview of the best practices we try to follow.
### Security
For any security vulnerabilities or concerns, please contact us directly at security[at]speckle.systems.
### License
Unless otherwise described, the code in this repository is licensed under the Apache-2.0 License. Please note that some modules, extensions or code herein might be otherwise licensed. This is indicated either in the root of the containing folder under a different license file, or in the respective file's header. If you have any questions, don't hesitate to get in touch with us via [email](mailto:hello@speckle.systems).
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

+242
View File
@@ -0,0 +1,242 @@
{
"dataRoles": [
{
"displayName": "Version Object ID",
"kind": "Grouping",
"name": "rootObjectId"
},
{
"displayName": "Object IDs",
"kind": "Grouping",
"name": "objectIds"
},
{
"displayName": "Color By",
"kind": "Grouping",
"name": "objectColorBy"
},
{
"displayName": "Tooltip Data",
"kind": "Measure",
"name": "tooltipData"
}
],
"dataViewMappings": [
{
"matrix": {
"rows": {
"dataReductionAlgorithm": {
"top": {
"count": 150000
}
},
"select": [
{
"bind": {
"to": "rootObjectId"
}
},
{
"bind": {
"to": "objectColorBy"
}
},
{
"for": {
"in": "objectIds"
}
}
]
},
"values": {
"select": [
{
"bind": {
"to": "tooltipData"
}
}
]
}
},
"conditions": [
{
"objectIds": { "max": 1 },
"rootObjectId": { "max": 1 }
}
]
}
],
"objects": {
"storedData": {
"properties": {
"speckleObjects": {
"type": { "text": true }
},
"receiveInfo": {
"type": { "text": true }
}
}
},
"viewMode": {
"properties": {
"defaultViewMode": {
"type": { "text": true }
}
}
},
"camera": {
"properties": {
"defaultView": {
"type": { "text": true }
},
"allowCameraUnder": {
"type": {
"bool": true
}
},
"zoomOnDataChange": {
"type": {
"bool": true
}
},
"projection": {
"type": {
"enumeration": [
{
"displayName": "Perspective",
"value": "perspective"
},
{
"displayName": "Orthographic",
"value": "orthographic"
}
]
}
}
}
},
"cameraPosition": {
"properties": {
"positionX": {
"type": { "text": true }
},
"positionY": {
"type": { "text": true }
},
"positionZ": {
"type": { "text": true }
},
"targetX": {
"type": { "text": true }
},
"targetY": {
"type": { "text": true }
},
"targetZ": {
"type": { "text": true }
}
}
},
"color": {
"properties": {
"enabled": {
"type": {
"bool": true
}
},
"fill": {
"type": {
"fill": {
"solid": {
"color": true
}
}
}
},
"context": {
"type": {
"enumeration": [
{
"displayName": "Hidden",
"value": "hidden"
},
{
"displayName": "Ghosted",
"value": "ghosted"
}
]
}
}
}
},
"lighting": {
"properties": {
"enabled": {
"type": {
"bool": true
}
},
"intensity": {
"type": {
"numeric": true
}
},
"elevation": {
"type": {
"numeric": true
}
},
"azimuth": {
"type": {
"numeric": true
}
},
"indirect": {
"type": {
"numeric": true
}
},
"shadows": {
"type": {
"bool": true
}
},
"shadowCatcher": {
"type": {
"bool": true
}
}
}
}
},
"privileges": [
{
"essential": true,
"name": "WebAccess",
"parameters": ["https://analytics.speckle.systems", "http://localhost:29364", "*"]
},
{
"essential": false,
"name": "ExportContent"
},
{
"essential": true,
"name": "LocalStorage",
"parameters": []
}
],
"sorting": {
"default": {}
},
"supportsEmptyDataView": true,
"supportsHighlight": true,
"supportsKeyboardFocus": true,
"supportsLandingPage": true,
"keepAllMetadataColumns": true,
"supportsMultiVisualSelection": true,
"supportsSynchronizingFilterState": true,
"suppressDefaultTitle": true,
"tooltips": {
"supportEnhancedTooltips": true
}
}
+14903
View File
File diff suppressed because it is too large Load Diff
+86
View File
@@ -0,0 +1,86 @@
{
"name": "@specklesystems/powerbi-visual",
"description": "A 3D viewer for Speckle Object in PowerBI",
"repository": {
"type": "github",
"url": "https://github.com/specklesystems/speckle-powerbi-visuals"
},
"license": "MIT",
"scripts": {
"generate-certs": "mkcert localhost",
"build": "webpack --config webpack.config.ts",
"build:dev": "webpack --config webpack.config.dev.ts",
"dev": "webpack-dev-server --config webpack.config.dev.ts"
},
"dependencies": {
"@babel/runtime": "^7.21.5",
"@babel/runtime-corejs3": "^7.21.5",
"@headlessui/vue": "^1.7.13",
"@heroicons/vue": "^2.0.12",
"@speckle/objectloader": "^2.23.8",
"@speckle/tailwind-theme": "2.23.2",
"@speckle/ui-components": "2.23.2",
"@speckle/viewer": "2.23.23",
"color-interpolate": "^1.0.5",
"core-js": "^3.30.2",
"lodash": "^4.17.21",
"nanoevents": "^9.1.0",
"pako": "^2.1.0",
"pinia": "^2.3.0",
"postcss-loader": "^7.3.0",
"postcss-preset-env": "^8.4.1",
"powerbi-visuals-api": "^5.11.0",
"powerbi-visuals-utils-colorutils": "^6.0.5",
"powerbi-visuals-utils-dataviewutils": "^6.1.0",
"powerbi-visuals-utils-formattingmodel": "^6.0.4",
"powerbi-visuals-utils-interactivityutils": "^6.0.4",
"powerbi-visuals-utils-tooltiputils": "^6.0.4",
"regenerator-runtime": "^0.13.11"
},
"devDependencies": {
"@babel/core": "^7.21.8",
"@babel/eslint-parser": "^7.21.8",
"@babel/preset-env": "^7.21.5",
"@tailwindcss/forms": "^0.5.3",
"@types/lodash": "^4.14.194",
"@types/node": "^20.1.7",
"@types/regenerator-runtime": "^0.13.1",
"@types/three": "^0.140.0",
"@types/webpack": "^5.28.1",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"autoprefixer": "^10.4.14",
"babel-loader": "^9.1.2",
"base64-inline-loader": "^2.0.1",
"css-loader": "^6.7.3",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-vue": "^9.13.0",
"extra-watch-webpack-plugin": "^1.0.3",
"json-loader": "^0.5.7",
"mini-css-extract-plugin": "^2.7.5",
"postcss": "^8.4.23",
"postcss-import": "^15.1.0",
"powerbi-visuals-tools": "^5.6.0",
"powerbi-visuals-webpack-plugin": "^4.1.0",
"prettier": "^2.8.8",
"style-loader": "^3.3.2",
"tailwindcss": "^3.3.2",
"ts-loader": "^9.4.2",
"ts-node": "^10.9.1",
"tsconfig-paths-webpack-plugin": "^4.0.1",
"typescript": "^5.0.4",
"user-agent-data-types": "^0.3.1",
"vue": "^3.5.13",
"vue-loader": "^17.4.2",
"vue-template-compiler": "^2.7.16",
"webpack": "^5.97.1",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.2"
},
"version": "3.0.0",
"engines": {
"node": "^20.17.0"
}
}
+20
View File
@@ -0,0 +1,20 @@
{
"visual": {
"name": "Speckle PowerBI Viewer",
"displayName": "Speckle PowerBI Viewer",
"guid": "specklePowerBiVisual",
"visualClassName": "Visual",
"version": "3.0.0.0",
"description": "An interactive 3D viewer for Speckle Data",
"supportUrl": "https://speckle.community",
"gitHubUrl": "https://github.com/specklesystems/speckle-powerbi-visuals"
},
"apiVersion": "5.4.0",
"author": { "name": "Speckle Systems", "email": "info@speckle.systems" },
"assets": { "icon": "assets/logo.png" },
"externalJS": [],
"style": "style/visual.css",
"capabilities": "capabilities.json",
"dependencies": null,
"stringResources": []
}
+7
View File
@@ -0,0 +1,7 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
'postcss-nesting': {}
}
}
+17
View File
@@ -0,0 +1,17 @@
<template>
<ViewerView v-if="visualStore.isViewerReadyToLoad" />
<HomeView v-else />
</template>
<script setup lang="ts">
import HomeView from './views/HomeView.vue'
import ViewerView from './views/ViewerView.vue'
import { onMounted } from 'vue'
import { useVisualStore } from './store/visualStore'
const visualStore = useVisualStore()
onMounted(() => {
console.log('App mounted')
})
</script>
@@ -0,0 +1,212 @@
<template>
<ButtonGroup>
<ButtonSimple flat secondary @click="onZoomExtentsClicked">
<ArrowsPointingOutIcon class="h-5 w-5" />
</ButtonSimple>
<!-- Canonical Views -->
<Menu as="div" class="relative z-50">
<MenuButton v-slot="{ open }" as="template">
<ButtonToggle flat secondary :active="open">
<VideoCameraIcon class="h-5 w-5" />
</ButtonToggle>
</MenuButton>
<Transition
enter-active-class="transform ease-out duration-300 transition"
enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
enter-to-class="translate-y-0 opacity-100 sm:translate-x-0"
leave-active-class="transition ease-in duration-100"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
>
<MenuItems
class="absolute w-20 left-2 mb-8 bottom-2 bg-foundation max-h-64 simple-scrollbar overflow-y-auto outline outline-2 outline-primary-muted rounded-lg shadow-lg overflow-hidden flex flex-col"
>
<MenuItem
v-for="view in canonicalViews"
:key="view.name"
v-slot="{ active }"
as="template"
>
<button
:class="{
'bg-primary text-foreground-on-primary': active,
'text-foreground': !active,
'text-sm py-1 transition': true
}"
@click="handleCameraViewChange(view.name.toLocaleLowerCase() as CanonicalView)"
>
{{ view.name }}
</button>
</MenuItem>
<MenuItem v-for="view in views" :key="view.name" v-slot="{ active }" as="template">
<button
:class="{
'bg-primary text-foreground-on-primary': active,
'text-foreground': !active,
'text-sm py-2 transition': true
}"
@click="handleCameraViewChange(view)"
>
{{ view.view.name ?? view.name }}
</button>
</MenuItem>
</MenuItems>
</Transition>
</Menu>
<!-- Speckle Custom Views -->
<Menu v-if="visualStore.speckleViews.length" as="div" class="relative z-40">
<MenuButton v-slot="{ open }" as="template">
<ButtonToggle flat secondary :active="open">
<ViewsIcon class="h-5 w-5" />
</ButtonToggle>
</MenuButton>
<Transition
enter-active-class="transform ease-out duration-300 transition"
enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
enter-to-class="translate-y-0 opacity-100 sm:translate-x-0"
leave-active-class="transition ease-in duration-100"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
>
<MenuItems
class="absolute w-24 left-2 mb-8 bottom-2 bg-foundation max-h-64 simple-scrollbar overflow-y-auto outline outline-2 outline-primary-muted rounded-lg shadow-lg overflow-hidden flex flex-col"
>
<MenuItem
v-for="view in visualStore.speckleViews"
:key="view.id"
v-slot="{ active }"
as="template"
>
<button
:class="{
'bg-primary text-foreground-on-primary': active,
'text-foreground': !active,
'text-sm py-2 transition': true
}"
@click="handleCameraViewChange(view)"
>
{{ view.name }}
</button>
</MenuItem>
</MenuItems>
</Transition>
</Menu>
<Menu as="div" class="relative z-30">
<MenuButton v-slot="{ open }" as="template">
<ButtonToggle flat secondary :active="open">
<ViewModesIcon class="h-5 w-5" />
</ButtonToggle>
</MenuButton>
<Transition
enter-active-class="transform ease-out duration-300 transition"
enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
enter-to-class="translate-y-0 opacity-100 sm:translate-x-0"
leave-active-class="transition ease-in duration-100"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
>
<MenuItems
class="absolute w-20 left-2 mb-8 bottom-2 bg-foundation max-h-64 simple-scrollbar overflow-y-auto outline outline-2 outline-primary-muted rounded-lg shadow-lg overflow-hidden flex flex-col"
>
<MenuItem
v-for="(label, mode) in viewModes"
:key="mode"
v-slot="{ active }"
as="template"
>
<button
:class="{
'bg-primary text-foreground-on-primary': active,
'text-foreground': !active,
'text-sm py-1 transition': true
}"
@click="handleCameraViewModeChange(Number(mode))"
>
{{ label }}
</button>
</MenuItem>
</MenuItems>
</Transition>
</Menu>
<!--
<ButtonToggle
flat
secondary
:active="sectionBox"
@click="$emit('update:sectionBox', !sectionBox)"
>
<CubeIcon class="h-5 w-5" />
</ButtonToggle>
<ButtonSimple flat secondary @click="onClearPalletteClicked">
<PaintBrushIcon class="h-5 w-5" />
</ButtonSimple> -->
</ButtonGroup>
</template>
<script setup lang="ts">
import {
VideoCameraIcon,
CubeIcon,
ArrowsPointingOutIcon,
PaintBrushIcon
} from '@heroicons/vue/24/solid'
import ViewModesIcon from 'src/components/icons/ViewModesIcon.vue'
import ViewsIcon from 'src/components/icons/ViewsIcon.vue'
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
import { CanonicalView, SpeckleView, ViewMode } from '@speckle/viewer'
import ButtonToggle from 'src/components/controls/ButtonToggle.vue'
import ButtonGroup from 'src/components/controls/ButtonGroup.vue'
import ButtonSimple from 'src/components/controls/ButtonSimple.vue'
import { inject, watch } from 'vue'
import { resetPalette } from 'src/utils/matrixViewUtils'
import { useVisualStore } from '@src/store/visualStore'
const visualStore = useVisualStore()
const emits = defineEmits([
'update:sectionBox',
'view-clicked',
'clear-palette',
'view-mode-clicked'
])
const props = withDefaults(defineProps<{ sectionBox: boolean; views: SpeckleView[] }>(), {
sectionBox: false
})
const canonicalViews = [
{ name: 'Top' },
{ name: 'Front' },
{ name: 'Left' },
{ name: 'Back' },
{ name: 'Right' }
]
const viewModes = {
[ViewMode.DEFAULT]: 'Default',
[ViewMode.DEFAULT_EDGES]: 'Edges',
[ViewMode.SHADED]: 'Shaded',
[ViewMode.PEN]: 'Pen',
[ViewMode.ARCTIC]: 'Arctic',
[ViewMode.COLORS]: 'Colors'
}
const handleCameraViewChange = (view: CanonicalView | SpeckleView) => {
emits('view-clicked', view)
// visualStore.writeCameraViewToFile(view)
}
const handleCameraViewModeChange = (viewMode: ViewMode) => {
emits('view-mode-clicked', viewMode)
visualStore.writeViewModeToFile(viewMode)
}
const onZoomExtentsClicked = (ev: MouseEvent) => {
visualStore.viewerEmit('zoomExtends')
}
const onClearPalletteClicked = (ev: MouseEvent) => {
console.log('Clear pallette clicked')
resetPalette()
emits('clear-palette')
}
</script>
@@ -0,0 +1,95 @@
<template>
<div class="flex flex-col justify-center items-center">
<div
ref="container"
class="fixed h-full w-full z-0"
@click="onCanvasClick"
@auxclick="onCanvasAuxClick"
/>
<!-- <div class="z-30 w-1/2 px-10">
<common-loading-bar :loading="isLoading" />
</div> -->
<viewer-controls
v-model:section-box="bboxActive"
:views="views"
class="fixed bottom-6"
@view-clicked="(view) => viewerHandler.setView(view)"
@view-mode-clicked="(viewMode) => viewerHandler.setViewMode(viewMode)"
/>
</div>
</template>
<script async setup lang="ts">
import { inject, onBeforeUnmount, onMounted, Ref, ref } from 'vue'
import { currentOS, OS } from '../utils/detectOS'
import ViewerControls from 'src/components/ViewerControls.vue'
import { SpeckleView } from '@speckle/viewer'
import { useClickDragged } from 'src/composables/useClickDragged'
import { ContextOption } from 'src/settings/colorSettings'
import { useVisualStore } from '@src/store/visualStore'
import { ViewerHandler } from '@src/plugins/viewer'
import { selectionHandlerKey, tooltipHandlerKey } from '@src/injectionKeys'
const visualStore = useVisualStore()
const { dragged } = useClickDragged()
const selectionHandler = inject(selectionHandlerKey)
const tooltipHandler = inject(tooltipHandlerKey)
let viewerHandler: ViewerHandler = null
const container = ref<HTMLElement>()
let bboxActive = ref(false)
let views: Ref<SpeckleView[]> = ref([])
onMounted(async () => {
console.log('Viewer Wrapper mounted')
viewerHandler = new ViewerHandler()
await viewerHandler.init(container.value)
visualStore.setViewerEmitter(viewerHandler.emit)
})
onBeforeUnmount(async () => {
await viewerHandler.dispose()
})
function isMultiSelect(e: MouseEvent) {
if (!e) return false
if (currentOS === OS.MacOS) return e.metaKey || e.shiftKey
else return e.ctrlKey || e.shiftKey
}
async function onCanvasClick(ev: MouseEvent) {
if (dragged.value) return
// eslint-disable-next-line no-debugger
debugger
const intersectResult = await viewerHandler.intersect({ x: ev.clientX, y: ev.clientY })
const multi = isMultiSelect(ev)
const hit = intersectResult?.hit
if (hit) {
const id = hit.object.id as string
if (multi || !selectionHandler.isSelected(id)) {
await selectionHandler.select(id, multi)
}
tooltipHandler.show(hit, { x: ev.clientX, y: ev.clientY })
const selection = selectionHandler.getCurrentSelection()
const ids = selection.map((s) => s.id)
await viewerHandler.selectObjects(ids)
} else {
tooltipHandler.hide()
if (!multi) {
selectionHandler.clear()
await viewerHandler.selectObjects(null)
}
}
}
async function onCanvasAuxClick(ev: MouseEvent) {
if (ev.button != 2 || dragged.value) return
const intersectResult = await viewerHandler.intersect({ x: ev.clientX, y: ev.clientY })
await selectionHandler.showContextMenu(ev, intersectResult?.hit)
}
</script>
@@ -0,0 +1,8 @@
<template>
<button
class="bg-foundation text-foreground shadow-md rounded-lg h-10 flex justify-center space-x-2 px-1"
>
<slot></slot>
</button>
</template>
<script setup lang="ts"></script>
@@ -0,0 +1,45 @@
<template>
<button
ref="button"
:class="`transition rounded-lg w-10 h-10 flex items-center justify-center ${shadowClasses} ${colorClasses} active:scale-[0.9] outline-none`"
>
<slot></slot>
</button>
</template>
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
let active = ref(false)
let button = ref<HTMLElement>()
const props = defineProps<{
flat?: boolean
secondary?: boolean
}>()
const shadowClasses = computed(() => (props.flat ? '' : 'shadow-md'))
const colorClasses = computed(() => {
const parts = []
if (active.value) {
if (props.secondary) parts.push('bg-foundation text-primary')
else parts.push('bg-primary text-foreground-on-primary')
} else {
parts.push('bg-foundation text-foreground')
}
return parts.join(' ')
})
const onPointerDown = () => (active.value = true)
const onPointerUp = () => (active.value = false)
onMounted(() => {
button.value.addEventListener('pointerdown', onPointerDown)
button.value.addEventListener('pointerup', onPointerUp)
})
onBeforeUnmount(() => {
button.value.removeEventListener('pointerdown', onPointerDown)
button.value.removeEventListener('pointerup', onPointerUp)
})
</script>
@@ -0,0 +1,29 @@
<template>
<button
:class="`transition rounded-lg w-10 h-10 flex items-center justify-center ${shadowClasses} ${colorClasses} active:scale-[0.9] outline-none`"
>
<slot></slot>
</button>
</template>
<script setup lang="ts">
import { computed } from 'vue'
const props = defineProps<{
active?: boolean
flat?: boolean
secondary?: boolean
}>()
const shadowClasses = computed(() => (props.flat ? '' : 'shadow-md'))
const colorClasses = computed(() => {
const parts = []
if (props.active) {
if (props.secondary) parts.push('bg-foundation text-primary')
else parts.push('bg-primary text-foreground-on-primary')
} else {
parts.push('bg-foundation text-foreground')
}
return parts.join(' ')
})
</script>
@@ -0,0 +1,39 @@
<template>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M8 7H6L3 15V17"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M16 7H18L21 15V17"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M10 16H14"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M14 16.5C14 17.4283 14.3687 18.3185 15.0251 18.9749C15.6815 19.6313 16.5717 20 17.5 20C18.4283 20 19.3185 19.6313 19.9749 18.9749C20.6313 18.3185 21 17.4283 21 16.5C21 15.5717 20.6313 14.6815 19.9749 14.0251C19.3185 13.3687 18.4283 13 17.5 13C16.5717 13 15.6815 13.3687 15.0251 14.0251C14.3687 14.6815 14 15.5717 14 16.5Z"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M3 16.5C3 16.9596 3.09053 17.4148 3.26642 17.8394C3.44231 18.264 3.70012 18.6499 4.02513 18.9749C4.35013 19.2999 4.73597 19.5577 5.16061 19.7336C5.58525 19.9095 6.04037 20 6.5 20C6.95963 20 7.41475 19.9095 7.83939 19.7336C8.26403 19.5577 8.64987 19.2999 8.97487 18.9749C9.29988 18.6499 9.55769 18.264 9.73358 17.8394C9.90947 17.4148 10 16.9596 10 16.5C10 16.0404 9.90947 15.5852 9.73358 15.1606C9.55769 14.736 9.29988 14.3501 8.97487 14.0251C8.64987 13.7001 8.26403 13.4423 7.83939 13.2664C7.41475 13.0905 6.95963 13 6.5 13C6.04037 13 5.58525 13.0905 5.16061 13.2664C4.73597 13.4423 4.35013 13.7001 4.02513 14.0251C3.70012 14.3501 3.44231 14.736 3.26642 15.1606C3.09053 15.5852 3 16.0404 3 16.5Z"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
@@ -0,0 +1,32 @@
<template>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M18.5 8.79167L12 12.5833M18.5 8.79167V15.2917L12 19.0833M18.5 8.79167L12 5L5.5 8.79167M12 12.5833L5.5 8.79167M12 12.5833V19.0833M12 19.0833L5.5 15.2917V8.79167"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M5.5 15.2917L1.5 17.6251"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M18.5 15.2957L22.5 17.629"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M12 5V1"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
@@ -0,0 +1,41 @@
<template>
<div
:class="[
'relative w-full h-1 bg-blue-500/30 text-xs text-foreground-on-primary overflow-hidden rounded-xl',
showBar ? 'opacity-100' : 'opacity-0'
]"
>
<div class="swoosher relative top-0 bg-blue-500/50"></div>
</div>
</template>
<script setup lang="ts">
import { useMounted } from '@vueuse/core'
import { computed } from 'vue'
const props = defineProps<{ loading: boolean; clientOnly?: boolean }>()
const mounted = useMounted()
const showBar = computed(() => (mounted.value || !props.clientOnly) && props.loading)
</script>
<style scoped>
.swoosher {
width: 100%;
height: 100%;
animation: swoosh 1s infinite linear;
transform-origin: 0% 30%;
}
@keyframes swoosh {
0% {
transform: translateX(0) scaleX(0);
}
40% {
transform: translateX(0) scaleX(0.4);
}
100% {
transform: translateX(100%) scaleX(0.5);
}
}
</style>
@@ -0,0 +1,51 @@
import { ref, onMounted, onUnmounted, Ref } from 'vue'
// by convention, composable function names start with "use"
export function useClickDragged(threshold = 1) {
// state encapsulated and managed by the composable
const dragged = ref(false)
const distance = ref(0)
const start: Ref<{ x: number; y: number }> = ref(null)
const current: Ref<{ x: number; y: number }> = ref(null)
function onPointerMove(ev) {
distance.value = Math.sqrt(
Math.pow(ev.x - start.value.x, 2) * Math.pow(ev.y - start.value.y, 2)
)
if (distance.value > threshold) {
dragged.value = true
}
}
function onPointerDown(ev) {
dragged.value = false
start.value = { x: ev.x, y: ev.y }
current.value = start.value
distance.value = 0
document.addEventListener('pointermove', onPointerMove)
}
function onPointerUp(_) {
if (dragged.value === false) reset()
document.removeEventListener('pointermove', onPointerMove)
}
function reset() {
start.value = null
current.value = null
distance.value = 0
}
// a composable can also hook into its owner component's
// lifecycle to setup and teardown side effects.
onMounted(() => {
document.addEventListener('pointerdown', onPointerDown)
document.addEventListener('pointerup', onPointerUp)
})
onUnmounted(() => {
document.removeEventListener('pointerdown', onPointerDown)
document.removeEventListener('pointerup', onPointerUp)
})
// expose managed state as return value
return { dragged, distance }
}
@@ -0,0 +1,66 @@
export default class SelectionHandler {
private selectionIdMap: Map<string, powerbi.extensibility.ISelectionId>
private currentSelection: Set<string>
private selectionManager: powerbi.extensibility.ISelectionManager
private host: powerbi.extensibility.visual.IVisualHost
public constructor(host: powerbi.extensibility.visual.IVisualHost) {
this.host = host
this.selectionManager = this.host.createSelectionManager()
this.selectionIdMap = new Map<string, powerbi.extensibility.ISelectionId>()
this.currentSelection = new Set<string>()
}
public async showContextMenu(ev: MouseEvent, hit?) {
const selectionId = !hit ? null : this.selectionIdMap.get(hit?.object?.id)
return this.selectionManager.showContextMenu(selectionId, {
x: ev.clientX,
y: ev.clientY
})
}
public set(objectId: string, data: powerbi.extensibility.ISelectionId) {
this.selectionIdMap.set(objectId, data)
}
public async select(objectId: string, multi = false) {
const selectionId = this.selectionIdMap.get(objectId)
if (multi) {
await this.selectionManager.select(selectionId, true)
if (this.currentSelection.has(objectId)) {
this.currentSelection.delete(objectId)
} else {
this.currentSelection.add(objectId)
}
} else {
await this.selectionManager.select(selectionId, false)
this.currentSelection.clear()
this.currentSelection.add(objectId)
}
}
public getCurrentSelection(): { id: string; selectionId: powerbi.extensibility.ISelectionId }[] {
return [...this.currentSelection].map((entry) => ({
id: entry,
selectionId: this.selectionIdMap.get(entry)
}))
}
public isSelected(id: string) {
return this.currentSelection.has(id)
}
public clear() {
this.selectionManager.clear()
this.currentSelection.clear()
}
public reset() {
this.clear()
this.selectionIdMap.clear()
}
public has(url) {
return this.selectionIdMap.has(url)
}
}
@@ -0,0 +1,53 @@
import powerbi from 'powerbi-visuals-api'
import ITooltipService = powerbi.extensibility.ITooltipService
import { IViewerTooltip } from '../types'
import { SpeckleTooltip } from '../interfaces'
export default class TooltipHandler {
private data: Map<string, IViewerTooltip>
private tooltipService: ITooltipService
public currentTooltip: SpeckleTooltip = null
constructor(tooltipService) {
this.tooltipService = tooltipService
this.data = new Map<string, IViewerTooltip>()
}
public setup(data: Map<string, IViewerTooltip>) {
this.data = data
}
public show(hit: { guid: string; object?; point }, screenLoc) {
const id = hit.object.id as string
const objTooltipData: IViewerTooltip = this.data.get(id)
if (!objTooltipData) return
const tooltipData = {
coordinates: [screenLoc.x, screenLoc.y],
dataItems: objTooltipData.data,
identities: [objTooltipData.selectionId],
isTouchEvent: false
}
this.currentTooltip = {
id: hit.object.id,
worldPos: hit.point,
screenPos: screenLoc,
tooltip: tooltipData
}
this.tooltipService.show(tooltipData)
if (Object.keys(tooltipData.dataItems).length > 0) this.tooltipService.show(tooltipData)
}
public hide() {
this.tooltipService.hide({ immediately: true, isTouchEvent: false })
this.currentTooltip = null
}
public move(pos: { x: number; y: number }) {
if (!this.currentTooltip) return
this.currentTooltip.tooltip.coordinates = [pos.x, pos.y]
this.tooltipService.move(this.currentTooltip.tooltip)
}
}
+4
View File
@@ -0,0 +1,4 @@
declare module '*.png' {
const source: string
export default source
}
+6
View File
@@ -0,0 +1,6 @@
import { InjectionKey } from 'vue'
import SelectionHandler from 'src/handlers/selectionHandler'
import TooltipHandler from 'src/handlers/tooltipHandler'
export const selectionHandlerKey: InjectionKey<SelectionHandler> = Symbol()
export const tooltipHandlerKey: InjectionKey<TooltipHandler> = Symbol()
+20
View File
@@ -0,0 +1,20 @@
import { IViewerTooltipData } from './types'
export interface SpeckleSelectionData {
id: powerbi.extensibility.ISelectionId
data: IViewerTooltipData[]
}
export interface SpeckleTooltip {
worldPos: {
x: number
y: number
z: number
}
screenPos: {
x: number
y: number
}
tooltip
id: string
}
@@ -0,0 +1,31 @@
import ObjectLoader from '@speckle/objectloader'
import { SpeckleLoader, WorldTree } from '@speckle/viewer'
export class SpeckleObjectsOfflineLoader extends SpeckleLoader {
constructor(targetTree: WorldTree, resourceData: string, resourceId?: string) {
super(targetTree, resourceId || '', undefined, undefined, resourceData)
}
protected initObjectLoader(
_resource: string,
_authToken?: string,
_enableCaching?: boolean,
resourceData?: string | ArrayBuffer
): ObjectLoader {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return ObjectLoader.createFromObjects(resourceData as unknown as [])
}
public async load(): Promise<boolean> {
const rootObject = await this.loader.getRootObject()
if (!rootObject && this._resource) {
console.error('No root id set!')
return false
}
/** If not id is provided, we make one up based on the root object id */
this._resource = this._resource || `/json/${rootObject.id as string}`
return super.load()
}
}
+3
View File
@@ -0,0 +1,3 @@
import { createPinia } from 'pinia'
export const pinia = createPinia()
+262
View File
@@ -0,0 +1,262 @@
import {
DefaultViewerParams,
FilteringState,
IntersectionQuery,
CameraController,
CanonicalView,
ViewModes,
CameraEvent,
SpeckleView,
ViewMode,
Viewer,
HybridCameraController,
SelectionExtension,
FilteringExtension
} from '@speckle/viewer'
import { SpeckleObjectsOfflineLoader } from '@src/laoder/SpeckleObjectsOfflineLoader'
import { useVisualStore } from '@src/store/visualStore'
import { Tracker } from '@src/utils/mixpanel'
import { createNanoEvents, Emitter } from 'nanoevents'
import { ColorPicker } from 'powerbi-visuals-utils-formattingmodel/lib/FormattingSettingsComponents'
import { Vector3 } from 'three'
export interface IViewer {
/**
* Events sent over from the host application.
*/
on: <E extends keyof IViewerEvents>(event: E, callback: IViewerEvents[E]) => void
}
export interface Hit {
guid: string
object?: Record<string, unknown>
point: { x: number; y: number; z: number }
}
export interface IViewerEvents {
ping: (message: string) => void
setSelection: (objectIds: string[]) => void
setViewMode: (viewMode: ViewMode) => void
colorObjectsByGroup: (
colorById: {
objectIds: string[]
slice: ColorPicker
color: string
}[]
) => void
isolateObjects: (objectIds: string[]) => void
unIsolateObjects: () => void
zoomExtends: () => void
loadObjects: (objects: object[]) => void
}
export class ViewerHandler {
public emitter: Emitter
public viewer: Viewer
public cameraControls: CameraController
public filtering: FilteringExtension
public selection: SelectionExtension
private filteringState: FilteringState
constructor() {
this.emitter = createNanoEvents()
this.emit = this.emit.bind(this)
this.emitter.on('ping', this.handlePing)
this.emitter.on('setSelection', this.selectObjects)
this.emitter.on('setViewMode', this.setViewMode)
this.emitter.on('colorObjectsByGroup', this.colorObjectsByGroup)
this.emitter.on('isolateObjects', this.isolateObjects)
this.emitter.on('unIsolateObjects', this.unIsolateObjects)
this.emitter.on('zoomExtends', this.zoomExtends)
this.emitter.on('zoomObjects', this.zoomObjects)
this.emitter.on('loadObjects', this.loadObjects)
}
async init(parent: HTMLElement) {
this.viewer = await createViewer(parent)
this.cameraControls = this.viewer.getExtension(CameraController)
this.filtering = this.viewer.getExtension(FilteringExtension)
this.selection = this.viewer.getExtension(SelectionExtension)
this.cameraControls.on(CameraEvent.Stationary, () => {
console.log('🎬 Storing the camera position into file')
const cameraController = this.viewer.getExtension(CameraController)
const position = cameraController.getPosition()
const target = cameraController.getTarget()
const store = useVisualStore()
store.writeCameraPositionToFile(position, target)
})
}
emit<E extends keyof IViewerEvents>(event: E, ...payload: Parameters<IViewerEvents[E]>): void {
this.emitter.emit(event, ...payload)
}
public zoomObjects = (objectIds: string[], animate = false) => {
/** Second argument here is for animating the camera movement. Default is false */
this.cameraControls.setCameraView(objectIds, animate)
}
public zoomExtends = () => this.cameraControls.setCameraView(undefined, false)
public setView = (view: CanonicalView) => this.cameraControls.setCameraView(view, false)
public setSectionBox = (bboxActive: boolean, objectIds: string[]) => {
// TODO
return
}
public setViewMode(viewMode: ViewMode) {
const viewModes = this.viewer.getExtension(ViewModes)
viewModes.setViewMode(viewMode)
}
public selectObjects = (objectIds: string[]) => {
console.log('🔗 Handling setSelection inside ViewerHandler:', objectIds)
if (objectIds) {
this.selection.selectObjects(objectIds)
}
}
public colorObjectsByGroup = (
colorByIds: {
objectIds: string[]
color: string
}[]
) => {
this.filteringState = this.filtering.setUserObjectColors(colorByIds ?? [])
}
public isolateObjects = (objectIds: string[], ghost: boolean) => {
this.unIsolateObjects()
this.filteringState = this.filtering.isolateObjects(objectIds, 'powerbi', true, ghost)
}
public unIsolateObjects = () => {
if (this.filteringState && this.filteringState.isolatedObjects) {
this.filteringState = this.filtering.unIsolateObjects(
this.filteringState.isolatedObjects,
'powerbi',
true
)
}
}
public intersect = (coords: { x: number; y: number }) => {
const point = this.viewer.Utils.screenToNDC(coords.x, coords.y)
const intQuery: IntersectionQuery = {
operation: 'Pick',
point
}
const res = this.viewer.query(intQuery)
if (!res) {
this.selection.clearSelection()
return
}
return {
hit: this.pickViewableHit(res.objects),
objects: res.objects
}
}
public loadObjects = async (modelObjects: object[][]) => {
await this.viewer.unloadAll()
// const stringifiedObject = JSON.stringify(objects)
const store = useVisualStore()
const speckleViews = []
modelObjects.forEach(async (objects) => {
//@ts-ignore
const loader = new SpeckleObjectsOfflineLoader(this.viewer.getWorldTree(), objects)
const speckleViewsInModel = objects.filter(
//@ts-ignore
(o) => o.speckle_type === 'Objects.BuiltElements.View:Objects.BuiltElements.View3D'
) as SpeckleView[]
speckleViews.concat(speckleViewsInModel)
// Since you are setting another camera position, maybe you want the second argument to false
await this.viewer.loadObject(loader, true)
})
store.setSpeckleViews(speckleViews)
if (store.defaultViewModeInFile) {
this.setViewMode(Number(store.defaultViewModeInFile))
}
Tracker.dataLoaded({ sourceHostApp: store.receiveInfo.sourceApplication })
// camera need to be set after objects loaded
if (store.cameraPosition) {
const position = new Vector3(
store.cameraPosition[0],
store.cameraPosition[1],
store.cameraPosition[2]
)
const target = new Vector3(
store.cameraPosition[3],
store.cameraPosition[4],
store.cameraPosition[5]
)
this.cameraControls.setCameraView({ position, target }, true)
}
}
private handlePing = (message: string) => {
console.log(message)
}
private pickViewableHit(hits: Hit[]): Hit | null {
// The current filtering state
const filteringState = this.filtering.filteringState
// Are there any objects isolated?
const hasIsolatedObjects =
!!filteringState.isolatedObjects && filteringState.isolatedObjects.length !== 0
// Are there any objects hidden?
const hasHiddenObjects =
!!filteringState.hiddenObjects && filteringState.hiddenObjects.length !== 0
// No isolated or hidden objects? Return the first hit
if (hasIsolatedObjects && !hasHiddenObjects) {
return hits.find((h) => filteringState.isolatedObjects.includes(h.guid))
}
for (let k = 0; k < hits.length; k++) {
/** Return the first one that's not hidden or isolated. */
if (
hasIsolatedObjects &&
filteringState.isolatedObjects?.includes(hits[k].guid) &&
hasHiddenObjects &&
filteringState.hiddenObjects?.includes(hits[k].guid)
)
return hits[k]
}
}
public dispose() {
this.viewer.getExtension(CameraController).dispose()
this.viewer.dispose()
this.viewer = null
}
}
const createViewer = async (parent: HTMLElement): Promise<Viewer> => {
const viewerSettings = DefaultViewerParams
viewerSettings.showStats = false
viewerSettings.verbose = true // Turning this on so we can see logs for now
const viewer = new Viewer(parent, viewerSettings)
await viewer.init()
viewer.createExtension(HybridCameraController) // camera controller
viewer.createExtension(SelectionExtension) // selection helper
// viewer.createExtension(SectionTool) // section tool, possibly not needed for now?
// viewer.createExtension(SectionOutlines) // section tool, possibly not needed for now?
// viewer.createExtension(MeasurementsExtension) // measurements, possibly not needed for now?
viewer.createExtension(FilteringExtension) // filtering
viewer.createExtension(ViewModes) // view modes
console.log('🎥 Viewer is created!')
return viewer
}
@@ -0,0 +1,35 @@
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
export class CameraSettings extends fs.SimpleCard {
public defaultView: fs.SimpleSlice = new fs.AutoDropdown({
name: 'defaultView',
displayName: 'Default View',
value: 'perspective'
})
public projection = new fs.AutoDropdown({
name: 'projection',
displayName: 'Projection',
value: 'perspective'
})
public allowCameraUnder = new fs.ToggleSwitch({
name: 'allowCameraUnder',
displayName: 'Allow under model',
value: false
})
public zoomOnDataChange = new fs.ToggleSwitch({
name: 'zoomOnDataChange',
displayName: 'Zoom extent on change',
value: true
})
name = 'camera'
displayName = 'Camera'
slices: fs.Slice[] = [
this.defaultView,
this.projection,
this.allowCameraUnder,
this.zoomOnDataChange
]
}
@@ -0,0 +1,50 @@
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
import {
createDataViewWildcardSelector,
DataViewWildcardMatchingOption
} from 'powerbi-visuals-utils-dataviewutils/lib/dataViewWildcard'
import VisualEnumerationInstanceKinds = powerbi.VisualEnumerationInstanceKinds
export enum ContextOption {
hidden = 'hidden',
ghosted = 'ghosted',
show = 'show'
}
export class ColorSettings extends fs.SimpleCard {
public enabled = new fs.ToggleSwitch({
name: 'enabled',
displayName: 'Enabled',
value: true
})
public fill = new fs.ColorPicker({
name: 'fill',
displayName: 'Color override',
description:
'Allows to override the colors of each object based on user-defined rules. Default color does not affect visualization.',
value: { value: '#c5c5c5' },
defaultColor: { value: '#c5c5c5' },
selector: createDataViewWildcardSelector(DataViewWildcardMatchingOption.InstancesAndTotals),
altConstantSelector: {
static: {}
},
instanceKind: VisualEnumerationInstanceKinds.ConstantOrRule
})
public context = new fs.AutoDropdown({
name: 'context',
displayName: 'Context display',
description: 'Determines how to display objects not present in the input data table.',
value: ContextOption.ghosted
})
name = 'color'
displayName = 'Object Display'
slices: fs.Slice[] = [this.context, this.fill]
}
export class ColorSelectorSettings extends fs.SimpleCard {
name = 'colorSelector'
displayName = 'Color Selector'
slices = []
}
@@ -0,0 +1,84 @@
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
import ValidatorType = powerbi.visuals.ValidatorType
import { SunLightConfiguration } from '@speckle/viewer'
export class LightingSettings extends fs.SimpleCard {
name = 'lighting'
displayName = 'Lighting'
public enabled = new fs.ToggleSwitch({
name: 'enabled',
displayName: 'Enabled',
value: true
})
public intensity = new fs.Slider({
name: 'intensity',
displayName: 'Intensity',
options: {
minValue: { type: ValidatorType.Min, value: 1 },
maxValue: { type: ValidatorType.Max, value: 10 }
},
value: 5
})
public elevation = new fs.Slider({
name: 'elevation',
displayName: 'Elevation',
options: {
minValue: { type: ValidatorType.Min, value: 0 },
maxValue: { type: ValidatorType.Max, value: Math.PI }
},
value: 1.33
})
public azimuth = new fs.Slider({
name: 'azimuth',
displayName: 'azimuth',
options: {
minValue: { type: ValidatorType.Min, value: -Math.PI * 0.5 },
maxValue: { type: ValidatorType.Max, value: Math.PI * 0.5 }
},
value: 0.75
})
public indirect = new fs.Slider({
name: 'indirect',
displayName: 'indirect',
options: {
minValue: { type: ValidatorType.Min, value: 0.0 },
maxValue: { type: ValidatorType.Max, value: 5.0 }
},
value: 1.2
})
public shadows = new fs.ToggleSwitch({
name: 'shadows',
displayName: 'Cast shadows',
value: true
})
public shadowCatcher = new fs.ToggleSwitch({
name: 'shadowCatcher',
displayName: 'Catch Shadows',
value: true
})
slices: fs.Slice[] = [
this.intensity,
this.elevation,
this.azimuth,
this.indirect,
this.shadows,
this.shadowCatcher
]
public getViewerConfiguration(): SunLightConfiguration {
return {
enabled: this.enabled.value,
castShadow: this.shadows.value,
intensity: this.intensity.value,
elevation: this.elevation.value,
azimuth: this.azimuth.value,
indirectLightIntensity: this.intensity.value,
shadowcatcher: this.shadowCatcher.value
}
}
}
@@ -0,0 +1,17 @@
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
import { ColorSelectorSettings, ColorSettings } from 'src/settings/colorSettings'
import { CameraSettings } from 'src/settings/cameraSettings'
import { LightingSettings } from 'src/settings/lightingSettings'
export class SpeckleVisualSettingsModel extends fs.Model {
// Building my visual formatting settings card
public color: ColorSettings = new ColorSettings()
public colorSelector: ColorSelectorSettings = new ColorSelectorSettings()
public camera: CameraSettings = new CameraSettings()
public lighting: LightingSettings = new LightingSettings()
cards = [this.color, this.camera, this.lighting]
}
+6
View File
@@ -0,0 +1,6 @@
/* eslint-disable @typescript-eslint/ban-types */
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
}
+260
View File
@@ -0,0 +1,260 @@
import { CanonicalView, SpeckleView, ViewMode } from '@speckle/viewer'
import { IViewerEvents } from '@src/plugins/viewer'
import { SpeckleDataInput } from '@src/types'
import { zipJSONChunks, zipModelObjects } from '@src/utils/compression'
import { ReceiveInfo } from '@src/utils/matrixViewUtils'
import { defineStore } from 'pinia'
import { Vector3 } from 'three'
import { ref, shallowRef } from 'vue'
export type InputState = 'valid' | 'incomplete' | 'invalid'
export type FieldInputState = {
rootObjectId: boolean
objectIds: boolean
colorBy: boolean
tooltipData: boolean
}
export const useVisualStore = defineStore('visualStore', () => {
const host = shallowRef<powerbi.extensibility.visual.IVisualHost>()
const loadingProgress = ref<{ summary: string; progress: number }>(undefined)
const objectsFromStore = ref<object[]>(undefined)
// once you see this shit, you might freak out and you are right. All of them needed because of "update" function trigger by API.
// most of the time we need to know what we are doing to treat operations accordingly. Ask for more to me (Ogu), but the answers will make both of us unhappy.
const isViewerInitialized = ref<boolean>(false)
const isViewerReadyToLoad = ref<boolean>(false)
const isViewerObjectsLoaded = ref<boolean>(false)
const viewerReloadNeeded = ref<boolean>(false)
const isLoadingFromFile = ref<boolean>(false)
const receiveInfo = ref<ReceiveInfo>(undefined)
const fieldInputState = ref<FieldInputState>({
rootObjectId: false,
objectIds: false,
colorBy: false,
tooltipData: false
})
const lastLoadedRootObjectId = ref<string>()
const cameraPosition = ref<number[]>(undefined)
const defaultViewModeInFile = ref<string>(undefined)
const speckleViews = ref<SpeckleView[]>([])
// callback mechanism to viewer to be able to manage input data accordingly.
// Note: storing whole viewer in store is not make sense and also pinia ts complains about it for serialization issues.
// Error was and you can not/should not compress: 👇
// `The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.ts(7056)`
const viewerEmit =
ref<
<E extends keyof IViewerEvents>(event: E, ...payload: Parameters<IViewerEvents[E]>) => void
>()
// TODO: investigate about shallow ref? https://vuejs.org/api/reactivity-advanced.html#shallowref
const dataInput = shallowRef<SpeckleDataInput | null>()
const dataInputStatus = ref<InputState>('incomplete')
/**
* Ideally one time setup on initialization.
* @param hostToSet interaction layer with powerbi host. it is useful when you wanna trigger `launchUrl` kind functions. TODO: need more understanding.
*/
const setHost = (hostToSet: powerbi.extensibility.visual.IVisualHost) => {
host.value = hostToSet
}
const setReceiveInfo = (newReceiveInfo: ReceiveInfo) => (receiveInfo.value = newReceiveInfo)
/**
* Ideally one time set when onMounted of `ViewerWrapper.vue` component
* @param emit picky emit function to trigger events under `IViewerEvents` interface
*/
const setViewerEmitter = (
emit: <E extends keyof IViewerEvents>(
event: E,
...payload: Parameters<IViewerEvents[E]>
) => void
) => {
if (emit) {
viewerEmit.value = emit
viewerEmit.value('ping', '✅ Emitter successfully attached to the store.')
isViewerInitialized.value = true // this is needed to be delay first load at the visual.ts file
}
}
const setObjectsFromStore = (newObjectsFromStore: object[]) => {
objectsFromStore.value = newObjectsFromStore
}
const setLoadingProgress = (summary: string, progress: number) => {
loadingProgress.value = { summary, progress }
if (loadingProgress.value.progress >= 1) {
clearLoadingProgress()
}
}
const clearLoadingProgress = () => (loadingProgress.value = undefined)
// MAKE TS HAPPY
type SpeckleObject = {
id: string
}
const loadObjectsFromFile = async (objects: object[]) => {
lastLoadedRootObjectId.value = (objects[0] as SpeckleObject).id // TODO fix
viewerReloadNeeded.value = false
console.log(`📦 Loading viewer from cached data with ${lastLoadedRootObjectId.value} id.`)
await viewerEmit.value('loadObjects', objects)
clearLoadingProgress()
objectsFromStore.value = objects
isViewerObjectsLoaded.value = true
viewerReloadNeeded.value = false
setIsLoadingFromFile(false)
}
/**
* Sets upcoming data input into store to be able to pass it through viewer by evaluating the data.
* @param newValue new data input that user dragged and dropped to the fields in visual
*/
const setDataInput = async (newValue: SpeckleDataInput) => {
dataInput.value = newValue
if (viewerReloadNeeded.value) {
const modelIds = dataInput.value.modelObjects.map((o) => (o[0] as SpeckleObject).id).join(',')
lastLoadedRootObjectId.value = modelIds
console.log(`🔄 Forcing viewer re-render for new root object id.`)
await viewerEmit.value('loadObjects', dataInput.value.modelObjects)
clearLoadingProgress()
viewerReloadNeeded.value = false
isViewerObjectsLoaded.value = true
writeObjectsToFile(dataInput.value.modelObjects)
}
if (dataInput.value.selectedIds.length > 0) {
viewerEmit.value('isolateObjects', dataInput.value.selectedIds)
} else {
viewerEmit.value('isolateObjects', dataInput.value.objectIds)
}
viewerEmit.value('colorObjectsByGroup', dataInput.value.colorByIds)
}
const writeObjectsToFile = (modelObjects: object[][]) => {
const compressedChunks = zipModelObjects(modelObjects, 10000) // Compress in chunks
host.value.persistProperties({
merge: [
{
objectName: 'storedData',
properties: {
speckleObjects: compressedChunks,
receiveInfo: JSON.stringify(receiveInfo.value)
},
selector: null
}
]
})
}
const writeCameraViewToFile = (view: CanonicalView) => {
host.value.persistProperties({
merge: [
{
objectName: 'camera',
properties: {
defaultView: view
},
selector: null
}
]
})
}
const writeViewModeToFile = (viewMode: ViewMode) => {
host.value.persistProperties({
merge: [
{
objectName: 'viewMode',
properties: {
defaultViewMode: viewMode
},
selector: null
}
]
})
}
const writeCameraPositionToFile = (position: Vector3, target: Vector3) => {
host.value.persistProperties({
merge: [
{
objectName: 'cameraPosition',
properties: {
positionX: position.x,
positionY: position.y,
positionZ: position.z,
targetX: target.x,
targetY: target.y,
targetZ: target.z
},
selector: null
}
]
})
}
const setFieldInputState = (newFieldInputState: FieldInputState) =>
(fieldInputState.value = newFieldInputState)
const clearDataInput = () => (dataInput.value = null)
const setIsLoadingFromFile = (newValue: boolean) => (isLoadingFromFile.value = newValue)
const setViewerReadyToLoad = () => (isViewerReadyToLoad.value = true)
const setViewerReloadNeeded = () => (viewerReloadNeeded.value = true)
const setCameraPositionInFile = (newValue: number[]) => (cameraPosition.value = newValue)
const setDefaultViewModeInFile = (newValue: string) => (defaultViewModeInFile.value = newValue)
const setSpeckleViews = (newSpeckleViews: SpeckleView[]) => (speckleViews.value = newSpeckleViews)
return {
host,
receiveInfo,
objectsFromStore,
isViewerInitialized,
isViewerReadyToLoad,
isViewerObjectsLoaded,
viewerReloadNeeded,
dataInput,
dataInputStatus,
viewerEmit,
fieldInputState,
lastLoadedRootObjectId,
loadingProgress,
isLoadingFromFile,
cameraPosition,
defaultViewModeInFile,
speckleViews,
setCameraPositionInFile,
setDefaultViewModeInFile,
setSpeckleViews,
loadObjectsFromFile,
setHost,
setReceiveInfo,
setViewerReloadNeeded,
setObjectsFromStore,
writeObjectsToFile,
writeCameraViewToFile,
writeViewModeToFile,
writeCameraPositionToFile,
setViewerEmitter,
setDataInput,
setFieldInputState,
clearDataInput,
setViewerReadyToLoad,
setLoadingProgress,
clearLoadingProgress,
setIsLoadingFromFile
}
})
+20
View File
@@ -0,0 +1,20 @@
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
export interface IViewerTooltipData {
displayName: string
value: string
}
export interface IViewerTooltip {
selectionId: powerbi.extensibility.ISelectionId
data: IViewerTooltipData[]
}
export interface SpeckleDataInput {
modelObjects: object[][]
objectIds: string[]
selectedIds: string[]
colorByIds: { objectIds: string[]; slice: fs.ColorPicker; color: string }[]
objectTooltipData: Map<string, IViewerTooltip>
view: powerbi.DataViewMatrix
isFromStore: boolean
}
@@ -0,0 +1,89 @@
import pako from 'pako'
function arrayBufferToBase64(buffer) {
let binary = ''
const bytes = new Uint8Array(buffer)
for (let i = 0; i < bytes.length; i++) {
binary += String.fromCharCode(bytes[i])
}
return btoa(binary)
}
function base64ToArrayBuffer(base64) {
const binaryString = atob(base64)
const bytes = new Uint8Array(binaryString.length)
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i)
}
return bytes
}
/**
* Splits an array into smaller chunks.
*/
function chunkArray(array, chunkSize) {
const chunks = []
for (let i = 0; i < array.length; i += chunkSize) {
chunks.push(array.slice(i, i + chunkSize))
}
return chunks
}
export function zipModelObjects(modelObjects: object[][], chunkSize = 1000) {
return modelObjects.map((objects) => zipJSONChunks(objects, chunkSize)).join('>')
}
/**
* Compresses JSON objects in chunks properly.
*/
export function zipJSONChunks(objectsInModel: object[], chunkSize = 1000) {
const chunks = chunkArray(objectsInModel, chunkSize)
return chunks.map((chunk, index) => {
const jsonString = JSON.stringify(chunk)
const originalSize = new TextEncoder().encode(jsonString).length / (1024 * 1024) // Original size in bytes
const compressed = pako.deflate(jsonString) // Returns Uint8Array
const compressedBase64 = btoa(arrayBufferToBase64(compressed))
const compressedSize = new TextEncoder().encode(compressedBase64).length / (1024 * 1024) // Compressed size in bytes
console.log(
`Chunk ${
index + 1
}: Original Size = ${originalSize} MB, Compressed Size = ${compressedSize} MB`
)
return compressedBase64
})
}
export function unzipModelObjects(compressedChunk: string) {
const compressedModelObjects = compressedChunk.split('>')
console.log(compressedModelObjects)
return compressedModelObjects.map((compressedModelObjs) =>
unzipJSONChunk(compressedModelObjs.split(','))
)
}
/**
* Decompresses JSON chunks properly.
*/
export function unzipJSONChunks(compressedChunks) {
return compressedChunks.flatMap((compressedStr) => {
const binaryString = atob(compressedStr) // Decode from Base64
const byteArray = base64ToArrayBuffer(binaryString)
const decompressed = pako.inflate(byteArray, { to: 'string' })
return JSON.parse(decompressed)
})
}
/**
* Decompresses a single JSON chunk properly.
*/
export function unzipJSONChunk(compressedChunk) {
const binaryString = atob(compressedChunk) // Decode from Base64
const byteArray = base64ToArrayBuffer(binaryString)
const decompressed = pako.inflate(byteArray, { to: 'string' })
return JSON.parse(decompressed)
}
+24
View File
@@ -0,0 +1,24 @@
// Add data types to window.navigator for use in this file. See https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types- for more info.
/// <reference types="user-agent-data-types" />
export function getOS(): OS {
const platform = window.navigator?.userAgentData?.platform || window.navigator.platform,
macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K', 'macOS'],
windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE']
let os = null
if (macosPlatforms.indexOf(platform) !== -1) {
os = 'MacOS'
} else if (windowsPlatforms.indexOf(platform) !== -1) {
os = 'Windows'
} else if (/Linux/.test(platform)) {
os = 'Linux'
}
return os
}
export enum OS {
Windows,
MacOS,
Linux
}
export const currentOS = getOS()
@@ -0,0 +1,55 @@
/**
* @param appname application name with its version, i.e. `Rhino 7`, `Revit 2024`
* @returns slug
*/
export function getSlugFromHostAppNameAndVersion(appname: string) {
if (!appname) {
return 'other'
}
// delete space if any
appname = appname.toLowerCase().replace(/\s/g, '')
// `NEW CONNECTOR CHECK`
const keywords = [
'dynamo',
'revit',
'autocad',
'civil',
'rhino',
'grasshopper',
'unity',
'gsa',
'microstation',
'openroads',
'openrail',
'openbuildings',
'etabs',
'sap',
'csibridge',
'safe',
'teklastructures',
'dxf',
'excel',
'unreal',
'powerbi',
'blender',
'qgis',
'arcgis',
'sketchup',
'archicad',
'topsolid',
'python',
'net',
'navisworks',
'advancesteel'
]
for (const keyword of keywords) {
if (appname.includes(keyword)) {
return keyword
}
}
return appname
}
@@ -0,0 +1,375 @@
import powerbi from 'powerbi-visuals-api'
import { IViewerTooltip, IViewerTooltipData, SpeckleDataInput } from '../types'
import { formattingSettings as fs } from 'powerbi-visuals-utils-formattingmodel'
import {
createDataViewWildcardSelector,
DataViewWildcardMatchingOption
} from 'powerbi-visuals-utils-dataviewutils/lib/dataViewWildcard'
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions
import { SpeckleVisualSettingsModel } from 'src/settings/visualSettingsModel'
import { FieldInputState, useVisualStore } from '@src/store/visualStore'
import { delay } from 'lodash'
import { getSlugFromHostAppNameAndVersion } from './hostAppSlug'
export class AsyncPause {
private lastPauseTime = 0
public needsWait = false
public tick(maxDelta: number) {
const now = performance.now()
const delta = now - this.lastPauseTime
// console.log('Delta -> ', delta)
if (delta > maxDelta) {
this.needsWait = true
}
}
public async wait(waitTime: number) {
this.lastPauseTime = performance.now()
await new Promise((resolve) => setTimeout(resolve, waitTime))
this.needsWait = false
}
}
export function validateMatrixView(options: VisualUpdateOptions): FieldInputState {
const matrixVew = options.dataViews[0].matrix
let hasRootObjectId = false,
hasObjectIds = false,
hasColorFilter = false,
hasTooltipData = false
matrixVew.rows.levels.forEach((level) => {
level.sources.forEach((source) => {
if (!hasRootObjectId) hasRootObjectId = source.roles['rootObjectId'] != undefined
if (!hasObjectIds) hasObjectIds = source.roles['objectIds'] != undefined
if (!hasColorFilter) hasColorFilter = source.roles['objectColorBy'] != undefined
})
})
matrixVew.columns.levels.forEach((level) => {
level.sources.forEach((source) => {
if (!hasTooltipData) hasTooltipData = source.roles['tooltipData'] != undefined
})
})
return {
rootObjectId: hasRootObjectId,
objectIds: hasObjectIds,
colorBy: hasColorFilter,
tooltipData: hasTooltipData
}
}
function processObjectValues(
objectIdChild: powerbi.DataViewMatrixNode,
matrixView: powerbi.DataViewMatrix
) {
const objectData: IViewerTooltipData[] = []
let shouldColor = true,
shouldSelect = false
if (objectIdChild.values)
Object.keys(objectIdChild.values).forEach((key) => {
const value: powerbi.DataViewMatrixNodeValue = objectIdChild.values[key]
const k: unknown = key
const colInfo = matrixView.valueSources[k as number]
const highLightActive = value.highlight !== undefined
if (highLightActive) {
shouldColor = false
}
const isHighlighted = value.highlight !== null
if (highLightActive && isHighlighted) {
shouldSelect = true
shouldColor = true
}
const propData: IViewerTooltipData = {
displayName: colInfo.displayName,
value: value.value.toString()
}
objectData.push(propData)
})
return { data: objectData, shouldColor, shouldSelect }
}
function processObjectNode(
objectIdChild: powerbi.DataViewMatrixNode,
host: powerbi.extensibility.visual.IVisualHost,
matrixView: powerbi.DataViewMatrix
): {
data: IViewerTooltipData[]
shouldColor: boolean
shouldSelect: boolean
id: string
selectionId: powerbi.visuals.ISelectionId
color?: string
} {
const objId = objectIdChild.value as string
// Create selection IDs for each object
const nodeSelection = host
.createSelectionIdBuilder()
.withMatrixNode(objectIdChild, matrixView.rows.levels)
.createSelectionId()
// Create value records for the tooltips
const objectValues = processObjectValues(objectIdChild, matrixView)
const res = { id: objId, selectionId: nodeSelection, color: undefined, ...objectValues }
// Process node objects, if any.
if (objectIdChild.objects) {
//@ts-ignore
const color = objectIdChild.objects.color.fill.solid.color as string
console.log('⚠️ HAS objects', color)
if (color) {
res.color = color
res.shouldColor = true
}
}
return res
}
function processObjectIdLevel(
parentObjectIdChild: powerbi.DataViewMatrixNode,
host: powerbi.extensibility.visual.IVisualHost,
matrixView: powerbi.DataViewMatrix
) {
return processObjectNode(parentObjectIdChild, host, matrixView)
}
export let previousPalette = null
export function resetPalette() {
previousPalette = null
}
export type ReceiveInfo = {
userEmail: string
serverUrl: string
sourceApplication?: string
}
async function getReceiveInfo(id) {
try {
const ids = (id as string).split(',')
const response = await fetch(`http://localhost:29364/user-info/${ids[0]}`)
if (!response.body) {
console.error('No response body')
return
}
return await response.json()
} catch (error) {
console.log(error)
console.log("User infp couldn't retrieved from local server.")
}
}
async function fetchStreamedData(commaSeparatedModelIds: string) {
const modelIds = (commaSeparatedModelIds as string).split(',')
const modelObjects = []
for await (const id of modelIds) {
const objects = await fetchStreamedDataForModel(id)
modelObjects.push(objects)
}
return modelObjects
}
async function fetchStreamedDataForModel(id) {
try {
const response = await fetch(`http://localhost:29364/get-objects/${id}`)
if (!response.body) {
console.error('No response body')
return
}
const reader = response.body.getReader()
const decoder = new TextDecoder()
const objects = []
let buffer = ''
const start = performance.now()
console.log('Streaming started...')
for await (const chunk of readStream(reader)) {
// chucks.push(chuck)
buffer += decoder.decode(chunk, { stream: true })
let boundary
while ((boundary = buffer.indexOf('\n')) !== -1) {
const jsonString = buffer.slice(0, boundary)
buffer = buffer.slice(boundary + 1)
try {
const obj = JSON.parse(jsonString)
objects.push(obj)
// console.log('Received object:', jsonObject)
} catch (e) {
console.error('Invalid JSON chunk:', jsonString)
}
}
}
try {
const obj = JSON.parse(buffer)
objects.push(obj)
// console.log('Received object:', jsonObject)
} catch (e) {
console.error('Invalid JSON chunk:', buffer)
}
const end = performance.now()
console.log(`Objects streamed in: ${(end - start) / 1000} s`)
const startObjectCleanup = performance.now()
// Skips first element
for (let i = 1; i < objects.length; i++) {
const obj = objects[i]
if (obj.speckle_type) {
if (obj.speckle_type.includes('Objects.Data.DataObject')) {
delete obj.properties
}
}
delete obj.__closure
}
const endObjectCleanup = performance.now()
console.log(`Objects cleaned up in: ${(endObjectCleanup - startObjectCleanup) / 1000} s`)
const sizeInBytes = new TextEncoder().encode(JSON.stringify(objects)).length
const sizeInMB = sizeInBytes / (1024 * 1024)
console.log(`Size of objects: ${sizeInMB} MB`)
return objects
} catch (error) {
console.log(error)
console.log("Objects couldn't retrieved from local server.")
} finally {
console.log('Streaming finished!')
}
}
async function* readStream(reader) {
while (true) {
const { done, value } = await reader.read()
if (done) break
yield value
}
}
export async function processMatrixView(
matrixView: powerbi.DataViewMatrix,
host: powerbi.extensibility.visual.IVisualHost,
hasColorFilter: boolean,
settings: SpeckleVisualSettingsModel,
onSelectionPair: (objId: string, selectionId: powerbi.extensibility.ISelectionId) => void
): Promise<SpeckleDataInput> {
const visualStore = useVisualStore()
const objectIds = [],
selectedIds = [],
colorByIds = [],
objectTooltipData = new Map<string, IViewerTooltip>()
console.log('🪜 Processing Matrix View', matrixView)
const localMatrixView = matrixView.rows.root.children[0]
const id = localMatrixView.value as unknown as string
console.log('🗝️ Root Object Id: ', id)
console.log('Last laoded root object id', visualStore.lastLoadedRootObjectId)
let modelObjects: object[][] = undefined
if (visualStore.isLoadingFromFile) {
console.log('The data is loading from file, skipping the streaming it.')
}
if (visualStore.lastLoadedRootObjectId !== id && !visualStore.isLoadingFromFile) {
const start = performance.now()
visualStore.setViewerReadyToLoad()
visualStore.setLoadingProgress('Loading', null)
// stream data
modelObjects = await fetchStreamedData(id)
const receiveInfo = await getReceiveInfo(id)
if (receiveInfo) {
visualStore.setReceiveInfo({
userEmail: receiveInfo.email,
serverUrl: receiveInfo.server,
sourceApplication: getSlugFromHostAppNameAndVersion(receiveInfo.sourceApplication)
})
}
visualStore.setViewerReloadNeeded() // they should be marked as deferred action bc of update function complexity.
console.log(`🚀 Upload is completed in ${(performance.now() - start) / 1000} s!`)
}
// NOTE: matrix view gave us already filtered out rows from tooltip data if it is assigned
localMatrixView.children?.forEach((obj) => {
// otherwise there is no point to collect objects
const processedObjectIdLevels = processObjectIdLevel(obj, host, matrixView)
objectIds.push(processedObjectIdLevels.id)
onSelectionPair(processedObjectIdLevels.id, processedObjectIdLevels.selectionId)
if (processedObjectIdLevels.shouldSelect) {
selectedIds.push(processedObjectIdLevels.id)
}
objectTooltipData.set(processedObjectIdLevels.id, {
selectionId: processedObjectIdLevels.selectionId,
data: processedObjectIdLevels.data
})
if (hasColorFilter) {
if (previousPalette) host.colorPalette['colorPalette'] = previousPalette
obj.children.forEach((child) => {
const colorSelectionId = host
.createSelectionIdBuilder()
.withMatrixNode(child, matrixView.rows.levels)
.createSelectionId()
const color = host.colorPalette.getColor(child.values[0].value as string)
const colorSlice = new fs.ColorPicker({
name: 'selectorFill',
displayName: child.value?.toString(),
value: {
value: color.value
},
selector: colorSelectionId.getSelector()
})
const colorGroup = {
color: color.value,
slice: colorSlice,
objectIds: []
}
const processedObjectIdLevels = processObjectIdLevel(child, host, matrixView)
objectIds.push(processedObjectIdLevels.id)
onSelectionPair(processedObjectIdLevels.id, processedObjectIdLevels.selectionId)
if (processedObjectIdLevels.shouldSelect) selectedIds.push(processedObjectIdLevels.id)
if (processedObjectIdLevels.shouldColor) {
colorGroup.objectIds.push(processedObjectIdLevels.id)
}
objectTooltipData.set(processedObjectIdLevels.id, {
selectionId: processedObjectIdLevels.selectionId,
data: processedObjectIdLevels.data
})
if (colorGroup.objectIds.length > 0) colorByIds.push(colorGroup)
})
}
})
previousPalette = host.colorPalette['colorPalette']
return {
modelObjects,
objectIds,
selectedIds,
colorByIds: colorByIds.length > 0 ? colorByIds : null,
objectTooltipData,
view: matrixView,
isFromStore: false
}
}
+181
View File
@@ -0,0 +1,181 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* Lightweight MD5 implementation.
* @see http://www.myersdaily.org/joseph/javascript/md5-text.html
*/
function md5cycle(x: any, k: any) {
let a = x[0],
b = x[1],
c = x[2],
d = x[3]
a = ff(a, b, c, d, k[0], 7, -680876936)
d = ff(d, a, b, c, k[1], 12, -389564586)
c = ff(c, d, a, b, k[2], 17, 606105819)
b = ff(b, c, d, a, k[3], 22, -1044525330)
a = ff(a, b, c, d, k[4], 7, -176418897)
d = ff(d, a, b, c, k[5], 12, 1200080426)
c = ff(c, d, a, b, k[6], 17, -1473231341)
b = ff(b, c, d, a, k[7], 22, -45705983)
a = ff(a, b, c, d, k[8], 7, 1770035416)
d = ff(d, a, b, c, k[9], 12, -1958414417)
c = ff(c, d, a, b, k[10], 17, -42063)
b = ff(b, c, d, a, k[11], 22, -1990404162)
a = ff(a, b, c, d, k[12], 7, 1804603682)
d = ff(d, a, b, c, k[13], 12, -40341101)
c = ff(c, d, a, b, k[14], 17, -1502002290)
b = ff(b, c, d, a, k[15], 22, 1236535329)
a = gg(a, b, c, d, k[1], 5, -165796510)
d = gg(d, a, b, c, k[6], 9, -1069501632)
c = gg(c, d, a, b, k[11], 14, 643717713)
b = gg(b, c, d, a, k[0], 20, -373897302)
a = gg(a, b, c, d, k[5], 5, -701558691)
d = gg(d, a, b, c, k[10], 9, 38016083)
c = gg(c, d, a, b, k[15], 14, -660478335)
b = gg(b, c, d, a, k[4], 20, -405537848)
a = gg(a, b, c, d, k[9], 5, 568446438)
d = gg(d, a, b, c, k[14], 9, -1019803690)
c = gg(c, d, a, b, k[3], 14, -187363961)
b = gg(b, c, d, a, k[8], 20, 1163531501)
a = gg(a, b, c, d, k[13], 5, -1444681467)
d = gg(d, a, b, c, k[2], 9, -51403784)
c = gg(c, d, a, b, k[7], 14, 1735328473)
b = gg(b, c, d, a, k[12], 20, -1926607734)
a = hh(a, b, c, d, k[5], 4, -378558)
d = hh(d, a, b, c, k[8], 11, -2022574463)
c = hh(c, d, a, b, k[11], 16, 1839030562)
b = hh(b, c, d, a, k[14], 23, -35309556)
a = hh(a, b, c, d, k[1], 4, -1530992060)
d = hh(d, a, b, c, k[4], 11, 1272893353)
c = hh(c, d, a, b, k[7], 16, -155497632)
b = hh(b, c, d, a, k[10], 23, -1094730640)
a = hh(a, b, c, d, k[13], 4, 681279174)
d = hh(d, a, b, c, k[0], 11, -358537222)
c = hh(c, d, a, b, k[3], 16, -722521979)
b = hh(b, c, d, a, k[6], 23, 76029189)
a = hh(a, b, c, d, k[9], 4, -640364487)
d = hh(d, a, b, c, k[12], 11, -421815835)
c = hh(c, d, a, b, k[15], 16, 530742520)
b = hh(b, c, d, a, k[2], 23, -995338651)
a = ii(a, b, c, d, k[0], 6, -198630844)
d = ii(d, a, b, c, k[7], 10, 1126891415)
c = ii(c, d, a, b, k[14], 15, -1416354905)
b = ii(b, c, d, a, k[5], 21, -57434055)
a = ii(a, b, c, d, k[12], 6, 1700485571)
d = ii(d, a, b, c, k[3], 10, -1894986606)
c = ii(c, d, a, b, k[10], 15, -1051523)
b = ii(b, c, d, a, k[1], 21, -2054922799)
a = ii(a, b, c, d, k[8], 6, 1873313359)
d = ii(d, a, b, c, k[15], 10, -30611744)
c = ii(c, d, a, b, k[6], 15, -1560198380)
b = ii(b, c, d, a, k[13], 21, 1309151649)
a = ii(a, b, c, d, k[4], 6, -145523070)
d = ii(d, a, b, c, k[11], 10, -1120210379)
c = ii(c, d, a, b, k[2], 15, 718787259)
b = ii(b, c, d, a, k[9], 21, -343485551)
x[0] = add32(a, x[0])
x[1] = add32(b, x[1])
x[2] = add32(c, x[2])
x[3] = add32(d, x[3])
}
function cmn(q: any, a: any, b: any, x: any, s: any, t: any) {
a = add32(add32(a, q), add32(x, t))
return add32((a << s) | (a >>> (32 - s)), b)
}
function ff(a: any, b: any, c: any, d: any, x: any, s: any, t: any) {
return cmn((b & c) | (~b & d), a, b, x, s, t)
}
function gg(a: any, b: any, c: any, d: any, x: any, s: any, t: any) {
return cmn((b & d) | (c & ~d), a, b, x, s, t)
}
function hh(a: any, b: any, c: any, d: any, x: any, s: any, t: any) {
return cmn(b ^ c ^ d, a, b, x, s, t)
}
function ii(a: any, b: any, c: any, d: any, x: any, s: any, t: any) {
return cmn(c ^ (b | ~d), a, b, x, s, t)
}
function md51(s: any) {
const n = s.length,
state = [1732584193, -271733879, -1732584194, 271733878]
let i
for (i = 64; i <= s.length; i += 64) {
md5cycle(state, md5blk(s.substring(i - 64, i)))
}
s = s.substring(i - 64)
const tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for (i = 0; i < s.length; i++) tail[i >> 2] |= s.charCodeAt(i) << (i % 4 << 3)
tail[i >> 2] |= 0x80 << (i % 4 << 3)
if (i > 55) {
md5cycle(state, tail)
for (i = 0; i < 16; i++) tail[i] = 0
}
tail[14] = n * 8
md5cycle(state, tail)
return state
}
function md5blk(s: any) {
/* I figured global was faster. */
const md5blks = []
let i
for (i = 0; i < 64; i += 4) {
md5blks[i >> 2] =
s.charCodeAt(i) +
(s.charCodeAt(i + 1) << 8) +
(s.charCodeAt(i + 2) << 16) +
(s.charCodeAt(i + 3) << 24)
}
return md5blks
}
const HEX_CHR = '0123456789abcdef'.split('')
function rhex(n: any) {
let s = '',
j = 0
for (; j < 4; j++) s += HEX_CHR[(n >> (j * 8 + 4)) & 0x0f] + HEX_CHR[(n >> (j * 8)) & 0x0f]
return s
}
function hex(x: any) {
for (let i = 0; i < x.length; i++) x[i] = rhex(x[i])
return x.join('')
}
let add32 = (a: any, b: any) => {
return (a + b) & 0xffffffff
}
/**
* Generate an MD5 hash for an input string
* @param {string} s input string
* @returns {string} md5 hash
*/
export function md5(s: string): string {
return hex(md51(s))
}
if (md5('hello') !== '5d41402abc4b2a76b9719d911017c592') {
add32 = (x, y) => {
const lsw = (x & 0xffff) + (y & 0xffff),
msw = (x >> 16) + (y >> 16) + (lsw >> 16)
return (msw << 16) | (lsw & 0xffff)
}
}
+73
View File
@@ -0,0 +1,73 @@
// TBD NOTE: if we decide to tackle certification on visual and deploy it on microsoft marketplace, we would need to remove this logic
// since we enable webaccess privile for the sake of mixpanel for now.
import { useVisualStore } from '@src/store/visualStore'
import { md5 } from './md5'
const TRACK_URL = 'https://analytics.speckle.systems/track?ip=1'
const MIXPANEL_TOKEN = 'acd87c5a50b56df91a795e999812a3a4'
const HOST_APP_NAME = 'powerbi-visual'
const IS_OFFLINE_SUPPORT = true
export enum SettingsChangedType {
Gradient = 'Gradient',
DefaultCamera = 'DefaultCamera',
OrthoMode = 'OrthoMode'
}
export class Tracker {
public static async track(event: string, properties: any = {}) {
const visualStore = useVisualStore()
const receiveInfo = visualStore.receiveInfo
let tempProperties = properties
if (receiveInfo) {
const hashedEmail = '@' + md5(receiveInfo.userEmail.toLowerCase() as string).toUpperCase()
const hashedServer = md5(
new URL(receiveInfo.serverUrl).hostname.toLowerCase() as string
).toUpperCase()
tempProperties = {
...tempProperties, // eslint-disable-next-line camelcase
distinct_id: hashedEmail,
// eslint-disable-next-line camelcase
server_id: hashedServer,
email: receiveInfo.userEmail,
isAnonymous: receiveInfo.userEmail === ''
}
}
return this.trackEvents([
{
event,
properties: tempProperties
}
])
}
private static async trackEvents(events: Array<{ event: string; properties: any }>) {
try {
await fetch(TRACK_URL, {
method: 'POST',
body:
'data=' +
JSON.stringify(
events.map((e) => {
Object.assign(e.properties, {
token: MIXPANEL_TOKEN,
hostApp: HOST_APP_NAME,
offlineSupport: IS_OFFLINE_SUPPORT,
ui: 'dui3',
type: 'action'
})
return e
})
)
})
} catch (e) {
console.error('Create track failed', e)
}
}
public static dataLoaded(properties = {}) {
return this.track('Receive', properties)
}
}
@@ -0,0 +1,67 @@
import powerbiVisualsApi from 'powerbi-visuals-api'
import powerbi = powerbiVisualsApi
import DataViewObject = powerbi.DataViewObject
import DataViewObjects = powerbi.DataViewObjects
import DataViewCategoryColumn = powerbi.DataViewCategoryColumn
/**
* Gets property value for a particular object.
*
* @function
* @param {DataViewObjects} objects - Map of defined objects.
* @param {string} objectName - Name of desired object.
* @param {string} propertyName - Name of desired property.
* @param {T} defaultValue - Default value of desired property.
*/
export function getValue<T>(
objects: DataViewObjects,
objectName: string,
propertyName: string,
defaultValue: T
): T {
if (objects) {
const object = objects[objectName]
if (object) {
const property: T = <T>object[propertyName]
if (property !== undefined) {
return property
}
}
}
return defaultValue
}
/**
* Gets property value for a particular object in a category.
*
* @function
* @param {DataViewCategoryColumn} category - List of category objects.
* @param {number} index - Index of category object.
* @param {string} objectName - Name of desired object.
* @param {string} propertyName - Name of desired property.
* @param {T} defaultValue - Default value of desired property.
*/
export function getCategoricalObjectValue<T>(
category: DataViewCategoryColumn,
index: number,
objectName: string,
propertyName: string,
defaultValue: T
): T {
const categoryObjects = category.objects
if (categoryObjects) {
const categoryObject: DataViewObject = categoryObjects[index]
if (categoryObject) {
const object = categoryObject[objectName]
if (object) {
const property: T = <T>object[propertyName]
if (property !== undefined) {
return property
}
}
}
}
return defaultValue
}
+63
View File
@@ -0,0 +1,63 @@
// Copyright (c) 2022 Davide Aversa
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
import * as _ from 'lodash'
export interface SignalBindingAsync<S, T> {
listener?: string
handler: (source: S, data: T) => Promise<void>
}
export interface IAsyncSignal<S, T> {
bind(listener: string, handler: (source: S, data: T) => Promise<void>): void
unbind(listener: string): void
}
export class AsyncSignal<S, T> implements IAsyncSignal<S, T> {
private handlers: Array<SignalBindingAsync<S, T>> = []
public bind(listener: string, handler: (source: S, data: T) => Promise<void>): void {
if (this.contains(listener)) {
this.unbind(listener)
}
this.handlers.push({ listener, handler })
}
public unbind(listener: string): void {
this.handlers = this.handlers.filter((h) => h.listener !== listener)
}
public async trigger(source: S, data: T): Promise<void> {
// Duplicate the array to avoid side effects during iteration.
this.handlers.slice(0).map((h) => h.handler(source, data))
}
public async triggerAwait(source: S, data: T): Promise<void> {
// Duplicate the array to avoid side effects during iteration.
const promises = this.handlers.slice(0).map((h) => h.handler(source, data))
await Promise.all(promises)
}
public contains(listener: string): boolean {
return _.some(this.handlers, (h) => h.listener === listener)
}
public expose(): IAsyncSignal<S, T> {
return this
}
}
@@ -0,0 +1,38 @@
import { FilteringState } from '@speckle/viewer'
import { OrthographicCamera, PerspectiveCamera } from 'three'
export function projectToScreen(cam: OrthographicCamera | PerspectiveCamera, loc) {
cam.updateProjectionMatrix()
const copy = loc.clone()
copy.project(cam)
return {
x: (copy.x * 0.5 + 0.5) * window.innerWidth - 10,
y: (copy.y * -0.5 + 0.5) * window.innerHeight
}
}
export interface Hit {
guid: string
object?: Record<string, unknown>
point: { x: number; y: number; z: number }
}
export function pickViewableHit(hits: Hit[], state: FilteringState): Hit | null {
let hit = null
if (state.isolatedObjects) {
// Find the first hit contained in the isolated objects
hit = hits.find((hit) => {
const hitId = hit.object.id as string
return state.isolatedObjects.includes(hitId)
})
}
return hit
}
export const createViewerContainerDiv = (parent: HTMLElement) => {
const container = parent.appendChild(document.createElement('div'))
container.style.backgroundColor = 'transparent'
container.style.height = '100%'
container.style.width = '100%'
container.style.position = 'fixed'
return container
}
+71
View File
@@ -0,0 +1,71 @@
<template>
<div
id="speckle-home-view"
class="flex flex-col justify-center items-center h-full w-full text-center space-y-4 p-2"
>
<div class="flex flex-col justify-center items-center h-full w-full text-center space-y-4">
<div class="flex flex-row justify-center items-center space-x-3">
<div class="flex justify-center items-center">
<img src="@assets/logo-big.png" alt="Logo" class="w-12" />
</div>
<div
class="bg-gradient-to-r from-blue-500 via-blue-400 to-blue-600 inline-block py-1 text-transparent bg-clip-text text-2xl"
>
<p>
<b>Speckle</b>
for
<b>PowerBI</b>
</p>
</div>
</div>
<div class="flex flex-col justify-center space-y-1">
<div class="flex flex-row space-x-2">
<EyeIcon class="w-6"></EyeIcon>
<p><b>Version Object ID</b></p>
<ArrowRightIcon class="w-4"></ArrowRightIcon>
<p>View your model</p>
</div>
<div class="flex flex-row space-x-2">
<CursorArrowRippleIcon class="w-6"></CursorArrowRippleIcon>
<p><b>Object IDs</b></p>
<ArrowRightIcon class="w-4"></ArrowRightIcon>
<p>Highlighting and interactivity</p>
</div>
<div class="flex flex-row space-x-2">
<ChatBubbleLeftIcon class="w-6"></ChatBubbleLeftIcon>
<p><b>Tooltip Data</b></p>
<ArrowRightIcon class="w-4"></ArrowRightIcon>
<p>Tooltip and interactivity</p>
</div>
</div>
</div>
<div class="flex justify-end gap-1">
<button :class="buttonClass" @click="goToGuide">Getting started</button>
<button :class="buttonClass" @click="goToForum">Help</button>
</div>
</div>
</template>
<script setup lang="ts">
import { useVisualStore } from '../store/visualStore'
import {
EyeIcon,
ArrowRightIcon,
CursorArrowRippleIcon,
ChatBubbleLeftIcon
} from '@heroicons/vue/24/outline'
const visualStore = useVisualStore()
const buttonClass = `btn p-2 rounded-md bg-primary-muted border-transparent font-medium
hover:bg-gray-200 hover:shadow-md
disabled:hover:bg-transparent focus-visible:border-foundation transition-all duration-150`
function goToForum() {
visualStore.host.launchUrl('https://speckle.community/tag/powerbi')
}
function goToGuide() {
visualStore.host.launchUrl('https://speckle.guide/user/powerbi')
}
</script>
@@ -0,0 +1,65 @@
<template>
<div
class="absolute top-0 left-0 z-10 cursor-pointer flex items-center"
@click="goToSpeckleWebsite"
>
<img class="w-8 h-auto mx-2 my-1" src="@assets/logo-big.png" />
<div class="font-medium">Speckle</div>
</div>
<div
v-if="isInteractive"
class="absolute top-2 left-1/2 -translate-x-1/2 z-20 bg-white bg-opacity-70 text-black text-center text-sm px-4 py-2 rounded shadow"
>
<div v-if="bothFieldsMissing">
<strong>Object IDs</strong>
and
<strong>Tooltip Data</strong>
fields are needed for interactivity with other visuals.
</div>
<div v-else-if="onlyObjectIdsMissing">
<strong>Object IDs</strong>
field is needed for interactivity with other visuals.
</div>
<div v-else-if="onlyTooltipDataMissing">
<strong>Tooltip Data</strong>
field is needed for interactivity with other visuals.
</div>
</div>
<div
v-if="visualStore.loadingProgress"
class="absolute top-1/2 left-1/2 w-1/2 -translate-x-1/2 z-20 text-center text-sm"
>
<!-- Progress Bar -->
<LoadingBar :loading="!!visualStore.loadingProgress"></LoadingBar>
</div>
<viewer-wrapper id="speckle-3d-view" class="h-full w-full"></viewer-wrapper>
</template>
<script setup lang="ts">
import ViewerWrapper from 'src/components/ViewerWrapper.vue'
import { useVisualStore } from '../store/visualStore'
import { computed } from 'vue'
import LoadingBar from '@src/components/loading/LoadingBar.vue'
const visualStore = useVisualStore()
const onlyObjectIdsMissing = computed(
() => !visualStore.fieldInputState.objectIds && visualStore.fieldInputState.tooltipData
)
const onlyTooltipDataMissing = computed(
() => visualStore.fieldInputState.objectIds && !visualStore.fieldInputState.tooltipData
)
const bothFieldsMissing = computed(
() => !visualStore.fieldInputState.objectIds && !visualStore.fieldInputState.tooltipData
)
const isInteractive = computed(
() => !visualStore.fieldInputState.objectIds || !visualStore.fieldInputState.tooltipData
)
const goToSpeckleWebsite = () => visualStore.host.launchUrl('https://speckle.systems')
</script>
+211
View File
@@ -0,0 +1,211 @@
import 'core-js/stable'
import 'regenerator-runtime/runtime'
import '../style/visual.css'
import { FormattingSettingsService } from 'powerbi-visuals-utils-formattingmodel'
import { createApp } from 'vue'
import App from './App.vue'
import { selectionHandlerKey, tooltipHandlerKey } from 'src/injectionKeys'
import { SpeckleDataInput } from './types'
import { processMatrixView, ReceiveInfo, validateMatrixView } from './utils/matrixViewUtils'
import { SpeckleVisualSettingsModel } from './settings/visualSettingsModel'
import TooltipHandler from './handlers/tooltipHandler'
import SelectionHandler from './handlers/selectionHandler'
import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions
import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions
import IVisual = powerbi.extensibility.visual.IVisual
import ITooltipService = powerbi.extensibility.ITooltipService
import { pinia } from './plugins/pinia'
import { useVisualStore } from './store/visualStore'
import { unzipModelObjects } from './utils/compression'
// noinspection JSUnusedGlobalSymbols
export class Visual implements IVisual {
private readonly host: powerbi.extensibility.visual.IVisualHost
private selectionHandler: SelectionHandler
private tooltipHandler: TooltipHandler
private isFirstViewerLoad: boolean
private formattingSettings: SpeckleVisualSettingsModel
private formattingSettingsService: FormattingSettingsService
// noinspection JSUnusedGlobalSymbols
public constructor(options: VisualConstructorOptions) {
this.isFirstViewerLoad = true
// Tracker.loaded()
this.host = options.host
this.formattingSettingsService = new FormattingSettingsService()
console.log('🚀 Init handlers')
this.selectionHandler = new SelectionHandler(this.host)
this.tooltipHandler = new TooltipHandler(this.host.tooltipService as ITooltipService)
console.log('🚀 Init Vue App')
createApp(App)
.use(pinia)
// .use(store, storeKey)
.provide(selectionHandlerKey, this.selectionHandler)
.provide(tooltipHandlerKey, this.tooltipHandler)
.mount(options.element)
// set `host` to visual store to be able use later in other components if needed
const visualStore = useVisualStore()
visualStore.setHost(this.host)
this.host.refreshHostData() // to be able to trigger `update` function after constructor! by this way i was able to trigger viewer load objects from properties store
}
private async clear() {
this.selectionHandler.clear()
}
public async update(options: VisualUpdateOptions) {
const visualStore = useVisualStore()
// @ts-ignore
console.log('⤴️ Update type 👉', powerbi.VisualUpdateType[options.type])
this.formattingSettings = this.formattingSettingsService.populateFormattingSettingsModel(
SpeckleVisualSettingsModel,
options.dataViews[0]
)
console.log('Selector colors', this.formattingSettings.colorSelector)
try {
const matrixView = options.dataViews[0].matrix
if (!matrixView) throw new Error('Data does not contain a matrix data view') // TODO: Could be toast notificiation too!
// we first need to check which inputs user provided to decide our strategy
const validationResult = validateMatrixView(options)
visualStore.setFieldInputState(validationResult)
console.log('❓Field inputs', validationResult)
switch (options.type) {
case powerbi.VisualUpdateType.Resize:
case powerbi.VisualUpdateType.ResizeEnd:
case powerbi.VisualUpdateType.Style:
case powerbi.VisualUpdateType.ViewMode:
case powerbi.VisualUpdateType.Resize + powerbi.VisualUpdateType.ResizeEnd:
return
case powerbi.VisualUpdateType.Data:
try {
// read saved data from file if any
if (
!visualStore.isViewerObjectsLoaded &&
this.isFirstViewerLoad &&
options.dataViews[0].metadata.objects
) {
const chunks = options.dataViews[0].metadata.objects.storedData
?.speckleObjects as string
const objectsFromFile = unzipModelObjects(chunks)
if (options.dataViews[0].metadata.objects.viewMode?.defaultViewMode as string) {
console.log(
`Default View Mode: ${
options.dataViews[0].metadata.objects.viewMode?.defaultViewMode as string
}`
)
visualStore.setDefaultViewModeInFile(
options.dataViews[0].metadata.objects.viewMode?.defaultViewMode as string
)
}
if (options.dataViews[0].metadata.objects.cameraPosition?.positionX as string) {
visualStore.setCameraPositionInFile([
Number(options.dataViews[0].metadata.objects.cameraPosition?.positionX),
Number(options.dataViews[0].metadata.objects.cameraPosition?.positionY),
Number(options.dataViews[0].metadata.objects.cameraPosition?.positionZ),
Number(options.dataViews[0].metadata.objects.cameraPosition?.targetX),
Number(options.dataViews[0].metadata.objects.cameraPosition?.targetY),
Number(options.dataViews[0].metadata.objects.cameraPosition?.targetZ)
])
}
// get receive info from file for mixpanel
try {
const receiveInfoFromFile = JSON.parse(
options.dataViews[0].metadata.objects.storedData?.receiveInfo as string
) as ReceiveInfo
visualStore.setReceiveInfo(receiveInfoFromFile)
} catch (error) {
console.warn(error)
console.log('missing mixpanel info')
}
if (visualStore.lastLoadedRootObjectId !== objectsFromFile[0].id) {
this.tryReadFromFile(objectsFromFile, visualStore)
}
}
const input = await processMatrixView(
matrixView,
this.host,
validationResult.colorBy,
this.formattingSettings,
(obj, id) => this.selectionHandler.set(obj, id)
)
this.updateViewer(input)
} catch (error) {
console.error('Data update error', error ?? 'Unknown')
}
break
default:
return
}
} catch (e) {
console.log('❌Input not valid:', (e as Error).message)
this.host.displayWarningIcon(
`Incomplete data input.`,
`"Viewer Data" and "Object IDs" data inputs are mandatory. If your data connector does not output all these columns, please update it.`
)
console.warn(
`Incomplete data input. "Viewer Data", "Object IDs" data inputs are mandatory. If your data connector does not output all these columns, please update it.`
)
visualStore.setFieldInputState({
rootObjectId: false,
objectIds: false,
colorBy: false,
tooltipData: false
})
return
}
}
public getFormattingModel(): powerbi.visuals.FormattingModel {
console.log('Showing Formatting settings', this.formattingSettings)
const model = this.formattingSettingsService.buildFormattingModel(this.formattingSettings)
console.log('Formatting model was created', model)
return model
}
private updateViewer(input: SpeckleDataInput) {
const visualStore = useVisualStore()
this.tooltipHandler.setup(input.objectTooltipData)
visualStore.setViewerReadyToLoad()
if (visualStore.isViewerInitialized && !visualStore.viewerReloadNeeded) {
visualStore.setDataInput(input)
} else {
// we should give some time to Vue to render ViewerWrapper component to be able to have proper emitter setup. Happiness level 6/10
setTimeout(() => {
visualStore.setDataInput(input)
// visualStore.writeObjectsToFile(input.objects)
}, 250)
}
}
private tryReadFromFile(objectsFromFile: object[], visualStore) {
visualStore.setViewerReadyToLoad()
visualStore.setIsLoadingFromFile(true) // to block unnecessary streaming data if bg service is running
setTimeout(() => {
visualStore.loadObjectsFromFile(objectsFromFile)
this.isFirstViewerLoad = false
}, 250)
console.log(`${objectsFromFile.length} objects retrieved from persistent properties!`)
}
public async destroy() {
await this.clear()
}
}
+4
View File
@@ -0,0 +1,4 @@
@import '@speckle/ui-components/style.css';
@tailwind base;
@tailwind components;
@tailwind utilities;
+11
View File
@@ -0,0 +1,11 @@
const speckleTheme = require("@speckle/tailwind-theme");
const themeConfig = require("@speckle/tailwind-theme/tailwind-configure");
const uiConfig = require("@speckle/ui-components/tailwind-configure");
const formsPlugin = require("@tailwindcss/forms");
/** @type {import("tailwindcss").Config} */
module.exports = {
darkMode: "class",
content: ["./src/**/*.{js,ts,vue}", themeConfig.tailwindContentEntry(require), uiConfig.tailwindContentEntry(require)],
plugins: [speckleTheme.default, formsPlugin]
};
+31
View File
@@ -0,0 +1,31 @@
{
"compilerOptions": {
"allowJs": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2020",
"sourceMap": true,
"outDir": "./.tmp/build/",
"moduleResolution": "node",
"skipLibCheck": true,
"declaration": true,
"lib": ["es2020", "dom"],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"types": [],
"baseUrl": ".",
"paths": {
"@src/*": ["src/*"],
"@assets/*": ["assets/*"]
}
},
"ts-node": {
"compilerOptions": {
"module": "CommonJS",
"esModuleInterop": true
}
},
"files": ["./src/visual.ts"],
"include": ["./src/**/*.ts", "./src/**/*.vue"],
"exclude": ["webpack.config.dev.ts"]
}
+4
View File
@@ -0,0 +1,4 @@
@import '@speckle/ui-components/style.css';
@tailwind base;
@tailwind components;
@tailwind utilities;
+269
View File
@@ -0,0 +1,269 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import path from 'path'
// api configuration
import powerbi from 'powerbi-visuals-api'
import ExtraWatchWebpackPlugin from 'extra-watch-webpack-plugin'
import { BundleAnalyzerPlugin as Visualizer } from 'webpack-bundle-analyzer'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import { PowerBICustomVisualsWebpackPlugin } from 'powerbi-visuals-webpack-plugin'
import webpack from 'webpack'
import fs from 'fs'
import { WebpackConfiguration } from 'webpack-cli'
import { VueLoaderPlugin } from 'vue-loader'
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin'
/**
* MAIN CONSTS
*/
const devServerPort = 8080
const pbivizPath = './pbiviz.json'
const capabilitiesPath = './capabilities.json'
const pluginLocation = './.tmp/precompile/visualPlugin.ts' // path to visual plugin file, the file generates by the plugin
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const powerbiApi: any = powerbi // Types for PowerBI seem to be off, so I'm instead forcing it to `any`
// visual configuration json path
const pbivizFile = require(path.join(__dirname, pbivizPath))
const packageJsonFile = require(path.join(__dirname, 'package.json'))
pbivizFile.visual.version = packageJsonFile.version
// the visual capabilities content
const capabilitiesFile = require(path.join(__dirname, capabilitiesPath))
// string resources
const resourcesFolder = path.join('.', 'stringResources')
const localizationFolders = fs.existsSync(resourcesFolder) && fs.readdirSync(resourcesFolder)
const statsLocation = '../../webpack.statistics.html'
// babel options to support IE11
const babelOptions = {
presets: [
[
'@babel/preset-env',
{
targets: {
ie: '11'
},
useBuiltIns: 'entry',
corejs: 3,
modules: false
}
]
],
plugins: [],
sourceType: 'unambiguous', // tell to babel that the project can contain different module types, not only es2015 modules
cacheDirectory: path.join('.tmp', 'babelCache') // path for cache files
}
export const buildConfig = (params: { mode: 'dev' | 'prod' }) => {
const isProd = params.mode === 'prod'
const loadCert = () => {
const keyPath = path.resolve(__dirname, 'localhost-key.pem')
const certPath = path.resolve(__dirname, 'localhost.pem')
if (!fs.existsSync(keyPath) || !fs.existsSync(certPath)) {
console.log('Unable to locate localhost certs, skipping...')
return undefined
}
console.log(
'Using locally generated localhost certs, make sure the CA cert is installed & trusted!'
)
return {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certPath)
}
}
const certInfo = isProd ? undefined : loadCert()
const config: WebpackConfiguration = {
entry: {
visual: pluginLocation
},
optimization: {
concatenateModules: false,
minimize: isProd // enable minimization for create *.pbiviz file less than 2 Mb, can be disabled for dev mode
},
devtool: isProd ? false : 'inline-source-map',
mode: isProd ? 'production' : 'development',
module: {
rules: [
{
test: /\.vue$/,
use: ['vue-loader']
},
{
parser: {
amd: false
}
},
{
test: /(\.ts)x|\.ts$/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
// '@babel/react',
'@babel/env'
]
}
},
{
loader: 'ts-loader',
options: {
transpileOnly: false,
experimentalWatchApi: false,
appendTsSuffixTo: [/\.vue$/]
}
}
],
exclude: [/node_modules/],
include: /.tmp|powerbi-visuals-|src|precompile\\visualPlugin.ts/
},
{
test: /(\.js)x|\.js$/,
use: [
{
loader: 'babel-loader',
options: babelOptions
}
],
exclude: [/node_modules/]
},
{
test: /\.json$/,
loader: 'json-loader',
type: 'javascript/auto'
},
{
test: /\.(css|scss)?$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader']
},
{
test: /\.(woff|ttf|ico|woff2|jpg|jpeg|png|webp|svg)$/i,
use: ['base64-inline-loader']
}
]
},
resolve: {
extensions: ['.tsx', '.ts', '.jsx', '.js', '.css'],
alias: {
src: path.resolve(__dirname, 'src/'),
assets: path.resolve(__dirname, 'assets/')
},
plugins: [new TsconfigPathsPlugin()]
},
output: {
publicPath: '/assets',
path: path.join(__dirname, '/.tmp', 'drop'),
library: +powerbiApi.version.replace(/\./g, '') >= 320 ? pbivizFile.visual.guid : undefined,
libraryTarget: +powerbiApi.version.replace(/\./g, '') >= 320 ? 'var' : undefined
},
...(isProd
? {}
: {
devServer: {
static: {
directory: path.join(__dirname, '.tmp', 'drop'), // path with assets for dev server, they are generated by webpack plugin
publicPath: '/assets'
},
compress: true,
port: devServerPort, // dev server port
hot: false,
...(certInfo
? {
server: {
type: 'https',
options: {
...certInfo
}
}
}
: {
https: {}
}),
liveReload: false,
webSocketServer: false,
headers: {
'access-control-allow-origin': '*',
'cache-control': 'public, max-age=0'
}
}
}),
externals:
powerbiApi.version.replace(/\./g, '') >= 320
? {
'powerbi-visuals-api': 'null',
fakeDefine: 'false'
}
: {
'powerbi-visuals-api': 'null',
fakeDefine: 'false',
corePowerbiObject: "Function('return this.powerbi')()",
realWindow: "Function('return this')()"
},
plugins: [
new webpack.DefinePlugin({
__VUE_OPTIONS_API__: JSON.stringify(true),
__VUE_PROD_DEVTOOLS__: JSON.stringify(false)
}),
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: 'visual.css',
chunkFilename: '[id].css'
}),
new Visualizer({
reportFilename: statsLocation,
openAnalyzer: false,
analyzerMode: `static`
}),
// visual plugin regenerates with the visual source, but it does not require relaunching dev server
new webpack.WatchIgnorePlugin({
paths: [path.join(__dirname, pluginLocation), './.tmp/**/*.*']
}),
// custom visuals plugin instance with options
new PowerBICustomVisualsWebpackPlugin({
...pbivizFile,
compression: isProd ? 9 : 0,
capabilities: capabilitiesFile,
stringResources:
localizationFolders &&
localizationFolders.map((localization) =>
path.join(resourcesFolder, localization, 'resources.resjson')
),
apiVersion: powerbiApi.version,
capabilitiesSchema: powerbiApi.schemas.capabilities,
pbivizSchema: powerbiApi.schemas.pbiviz,
stringResourcesSchema: powerbiApi.schemas.stringResources,
dependenciesSchema: powerbiApi.schemas.dependencies,
devMode: false,
generatePbiviz: isProd,
generateResources: true,
minifyJS: isProd,
minify: isProd,
modules: true,
visualSourceLocation: '../../src/visual',
pluginLocation: pluginLocation,
packageOutPath: path.join(__dirname, 'dist')
}),
new ExtraWatchWebpackPlugin({
files: [pbivizPath, capabilitiesPath]
}),
powerbiApi.version.replace(/\./g, '') >= 320
? new webpack.ProvidePlugin({
define: 'fakeDefine'
})
: new webpack.ProvidePlugin({
window: 'realWindow',
define: 'fakeDefine',
powerbi: 'corePowerbiObject'
})
]
}
return config
}
+3
View File
@@ -0,0 +1,3 @@
import { buildConfig } from './webpack.config.base'
export default buildConfig({ mode: 'dev' })
+3
View File
@@ -0,0 +1,3 @@
import { buildConfig } from './webpack.config.base'
export default buildConfig({ mode: 'prod' })

Some files were not shown because too many files have changed in this diff Show More