Link to disable monitoring
This commit is contained in:
parent
0bdce5debb
commit
5a5c70cfb1
10 changed files with 230 additions and 0 deletions
|
@ -51,6 +51,7 @@
|
|||
<script src="scripts/controllers/updateNodeCtrl.js"></script>
|
||||
<script src="scripts/controllers/deleteNodeCtrl.js"></script>
|
||||
<script src="scripts/controllers/confirmMonitoringCtrl.js"></script>
|
||||
<script src="scripts/controllers/disableMonitoringCtrl.js"></script>
|
||||
|
||||
<script src="scripts/services/nodeService.js"></script>
|
||||
<script src="scripts/services/monitoringService.js"></script>
|
||||
|
|
|
@ -36,6 +36,11 @@ angular.module('ffffng', [
|
|||
controller: 'ConfirmMonitoringCtrl',
|
||||
title: 'Versand von Status-E-Mails bestätigen'
|
||||
})
|
||||
.when('/monitoring/disable', {
|
||||
templateUrl: 'views/disableMonitoring.html',
|
||||
controller: 'DisableMonitoringCtrl',
|
||||
title: 'Versand von Status-E-Mails deaktivieren'
|
||||
})
|
||||
.otherwise({
|
||||
redirectTo: '/'
|
||||
});
|
||||
|
|
35
app/scripts/controllers/disableMonitoringCtrl.js
Normal file
35
app/scripts/controllers/disableMonitoringCtrl.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ffffng')
|
||||
.controller('DisableMonitoringCtrl', function ($scope, Navigator, MonitoringService, $routeParams, config) {
|
||||
if (!config.monitoring.enabled) {
|
||||
Navigator.home();
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.config = config;
|
||||
|
||||
$scope.monitoringInfo = {};
|
||||
$scope.monitoringStatus = 'loading';
|
||||
|
||||
MonitoringService.disable($routeParams['mac'], $routeParams['token'])
|
||||
.then(
|
||||
function (response) {
|
||||
// success
|
||||
$scope.monitoringInfo = response.data;
|
||||
$scope.monitoringStatus = 'disabled';
|
||||
},
|
||||
function () {
|
||||
// error
|
||||
$scope.monitoringStatus = 'error';
|
||||
}
|
||||
);
|
||||
|
||||
$scope.goHome = function () {
|
||||
Navigator.home();
|
||||
};
|
||||
|
||||
$scope.goToUpdate = function () {
|
||||
Navigator.updateNode();
|
||||
};
|
||||
});
|
|
@ -8,6 +8,13 @@ angular.module('ffffng')
|
|||
return $q.reject({});
|
||||
}
|
||||
return $http.put('/api/monitoring/confirm/' + mac + '?token=' + token);
|
||||
},
|
||||
|
||||
'disable': function (mac, token) {
|
||||
if (!mac || !token) {
|
||||
return $q.reject({});
|
||||
}
|
||||
return $http.put('/api/monitoring/disable/' + mac + '?token=' + token);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
@import "views/_updateNodeForm";
|
||||
@import "views/_deleteNodeForm";
|
||||
@import "views/_confirmMonitoring";
|
||||
@import "views/_disableMonitoring";
|
||||
@import "views/directives/_help";
|
||||
@import "views/directives/_nodeForm";
|
||||
@import "views/directives/_nodeSaved";
|
||||
|
|
55
app/styles/views/_disableMonitoring.scss
Normal file
55
app/styles/views/_disableMonitoring.scss
Normal file
|
@ -0,0 +1,55 @@
|
|||
.disable-monitoring {
|
||||
@extend .jumbotron, .container;
|
||||
|
||||
.actions {
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.back-button {
|
||||
@extend .btn, .btn-lg, .btn-info;
|
||||
}
|
||||
|
||||
.summary {
|
||||
@extend .well;
|
||||
|
||||
display: table;
|
||||
margin: {
|
||||
left: auto;
|
||||
right: auto;
|
||||
top: 30px;
|
||||
bottom: 30px;
|
||||
};
|
||||
|
||||
border: 3px dashed $gray;
|
||||
|
||||
.icon {
|
||||
@extend .fa, .fa-heartbeat;
|
||||
|
||||
display: table-cell;
|
||||
|
||||
color: $gray-light;
|
||||
font-size: 64px;
|
||||
}
|
||||
|
||||
.node {
|
||||
@extend .dl-horizontal;
|
||||
|
||||
display: table-cell;
|
||||
|
||||
overflow: hidden;
|
||||
|
||||
font-family: monospace;
|
||||
font-size: 24px;
|
||||
|
||||
dt {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
dd {
|
||||
text-overflow: ellipsis;
|
||||
margin-left: 120px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
app/views/disableMonitoring.html
Normal file
75
app/views/disableMonitoring.html
Normal file
|
@ -0,0 +1,75 @@
|
|||
<div class="disable-monitoring" ng-switch="monitoringStatus">
|
||||
<h2 ng-switch-when="loading">Einen Moment bitte...</h2>
|
||||
|
||||
<div ng-switch-when="disabled">
|
||||
<h2>Der Versand von Status-E-Mails ist nun deaktiviert!</h2>
|
||||
|
||||
<p>
|
||||
Für diesen Knoten wirst Du in Zukunft keine weiteren Status-E-Mails mehr erhalten. Bitte habe Verständnis
|
||||
dafür, dass das An- und Abschalten des Versands für jeden Deiner Knoten einzeln erfolgt.
|
||||
</p>
|
||||
|
||||
<div class="summary">
|
||||
<i class="icon"></i>
|
||||
<dl class="node">
|
||||
<dt>Name</dt>
|
||||
<dd>{{monitoringInfo.hostname}}</dd>
|
||||
|
||||
<dt>MAC</dt>
|
||||
<dd>{{monitoringInfo.mac}}</dd>
|
||||
|
||||
<dt><i class="fa fa-envelope"></i></dt>
|
||||
<dd>{{monitoringInfo.email}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<em>
|
||||
Möchtest Du wieder Status-E-Mails zu Deinem Knoten erhalten, so kannst Du den Versand
|
||||
jederzeit unter <a href="javascript:" ng-click="goToUpdate()">„Knotendaten ändern“</a> reaktivieren.
|
||||
Gib dazu dort Dein Token ein und scrolle dann ganz nach unten.
|
||||
</em>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Bei Fragen wende Dich gerne an
|
||||
<a href="mailto:{{ config.community.contactEmail }}">{{ config.community.contactEmail }}</a>.
|
||||
</p>
|
||||
|
||||
<div class="actions">
|
||||
<button class="back-button" ng-click="goHome()"><i class="fa fa-reply"></i> Zurück zum Anfang</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-switch-when="error">
|
||||
<h2>Die Deaktivierung des Versands von Status-E-Mails ist fehlgeschlagen</h2>
|
||||
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<p><strong>Dies kann mehrere Gründe haben:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li>Du hast zwischenzeitlich die E-Mail-Adresse für den Knoten geändert.</li>
|
||||
<li>Du hast den Link nicht vollständig aus der E-Mail kopiert.</li>
|
||||
<li>Es ist ein interner Fehler aufgetreten.</li>
|
||||
<li>Der Versand von Status-E-Mail ist bereits deaktiviert.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Um zu prüfen, ob der Versand bereits deaktiviert ist, gehe bitte auf
|
||||
<a href="javascript:" ng-click="goToUpdate()">„Knotendaten ändern“</a>, gib dort Dein Token ein
|
||||
und scrolle dann ganz nach unten. Dort kannst Du auch den Versand manuell an- und abschalten.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>
|
||||
Sollte das Problem so nicht zu beheben sein, wende Dich gerne an
|
||||
<a href="mailto:{{ config.community.contactEmail }}">{{ config.community.contactEmail }}</a>.
|
||||
</strong>
|
||||
</p>
|
||||
|
||||
<div class="actions">
|
||||
<button class="back-button" ng-click="goHome()"><i class="fa fa-reply"></i> Zurück zum Anfang</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -34,9 +34,36 @@ angular.module('ffffng').factory('MonitoringResource', function (
|
|||
hostname: node.hostname,
|
||||
mac: node.mac,
|
||||
email: node.email,
|
||||
monitoring: node.monitoring,
|
||||
monitoringConfirmed: node.monitoringConfirmed
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
disable: function (req, res) {
|
||||
var data = Resources.getData(req);
|
||||
|
||||
var mac = Strings.normalizeMac(data.mac);
|
||||
if (!isValidMac(mac)) {
|
||||
return Resources.error(res, {data: 'Invalid MAC.', type: ErrorTypes.badRequest});
|
||||
}
|
||||
|
||||
var token = Strings.normalizeString(data.token);
|
||||
if (!isValidToken(token)) {
|
||||
return Resources.error(res, {data: 'Invalid token.', type: ErrorTypes.badRequest});
|
||||
}
|
||||
|
||||
return MonitoringService.disable(mac, token, function (err, node) {
|
||||
if (err) {
|
||||
return Resources.error(res, err);
|
||||
}
|
||||
return Resources.success(res, {
|
||||
hostname: node.hostname,
|
||||
mac: node.mac,
|
||||
email: node.email,
|
||||
monitoring: node.monitoring
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ angular.module('ffffng').factory('Router', function (app, NodeResource, Monitori
|
|||
app.get('/api/node/:token', NodeResource.get);
|
||||
|
||||
app.put('/api/monitoring/confirm/:mac', MonitoringResource.confirm);
|
||||
app.put('/api/monitoring/disable/:mac', MonitoringResource.disable);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -18,6 +18,29 @@ angular.module('ffffng')
|
|||
}
|
||||
|
||||
node.monitoringConfirmed = true;
|
||||
NodeService.internalUpdateNode(node.token, node, nodeSecrets, function (err, token, node) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, node);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
disable: function (mac, token, callback) {
|
||||
NodeService.getNodeDataByMac(mac, function (err, node, nodeSecrets) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!node.monitoring || !nodeSecrets.monitoringToken || nodeSecrets.monitoringToken !== token) {
|
||||
return callback({data: 'Invalid token.', type: ErrorTypes.badRequest});
|
||||
}
|
||||
|
||||
node.monitoring = false;
|
||||
node.monitoringConfirmed = false;
|
||||
nodeSecrets.monitoringToken = '';
|
||||
|
||||
NodeService.internalUpdateNode(node.token, node, nodeSecrets, function (err, token, node) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
|
|
Loading…
Reference in a new issue