Skip to content

Commit

Permalink
WELD-2104 Probe - introduce dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mkouba committed Feb 10, 2016
1 parent adc9b7e commit e4555f6
Show file tree
Hide file tree
Showing 12 changed files with 460 additions and 56 deletions.
89 changes: 79 additions & 10 deletions probe/core/src/main/client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ Probe.ResetScroll = Ember.Mixin.create({
});

Probe.Router.map(function() {
this.route('beanArchives', {
this.route('dashboard', {
path : '/'
});
this.route('beanArchives', {
path : '/beanArchives'
});
this.route('beanArchive', {
path : '/bda/:id'
});
Expand Down Expand Up @@ -111,13 +114,52 @@ Probe.ApplicationRoute = Ember.Route
var qualifierStart = data.version.indexOf('(');
data.versionShort = qualifierStart != -1 ? data.version
.substring(0, qualifierStart) : data.version;
controller.set('dashboard', data.dashboard);
return data;
}).fail(function(jqXHR, textStatus, errorThrown) {
alert('Unable to get JSON data: ' + textStatus);
});
}
});

Probe.DashboardRoute = Ember.Route.extend({
model : function() {
var appController = this.controllerFor('application');
return $.getJSON(appController.get('restUrlBase') + 'monitoring').done(
function(data) {
var devmodeProperties = new Array();
appController.get('configuration').forEach(
function(property, index, array) {
if (property.name.indexOf('probe') != -1) {
var devproperty = new Object();
devproperty.name = property.name;
devproperty.value = property.value;
devproperty.description = property.description;
devmodeProperties.push(devproperty);
}
});
data.devmodeProperties = devmodeProperties;
var appBdas = 0;
appController.get('bdas').forEach(
function(bda) {
if (!isAdditionalBda(appController
.get('additionalBdaSuffix'), bda.bdaId)) {
appBdas++;
}
});
data.appBdas = appBdas;
return data;
}).fail(function(jqXHR, textStatus, errorThrown) {
alert('Unable to get JSON data: ' + textStatus);
});
},
actions : {
refreshData : function() {
this.refresh();
}
}
});

Probe.BeanArchivesRoute = Ember.Route.extend({
model : function() {
return this.controllerFor('application').get('bdas');
Expand Down Expand Up @@ -597,17 +639,32 @@ Probe.ApplicationController = Ember.ObjectController
'YYYY-MM-DD HH:mm:ss');
}.property(),
initTimeFromNow : function() {
return moment(this.get("content").initTs).fromNow();
return moment(this.get("content").initTs).fromNow(true);
}.property("initTime"),
startWatchingTime : function() {
var self = this;
Ember.run.later(this, function() {
self.notifyPropertyChange("initTime");
self.startWatchingTime();
}, 5 * 1000 * 60);
}
},
dashboard : null
});

Probe.DashboardController = Ember.ObjectController.extend({
needs : [ 'application' ],
lastUpdate : null,
onModelChanged : function() {
this.set('lastUpdate', moment(new Date()).format(
'YYYY-MM-DD HH:mm:ss'));
}.observes('model'),
actions : {
refresh : function() {
this.send('refreshData');
}
}
});

