|
@@ -1,48 +1,5 @@
|
|
|
app.controller('status', function($scope, statusService, $interval) {
|
|
|
- $.getScript("https://www.google.com/jsapi", function() {
|
|
|
- //google.load('visualization', '1.1', {packages: ['line'], callback:function(){
|
|
|
- google.load('visualization', '1', {packages: ['corechart'], callback: function() {
|
|
|
- google.setOnLoadCallback(InitChart);
|
|
|
- }});
|
|
|
- });
|
|
|
-
|
|
|
- var chart, chartData;
|
|
|
-
|
|
|
- var chartOptions = {
|
|
|
- chart: {
|
|
|
- title: 'System Info History',
|
|
|
- },
|
|
|
- height: 400,
|
|
|
- legend: {
|
|
|
- position: 'top',
|
|
|
- alignment: 'start'
|
|
|
- },
|
|
|
- backgroundColor: 'transparent'
|
|
|
- };
|
|
|
-
|
|
|
- var chartLoaded = false;
|
|
|
- var currentId = 0;
|
|
|
-
|
|
|
- function InitChart() {
|
|
|
- chart = new google.visualization.LineChart(document.getElementById('linechart'));
|
|
|
-
|
|
|
- chartData = new google.visualization.DataTable();
|
|
|
- chartData.addColumn('number', 'id');
|
|
|
- chartData.addColumn('number', 'CPU');
|
|
|
- chartData.addColumn('number', 'MEM');
|
|
|
- chartData.addColumn('number', 'TEMP');
|
|
|
-
|
|
|
- chartLoaded = true;
|
|
|
- }
|
|
|
- function AddDataToChart(cpu, mem, temp) {
|
|
|
- if (!chartLoaded)
|
|
|
- return;
|
|
|
- currentId++;
|
|
|
- chartData.addRow([currentId, cpu, mem, temp]);
|
|
|
- if (chartData.getNumberOfRows() > 50)
|
|
|
- chartData.removeRow(0);
|
|
|
- chart.draw(chartData, chartOptions);
|
|
|
- }
|
|
|
+ $scope.chartData=[];
|
|
|
|
|
|
function reloadUptime() {
|
|
|
statusService.getUptime().then(function(data) {
|
|
@@ -57,8 +14,8 @@ app.controller('status', function($scope, statusService, $interval) {
|
|
|
|
|
|
function reloadSystemInfo() {
|
|
|
statusService.getSystemInfo().then(function(data) {
|
|
|
+ $scope.chartData=$scope.chartData.concat([{id: $scope.chartData.length, CPU: data.load[0]*100, Mem: data.memUsage, Temp: data.cpuTemp}]);
|
|
|
$scope.load = data.load;
|
|
|
- AddDataToChart(data.load[0] * 100, data.memUsage, data.cpuTemp);
|
|
|
$scope.cpuTemp = data.cpuTemp;
|
|
|
$scope.memory = {
|
|
|
free: data.memFree,
|