Added confirmation page for monitoring + a few tweaks.

This commit is contained in:
baldo 2016-05-18 22:50:06 +02:00
parent 1b173b79d4
commit 0bdce5debb
24 changed files with 431 additions and 72 deletions

View file

@ -31,6 +31,11 @@ angular.module('ffffng', [
controller: 'DeleteNodeCtrl',
title: 'Knoten löschen'
})
.when('/monitoring/confirm', {
templateUrl: 'views/confirmMonitoring.html',
controller: 'ConfirmMonitoringCtrl',
title: 'Versand von Status-E-Mails bestätigen'
})
.otherwise({
redirectTo: '/'
});

View file

@ -0,0 +1,35 @@
'use strict';
angular.module('ffffng')
.controller('ConfirmMonitoringCtrl', function ($scope, Navigator, MonitoringService, $routeParams, config) {
if (!config.monitoring.enabled) {
Navigator.home();
return;
}
$scope.config = config;
$scope.monitoringInfo = {};
$scope.monitoringStatus = 'loading';
MonitoringService.confirm($routeParams['mac'], $routeParams['token'])
.then(
function (response) {
// success
$scope.monitoringInfo = response.data;
$scope.monitoringStatus = 'confirmed';
},
function () {
// error
$scope.monitoringStatus = 'error';
}
);
$scope.goHome = function () {
Navigator.home();
};
$scope.goToUpdate = function () {
Navigator.updateNode();
};
});

View file

@ -123,6 +123,10 @@ angular.module('ffffng')
return $scope.nodeForm && $scope.nodeForm[field].$invalid && submitted;
};
$scope.monitoringActive = function () {
return $scope.node.monitoring && monitoringConfirmed && $scope.node.email === initialEmail;
};
$scope.monitoringInitialConfirmationRequired = function () {
return $scope.node.monitoring
&& ($scope.action === 'create' || $scope.node.email !== initialEmail || !initialMonitoring);
@ -151,7 +155,8 @@ angular.module('ffffng')
}
$scope.error = null;
$scope.save(node).error(function (response, code) {
$scope.save(node).catch(function (response, code) {
// error
switch (code) {
case 409: // conflict
$scope.error = duplicateError[response.field];

View file

@ -15,7 +15,7 @@ angular.module('ffffng')
$scope.error = null;
$scope.onSubmit(token)
.error(function (response, code) {
.catch(function (response, code) {
switch (code) {
case 404: // not found
$scope.error = 'Zum Token wurde kein passender Eintrag gefunden.';

View file

@ -0,0 +1,13 @@
'use strict';
angular.module('ffffng')
.service('MonitoringService', function ($http, $q) {
return {
'confirm': function (mac, token) {
if (!mac || !token) {
return $q.reject({});
}
return $http.put('/api/monitoring/confirm/' + mac + '?token=' + token);
}
};
});