Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

PaperUI: rework bindings list view & binding detail view #3782

Merged
merged 2 commits into from Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion extensions/ui/org.eclipse.smarthome.ui.paper/gulpfile.js
Expand Up @@ -54,7 +54,8 @@ var paths = {
'./node_modules/angular-material/angular-material.min.js',
'./node_modules/angular-messages/angular-messages.min.js',
'./node_modules/angular-sanitize/angular-sanitize.min.js',
'./node_modules/angular-ui-sortable/dist/sortable.min.js'
'./node_modules/angular-ui-sortable/dist/sortable.min.js',
'./node_modules/angular-material-expansion-panel/dist/md-expansion-panel.min.js',
],
'name': 'angular-bundle.js'
}],
Expand Down Expand Up @@ -83,6 +84,7 @@ var paths = {
CSSLibs: [
'./node_modules/bootstrap/dist/css/bootstrap.min.css',
'./node_modules/angular-material/angular-material.min.css',
'./node_modules/angular-material-expansion-panel/dist/md-expansion-panel.min.css'
],
FontLibs: [
'./node_modules/roboto-fontface/fonts/*.woff',
Expand Down Expand Up @@ -212,6 +214,7 @@ gulp.task('inject', ['build'], function () {
'./web-src/js/app.js',
'./web-src/js/constants.js',
'./web-src/js/controllers.configuration.js',
'./web-src/js/controllers.configuration.bindings.js',
'./web-src/js/controllers.system.js',
'./web-src/js/controllers.items.js',
'./web-src/js/controllers.control.js',
Expand Down
1 change: 1 addition & 0 deletions extensions/ui/org.eclipse.smarthome.ui.paper/package.json
Expand Up @@ -12,6 +12,7 @@
"angular-animate": "1.4.8",
"angular-aria": "1.4.8",
"angular-material": "1.0.1",
"angular-material-expansion-panel": "^0.7.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that for stuff that we package we have to stick to the exact version, only for build&test dependencies like gulp we can go higher.

"angular-messages": "1.4.8",
"angular-resource": "1.4.8",
"angular-route": "1.4.8",
Expand Down
@@ -0,0 +1,73 @@
describe('module PaperUI.controllers.configuration.bindings', function() {
beforeEach(function() {
module('PaperUI');
});
describe('tests for BindingController', function() {
var bindingController, scope, mdDialog;
beforeEach(inject(function($injector, $rootScope, $controller, $mdDialog) {
scope = $rootScope.$new();
mdDialog = $mdDialog
$controller('BodyController', {
'$scope' : scope
});
bindingController = $controller('BindingController', {
'$scope' : scope
});
}));
it('should require BindingController', function() {
expect(bindingController).toBeDefined();
});
});

describe('tests for ConfigureBindingDialogController', function() {
var configureBindingDialogController, scope, bindingService;
var restConfig;
beforeEach(inject(function($injector, $rootScope, $controller) {
scope = $rootScope.$new();
var bindingRepository = $injector.get('bindingRepository');
restConfig = $injector.get('restConfig');
$rootScope.data.bindings = [ {
id : 'B'
} ];
configureBindingDialogController = $controller('ConfigureBindingDialogController', {
'$scope' : scope,
'binding' : {
'id' : 'B',
'configDescriptionURI' : 'CDURI'
},
'bindingRepository' : bindingRepository
});
$httpBackend = $injector.get('$httpBackend');
$httpBackend.when('GET', restConfig.restPath + "/config-descriptions/CDURI").respond({
parameters : [ {
type : 'input',
name : 'PNAME'
} ]
});
$httpBackend.when('GET', restConfig.restPath + "/bindings/B/config").respond({
PNAME : '1'
});
$httpBackend.flush();
bindingService = $injector.get('bindingService');
}));
it('should require ConfigureBindingDialogController', function() {
expect(configureBindingDialogController).toBeDefined();
});
it('should get binding parameters', function() {
expect(scope.parameters.length).toEqual(1);
});
it('should get binding configuration', function() {
expect(scope.configuration.PNAME).toEqual(1);
});
it('should add binding parameter', function() {
scope.configArray = [];
scope.addParameter();
expect(scope.configArray.length).toEqual(1);
});
it('should save binding configuration', function() {
spyOn(bindingService, 'updateConfig');
scope.save();
expect(bindingService.updateConfig).toHaveBeenCalled();
});
});
});
Expand Up @@ -2,7 +2,6 @@ describe('module PaperUI.controllers.configuration', function() {
beforeEach(function() {
module('PaperUI');
});
var restConfig;
describe('tests for ConfigurationPageController', function() {
var configurationPageController, scope;
beforeEach(inject(function($injector, $rootScope, $controller) {
Expand All @@ -22,112 +21,6 @@ describe('module PaperUI.controllers.configuration', function() {
expect(label).toEqual('1');
});
});
describe('tests for BindingController', function() {
var bindingController, scope, mdDialog;
beforeEach(inject(function($injector, $rootScope, $controller, $mdDialog) {
scope = $rootScope.$new();
mdDialog = $mdDialog
$controller('BodyController', {
'$scope' : scope
});
bindingController = $controller('BindingController', {
'$scope' : scope
});
}));
it('should require BindingController', function() {
expect(bindingController).toBeDefined();
});
it('should open binding info dialog', function() {
spyOn(mdDialog, 'show');
scope.openBindingInfoDialog(0);
expect(mdDialog.show).toHaveBeenCalled();
});
it('should open binding configuration dialog', function() {
spyOn(mdDialog, 'show');
scope.configure(0);
expect(mdDialog.show).toHaveBeenCalled();
});
});

describe('tests for BindingInfoDialogController', function() {
var bindingInfoDialogController, scope, mdDialog;
beforeEach(inject(function($injector, $rootScope, $controller) {
scope = $rootScope.$new();
var bindingRepository = $injector.get('bindingRepository');
var thingTypeRepository = $injector.get('thingTypeRepository');
restConfig = $injector.get('restConfig');
$rootScope.data.bindings = [ {
id : 'B'
} ];

$httpBackend = $injector.get('$httpBackend');
$httpBackend.when('GET', restConfig.restPath + "/thing-types").respond([ {
UID : 'B:T'
} ]);
bindingInfoDialogController = $controller('BindingInfoDialogController', {
'$scope' : scope,
'bindingId' : 'B',
'bindingRepository' : bindingRepository,
'thingTypeRepository' : thingTypeRepository
});
$httpBackend.flush();
}));
it('should require BindingInfoDialogController', function() {
expect(bindingInfoDialogController).toBeDefined();
});
it('should get ThingTypes of Binding', function() {
expect(scope.binding.thingTypes[0].UID).toEqual('B:T');
});

});

describe('tests for ConfigureBindingDialogController', function() {
var configureBindingDialogController, scope, bindingService;
beforeEach(inject(function($injector, $rootScope, $controller) {
scope = $rootScope.$new();
var bindingRepository = $injector.get('bindingRepository');
$rootScope.data.bindings = [ {
id : 'B'
} ];
configureBindingDialogController = $controller('ConfigureBindingDialogController', {
'$scope' : scope,
'bindingId' : 'B',
'configDescriptionURI' : 'CDURI',
'bindingRepository' : bindingRepository
});
$httpBackend = $injector.get('$httpBackend');
$httpBackend.when('GET', restConfig.restPath + "/config-descriptions/CDURI").respond({
parameters : [ {
type : 'input',
name : 'PNAME'
} ]
});
$httpBackend.when('GET', restConfig.restPath + "/bindings/B/config").respond({
PNAME : '1'
});
$httpBackend.flush();
bindingService = $injector.get('bindingService');
}));
it('should require ConfigureBindingDialogController', function() {
expect(configureBindingDialogController).toBeDefined();
});
it('should get binding parameters', function() {
expect(scope.parameters.length).toEqual(1);
});
it('should get binding configuration', function() {
expect(scope.configuration.PNAME).toEqual(1);
});
it('should add binding parameter', function() {
scope.configArray = [];
scope.addParameter();
expect(scope.configArray.length).toEqual(1);
});
it('should save binding configuration', function() {
spyOn(bindingService, 'updateConfig');
scope.save();
expect(bindingService.updateConfig).toHaveBeenCalled();
});
});

describe('tests for ServicesController', function() {
var ServicesController, scope, injector;
Expand Down