Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 11efc186

Přidáno uživatelem Jakub Hlaváč před více než 3 roky(ů)

Re #8792 - Sensor page - tweak

+ form and to input fields
  • show aggregation input for analytics endpoint

Zobrazit rozdíly:

src/app/unit/components/unit.component.ts
5 5
import {Sensors} from '../../shared/api/endpoints/models/sensors';
6 6
import {AggreationModel} from '../../shared/models/aggreation.model';
7 7
import * as moment from 'moment-timezone';
8
import {GraphLoader} from "../../shared/graph-loading/graphloader";
8
import {GraphLoader} from '../../shared/graph-loading/graphloader';
9 9

  
10 10
declare var require: any
11 11

  
......
20 20
  unitId: number;
21 21
  viewCount = 0;
22 22
  data;
23
  sensorGroups = [];
23 24
  rangeDates: Date[];
24 25
  aggregationFunction: AggreationModel[];
25 26
  selectedAggregationFunction: string;
......
63 64
      from: moment(range[0]).format('yyyy-MM-DD HH:mm:ssZ').slice(0, -3),
64 65
      to: moment(range[1]).format('yyyy-MM-DD HH:mm:ssZ').slice(0, -3), interval: agg}).pipe(
65 66
      tap(data => {
66
        //this.data = Object.entries(data);
67
        //console.log(this.data);
67
        // this.data = Object.entries(data);
68
        // console.log(this.data);
68 69

  
69
        //for (const [key, value] of Object.entries(data)) {
70
        // for (const [key, value] of Object.entries(data)) {
70 71
        //  console.log(key, Object.entries(value));
71
        //}
72
        // }
72 73

  
73 74
        var objectKeys = Object.keys(data);
74 75
        for(const key of objectKeys ) {
75 76
          let element = this.createView();
76 77
          GraphLoader.getGraph(key, data[key]["data"], data[key]["interval"], element);
77

  
78 78
        }
79 79
      })
80 80
    ).subscribe();
81 81
  }
82 82

  
83
 /* getGraph(sensorId, data, interval) {
84
    let spec = this.getGraphType(sensorId);
85
    let elementName = this.createView();
86
    const vega = require('vega');
87
    const config = require('/src/vega/config.json');
88
    const vegaTooltip = require('vega-tooltip');
89

  
90
    spec.data[0].values = data;
91
    spec.signals[0].value = interval;
92

  
93

  
94
    let handler = new vegaTooltip.Handler();
95

  
96

  
97
    const loc = vega.locale({
98
      "decimal": ",",
99
      "thousands": "\u00a0",
100
      "grouping": [3],
101
      "currency": ["", "\u00a0Kč"]
102
    },{
103
      "dateTime": "%A,%e.%B %Y, %X",
104
      "date": "%-d.%-m.%Y",
105
      "time": "%H:%M:%S",
106
      "periods": ["AM", "PM"],
107
      "days": ["neděle", "pondělí", "úterý", "středa", "čvrtek", "pátek", "sobota"],
108
      "shortDays": ["ne.", "po.", "út.", "st.", "čt.", "pá.", "so."],
109
      "months": ["leden", "únor", "březen", "duben", "květen", "červen", "červenec", "srpen", "září", "říjen", "listopad", "prosinec"],
110
      "shortMonths": ["led", "úno", "břez", "dub", "kvě", "čer", "červ", "srp", "zář", "říj", "list", "pros"]
111
    });
112

  
113
    let view = new vega.View(vega.parse(spec, config))
114
      .tooltip(handler.call)
115
      .initialize(elementName)
116
      .hover()
117
      .locale(loc)
118
      .runAsync();
119

  
120

  
121

  
122
  }
123

  
124
  getGraphType(sensorId) {
125
    const lodash = require('lodash/object');
126

  
127
    if(sensorId >= 480000000 && sensorId < 490000000) {
128

  
129
      let rvalue: any = {};
130
      let base = require('/src/vega/base/default.json');
131
      let chart = require('/src/vega/body/barchart.json');
132
      let tooltip = require('/src/vega/tooltip/samm-tooltip.json')
133
      lodash.merge(rvalue, base, chart, tooltip);
134
      return rvalue;
135

  
136
    } else if((sensorId >= 470020000 && sensorId <  470030000) || (sensorId >=470060000 && sensorId < 470090000) ||
137
      (sensorId >= 470130000 && sensorId < 470140000) || (sensorId >=470180000 && sensorId < 470190000)) {
138

  
139
      let rvalue: any = {};
140
      let base = require('/src/vega/base/default.json');
141
      let chart = require('/src/vega/body/windchart.json');
142
      let tooltip = require('/src/vega/tooltip/samm-tooltip.json')
143
      lodash.merge(rvalue, base, chart, tooltip);
144
      return rvalue;
145

  
146
    } else {
147

  
148
      let rvalue: any = {};
149
      let base = require('/src/vega/base/default.json');
150
      let chart = require('/src/vega/body/linechart.json');
151
      let tooltip = require('/src/vega/tooltip/samm-tooltip.json')
152
      lodash.merge(rvalue, base, chart, tooltip);
153
      return rvalue;
154

  
155
    }
156

  
157

  
158
  }*/
159

  
160 83
  createView() {
161 84
    let div = document.createElement("div");
162 85
    let name = "view" + this.viewCount;
......
167 90
    container.appendChild(div);
168 91

  
169 92
    return '#' + name;
170

  
171 93
  }
172 94
}

Také k dispozici: Unified diff