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 all commits
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
23 changes: 12 additions & 11 deletions extensions/ui/org.eclipse.smarthome.ui.paper/package.json
Expand Up @@ -12,24 +12,14 @@
"angular-animate": "1.4.8",
"angular-aria": "1.4.8",
"angular-material": "1.0.1",
"angular-material-expansion-panel": "0.7.2",
"angular-messages": "1.4.8",
"angular-resource": "1.4.8",
"angular-route": "1.4.8",
"angular-sanitize": "1.4.8",
"angular-ui-sortable": "0.13.4",
"bootstrap": "3.3.2",
"browser-sync": "~2.7.12",
"del": "^2.0.0",
"eventsource-polyfill": "^0.9.6",
"gulp": "^3.9.0",
"gulp-angular-filesort": "~1.1.1",
"gulp-concat": "^2.6.0",
"gulp-inject": "^4.0.0",
"gulp-ng-annotate": "~1.0.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.1",
"gulp-util": "^3.0.7",
"http-proxy-middleware": "^0.9.0",
"jquery": "2.1.3",
"jquery-ui": "^1.11.2",
"masonry-layout": "3.3.1",
Expand All @@ -43,6 +33,17 @@
},
"devDependencies": {
"angular-mocks": "1.4.8",
"browser-sync": "~2.7.12",
"del": "^2.0.0",
"gulp": "^3.9.0",
"gulp-angular-filesort": "~1.1.1",
"gulp-concat": "^2.6.0",
"gulp-inject": "^4.0.0",
"gulp-ng-annotate": "~1.0.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.1",
"gulp-util": "^3.0.7",
"http-proxy-middleware": "^0.9.0",
"jasmine-core": "^2.5.2",
"karma": "^1.1.0",
"karma-angular": "0.0.6",
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