Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 8cca41c0

Přidáno uživatelem Štěpán Červenka před více než 3 roky(ů)

Re #8775 - Agregovat grafy se stejným typem sensoru

  • graph loading decomposition
  • some bugs fixed

Zobrazit rozdíly:

src/app/unit/components/unit.component.ts
64 64
            if (!this.sensorGroups.some(group => group === sensorType)) {
65 65
              this.sensorGroups.push(sensorType);
66 66
              setTimeout(() => {
67
                GraphLoader.getGraph(null, null, null, '#vega_container_' + sensor.sensorId.toString().slice(0, 5));
67
                //GraphLoader.getAnalyticsGraph(null, null, null, '#vega_container_' + sensor.sensorId.toString().slice(0, 5));
68
                GraphLoader.getGraph(null, null, '#vega_container_' + sensor.sensorId.toString().slice(0, 5),null );
68 69
              }, 0);
69 70
            }
70 71
          });
......
109 110
            if (response.status === 200) {
110 111
              return response.body;
111 112
            } else if (response.status === 204) {
112
              GraphLoader.getGraph(null, null, null, '#vega_container_' + selectSens.toString().slice(0, 5));
113
              //GraphLoader.getAnalyticsGraph(null, null, null, '#vega_container_' + selectSens.toString().slice(0, 5));
114
              GraphLoader.getGraph(null, null, '#vega_container_' + selectSens.toString().slice(0, 5),null );
113 115
              this.toastService.showWarningNoData();
114 116
              return response.body;
115 117
            } else {
......
124 126
              if (data[key].data) {
125 127
                const view = '#vega_container_' + key.slice(0, 5);
126 128
                if (this.selectedSensors.some(sens => sens.toString() === key)) {
127
                  GraphLoader.getGraph(key, data[key].data, data[key].interval, view);
129
                  //GraphLoader.getAnalyticsGraph(key, data[key].data, data[key].interval, view);
130
                  //GraphLoader.getGraph(this.selectedSensors, this.filteredAnalyticsData(groupId), view, true);
128 131
                } else {
129
                  GraphLoader.getGraph(null, null, null, view);
132
                  GraphLoader.getGraph(null, null, view, null);
130 133
                }
131 134
              }
132 135
            }
......
155 158
            if (data[key].data) {
156 159
              const view = '#vega_container_' + key.slice(0, 5);
157 160
              if (this.selectedSensors.some(sens => sens.toString() === key)) {
158
                GraphLoader.getGraph(key, data[key].data, data[key].interval, view);
161
               // GraphLoader.getAnalyticsGraph(key, data[key].data, data[key].interval, view);
162
                GraphLoader.getGraph(this.selectedSensors, this.analyticsData, view, true);
159 163
              } else {
160
                GraphLoader.getGraph(null, null, null, view);
164
                //GraphLoader.getAnalyticsGraph(null, null, null, view);
165
                GraphLoader.getGraph(null, null, view, null);
161 166
              }
162 167
            }
163 168
          }
......
175 180
    const groupId = sensorId.toString().slice(0, 5);
176 181
    const sensorGroupElement = '#vega_container_' + groupId;