Probe.BeanArchivesController = Ember.ArrayController.extend({
needs : [ 'application' ],
lastModelUpdateTs : null,
Expand All @@ -629,6 +686,7 @@ Probe.BeanArchivesController = Ember.ArrayController.extend({
visibleBdas : Ember.computed.filterBy('bdas', 'visible', true),
selectedBdas : Ember.computed.filterBy('visibleBdas', 'selected', true),
selectedBdasUnwrapped : Ember.computed.mapBy('selectedBdas', 'content'),
queryParams : [ 'hideAddBda' ],
actions : {
settingHasChanged : function(checkTooMuchData) {
var controller = this;
Expand Down Expand Up @@ -872,17 +930,18 @@ Ember.Handlebars.registerBoundHelper('eachLiAbbr', function(types, limit,

/*
* This helper takes two params: text and limit. Furthermore it's possible to
* specify optional hash arguments: title and suppressHtml.
* specify optional hash arguments: title, suppressHtml and skipIcon.
*/
Ember.Handlebars.registerBoundHelper('abbr', function(text, limit, options) {
var addTitle = options.hash.title || true;
var suppresshtmlOutput = options.hash.suppressHtml || false;
var skipIcon = options.hash.skipIcon || false;
var escaped = Handlebars.Utils.escapeExpression(text);
if (escaped.length > limit) {
var ret = '';
ret += escaped.charAt(0) === '@' ? abbreviateAnnotation(escaped,
!suppresshtmlOutput, addTitle) : abbreviateType(escaped,
!suppresshtmlOutput, addTitle);
!suppresshtmlOutput, addTitle, skipIcon) : abbreviateType(escaped,
!suppresshtmlOutput, addTitle, skipIcon);
escaped = ret;
}
return new Handlebars.SafeString(escaped);
Expand All @@ -904,6 +963,10 @@ Ember.Handlebars
* This helper is used to render a tooltip-like icon.
*/
Ember.Handlebars.registerBoundHelper('tip', function(text, options) {
var stripHtml = options.hash.stripHtml || false;
if (stripHtml) {
text = text.replace(/(<([^>]+)>)/ig,"");
}
return new Handlebars.SafeString(
'<i class="fa fa-lg fa-info-circle" title="' + text + '"></i>');
});
Expand Down Expand Up @@ -2068,9 +2131,10 @@ function isAdditionalBda(additionalBdaSuffix, bdaId) {
* @param type
* @param htmlOutput
* @param title
* @param skipIcon
* @returns {String}
*/
function abbreviateType(type, htmlOutput, title) {
function abbreviateType(type, htmlOutput, title, skipIcon) {
var parts = type.split('.');
var ret = '';
var lastIdx = parts.length - 1;
Expand All @@ -2095,7 +2159,9 @@ function abbreviateType(type, htmlOutput, title) {
if (title) {
ret += '</span>';
}
ret += ' <i class="fa fa-compress abbreviated"></i>';
if (!skipIcon) {
ret += ' <i class="fa fa-compress abbreviated"></i>';
}
}
return ret;
}
Expand All @@ -2106,9 +2172,10 @@ function abbreviateType(type, htmlOutput, title) {
* @param annotation
* @param htmlOutput
* @param title
* @param skipIcon
* @returns {String}
*/
function abbreviateAnnotation(annotation, htmlOutput, title) {
function abbreviateAnnotation(annotation, htmlOutput, title, skipIcon) {
var ret = (htmlOutput && title) ? ' <span title="' + annotation + '">@'
: '@';
if (annotation.indexOf('(') !== -1) {
Expand Down Expand Up @@ -2136,7 +2203,9 @@ function abbreviateAnnotation(annotation, htmlOutput, title) {
if (title) {
ret += '</span>';
}
ret += ' <i class="fa fa-compress abbreviated"></i>';
if (!skipIcon) {
ret += ' <i class="fa fa-compress abbreviated"></i>';
}
}
return ret;
}
Expand Down
44 changes: 29 additions & 15 deletions probe/core/src/main/client/basic.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
body {
margin: 25px;
font-family: sans-serif;
font-family: "Droid Sans", Arial, sans-serif;
}

h1, h2, h3, h4 {
font-family: sans-serif;
font-family: "Droid Sans", Arial, sans-serif;
}

h1 {
Expand Down Expand Up @@ -179,19 +179,32 @@ ul.plain-list li {
margin-top: 25%;
}

#navigation-menu a, #navigation-menu span {
color: silver;
}

#navigation-menu.navbar {
border-width: 0px;
}

#navigation-menu ul.dropdown-menu li a {
color: #1d1d1d;
}

#navigation-menu a.active, #navigation-menu li.active a.dropdown-toggle
{
background-color: #337ab7;
color: #fff;
background-image: none;
border-radius: 3px;
}

#navigation-menu a:HOVER, #navigation-menu li.active a.dropdown-toggle:HOVER {
background-color: #1d1d1d;
}

a.nav-link {
padding: 5px 8px 5px 4px;
margin-right: 5px;
background-image: none;
/*border: 1px solid silver;*/
border-radius: 3px;
}

Expand All @@ -200,12 +213,12 @@ a.nav-link {
}

#navigation-menu a:HOVER {
text-decoration: underline;
/*text-decoration: underline;*/
}

#navigation-menu .navbar-nav>li {
border-right: 2px solid #f6f4f4;
}
/*#navigation-menu .navbar-nav>li {
border-right: 2px solid #4D4D4D;
}*/

div.content {
padding: 30px 10px 10px 10px;
Expand Down Expand Up @@ -254,17 +267,12 @@ div.content {

.quick-links a.dropdown-toggle {
background-color: Salmon;
border-radius: 5px;
}

#navigation-menu .quick-links a.dropdown-toggle {
color: white;
}

#navigation-menu .quick-links a.dropdown-toggle:HOVER {
color: black;
}

.centered {
text-align: center;
}
Expand Down Expand Up @@ -298,8 +306,9 @@ a.probe-comp, i.probe-comp, span.probe-comp {
color: silver;
}

p.version {
p.version span {
padding-right: 10px;
color: white;
}

code {
Expand All @@ -310,4 +319,9 @@ code {
padding: 2px 4px;
white-space: nowrap;
font-family: sans-serif;
}

div.content .panel-default>.panel-heading {
background-image: none;
font-weight: bold;
}
Loading

0 comments on commit e4555f6

Please sign in to comment.