Allow metrics to calculate the sum or average. Closes #517.
This commit is contained in:
committed by
James Brooks
parent
f11d238258
commit
8e372c55b1
@@ -31,6 +31,13 @@
|
||||
<textarea name="metric[description]" class="form-control" rows="5" required>{{ Input::old('metric.description') }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{ trans('forms.metrics.calc_type') }}</label>
|
||||
<select name="metric[calc_type]" class="form-control" required>
|
||||
<option value="0" selected>{{ trans('forms.metrics.type_sum') }}</option>
|
||||
<option value="1">{{ trans('forms.metrics.type_avg') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="metric-default_value">{{ trans('forms.metrics.default-value') }}</label>
|
||||
<input type="number" class="form-control" name="metric[default_value]" id="metric-default_value" value="{{ Input::old('metric.default_value') }}">
|
||||
|
||||
@@ -31,6 +31,13 @@
|
||||
<textarea name="metric[description]" class="form-control" rows="5" required>{{ $metric->description }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>{{ trans('forms.metrics.calc_type') }}</label>
|
||||
<select name="metric[calc_type]" class="form-control" required>
|
||||
<option value="0" {{ $metric->calc_type === 0 ? "selected" : null }}>{{ trans('forms.metrics.type_sum') }}</option>
|
||||
<option value="1" {{ $metric->calc_type === 1 ? "selected" : null }}>{{ trans('forms.metrics.type_avg') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="metric-default_value">{{ trans('forms.metrics.default-value') }}</label>
|
||||
<input type="number" class="form-control" name="metric[default_value]" id="metric-default_value" value="{{ $metric->default_value }}">
|
||||
|
||||
@@ -31,37 +31,36 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var hourList = [];
|
||||
var date = new Date();
|
||||
(function () {
|
||||
var hourList = [], date = new Date();
|
||||
|
||||
for (var i = 10; i >= 1; i--) {
|
||||
hourList.push(moment(date).subtract(i, 'hours').seconds(0).format('HH:ss'));
|
||||
}
|
||||
for (var i = 10; i >= 1; i--) {
|
||||
hourList.push(moment(date).subtract(i, 'hours').seconds(0).format('HH:ss'));
|
||||
}
|
||||
|
||||
hourList.push(moment(date).seconds(0).format('HH:ss'));
|
||||
hourList.push(moment(date).seconds(0).format('HH:ss'));
|
||||
|
||||
var data = {
|
||||
showTooltips: false,
|
||||
labels: hourList,
|
||||
datasets: [{
|
||||
fillColor: "rgba(220,220,220,0.2)",
|
||||
strokeColor: "rgba(220,220,220,1)",
|
||||
pointColor: "rgba(220,220,220,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(220,220,220,1)",
|
||||
data: [{{ implode(',', $points) }}]
|
||||
}]
|
||||
};
|
||||
var data = {
|
||||
showTooltips: false,
|
||||
labels: hourList,
|
||||
datasets: [{
|
||||
fillColor: "rgba(220,220,220,0.2)",
|
||||
strokeColor: "rgba(220,220,220,1)",
|
||||
pointColor: "rgba(220,220,220,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(220,220,220,1)",
|
||||
data: [{{ implode(',', $points) }}]
|
||||
}]
|
||||
};
|
||||
|
||||
window.onload = function() {
|
||||
var ctx = document.getElementById("metric-{{ $metric->id }}").getContext("2d");
|
||||
window.myLine = new Chart(ctx).Line(data, {
|
||||
new Chart(ctx).Line(data, {
|
||||
scaleShowVerticalLines: true,
|
||||
pointDot: false,
|
||||
responsive: true
|
||||
});
|
||||
};
|
||||
}());
|
||||
</script>
|
||||
</li>
|
||||
@endforeach
|
||||
|
||||
Reference in New Issue
Block a user