@@ -10,7 +10,7 @@ The test dashboard is part of the Sparc Portal and is meant to compare various v
1010View the storybook of working components here
1111https://nih-sparc.github.io/TestDashboard/?path=/docs/components-biolucidaviewer--docs
1212
13- Dev version here
13+ Live Demo Here
1414https://sparc-app-2-dev-features-2a5a06b8ea5c.herokuapp.com/apps/dashboard
1515
1616## Recommended IDE Setup
@@ -59,63 +59,146 @@ Yarn run lint
5959## Dependency Setup
6060
6161If you are installing this project as a node module [ npm] ( https://www.npmjs.com/package/sparc-dashboard-beta ) dependency you need the following installed in your project.
62- Vue(^3.5.11)
62+
63+ Vue(^3.5.13)
6364``` sh
6465yarn add vue
6566```
67+ Element-Plus(^2.8.4)
68+ ``` sh
69+ yarn add element-plus
70+ ```
6671### Importing Dashboard into your project
6772
73+ Example main.js
74+
6875main.js
6976```
7077import { createApp } from 'vue';
7178import { createPinia } from 'pinia';
72- import { installDashboard } from 'sparc-dashboard-plugin';
79+ import {installDashboard} from 'sparc-dashboard-beta'
80+ import ElementPlus from 'element-plus';
81+ import 'element-plus/dist/index.css';
7382import App from './App.vue';
7483
7584const app = createApp(App);
7685const pinia = createPinia();
7786
78- //add the components you want to be included in your dashboard
87+ //add the components you want to be included in your dashboard. This populates the drop down
88+ //name must match what you named your component in [filename].vue
7989const componentMap = [
8090 'FlatmapViewer',
8191 'ImageSelector',
8292 'BiolucidaViewer',
8393 'QDBGraph',
84- 'TextWidget',
85- 'CountWidget'
94+ 'TextWidget'
8695]
8796
97+ //pinia is optional, dashboard will initiate a pinia instance if it is excluded
98+ //app and componentMap are required
8899installDashboard(app, componentMap, pinia);
89100
101+ app.use(ElementPlus);
90102app.use(pinia);
91103app.mount('#app');
92104
93105```
94- In your vue app.vue or component .vue
106+ In your vue app.vue or componentName .vue
95107```
96108<template>
97- <SparcDashboard />
109+ <SparcDashboard :dBItems="dashboardItems" :hideHeader="true" :options="dashboardOptions" />
98110</template>
99111<script>
100112//using this naming convention [componenentName]-n, you can customize the dashboard for it's initial load.
113+ // -n should start with 0 or 1 and count up one integer at a time
101114//dbItems is required. If you want the dashboard to be blank, send it an empty array
102- const dBItems = [
115+ const dashboardItems = [
103116 { id: "FlatmapViewer-1", x: 0, y: 0, h: 8, w:2, componentName:"Flatmap Viewer",component:"FlatmapViewer" },
104117 { id: "ImageSelector-2", x: 2, y: 0, h: 8, w:3, componentName:"Image Selector", component:"ImageSelector"},
105118 { id: "BiolucidaViewer-3", x: 5, y: 0,h: 11, w:7, componentName:"MBF Viewer", component:"BiolucidaViewer"},
106- { id: "ODBGraph-4", x: 0, y: 8, h: 3, w:5, componentName:"Flatmap Viewer",component:"QDBGraph" }
107- ]
119+ { id: "ODBGraph-4", x: 0, y: 8, h: 3, w:5, componentName:"Flatmap Viewer",component:"QDBGraph"},
120+ { id: "TextWidget-1", x: 0, y: 0, h: 1, w:4, componentName:"Text",component:"TextWidget",hideHeader:true, Props:{displayText:"Dataset Overview",hideHeader:true} }
121+ ]
122+ const dashboardOptions = {
123+ globalData: {
124+ FileCount: 10,
125+ Status: "Published",
126+ CollaboratorCounts: 8
127+ }
128+ };
108129</script>
109130```
110- ## List of Components
131+ ## List of Available Components
111132- any of these may be imported in the componentMap
133+
112134BiolucidaViewer - Surfaces Biolucida Images when SELECTED_IMAGE (in global vars) is updated
135+
113136FlatmapViewer - Shows the vagas flatmap. Updats the FLATMAP_LOCATION global var
137+
114138ImageSelector - Displays list of images in the global var DASH_IMAGE_ARRAY. Updates SELECTED_IMAGE
115139QDBGraph - displays QDB data
140+
116141ScaffoldViewer - Displays 3D Scaffold
142+
117143TextWidget - Displays text assigned by user or from data
118144
145+ ## DashboardItems
146+
147+ How to add to the global variable in the dashboard, so that your widget can have access to them.
148+ globalData is set up as a key value pair.
149+
150+ ```
151+ <template>
152+ <SparcDashboard :dBItems="dashboardItems" :hideHeader="true" :options="dashboardOptions"/>
153+ </template>
154+ <script>
155+ const dashboardOptions = {
156+ globalData: {
157+ FileCount: 10,
158+ Status: "Published",
159+ CollaboratorCounts: 8,
160+ ListOfCollabs: [{name:"jen", id:5},{name:"Bruce",id:23}],
161+ }
162+ };
163+ </script>
164+ ```
165+ It is recomended, but not necissary, that you ensure you are passing reactive data or that the dashboard options are reactive
166+ ex
167+ ```
168+ const dashboardOptions = computed(() => ({
169+ globalData: {
170+ FileCount: filesCount.value,
171+ Status: publicationStatus.value,
172+ CollaboratorCounts: collaboratorCounts.value,
173+ viewerComponents: [TimeseriesComponent, SlideViewer],
174+ package:pkg
175+ }
176+ }));
177+ ```
178+
179+ ### Props
180+
181+ You can pass key/value pairs to your inital component list.
182+
183+ * when your component is added by a user, you will need to have a way for them to set what would otherwise be properties. This would intail surfacing the properties through the dashboardOptions > globalData
184+
185+ ```
186+ { id: "TextWidget-1", x: 0, y: 0, h: 1, w:4, componentName:"Text",component:"TextWidget",hideHeader:true, Props:{displayText:"Dataset Overview",hideHeader:true} }
187+ ```
188+
189+ is the same as sending a component a property in vue 3. The above code is the functional equivalent as the below code.
190+
191+ ```
192+ <script>
193+ const displayText = "Dataset Overview";
194+ const noHeader = true;
195+ </script>
196+ <template>
197+ <custom-component :displayText="displayText" :hideHeader="noHeader"></custom-component>
198+ </template
199+ ```
200+ ## Dashboard Options
201+
119202# DOCUMENTATION
120203- adding custom component to dashboard
121204
@@ -127,7 +210,8 @@ Custom component that can be added within the dashboard and has the capabilities
127210Clone the github repo and navigate to src/components/SampleComponent.vue
128211
129212Expose Your Custom Component to the Dashboard:
130- - Add component tag name to the main.ts document
213+ - Add component tag name to the main.ts document in your project
214+
131215 src/main.ts or src/main.js
132216```
133217const componentMap = [
@@ -175,18 +259,21 @@ This is your default template. Customize however you like with html and vue 3 ma
175259### Set Name
176260
177261This line in your setup script allows you to set the header to your widget name. It does not have to match to file name.
262+
263+ DEPRICATED FOR NOW
178264```
179265 const widgetName = ref('New Custom Component!');//replace with component name you want shown
180266 ```
267+
181268DO NOT DELETE SLOT
182269
183- This is where your default header is set. Do not delete or change the variable name
270+ This is where your default header and icons are set. Do not delete or change the variable name
184271```
185- <slot :widgetName="widgetName"></slot>
272+ <slot :widgetName="widgetName" :childIcons="childIcons" ></slot>
186273```
187274
188275
189- you can also set the name in your dBItems object.
276+ you can also set the name in your dBItems object. The user can set the name by clicking on the header and typeing what they want.
190277
191278```
192279 { id: "FlatmapViewer-1", x: 0, y: 0, h: 8, w:2, componentName:"Flatmap Viewer",component:"FlatmapViewer" },
@@ -223,20 +310,36 @@ const dBItems = [
223310
224311### CUSTOM EMITS/EVENTS:
225312
226- add your emits to your global pinia instance
313+ add your emits to your global pinia instance or create your own store
227314```
228315 import {useGlobalVarsStore} from "../stores/globalVars"
229316 const GlobalVars = useGlobalVarsStore();
230317```
231318
232319*** Building a custom emit/event***
233- tdb
234- ```
235320
321+ Use the store as you would any vue project the update or watch global vars
322+
323+ ex: This shows a header that is computed based on if its property key matches the optionsData in the globalVars
324+ ```
325+ <template>
326+ <h2>{{ textContentGV }}</h2>
327+ </template>
328+ <script>
329+ import {useGlobalVarsStore} from "../stores/globalVars.ts"
330+ const globalVars = useGlobalVarsStore();
331+
332+ const textContentGV = computed(() => {
333+ const optionMatch = globalVars.optionsData.find(item => item.name === props.bindedKey);
334+ return optionMatch?.value ?? "—";
335+ })
336+ </script>
236337```
237338
238339### GLOBAL VARS AND FUNCTIONS
239340
341+ Examples are based off of the globalVar selectedImage.
342+
240343*** setSelectedImage***
241344- call function when widget has selected an image
242345Example for use:
0 commit comments