Permalink
Browse files

Merge pull request #44 from stelcheck/feature/groups

Feature/groups
  • Loading branch information...
2 parents 30d7111 + fb59154 commit 9f801c1d15cd98c88b877f06ad70a6db65de07c5 @obazoud obazoud committed Jan 24, 2013
Showing with 55 additions and 19 deletions.
  1. +1 −0 api.js
  2. +46 −19 public/index.html
  3. +8 −0 public/styles/master.css
View
@@ -96,6 +96,7 @@ module.exports.checkAllServices = function() {
for (var i = 0; i < settings.services.length; i++) {
status.services[i] = {};
status.services[i].name = settings.services[i].name;
+ status.services[i].group = settings.services[i].group;
status.services[i].label = settings.services[i].label;
status.services[i].status = 'unknown';
status.services[i].statusCode = 0;
View
@@ -44,13 +44,32 @@
});
socket.on('status', function (status) {
- var statusTab = _.map(status.services, function(value, key) { return value; });
+ var statusTab = [];
+ var groups = [];
+
+ _.each(status.services, function(value, key) {
+ if (typeof(value.group) !== 'string') {
+ value.group = 'others';
+ }
+
+ var groupIndex = groups.indexOf(value.group);
+
+ if (groupIndex === -1) {
+ groupIndex = groups.length;
+ groups.push(value.group);
+ statusTab.push({ name:value.group, projects: []});
+ };
+
+ statusTab[groupIndex].projects.push(value);
+ });
$('#summarize').empty();
$('#projects').empty();
- $("#projectTemplate").template("projectsList");
+
+ $("#groupTemplate").template("group");
$("#summarizeTemplate").template("summarizeData");
- $.tmpl("projectsList", statusTab).appendTo("#projects");
+
+ $.tmpl("group", statusTab).appendTo("#projects");
$.tmpl("summarizeData", status.summarize).appendTo("#summarize");
});
@@ -96,17 +115,30 @@
});
});
</script>
- <script id="projectTemplate" type="text/html">
- <li class="project">
- <h2>
- <span class="service"><span class="strikethrough"></span><strong>${label}</strong></span>
- <span class="status ${status} glow"><span class="strikethrough"></span><strong>${status}</strong></span>
- <span class="code"><span class="strikethrough"></span><strong>{{if statusCode != 0 && status != 'up'}}${statusCode}{{else}}&nbsp;{{/if}}</strong></span>
- </h2>
- {{if message }}
- <p class="info"><span class="label">Message:</span>${message}</p>
- {{/if}}
- </li>
+ <script id="groupTemplate" type="text/html">
+ <li>
+ <h1 class="legend">${name}</h1>
+
+ <div class="legend">
+ <span class="service">Service</span>
+ <span class="status">Status</span>
+ <span class="code">Code</span>
+ </div>
+ <ul>
+ {{each(i, project) projects}}
+ <li class="project">
+ <h2>
+ <span class="service"><span class="strikethrough"></span><strong>${project.label}</strong></span>
+ <span class="status ${project.status} glow"><span class="strikethrough"></span><strong>${project.status}</strong></span>
+ <span class="code"><span class="strikethrough"></span><strong>{{if project.statusCode != 0 && project.status != 'up'}}${project.statusCode}{{else}}&nbsp;{{/if}}</strong></span>
+ </h2>
+ {{if project.message }}
+ <p class="info"><span class="label">Message:</span>${project.message}</p>
+ {{/if}}
+ </li>
+ {{/each}}
+ </ul>
+ </li>
</script>
<script id="summarizeTemplate" type="text/html">
<li class="project">
@@ -148,11 +180,6 @@ <h1 id="title">Services Status Dashboard</h1>
</div>
<div id="plugins" class="plugins">
</div>
- <div class="legend">
- <span class="service">Service</span>
- <span class="status">Status</span>
- <span class="code">Code</span>
- </div>
<ul id="projects"></ul>
</div>
<div id="footer">
@@ -106,6 +106,14 @@ body {
left: 507px;
}
+ h1.legend {
+ height:auto;
+ font-size:24px;
+ line-height:36px;
+ padding:20px 10px 0px;
+ text-align:left;
+ color: #888;
+ }
/* PROJECTS */
.plugin {
cursor: pointer;

0 comments on commit 9f801c1

Please sign in to comment.