Skip to content

Commit f167612

Browse files
committed
update data load to use events.
1 parent 0170455 commit f167612

File tree

4 files changed

+31
-22
lines changed

4 files changed

+31
-22
lines changed

src/js/panel._utils.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ window.Widgets.Panel.Utils = {};
4949

5050
ns.options = {
5151
tree_data: {
52-
sighting: 'data/sightingIndex.json',
53-
task: 'data/taskIndex.json',
54-
impact: 'data/impactIndex.json',
55-
event: 'data/eventIndex.json',
56-
me: 'data/meIndex.json',
57-
company: 'data/companyIndex.json',
52+
sighting: 'sighting',
53+
task: 'task',
54+
impact: 'impact',
55+
event: 'event',
56+
me: 'user',
57+
company: 'company',
5858
},
5959
tree_data_default: 'sighting',
6060
duration: 350,

src/js/panel.filter.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ window.Widgets.Panel.Filter = {};
88

99
ns.options = {};
1010

11-
ns.filterChange = function(url) {
11+
ns.filterChange = function(type) {
1212
console.group(`Widgets.Panel.Filter.filterChange on ${window.location}`);
1313
console.log('filter change');
1414
//call update function for tree panel
15-
window.Widgets.Panel.Tree.updateTree(url);
15+
window.Widgets.Panel.Tree.updateTree(type);
1616
console.groupEnd();
1717
}
1818

@@ -28,11 +28,11 @@ window.Widgets.Panel.Filter = {};
2828

2929
$filter_options.on('change', function (d) {
3030
console.group(`Widgets.Panel.Filter filter.change on ${window.location}`);
31-
var filterValue = this.value;
32-
var url = window.Widgets.Panel.Utils.options.tree_data[filterValue]
33-
console.log('source changed to ' + url);
31+
let filterValue = this.value;
32+
let type = window.Widgets.Panel.Utils.options.tree_data[filterValue]
33+
console.log('source changed to ' + type);
3434

35-
window.Widgets.Panel.Filter.filterChange(url);
35+
window.Widgets.Panel.Filter.filterChange(type);
3636

3737
console.groupEnd();
3838
});
@@ -85,14 +85,16 @@ window.Widgets.Panel.Filter = {};
8585
id: id,
8686
type: 'button'
8787
}
88-
const eventName = "embed-viz-event-request-data1";
89-
const config = "data/scratch.json";
88+
const eventName = "embed-viz-event-payload-data-unattached-force-graph";
89+
const config = "scratch";
9090
const action = "DATA_REQUEST";
9191
const data = eventNs.compileEventData(payload, eventName, action, componentId, config);
9292

9393
eventNs.raiseEvent(eventName, data);
9494
});
9595

96+
ns.filterChange(ns.options.tree_data_default);
97+
9698
console.groupEnd();
9799
}
98100

src/js/panel.tree.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,23 @@ window.Widgets.Panel.Tree = {}
154154
console.groupEnd();
155155
}
156156

157-
ns.updateTree = function(url) {
157+
ns.updateTree = function(type) {
158158
console.log('window.Widgets.Panel.Tree updated');
159+
160+
const eventName = `embed-viz-event-payload-data-tree-${type}`;
161+
const topics = [`embed-viz-event-payload-data-tree-${type}`];
162+
159163
//call update function for tree panel
160-
console.log('loading data from ' + url);
164+
console.log(`loading data from type=${type} eventName=${eventName} topics=${topics}`);
161165

162166
//hide tooltip if it is visible
163167
panelUtilsNs.hideTooltip();
164168

165-
ns.loadData(url);
169+
//raise event to load data
170+
window.Widgets.Widget.raiseEventDataRequest(eventName, topics, "load_data", type, (data) => {
171+
console.log(`raiseEventDataRequest callback loadData ${type}=${type}`, data);
172+
ns.loadData(data);
173+
});
166174
}
167175

168176

src/js/widget.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ window.Widgets.Widget = {};
1010
ns.selectorTooltipContainer = 'body';
1111

1212

13-
ns.scratch = 'data/scratch.json';
13+
ns.scratch = '/viz-data/unattached-force-graph';
1414

1515
ns.raiseEventDataRequest = function(eventName, topics = [], action, id, callbackFn) {
1616
console.group(`raiseEventDataRequest on ${window.location}`);
@@ -62,13 +62,12 @@ window.Widgets.Widget = {};
6262

6363
// request tree data
6464
console.log("request tree data");
65-
ns.raiseEventDataRequest("embed-viz-event-request-datatree", ["embed-viz-event-payload-data-tree"], "load_data", "sighting", (data) => {
66-
panelTreeNs.loadData(data);
67-
});
65+
6866

6967
console.log("request filter data");
7068
//request panel data
71-
ns.raiseEventDataRequest("embed-viz-event-request-data1", ["embed-viz-event-payload-data1"], "load_data", "scratch", (data) => {
69+
ns.raiseEventDataRequest("embed-viz-event-payload-data-unattached-force-graph", ["embed-viz-event-payload-data-unattached-force-graph"], "load_data", "scratch", (data) => {
70+
console.log("raiseEventDataRequest callback loadData scratch", data);
7271
ns.loadData(data);
7372
});
7473
console.log("requestData done");

0 commit comments

Comments
 (0)