projects
/
mkws-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Template Stat widget
[mkws-moved-to-github.git]
/
src
/
mkws-widget-main.js
diff --git
a/src/mkws-widget-main.js
b/src/mkws-widget-main.js
index
07243e7
..
91c2d93
100644
(file)
--- a/
src/mkws-widget-main.js
+++ b/
src/mkws-widget-main.js
@@
-6,43
+6,34
@@
mkws.registerWidgetType('Targets', function() {
if (!this.config.show_switch) return;
var that = this;
mkws.registerWidgetType('Targets', function() {
if (!this.config.show_switch) return;
var that = this;
- var M = mkws.M;
this.node.html('No information available yet.');
this.node.css("display", "none");
this.team.queue("targets").subscribe(function(data) {
this.node.html('No information available yet.');
this.node.css("display", "none");
this.team.queue("targets").subscribe(function(data) {
- var table ='<table><thead><tr>' +
- '<td>' + M('Target ID') + '</td>' +
- '<td>' + M('Hits') + '</td>' +
- '<td>' + M('Diags') + '</td>' +
- '<td>' + M('Records') + '</td>' +
- '<td>' + M('State') + '</td>' +
- '</tr></thead><tbody>';
-
+ // There is a bug in pz2.js
+ var cleandata = [];
for (var i = 0; i < data.length; i++) {
for (var i = 0; i < data.length; i++) {
- table += "<tr><td>" + data[i].id +
- "</td><td>" + data[i].hits +
- "</td><td>" + data[i].diagnostic +
- "</td><td>" + data[i].records +
- "</td><td>" + data[i].state + "</td></tr>";
+ var cur = {};
+ cur.id = data[i].id;
+ cur.hits = data[i].hits;
+ cur.diagnostic = data[i].diagnostic;
+ cur.records = data[i].records;
+ cur.state = data[i].state;
+ cleandata.push(cur);
}
}
- table += '</tbody></table>';
- that.node.html(table);
+ var template = that.team.loadTemplate(that.config.template || "Targets");
+ that.node.html(template({data: cleandata}));
});
});
mkws.registerWidgetType('Stat', function() {
var that = this;
});
});
mkws.registerWidgetType('Stat', function() {
var that = this;
- var M = mkws.M;
-
this.team.queue("stat").subscribe(function(data) {
this.team.queue("stat").subscribe(function(data) {
- that.node.html(' -- ' +
- '<span class="mkwsClientCount">' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '</span>' +
- ' -- ' +
- M('Retrieved records') + ': ' + data.records + '/' + data.hits);
+ var template = that.team.loadTemplate(that.config.template || "Stat");
+ that.node.html(template(data));
});
});
});
});
@@
-116,31
+107,29
@@
mkws.registerWidgetType('Records', function() {
var team = this.team;
this.team.queue("records").subscribe(function(data) {
var team = this.team;
this.team.queue("records").subscribe(function(data) {
- var html = [];
for (var i = 0; i < data.hits.length; i++) {
var hit = data.hits[i];
that.team.queue("record").publish(hit);
for (var i = 0; i < data.hits.length; i++) {
var hit = data.hits[i];
that.team.queue("record").publish(hit);
- var divId = team.recordElementId(hit.recid[0]);
- html.push('<div class="mkwsSummary mkwsTeam_' + team.name() + ' ' + divId + '">', renderSummary(hit), '</div>');
+ hit.detailLinkId = team.recordElementId(hit.recid[0]);
+ hit.detailClick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;"
+ hit.containerClass = "mkwsSummary mkwsTeam_" + team.name();
+ hit.containerClass += " " + hit.detailLinkId;
// ### At some point, we may be able to move the
// m_currentRecordId and m_currentRecordData members
// from the team object into this widget.
if (hit.recid == team.currentRecordId()) {
// ### At some point, we may be able to move the
// m_currentRecordId and m_currentRecordData members
// from the team object into this widget.
if (hit.recid == team.currentRecordId()) {
- if (team.currentRecordData())
- html.push(team.renderDetails(team.currentRecordData()));
+ if (team.currentRecordData()) {
+ hit.renderedDetails = team.renderDetails(team.currentRecordData());
+ console.log(hit.renderedDetails);
+ }
}
}
}
}
- that.node.html(html.join(''));
-
- function renderSummary(hit) {
- var template = team.loadTemplate(that.config.template || "Summary");
- hit._id = team.recordElementId(hit.recid[0]);
- hit._onclick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;"
- return template(hit);
- }
+ var template = team.loadTemplate(that.config.template || "Records");
+ var targs = $.extend({}, {"hits": data.hits}, that.config.template_vars);
+ that.node.html(template(targs));
});
});
- widget.autosearch(that);
+ that.autosearch();
});
});
@@
-216,7
+205,7
@@
mkws.registerWidgetType('Switch', function() {
<a href="#" onclick="mkws.switchView(\'' + tname + '\', \'records\')">Records</a><span> \
| \
</span><a href="#" onclick="mkws.switchView(\'' + tname + '\', \'targets\')">Targets</a>');
<a href="#" onclick="mkws.switchView(\'' + tname + '\', \'records\')">Records</a><span> \
| \
</span><a href="#" onclick="mkws.switchView(\'' + tname + '\', \'targets\')">Targets</a>');
- widget.hideWhenNarrow(this);
+ this.hideWhenNarrow();
});
});
@@
-265,7
+254,7
@@
mkws.registerWidgetType('Results', function() {
</tr>\
</table>');
</tr>\
</table>');
- widget.autosearch(this);
+ this.autosearch();
});
});
@@
-372,7
+361,7
@@
mkws.registerWidgetType('Lang', function() {
}
this.node.html(data);
}
this.node.html(data);
- widget.hideWhenNarrow(this);
+ this.hideWhenNarrow();
// set or re-set "lang" URL parameter
// set or re-set "lang" URL parameter
@@
-413,7
+402,7
@@
mkws.registerWidgetType('Config', function() {
var c = this.config;
for (var name in c) {
if (c.hasOwnProperty(name)) {
var c = this.config;
for (var name in c) {
if (c.hasOwnProperty(name)) {
- this.team.config()[name] = c[name];
+ this.team.config[name] = c[name];
this.log(this + " copied property " + name + "='" + c[name] + "' up to team");
}
}
this.log(this + " copied property " + name + "='" + c[name] + "' up to team");
}
}
@@
-431,7
+420,7
@@
mkws.registerWidgetType('Progress', function() {
s += '</span>';
s += '<span class="mkwsWaiting">';
}
s += '</span>';
s += '<span class="mkwsWaiting">';
}
- s += '█';
+ s += '█';
}
s += '</span>';
that.node.html(s);
}
s += '</span>';
that.node.html(s);
@@
-448,6
+437,5
@@
mkws.registerWidgetType('Progress', function() {
mkws.registerWidgetType('Query', function() {});
mkws.registerWidgetType('MOTDContainer', function() {});
mkws.registerWidgetType('Button', function() {});
mkws.registerWidgetType('Query', function() {});
mkws.registerWidgetType('MOTDContainer', function() {});
mkws.registerWidgetType('Button', function() {});
-mkws.registerWidgetType('Popup', function() {});