Skip to content

Commit

Permalink
Merge branch 'master' into AsusWRT-Merlin
Browse files Browse the repository at this point in the history
  • Loading branch information
VREMSoftwareDevelopment committed Jan 1, 2019
2 parents 36db392 + 2812afd commit 88ea786
Show file tree
Hide file tree
Showing 22 changed files with 102 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ A simple shell script designed to run on [AsusWRT-Merlin](https://asuswrt.lostre
- `cd /mnt/<mounted_name>/`
- `mkdir bwmon`
- `cd bwmon`
- `wget https://github.com/VREMSoftwareDevelopment/bwmon/releases/download/v2.4.2-Merlin/bwmon.tar.gz`
- `wget https://github.com/VREMSoftwareDevelopment/bwmon/releases/download/v2.5.0-Merlin/bwmon.tar.gz`
- `tar -xzvf bwmon.tar.gz`
- `chmod +x install.sh`
- `./install.sh`
Expand Down
1 change: 1 addition & 0 deletions app/common/chartType.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('BWMonApp.ChartType module, chartType directive ', function() {
template = angular.element('<chart-type ng-model="myType"></chart-type>');

scope = _$rootScope_.$new();
scope.myType = chartTypes[0];

chartService = _chartService_;
spyOn(chartService, 'getChartTypes').and.returnValue(chartTypes);
Expand Down
4 changes: 1 addition & 3 deletions app/common/chartType.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ angular.module('BWMonApp.ChartType', [])
chartType: '=ngModel'
},
controller: function(chartService) {
var chartTypes = chartService.getChartTypes();
angular.extend(this, {
chartTypes: chartTypes,
chartType: chartTypes[0]
chartTypes: chartService.getChartTypes()
});
},
controllerAs: 'chartTypeCtrl'
Expand Down
3 changes: 2 additions & 1 deletion app/common/selectMonth.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ describe('BWMonApp.SelectMonth module, selectMonth directive', function() {
template = angular.element('<select-month ng-model="myMonth" year="myYear"></select-month></div>');

scope = _$rootScope_.$new();
scope.myYear = data[0].year;
scope.myMonth = data[0].months[0];

dataService = _dataService_;
spyOn(dataService, 'getMonths').and.returnValue(data[0].months);

element = _$compile_(template)(scope);
controller = template.controller('selectMonth');

scope.myYear = data[0].year;
}));

it('should have element', function() {
Expand Down
1 change: 1 addition & 0 deletions app/common/selectYear.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('BWMonApp.SelectYear module, selectYear directive ', function() {
template = angular.element('<select-year ng-model="myYear"></select-year>');

scope = _$rootScope_.$new();
scope.myYear = years[0];

dataService = _dataService_;
spyOn(dataService, 'getYears').and.returnValue(years);
Expand Down
4 changes: 1 addition & 3 deletions app/common/selectYear.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ angular.module('BWMonApp.SelectYear', [])
year: '=ngModel'
},
controller: function(dataService) {
var years = dataService.getYears();
angular.extend(this, {
years: years,
year: years[0]
years: dataService.getYears()
});
},
controllerAs: 'selectYearCtrl'
Expand Down
8 changes: 4 additions & 4 deletions app/navigation/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ angular.module('BWMonApp.Navigation', [])
'<div class="navbar navbar-default">',
'<ul class="nav navbar-nav">',
'<li ng-repeat="route in ::navigationCtrl.routes" ng-class="{active: navigationCtrl.isActive(\'{{::route.href}}\')}" >',
'<a href="#{{::route.href}}">{{::route.name}}</a>',
'<a href="#!{{::route.href}}">{{::route.name}}</a>',
'</li>',
'</ul>',
'</div>'
Expand All @@ -34,13 +34,13 @@ angular.module('BWMonApp.Navigation', [])
return viewLocation === $location.path();
},
routes: [{
href: '/UsageByUser',
href: 'UsageByUser',
name: 'Usage By User'
}, {
href: '/UsageByMonth',
href: 'UsageByMonth',
name: 'Usage By Month'
}, {
href: '/UsageByYear',
href: 'UsageByYear',
name: 'Usage By Year'
}]
});
Expand Down
8 changes: 4 additions & 4 deletions app/services/chartService.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('BWMonApp.ChartService module, chartService factory ', function() {

it('should have all choices in chart types', function(){
var expected = [
['column'],
['line', 'dot'],
['line', 'dot', 'area']
'column',
'line',
'area'
];
expect(chartService.getChartTypes()).toEqual(expected);
});
Expand All @@ -33,7 +33,7 @@ describe('BWMonApp.ChartService module, chartService factory ', function() {
color: '#3366CC',
label: 'GBytes',
grid: {x: false, y: true},
type: ['column'],
type: 'column',
id: 'series00'
}];
expect(chartService.getChartOptions().series).toEqual(expected);
Expand Down
6 changes: 3 additions & 3 deletions app/services/chartService.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ angular.module('BWMonApp.ChartService', [])
.factory('chartService', function() {
var _getChartTypes = function() {
return [
['column'],
['line', 'dot'],
['line', 'dot', 'area']
'column',
'line',
'area'
];
},
_getChartOptions = function(labelFn, tooltipFn) {
Expand Down
17 changes: 16 additions & 1 deletion app/usagebymonth/usageByMonth.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ describe('BWMonApp.UsageByMonth module, ', function() {

describe('UsageByMonthController controller ', function() {
var controller,
years = ['2011', '2012'],
usageData = {
data: [
{usage: 5, total: 10},
{usage: 2, total: 11},
{usage: 1, total: 12}
]
},
chartTypes = [
['type1'],
['type2']
],
chartOptions = {
series: [{
type: 'type'
type: chartTypes[0]
}]
},
chartData = {
Expand All @@ -44,9 +49,11 @@ describe('BWMonApp.UsageByMonth module, ', function() {

beforeEach(inject(function(_$controller_, _dataService_, _chartService_){
dataService = _dataService_;
spyOn(dataService, 'getYears').and.returnValue(years);
spyOn(dataService, 'getUsageByMonth').and.returnValue(usageData);

chartService = _chartService_;
spyOn(chartService, 'getChartTypes').and.returnValue(chartTypes);
spyOn(chartService, 'getChartOptions').and.returnValue(chartOptions);
spyOn(chartService, 'getChartData').and.returnValue(chartData);

Expand All @@ -59,6 +66,14 @@ describe('BWMonApp.UsageByMonth module, ', function() {
scope.usageByMonthCtrl = controller;
}));

it('should set selected year', function() {
expect(controller.selected.year).toBe(years[0]);
});

it('should set selected chart type', function() {
expect(controller.selected.chartType).toBe(chartTypes[0]);
});

it('should set predicate to id', function() {
expect(controller.predicate).toEqual('id');
});
Expand Down
10 changes: 7 additions & 3 deletions app/usagebymonth/usageByMonth.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ angular.module('BWMonApp.UsageByMonth', ['ngRoute'])
ctrl.descending = true;
};

ctrl.selected = {};
reset();

ctrl.setOrder = function(predicate) {
ctrl.descending = (ctrl.predicate === predicate) ? !ctrl.descending : true;
ctrl.predicate = predicate;
Expand Down Expand Up @@ -59,5 +56,12 @@ angular.module('BWMonApp.UsageByMonth', ['ngRoute'])

reset();
}, true);

ctrl.selected = {
year: dataService.getYears()[0],
chartType: chartService.getChartTypes()[0]
};
reset();

})
;
17 changes: 16 additions & 1 deletion app/usagebyuser/usageByUser.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('BWMonApp.UsageByUser module, ', function() {
page = {
reset: function() {}
},
years = ['2011', '2012'],
months = ['Jan', 'Mar', 'Jun'],
usageByUser = {
data: {
Expand All @@ -43,9 +44,13 @@ describe('BWMonApp.UsageByUser module, ', function() {
{x: 3, y: 2}
]
},
chartTypes = [
['type1'],
['type2']
],
chartOptions = {
series: [{
type: 'type'
type: chartTypes[0]
}]
},
chartService,
Expand All @@ -54,10 +59,12 @@ describe('BWMonApp.UsageByUser module, ', function() {
beforeEach(inject(function($controller, _dataService_, _chartService_){
dataService = _dataService_;

spyOn(dataService, 'getYears').and.returnValue(years);
spyOn(dataService, 'getMonths').and.returnValue(months);
spyOn(dataService, 'getUsageByUser').and.returnValue(usageByUser);

chartService = _chartService_;
spyOn(chartService, 'getChartTypes').and.returnValue(chartTypes);
spyOn(chartService, 'getChartData').and.returnValue(chartData);
spyOn(chartService, 'getChartOptions').and.returnValue(chartOptions);

Expand Down Expand Up @@ -102,6 +109,14 @@ describe('BWMonApp.UsageByUser module, ', function() {
expect(controller.getOrder('XYZ')).toEqual({});
});

it('should set selected year', function() {
expect(controller.selected.year).toBe(years[0]);
});

it('should set selected chart type', function() {
expect(controller.selected.chartType).toBe(chartTypes[0]);
});

it('should set selected user to empty', function() {
expect(controller.selected.user).toBe('');
});
Expand Down
12 changes: 8 additions & 4 deletions app/usagebyuser/usageByUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ angular.module('BWMonApp.UsageByUser', ['ngRoute'])
return result;
};

ctrl.selected = {};
ctrl.pageSize = 15;
reset();

ctrl.setOrder = function(predicate) {
ctrl.descending = (ctrl.predicate === predicate) ? !ctrl.descending : false;
ctrl.predicate = predicate;
Expand Down Expand Up @@ -87,5 +83,13 @@ angular.module('BWMonApp.UsageByUser', ['ngRoute'])
ctrl.chartOptions = chartService.getChartOptions(ctrl.getLabel, ctrl.getTooltip);
ctrl.chartOptions.series[0].type = ctrl.selected.chartType;
}, true);

ctrl.selected = {
year: dataService.getYears()[0],
chartType: chartService.getChartTypes()[0]
};
ctrl.pageSize = 15;
reset();

})
;
11 changes: 10 additions & 1 deletion app/usagebyyear/usageByYear.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ describe('BWMonApp.UsageByYear module, ', function() {
{id: 2},
{id: 3}
],
chartTypes = [
['type1'],
['type2']
],
chartOptions = {
series: [{
type: 'type'
type: chartTypes[0]
}]
},
chartData = {
Expand All @@ -41,6 +45,7 @@ describe('BWMonApp.UsageByYear module, ', function() {
spyOn(dataService, 'getUsageByYear').and.returnValue({data: data, chartData: data});

chartService = _chartService_;
spyOn(chartService, 'getChartTypes').and.returnValue(chartTypes);
spyOn(chartService, 'getChartOptions').and.returnValue(chartOptions);
spyOn(chartService, 'getChartData').and.returnValue(chartData);

Expand All @@ -51,6 +56,10 @@ describe('BWMonApp.UsageByYear module, ', function() {
});
}));

it('should set selected chart type', function() {
expect(controller.selected.chartType).toBe(chartTypes[0]);
});

it('should set predicate to id', function() {
expect(controller.predicate).toEqual('id');
});
Expand Down
4 changes: 3 additions & 1 deletion app/usagebyyear/usageByYear.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ angular.module('BWMonApp.UsageByYear', ['ngRoute'])

ctrl.predicate = 'id';
ctrl.descending = true;
ctrl.selected = {};
ctrl.selected = {
chartType: chartService.getChartTypes()[0]
};
ctrl.data = usageData.data;
ctrl.chartData = chartService.getChartData(usageData.data);
ctrl.chartOptions = chartService.getChartOptions(ctrl.getLabel, ctrl.getLabel);
Expand Down
14 changes: 7 additions & 7 deletions e2e/routes.Test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ describe('bwmon e2e routes tests', function() {
it('should default to Usage By User page', function() {
browser.get(URL);
browser.waitForAngular();
expect(browser.getCurrentUrl()).toEqual(URL+'#/UsageByUser');
expect(browser.getCurrentUrl()).toEqual(URL+'#!/UsageByUser');
});

it('should switch to Usage By User page', function() {
browser.get(URL+'#/UsageByUser');
browser.get(URL+'#!UsageByUser');
browser.waitForAngular();
expect(browser.getCurrentUrl()).toEqual(URL+'#/UsageByUser');
expect(browser.getCurrentUrl()).toEqual(URL+'#!/UsageByUser');
});

it('should switch to Usage By Month page', function() {
browser.get(URL+'#/UsageByMonth');
browser.get(URL+'#!UsageByMonth');
browser.waitForAngular();
expect(browser.getCurrentUrl()).toEqual(URL+'#/UsageByMonth');
expect(browser.getCurrentUrl()).toEqual(URL+'#!/UsageByMonth');
});

it('should switch to Usage By Year page', function() {
browser.get(URL+'#/UsageByYear');
browser.get(URL+'#!/UsageByYear');
browser.waitForAngular();
expect(browser.getCurrentUrl()).toEqual(URL+'#/UsageByYear');
expect(browser.getCurrentUrl()).toEqual(URL+'#!/UsageByYear');
});

});
2 changes: 1 addition & 1 deletion e2e/usageByMonth.Test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('bwmon e2e usage by month, ', function() {
beforeEach(function () {
browser.get('http://localhost:8080/#/UsageByMonth');
browser.get('http://localhost:8080/#!/UsageByMonth');
browser.waitForAngular();
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/usageByUser.Test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('bwmon e2e usage by user, ', function() {
var URL = 'http://localhost:8080/#/UsageByUser';
var URL = 'http://localhost:8080/#!/UsageByUser';

beforeEach(function () {
browser.get(URL);
Expand Down
2 changes: 1 addition & 1 deletion e2e/usageByYear.Test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe('bwmon e2e usage by year, ', function() {

beforeEach(function () {
browser.get('http://localhost:8080/#/UsageByYear');
browser.get('http://localhost:8080/#!/UsageByYear');
browser.waitForAngular();
});

Expand Down
Loading

0 comments on commit 88ea786

Please sign in to comment.