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) {
- 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++) {
- 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}));
});
});
--- /dev/null
+{{!
+Target detail
+
+data:
+ id - target id
+ hits - number of hits for this target
+ diagnostic -
+ records -
+ state - target state
+}}
+<table>
+ <thead>
+ <tr>
+ <td>{{mkws-translate "Target ID"}}</td>
+ <td>{{mkws-translate "Hits"}}</td>
+ <td>{{mkws-translate "Diags"}}</td>
+ <td>{{mkws-translate "Records"}}</td>
+ <td>{{mkws-translate "State"}}</td>
+ </td>
+ </tr>
+ </thead>
+ <tbody>
+ {{#each data}}
+ <tr>
+ <td>{{{id}}}</td>
+ <td>{{hits}}</td>
+ <td>{{diagnostic}}</td>
+ <td>{{records}}</td>
+ <td>{{hits}}</td>
+ </tr>
+ {{/each}}
+ </tbody>
+</table>