Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 4113be6

Browse files
committed
Adding the model and upgrade script for key metrics.
Also some very preliminary UI.
1 parent 7efd2f7 commit 4113be6

File tree

6 files changed

+71
-4
lines changed

6 files changed

+71
-4
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
/*=========================================================================
3+
Midas Server
4+
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France.
5+
All rights reserved.
6+
For more information visit http://www.kitware.com/.
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0.txt
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
=========================================================================*/
20+
21+
/** Upgrade the tracker module to version 1.2.1. */
22+
class Tracker_Upgrade_1_2_1 extends MIDASUpgrade
23+
{
24+
/** Upgrade a MySQL database. */
25+
public function mysql()
26+
{
27+
$this->db->query(
28+
'ALTER TABLE `tracker_trend` ADD COLUMN `is_key_metric` boolean NOT NULL DEFAULT FALSE');
29+
}
30+
31+
/** Upgrade a PostgreSQL database. */
32+
public function pgsql()
33+
{
34+
$this->db->query(
35+
'ALTER TABLE tracker_trend ADD COLUMN is_key_metric boolean NOT NULL DEFAULT FALSE');
36+
}
37+
}

modules/tracker/models/base/TrendModelBase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function __construct()
3737
'config_item_id' => array('type' => MIDAS_DATA),
3838
'test_dataset_id' => array('type' => MIDAS_DATA),
3939
'truth_dataset_id' => array('type' => MIDAS_DATA),
40+
'is_key_metric' => array('type' => MIDAS_DATA),
4041
'producer' => array(
4142
'type' => MIDAS_MANY_TO_ONE,
4243
'model' => 'Producer',

modules/tracker/public/css/producer/producer.view.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/tracker/public/js/producer/producer.view.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,23 @@ $(document).ready(function () {
5959
else {
6060
$('a.visualizeSelected').unbind('click').hide();
6161
}
62+
63+
if (checked.length == 1) {
64+
var isKey = $(checked[0]).attr('iskey') === '1';
65+
var verb = isKey ? 'Unset' : 'Set';
66+
$('span.keyMetricToggleVerb').html(verb);
67+
$('a.toggleKeyMetric').show().unbind('click').click(function () {
68+
69+
});
70+
} else {
71+
$('a.toggleKeyMetric').unbind('click').hide();
72+
}
73+
});
74+
75+
/**
76+
* Set tooltip for key metric icon
77+
*/
78+
$('.keyMetric').qtip({
79+
'content': 'This is a key metric'
6280
});
6381
});

modules/tracker/public/scss/producer/producer.view.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ a.trendLink {
5757
input.selectTrend {
5858
display: inline;
5959
}
60+
61+
.keyMetric {
62+
float: right;
63+
}

modules/tracker/views/producer/view.phtml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,13 @@ $this->headScript()->appendFile($this->moduleWebroot.'/public/js/producer/produc
7676
/** @var Tracker_TrendDao $trendDao */
7777
foreach ($trendGroup['trends'] as $trendDao) {
7878
echo '<div class="trendContainer">';
79-
echo '<input type="checkbox" class="selectTrend" element="'.$this->escape($trendDao->getKey()).'" />';
79+
echo '<input type="checkbox" class="selectTrend" iskey="'.$trendDao->getIsKeyMetric().'" element="'.$this->escape($trendDao->getKey()).'" />';
8080
echo '<a class="trendLink" href="'.$this->webroot.'/tracker/trend/view?trendId='.$this->escape($trendDao->getKey()).'">';
81-
echo $this->escape($trendDao->getDisplayName()).'</a>';
82-
echo '</div>';
81+
echo $this->escape($trendDao->getDisplayName());
82+
if($trendDao->getIsKeyMetric()) {
83+
echo '<span class="keyMetric"><img src="'.$this->coreWebroot.'/public/images/icons/key.png" alt="Key metric"></span>';
84+
}
85+
echo '<a/></div>';
8386
}
8487
?>
8588
</div>
@@ -116,6 +119,10 @@ $this->headScript()->appendFile($this->moduleWebroot.'/public/js/producer/produc
116119
<a style="display: none;" class="visualizeDualAxis"><img alt="" src="<?php echo $this->moduleWebroot; ?>/public/images/chart_line.png"/>
117120
Dual axis plot</a>
118121
</li>
122+
<li>
123+
<a style="display: none;" class="toggleKeyMetric"><img alt="" src="<?php echo $this->coreWebroot; ?>/public/images/icons/key.png"/>
124+
<span class="keyMetricToggleVerb"></span> metric as key</a>
125+
</li>
119126
</ul>
120127
</div>
121128
</div>

0 commit comments

Comments
 (0)