The dashboard view controller
There isn't any interactivity on the dashboard, so there's not much for the view controller to do. We'll use it to control the live refresh aspect of the charts:
// app/view/dashboard/DashboardController.js Ext.define('Instrumatics.view.dashboard.DashboardController', { extend: 'Ext.app.ViewController', alias: 'controller.dashboard-dashboard', init: function() { var data = this.getViewModel().getData(), me = this; setInterval(function() { data.webLogs.load({ addRecords: true }); data.sqlLogs.load({ addRecords: true }); }, 1000); } });
It's as simple as this; every second, grab the store powering the live chart and call its load method with the addRecords
option set to true
. This will cause new records to be appended to the store rather than overwriting old records.
While there's not much code here, there are a couple of discussion points. We could have avoided using a view controller...