177 182
    if (!this.selectedSensors.find(sensId => sensId.toString().slice(0, 5) === groupId)) { // if group of sensors is empty show empty graph
178
      GraphLoader.getGraph(null, null, null, sensorGroupElement);
183
      //GraphLoader.getAnalyticsGraph(null, null, null, sensorGroupElement);
184
      GraphLoader.getGraph(null, null, sensorGroupElement, null);
179 185
    } else {
180 186
      if (this.useAnalyticsData) { // use analytics data
181 187
        if (event.checked) { // if checked > add to graph
182 188
          if (this.analyticsData.some(sens => sens.sensorId === sensorId)) { // if already data for selected sensor in memory
183
            GraphLoader.getGraph(sensorId, this.analyticsData.find(sens => sens.sensorId === sensorId).data,
184
              this.analyticsData.find(sens => sens.sensorId === sensorId).interval, sensorGroupElement);
189
            //GraphLoader.getAnalyticsGraph(sensorId, this.analyticsData.find(sens => sens.sensorId === sensorId).data,
190
            // this.analyticsData.find((sens => sens.sensorId === sensorId).interval, sensorGroupElement);
191
            GraphLoader.getGraph(this.selectedSensors, this.analyticsData, sensorGroupElement, true);
192

  
185 193
          } else { // get data from server for added sensor and show graph for selected sensors
186 194
            this.showGraph(false, sensorId);
187 195
          }
188 196
        } else { // remove sensor from graph
189
          GraphLoader.getGraph(sensorId, this.analyticsData.find(sens => sens.sensorId === sensorId).data,
190
            this.analyticsData.find(sens => sens.sensorId === sensorId).interval, sensorGroupElement);
197
          //GraphLoader.getAnalyticsGraph(sensorId, this.analyticsData.find(sens => sens.sensorId === sensorId).data,
198
          // this.analyticsData.find(sens => sens.sensorId === sensorId).interval, sensorGroupElement);
199
          GraphLoader.getGraph(this.selectedSensors, this.analyticsData, sensorGroupElement, true);
200

  
191 201
        }
192 202
      } else { // use observations data
193 203
        if (event.checked) { // if checked > add to graph
194 204
          if (this.observationsData.some(sens => sens.sensorId.toString() === sensorId)) { // if already data for selected sensor in memory
195
            GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(groupId), sensorGroupElement)
205
            GraphLoader.getGraph(this.selectedSensors, this.filteredObservationData(groupId), sensorGroupElement, false);
206
            //GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(groupId), sensorGroupElement)
196 207
          } else { // get data from server for added sensor and show graph for selected sensors
197 208
            this.showGraph(false, sensorId);
198 209
          }
199 210
        } else { // remove sensor from graph
200
          GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(groupId), sensorGroupElement)
211
          //GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(groupId), sensorGroupElement)
212
          GraphLoader.getGraph(this.selectedSensors, this.filteredObservationData(groupId), sensorGroupElement, false);
201 213
        }
202 214
      }
203 215
    }
......
215 227
  /**
216 228
   * Filter analytics data only fro selected sensors.
217 229
   */
218
  filteredAnalyticsData(): any {
219
    return this.analyticsData.filter(sen => this.selectedSensors.includes(sen.sensorId.toString()));
230
  filteredAnalyticsData(sensorGroupId: string): any {
231
    return this.analyticsData.filter(sen => this.selectedSensors.includes(sen.sensorId.toString()) &&
232
      sen.sensorId.toString().slice(0, 5) === sensorGroupId);
220 233
  }
221 234

  
222 235
  private getObservations(range: Date[], changedDate: boolean, changedSensorId: string) {
......
250 263
              const view = '#vega_container_' + selectSens.toString().slice(0, 5);
251 264
              setTimeout(() => {
252 265
                console.log(this.selectedSensors);
253
                GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(selectSens.toString().slice(0, 5)), view);
266
                //GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(selectSens.toString().slice(0, 5)), view);
267
                GraphLoader.getGraph(this.selectedSensors,  this.filteredObservationData(changedSensorId.toString().slice(0, 5)), view, false);
254 268
              }, 10);
255 269
            }
256 270
          })
......
280 294
          const view = '#vega_container_' + changedSensorId.toString().slice(0, 5);
281 295
          if (observations) {
282 296
            console.log(this.observationsData);
283
            GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(changedSensorId.toString().slice(0, 5)), view);
297
            GraphLoader.getGraph(this.selectedSensors,  this.filteredObservationData(changedSensorId.toString().slice(0, 5)), view, false);
298
            //GraphLoader.getMultilineGraph(this.selectedSensors, this.filteredObservationData(changedSensorId.toString().slice(0, 5)), view);
284 299
          } else {
285
            GraphLoader.getMultilineGraph(null, null, null);
300
            //GraphLoader.getMultilineGraph(null, null, null);
301
            GraphLoader.getGraph(this.selectedSensors,  this.filteredObservationData(changedSensorId.toString().slice(0, 5)), view, false);
286 302
          }
287 303
        }, err => this.toastService.showError(err.error.message));
288 304
    }

Také k dispozici: Unified diff