diff --git a/app/scripts/controllers/register.js b/app/scripts/controllers/register.js index 95ff8440..d4cba766 100644 --- a/app/scripts/controllers/register.js +++ b/app/scripts/controllers/register.js @@ -67,6 +67,7 @@ }; vm.privacy = false; vm.completed = false; + vm.sensorIncomplete = true; //new sensebox object vm.newSenseBox = { @@ -128,9 +129,7 @@ vm.markers = {}; vm.sensors = []; vm.editMarkerInput = {}; - vm.sensorSetup = ''; vm.editing = {}; - vm.isCustom = {}; vm.events = { autolocation: true, }; @@ -182,7 +181,7 @@ function randomFixedInteger (length) { return Math.floor( Math.pow(10, length - 1) + - Math.random() * (Math.pow(10, length) - Math.pow(10, length - 1) - 1) + Math.random() * (Math.pow(10, length) - Math.pow(10, length - 1) - 1) ); } @@ -208,7 +207,7 @@ .then(function (response) { vm.boxScript = response; }) - .catch(function () {}); + .catch(function () { }); } function compile () { @@ -218,8 +217,8 @@ board: 'sensebox-mcu', sketch: vm.boxScript, }) - .then(function () {}) - .catch(function () {}) + .then(function () { }) + .catch(function () { }) .finally(function () { vm.compiling = false; }); @@ -326,15 +325,14 @@ function add (icon, title, unit, sensorType) { var sensor = { - id: vm.sensors.length, + id: randomFixedInteger(4), + index: vm.sensors.length, icon: icon, title: title, unit: unit, sensorType: sensorType, }; vm.sensors.push(sensor); - vm.sensorSetup = JSON.stringify(vm.sensors); - edit(sensor.id); vm.sensorIncomplete = false; if (vm.ttn.profile === 'cayenne-lpp') { @@ -344,16 +342,11 @@ function remove (index) { vm.sensors.splice(index, 1); - vm.isCustom[index] = false; - vm.editing[index] = false; for (var i = 0; i < vm.sensors.length; i++) { - vm.sensors[i].id = i; + vm.sensors[i].index = i; } if (vm.sensors.length === 0) { - vm.sensorSetup = ''; vm.sensorIncomplete = true; - } else { - vm.sensorSetup = JSON.stringify($scope.sensors); } if (vm.ttn.profile === 'cayenne-lpp') { @@ -361,10 +354,6 @@ } } - function edit (index) { - vm.editing[index] = true; - } - function setSensorIcon (sensor, newIcon) { sensor.icon = newIcon.name; } @@ -381,7 +370,7 @@ .then(function (data) { vm.boxScript = data; }) - .catch(function () {}); + .catch(function () { }); } function completeRegistration () { @@ -515,6 +504,7 @@ function senseBoxSetupValid () { var validTTN = true; var validMQTT = true; + var validSensorSetup = false; if (vm.ttnEnabled) { validTTN = vm.validTTNconfig; @@ -524,7 +514,11 @@ validMQTT = vm.validMQTTURL; } - return validTTN && validMQTT; + if (vm.modelSelected.id === 'custom' || vm.modelSelected.id === 'edu') { + validSensorSetup = vm.sensorIncomplete; + } + + return validTTN && validMQTT && !validSensorSetup; } function generateSensorTemplate (templateName) { @@ -804,7 +798,7 @@ map.setView([vm.markers.box.lat, vm.markers.box.lng], 16); } }) - .catch(function () {}); + .catch(function () { }); }, 200); } }); @@ -812,7 +806,6 @@ $scope.$watch('register.modelSelected.id', function (newValue) { if (newValue.indexOf('home') === 0) { vm.modelSelected.name = 'senseBox Home ' + newValue.substring(4); - vm.sensorSetup = vm.modelSelected.id; vm.newModel.connection = null; vm.extensions.feinstaub.id = ''; @@ -823,7 +816,6 @@ } if (newValue.indexOf('luftdaten') === 0) { - vm.sensorSetup = vm.modelSelected.id; vm.extensions.feinstaub.id = ''; vm.newModel.connection = null; @@ -845,13 +837,11 @@ } if (newValue.indexOf('hackair') === 0) { - vm.sensorSetup = vm.modelSelected.id; vm.extensions.feinstaub.id = ''; vm.newModel.connection = null; } if (newValue === 'custom') { - vm.sensorSetup = ''; vm.extensions.feinstaub.id = ''; vm.newModel.connection = null; vm.newModel.sensors = { diff --git a/app/views/account.box.register.html b/app/views/account.box.register.html index 4d60cf10..f6dec056 100644 --- a/app/views/account.box.register.html +++ b/app/views/account.box.register.html @@ -899,8 +899,7 @@

CO2

-
+
@@ -1122,8 +1123,7 @@

CO2

-
+
- @@ -1319,6 +1320,11 @@

{{ 'STEP2_SUB4' | translate }}

+
+ +
+ ng-required="register.ttn.profile !== 'sensebox/home'" ng-show="register.ttn.profile != 'cayenne-lpp'">