-function ArvApiDirectoryComponent(connections) {
- this.controller = Controller;
- Controller.prototype = new BaseController();
- function Controller(vm) {
- this.vm = vm || {};
- this.vm.widgets = connections().map(function(conn) {
- var component = new ArvApiStatusComponent(conn);
- return {
- view: component.view,
- controller: new component.controller(),
- };
- });
- // Give BaseController a list of components to unload.
- this.controllers = function() {
- return this.vm.widgets.map(function(widget) {
- return widget.controller;
- });
- }.bind(this);
-
- this.redrawTimer = setInterval(function() {
- // If redraw is really really cheap, we can do this to make
- // "#seconds old" timers count in real time.
- m.redraw();
- }, 1000);
- this.onunload = function() {
- clearTimeout(this.redrawTimer);
+function ArvApiDirectoryComponent(opts) {
+ _.extend(this, {
+ controller: this.controller.bind(this, opts),
+ });
+}
+_.extend(ArvApiDirectoryComponent.prototype, {
+ controller: controller,
+ view: view,
+});
+function controller(opts) {
+ _.extend(this, {connections: m.prop([])}, opts);
+ this.redrawTimer = setInterval(function() {
+ // If redraw is really really cheap, we can do this to make
+ // "#seconds old" timers count in real time.
+ m.redraw();
+ }, 1000);
+ this.widgets = this.connections().map(function(conn) {
+ var component = new ArvApiStatusComponent(conn);
+ return {
+ view: component.view,
+ controller: new component.controller(),