tsviewer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/babel.config.js +5 -0
- package/dist/demo.html +1 -0
- package/dist/tsviewer.common.js +33247 -0
- package/dist/tsviewer.common.js.map +1 -0
- package/dist/tsviewer.umd.js +33259 -0
- package/dist/tsviewer.umd.js.map +1 -0
- package/dist/tsviewer.umd.min.js +4 -0
- package/dist/tsviewer.umd.min.js.map +1 -0
- package/jsconfig.json +19 -0
- package/package.json +61 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/src/App.vue +41 -0
- package/src/assets/icons/blackfynn-amplitude-zoom.js +11 -0
- package/src/assets/icons/blackfynn-timescale.js +11 -0
- package/src/assets/icons/icon-controller-pause.js +11 -0
- package/src/assets/icons/icon-controller-play.js +11 -0
- package/src/assets/icons/icon-next-page.js +11 -0
- package/src/assets/icons/icon-previous-page.js +11 -0
- package/src/assets/icons/icon-stopwatch.js +11 -0
- package/src/assets/icons/index.js +7 -0
- package/src/components/TSPlotCanvas.vue +1868 -0
- package/src/components/TSScrubber.vue +420 -0
- package/src/components/TSViewer.vue +595 -0
- package/src/components/TSViewerCanvas.vue +793 -0
- package/src/components/TSViewerToolbar.vue +356 -0
- package/src/components/index.js +13 -0
- package/src/main.js +23 -0
- package/src/mixins/request/index.js +100 -0
- package/src/mixins/ts-annotation/index.js +202 -0
- package/src/mixins/viewer-active-tool/index.js +36 -0
- package/src/store/index.js +184 -0
- package/src/utils/constants.js +15 -0
- package/vue.config.js +12 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
computed: {
|
|
3
|
+
viewerActiveTool: function() {
|
|
4
|
+
return this.$store.getters.viewerActiveTool
|
|
5
|
+
},
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
watch: {
|
|
9
|
+
viewerActiveTool: {
|
|
10
|
+
handler: function (val) {
|
|
11
|
+
if (val) {
|
|
12
|
+
this.setActiveTool(val)
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
immediate: true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
methods: {
|
|
20
|
+
/**
|
|
21
|
+
* Invoke method for tool if it exists
|
|
22
|
+
* @param {String} activeTool
|
|
23
|
+
*/
|
|
24
|
+
setActiveTool: function(activeTool) {
|
|
25
|
+
if (activeTool) {
|
|
26
|
+
// Set first character of tool to be capitalized to the method is camel case
|
|
27
|
+
const methodName = 'set' + activeTool.charAt(0).toUpperCase() + activeTool.slice(1)
|
|
28
|
+
|
|
29
|
+
// Check the method
|
|
30
|
+
if(typeof this[methodName] === 'function') {
|
|
31
|
+
this[methodName]()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { propOr, propEq, findIndex, mergeWith } from 'ramda'
|
|
2
|
+
import { viewerSidePanelTypes, viewerToolTypes } from '@/utils/constants'
|
|
3
|
+
|
|
4
|
+
const store = {
|
|
5
|
+
state: {
|
|
6
|
+
userToken: '',
|
|
7
|
+
selectedPackage: {},
|
|
8
|
+
// active viewer contains the package info response
|
|
9
|
+
activeViewer: {},
|
|
10
|
+
viewerSidePanelOpen: false,
|
|
11
|
+
viewerSlideInfo: {
|
|
12
|
+
curRotation: 0,
|
|
13
|
+
curZoom: 0,
|
|
14
|
+
isMeasuring: false,
|
|
15
|
+
measureLength: 0,
|
|
16
|
+
zoomPerClick: 0,
|
|
17
|
+
minZoom: 0,
|
|
18
|
+
maxZoom: 0
|
|
19
|
+
},
|
|
20
|
+
viewerChannels: [],
|
|
21
|
+
viewerAnnotations: [],
|
|
22
|
+
activeAnnotationLayer: {},
|
|
23
|
+
activeAnnotation: {},
|
|
24
|
+
viewerErrors: {},
|
|
25
|
+
|
|
26
|
+
//TODO make strings enum constants
|
|
27
|
+
viewerSidePanelView: viewerSidePanelTypes.INFO_PANEL,
|
|
28
|
+
viewerActiveTool: viewerToolTypes.PAN,
|
|
29
|
+
viewerMontageScheme: 'NOT_MONTAGED',
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
getters: {
|
|
33
|
+
viewerSelectedChannels: state => {
|
|
34
|
+
return state.viewerChannels.filter(channel => {
|
|
35
|
+
return channel.selected
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
viewerChannels: state => state.viewerChannels,
|
|
39
|
+
viewerMontageScheme: state => state.viewerMontageScheme,
|
|
40
|
+
activeViewer: state => state.activeViewer,
|
|
41
|
+
viewerActiveTool: state => state.viewerActiveTool,
|
|
42
|
+
activeAnnotation: state => state.activeAnnotation,
|
|
43
|
+
viewerSidePanelOpen: state => state.viewerSidePanelOpen,
|
|
44
|
+
viewerAnnotations: state => state.viewerAnnotations,
|
|
45
|
+
userToken: state => state.userToken
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
mutations: {
|
|
49
|
+
//TODO figure out why we clear state twice?
|
|
50
|
+
CLEAR_STATE(state) {
|
|
51
|
+
//reset all state to initial state
|
|
52
|
+
const _initialState = initialState()
|
|
53
|
+
// need to iteratively set keys to preserve reactivity
|
|
54
|
+
Object.keys(_initialState).forEach(key => state[key] = _initialState[key])
|
|
55
|
+
},
|
|
56
|
+
OPEN_VIEWER(state, viewer) {
|
|
57
|
+
state.activeViewer = viewer
|
|
58
|
+
},
|
|
59
|
+
SET_SIDE_PANEL(state, sidePanel) {
|
|
60
|
+
state.viewerSidePanelOpen = sidePanel.open
|
|
61
|
+
state.viewerSidePanelView = sidePanel.view
|
|
62
|
+
},
|
|
63
|
+
SET_ACTIVE_TOOL(state, tool) {
|
|
64
|
+
state.viewerActiveTool = tool
|
|
65
|
+
},
|
|
66
|
+
UPDATE_VIEWER_SLIDE_INFO (state, newSlideInfo) {
|
|
67
|
+
state.viewerSlideInfo = newSlideInfo
|
|
68
|
+
},
|
|
69
|
+
SET_CHANNELS (state, channels) {
|
|
70
|
+
state.viewerChannels = channels
|
|
71
|
+
},
|
|
72
|
+
UPDATE_VIEW_CHANNEL (state, data) {
|
|
73
|
+
if (data.channelId) {
|
|
74
|
+
const channelIndex = findIndex(propEq('id', data.channelId), state.viewerChannels)
|
|
75
|
+
for (let d in data.data) {
|
|
76
|
+
state.viewerChannels[channelIndex][d] = data.data[d]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
SET_ACTIVE_ANNOTATION_LAYER (state, data) {
|
|
81
|
+
state.activeAnnotationLayer = data
|
|
82
|
+
state.viewerAnnotations.forEach(index => index.selected = false)
|
|
83
|
+
const layerIndex = findIndex(propEq('id', data), state.viewerAnnotations)
|
|
84
|
+
state.viewerAnnotations[layerIndex].selected = true
|
|
85
|
+
|
|
86
|
+
},
|
|
87
|
+
SET_ACTIVE_ANNOTATION (state, data) {
|
|
88
|
+
state.viewerAnnotations.forEach( index =>
|
|
89
|
+
index.annotations.forEach(ann =>
|
|
90
|
+
ann.selected = false
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
if (data.id) {
|
|
94
|
+
const layerIndex = findIndex(propEq('id', data.layer_id), state.viewerAnnotations)
|
|
95
|
+
const annotationIndex = findIndex(propEq('id', data.id), state.viewerAnnotations[layerIndex].annotations)
|
|
96
|
+
state.viewerAnnotations[layerIndex].annotations[annotationIndex].selected = true
|
|
97
|
+
}
|
|
98
|
+
state.activeAnnotation = data
|
|
99
|
+
},
|
|
100
|
+
SET_ANNOTATIONS (state, data) {
|
|
101
|
+
state.viewerAnnotations = data
|
|
102
|
+
},
|
|
103
|
+
SET_DISCUSSIONS (state, { discussions, comments }) {
|
|
104
|
+
state.viewerDiscussions = {
|
|
105
|
+
discussions,
|
|
106
|
+
comments
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
SET_VIEWER_ERRORS (state, data) {
|
|
110
|
+
state.viewerErrors = data
|
|
111
|
+
},
|
|
112
|
+
SET_VIEWER_MONTAGE_SCHEME (state, data) {
|
|
113
|
+
state.viewerMontageScheme = data
|
|
114
|
+
},
|
|
115
|
+
UPDATE_USER_TOKEN(state, data) {
|
|
116
|
+
state.userToken = data
|
|
117
|
+
},
|
|
118
|
+
// Leveraged to get individual package state to package details route
|
|
119
|
+
SELECT_PACKAGE(state, data) {
|
|
120
|
+
state.selectedPackage = data
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
actions: {
|
|
125
|
+
openViewer: ({ commit }, evt) =>
|
|
126
|
+
commit('OPEN_VIEWER', evt),
|
|
127
|
+
setSidePanel: ({ commit }, evt) =>
|
|
128
|
+
commit('SET_SIDE_PANEL', evt),
|
|
129
|
+
setActiveTool: ({ commit }, evt) =>
|
|
130
|
+
commit('SET_ACTIVE_TOOL', evt),
|
|
131
|
+
setChannels: ({ commit }, evt) => {
|
|
132
|
+
commit('SET_CHANNELS', evt)},
|
|
133
|
+
updateViewChannel: ({commit}, data) => {
|
|
134
|
+
commit('UPDATE_VIEW_CHANNEL', data)},
|
|
135
|
+
setActiveAnnotationLayer: ({ commit }, evt) =>
|
|
136
|
+
commit('SET_ACTIVE_ANNOTATION_LAYER', evt),
|
|
137
|
+
setAnnotations: ({ commit }, annotations) =>
|
|
138
|
+
commit('SET_ANNOTATIONS', annotations),
|
|
139
|
+
setActiveAnnotation: ({ commit }, data) =>
|
|
140
|
+
commit('SET_ACTIVE_ANNOTATION', data),
|
|
141
|
+
updateViewerSlideInfo: ({ commit }, evt) => {
|
|
142
|
+
const newSlideInfo = mergeWith(this.state.viewerSlideInfo, evt)
|
|
143
|
+
commit('UPDATE_VIEWER_SLIDE_INFO', newSlideInfo)
|
|
144
|
+
},
|
|
145
|
+
setDiscussions: ({commit}, discussionData) => {
|
|
146
|
+
const discussions = propOr([], 'discussions', discussionData)
|
|
147
|
+
const comments = propOr({}, 'comments', discussionData)
|
|
148
|
+
commit('SET_DISCUSSIONS', { discussions, comments })
|
|
149
|
+
},
|
|
150
|
+
setViewerErrors: ({ commit }, evt) =>
|
|
151
|
+
commit('SET_VIEWER_ERRORS', evt),
|
|
152
|
+
setViewerMontageScheme: ({commit}, evt) =>
|
|
153
|
+
commit('SET_VIEWER_MONTAGE_SCHEME', evt),
|
|
154
|
+
setSelectedPackage: ({commit}, evt) => commit('SELECT_PACKAGE', evt),
|
|
155
|
+
updateUserToken: ({commit}, evt) =>
|
|
156
|
+
commit('UPDATE_USER_TOKEN', evt)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const initialState = () => ({
|
|
161
|
+
activeViewer: {},
|
|
162
|
+
viewerSidePanelOpen: false,
|
|
163
|
+
viewerSlideInfo: {
|
|
164
|
+
curRotation: 0,
|
|
165
|
+
curZoom: 0,
|
|
166
|
+
isMeasuring: false,
|
|
167
|
+
measureLength: 0,
|
|
168
|
+
zoomPerClick: 0,
|
|
169
|
+
minZoom: 0,
|
|
170
|
+
maxZoom: 0
|
|
171
|
+
},
|
|
172
|
+
viewerChannels: [],
|
|
173
|
+
viewerAnnotations: [],
|
|
174
|
+
activeAnnotationLayer: {},
|
|
175
|
+
activeAnnotation: {},
|
|
176
|
+
viewerErrors: {},
|
|
177
|
+
|
|
178
|
+
//TODO make strings enum constants
|
|
179
|
+
viewerSidePanelView: viewerSidePanelTypes.INFO_PANEL,
|
|
180
|
+
viewerActiveTool: viewerToolTypes.PAN,
|
|
181
|
+
viewerMontageScheme: 'NOT_MONTAGED'
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
export default store
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const viewerSidePanelTypes = Object.freeze({
|
|
2
|
+
INFO_PANEL: 'infoPanel',
|
|
3
|
+
DISCUSSION: 'discussion',
|
|
4
|
+
FILE_BROWSER: 'fileBrowser',
|
|
5
|
+
ANNOTATIONS: 'annotations',
|
|
6
|
+
CHANNELS: 'channels'
|
|
7
|
+
})
|
|
8
|
+
export const viewerToolTypes = Object.freeze({
|
|
9
|
+
PAN: 'pan',
|
|
10
|
+
ANNOTATION_SHAPE: 'annotationShape',
|
|
11
|
+
ANNOTATION_DRAW: 'annotationDraw',
|
|
12
|
+
MEASURE: 'measure',
|
|
13
|
+
ANNOTATE: 'annotate',
|
|
14
|
+
POINTER: 'pointer'
|
|
15
|
+
})
|