forked from AravinthPanch/rssi-based-indoor-localization
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.js
More file actions
201 lines (157 loc) · 5.38 KB
/
controller.js
File metadata and controls
201 lines (157 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/**
* Controller is the hub of APP. APP is implemented with the Event-Driven-Architecture.
* Controller is responsible for capturing events and sets the respective callbacks for every events which are triggered
* throughout APP.
*
* @class controller
*/
app.controller = {
/**
It initialises the controller to process the captured events. These events are triggered in various parts of APP
and captured by the controller
@method initialize
**/
initialize: function () {
/**
Triggered when a server is selected by user
@event server:selected
@param {String} serverId The name of the selected Server
**/
app.eventBus.subscribe("server:selected", function (serverId) {
app.controller.serverSelected(serverId);
});
/**
Triggered when database is retrieved from the Remote API
@event databaseList:retrieved
**/
app.eventBus.subscribe("databaseList:retrieved", function () {
app.view.updateDatabaseListUi(app.databaseList);
});
/**
Triggered when a Database is selected by user
@event database:selected
@param {String} databaseUri The URI of the selected Database
**/
app.eventBus.subscribe("database:selected", function (databaseUri) {
app.collection.getCollectionList(databaseUri);
});
/**
Triggered when list of Collections is retrieved from backend
@event collectionList:retrieved
**/
app.eventBus.subscribe("collectionList:retrieved", function () {
app.view.updateCollectionListUi(app.collectionList);
});
/**
Triggered when a Collection is selected by user
@event collection:selected
@param {String} collectionUri The URI of the selected Collection
**/
app.eventBus.subscribe("collection:selected", function (collectionUri) {
app.view.showLoader();
app.collection.getSelectedCollectionData(collectionUri);
});
/**
Triggered when internal list of the selected Collection is retrieved from backend
@event selectedCollectionData:retrieved
**/
app.eventBus.subscribe("selectedCollectionData:retrieved", function () {
app.collection.getRawData(app.selectedCollectionData);
});
/**
Triggered when complete RawData of the selected Collection is retrieved from backend
@event rawData:retrieved
**/
app.eventBus.subscribe("rawData:retrieved", function () {
app.view.hideLoader();
app.collection.getMetadata(app.metadataId);
//app.utils.dumpPlotData(app.rawData);
});
app.eventBus.subscribe("plot:data:retrieved", function () {
app.view.updatePlotData();
app.view.updatePlotDataRepeat();
});
//getSmallRepeatability();
//getWifiStatRepeatability();
//getSigGenRepeatability();
/**
Triggered when Metadata of the selected collection is retrieved from backend
@event metadata:retrieved
**/
app.eventBus.subscribe("metadata:retrieved", function () {
app.view.updateMetadataUi(app.metadata);
});
/**
Triggered when a Floor Plan is selected by user
@event floorPlan:selected
**/
app.eventBus.subscribe("floorPlan:selected", function () {
app.collection.filterRawDataByFloor(app.rawData);
app.floor.mapCoordinates(app.filteredRawDataByFloor);
});
/**
Triggered when coordinates are mapped to the selected Floor Plan
@event coordinates:mapped
**/
app.eventBus.subscribe("coordinates:mapped", function () {
app.view.updateNodeUi(app.filteredRawDataByFloor);
app.view.updateFloorInfo(app.selectedNodeData);
app.view.showFloorPanel();
});
/**
Triggered when a Node in the FloorPlan is selected by user
@event node:selected
@param {String} selectedNodeId The Id of the selected Node in the FloorPlan
**/
app.eventBus.subscribe("node:selected", function (selectedNodeId) {
app.collection.getSelectedNodeData(selectedNodeId);
app.collection.groupNodeDataByChannel(app.selectedNodeData);
app.view.updateFloorInfo(app.selectedNodeData);
app.view.updateChannelList(app.channelList);
});
/**
Triggered when a Channel is selected by user
@event channel:selected
@param {Integer} selectedChannel The number of the selected channel
**/
app.eventBus.subscribe("channel:selected", function (selectedChannel) {
app.collection.getSelectedChannelData(selectedChannel);
app.collection.groupSelectedChannelDataBySsid(app.selectedChannelData);
app.view.updateAccessPointUi(app.groupedSsidData);
});
/**
Triggered when an AccessPoint is selected by user
@event accessPoint:selected
@param {String} selectedSsidData The SSID_BSSID of the selected AccessPoint
**/
app.eventBus.subscribe("accessPoint:selected", function (selectedSsidData) {
app.collection.processGraphData(selectedSsidData);
app.view.showGraphPanel();
app.view.updateGraphInfoUi(app.selectedNodeData.receiver_location);
app.graph.draw(app.graphData);
});
},
/**
It is a callback for an event when a server is selected by user
@method serverSelected
@param {String} serverId The name of the selected Server
**/
serverSelected: function (data) {
app.view.clearDatabaseList();
app.view.clearCollectionList();
app.view.resetFloorPlanList();
switch (data) {
case "server1" :
app.collection.getDatabaseList(app.dataBaseUriLocal);
break;
case "server2" :
app.collection.getDatabaseList(app.dataBaseUriRemote);
break;
case "server3" :
app.rawData = staticData;
app.selectedFloorPlan = 'twist2Floor';
app.floor.mapCoordinates(app.rawData);
break;
}
}
};