Skip to content

Commit

Permalink
Merge branch 'master' of github.com:eleme/banshee into dev
Browse files Browse the repository at this point in the history
* 'master' of github.com:eleme/banshee:
  Add rules select which link to project page
  • Loading branch information
hit9 committed Mar 3, 2016
2 parents b244dfc + 4966c4a commit 2b59893
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 30 deletions.
1 change: 1 addition & 0 deletions static/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"noarg": true,
"quotmark": "single",
"undef": true,
"latedef": false,
"unused": true,
"strict": false,
"predef": [
Expand Down
69 changes: 41 additions & 28 deletions static/src/modules/main/MainListCtrl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*@ngInject*/
module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, Config, Project, DateTimes) {
module.exports = function($scope, $rootScope, $timeout, $stateParams, Metric, Config, Project, DateTimes) {
var chart = require('./chart');
var cubism;
var initOpt;
Expand Down Expand Up @@ -61,7 +61,7 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C

$scope.filter = angular.copy(initOpt);

$scope.toggleCubism = function () {
$scope.toggleCubism = function() {
$scope.filter.status = !$scope.filter.status;
if (!$scope.filter.status) {
buildCubism();
Expand All @@ -70,7 +70,7 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C
}
};

$scope.restart = function () {
$scope.restart = function() {
$scope.filter = angular.copy(initOpt);

if ($scope.initProject) {
Expand All @@ -89,13 +89,13 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C
buildCubism();
};

$scope.searchPattern = function () {
$scope.searchPattern = function() {
$scope.filter.project = '';
$scope.autoComplete.searchText = '';
buildCubism();
};

$scope.searchProject = function (project) {
$scope.searchProject = function(project) {
$scope.filter.project = project.id;
$scope.filter.pattern = '';
$scope.project = project;
Expand All @@ -105,18 +105,28 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C
};


$scope.$on('$destroy', function () {
$scope.$on('$destroy', function() {
$rootScope.currentMain = false;
});

/**
* watch filter.
*/
function watchAll() {
$scope.$watchGroup(['filter.datetime', 'filter.limit', 'filter.sort', 'filter.type'], function() {
buildCubism();
});
}


function loadData() {
Project.getAllProjects().$promise
.then(function (res) {
.then(function(res) {
var projectId = parseInt($stateParams.project);
$scope.projects = res;

if (projectId) {
$scope.projects.forEach(function (el) {
$scope.projects.forEach(function(el) {
if (el.id === projectId) {
$scope.autoComplete.searchText = el.name;
$scope.initProject = el;
Expand All @@ -127,7 +137,7 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C
});

Config.getInterval().$promise
.then(function (res) {
.then(function(res) {
$scope.filter.interval = res.interval;

setIntervalAndRunNow(buildCubism, 10 * 60 * 1000);
Expand All @@ -140,14 +150,6 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C
$scope.notice = res;
});
}
/**
* watch filter.
*/
function watchAll() {
$scope.$watchGroup(['filter.datetime', 'filter.limit', 'filter.sort', 'filter.type'], function () {
buildCubism();
});
}

function buildCubism() {
var params = {
Expand All @@ -173,7 +175,7 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C
});

Metric.getMetricIndexes(params).$promise
.then(function (res) {
.then(function(res) {
plot(res);
});
}
Expand All @@ -196,16 +198,27 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C
if (isInit) {
return;
}
_titles.forEach(function (el, index) {
_titles.forEach(function(el, index) {
var _el = _titles[index];
var currentEl = data[index];
var className = getClassNameByTrend(currentEl.score);
var str = [
'<a href="#/main?pattern=' + currentEl.name + '" class="' + className + '">',
getTextByTrend(currentEl.score),
currentEl.name,
'</a>'
var str;
var _box = ['<div class="box"><span>rules <span class="icon-tr"></span></span><ul>'];

for (var i = 0; i < currentEl.matchedRules.length; i++) {
var rule = currentEl.matchedRules[i];
_box.push('<li><a href="#/admin/project/' + rule.projectID + '">' + rule.pattern + '</a></li>');
}
_box.push('</ul></div>');

str = [
'<a href="#/main?pattern=' + currentEl.name + '" class="' + className + '">',
getTextByTrend(currentEl.score),
currentEl.name,
'</a>',
_box.join('')
].join('');

_el.innerHTML = str;
isInit = true;
});
Expand All @@ -227,10 +240,10 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C
* Scrollbars
*/
function initScrollbars() {
$('.chart-box-top').scroll(function () {
$('.chart-box-top').scroll(function() {
$('.chart-box').scrollLeft($('.chart-box-top').scrollLeft());
});
$('.chart-box').scroll(function () {
$('.chart-box').scroll(function() {
$('.chart-box-top').scrollLeft($('.chart-box').scrollLeft());
});
}
Expand All @@ -242,7 +255,7 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C
* @return {Metric}
*/
function feed(name, data, cb) {
return chart.metric(function (start, stop, step, callback) {
return chart.metric(function(start, stop, step, callback) {
var values = [],
i = 0;
// cast to timestamp from date
Expand All @@ -257,7 +270,7 @@ module.exports = function ($scope, $rootScope, $timeout, $stateParams, Metric, C
};
// request data and call `callback` with values
// data schema: {name: {String}, times: {Array}, vals: {Array}}
Metric.getMetricValues(params, function (data) {
Metric.getMetricValues(params, function(data) {
// the timestamps from statsd DONT have exactly steps `10`
var len = data.length;
while (start < stop && i < len) {
Expand Down
45 changes: 43 additions & 2 deletions static/src/modules/main/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@
}

.horizon {
overflow: hidden;
position: relative;
}

Expand All @@ -169,7 +168,7 @@
.horizon .title,
.horizon .value {
bottom: 0;
line-height: 32px;
line-height: 30px;
margin: 0 6px;
position: absolute;
text-shadow: 0 1px 0 rgba(255,255,255,.5);
Expand All @@ -194,4 +193,46 @@
background: black;
z-index: 1000;
}

.box {
margin-left: 10px;
position: relative;
display: inline-block;
float: right;

>span {
color: #333;
border-bottom: 1px solid #000;
}
.icon-tr:after {
margin-left: 2px;
content: '\25BC';
display: inline-block;
speak: none;
-webkit-transform: scaleY(.6) scaleX(1);
transform: scaleY(.6) scaleX(1);
}
>ul {
padding: 5px 10px;
display: none;
position: absolute;
top: 15px;
left: 0;
z-index: 9999;
background-color: #fff;
box-shadow: 0 1px 3px 0 rgba(0,0,0,.2),0 1px 1px 0 rgba(0,0,0,.14),0 2px 1px -1px rgba(0,0,0,.12);

li {
a {
color: #333;
}
}
}

&:hover {
>ul {
display: block;
}
}
}
}

0 comments on commit 2b59893

Please sign in to comment.