Allow metrics to calculate the sum or average. Closes #517.
This commit is contained in:
committed by
James Brooks
parent
f11d238258
commit
8e372c55b1
@@ -19,6 +19,7 @@ class CreateMetricsTable extends Migration
|
||||
$table->string('suffix');
|
||||
$table->text('description');
|
||||
$table->decimal('default_value', 10, 3);
|
||||
$table->tinyInteger('calc_type');
|
||||
$table->boolean('display_chart')->default(1);
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
@@ -58,6 +58,9 @@ return [
|
||||
'description' => 'Description',
|
||||
'description-help' => 'You may also use Markdown.',
|
||||
'display-chart' => 'Display chart on status page?',
|
||||
'calc_type' => 'Calculation of metrics',
|
||||
'type_sum' => 'Sum',
|
||||
'type_avg' => 'Average',
|
||||
|
||||
'points' => [
|
||||
'value' => 'Value',
|
||||
|
||||
@@ -61,6 +61,9 @@ return [
|
||||
'description-help' => 'You may also use Markdown.',
|
||||
'display-chart' => 'Display chart on status page?',
|
||||
'default-value' => 'Default value',
|
||||
'calc_type' => 'Calculation of metrics',
|
||||
'type_sum' => 'Sum',
|
||||
'type_avg' => 'Average',
|
||||
|
||||
'points' => [
|
||||
'value' => 'Value',
|
||||
|
||||
@@ -59,6 +59,9 @@ return [
|
||||
'description' => 'Descripción',
|
||||
'description-help' => 'Puedes usar también Markdown.',
|
||||
'display-chart' => '¿Vizualizar gráfica en la página de estado?',
|
||||
'calc_type' => 'Calculation of metrics',
|
||||
'type_sum' => 'Sum',
|
||||
'type_avg' => 'Average',
|
||||
|
||||
'points' => [
|
||||
'value' => 'Valor',
|
||||
|
||||
@@ -58,6 +58,9 @@ return [
|
||||
'description' => 'Description',
|
||||
'description-help' => 'You may also use Markdown.',
|
||||
'display-chart' => 'Display chart on status page?',
|
||||
'calc_type' => 'Calculation of metrics',
|
||||
'type_sum' => 'Sum',
|
||||
'type_avg' => 'Average',
|
||||
|
||||
'points' => [
|
||||
'value' => 'Value',
|
||||
|
||||
@@ -61,6 +61,9 @@ return [
|
||||
'description-help' => '',
|
||||
'display-chart' => '',
|
||||
'default-value' => '',
|
||||
'calc_type' => 'Calculation of metrics',
|
||||
'type_sum' => 'Sum',
|
||||
'type_avg' => 'Average',
|
||||
|
||||
'points' => [
|
||||
'value' => '',
|
||||
|
||||
@@ -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