token-validator: use SuffixIP, can modify it and can delete tunnels
This commit is contained in:
parent
060831d9c2
commit
da1920673d
4 changed files with 137 additions and 9 deletions
|
|
@ -44,6 +44,17 @@ angular.module("AdLinApp")
|
|||
}
|
||||
})
|
||||
|
||||
.directive('integer', function() {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function(scope, ele, attr, ctrl){
|
||||
ctrl.$parsers.unshift(function(viewValue){
|
||||
return parseInt(viewValue, 10);
|
||||
});
|
||||
}
|
||||
};
|
||||
})
|
||||
|
||||
.component('toast', {
|
||||
bindings: {
|
||||
date: '=',
|
||||
|
|
@ -150,7 +161,10 @@ angular.module("AdLinApp")
|
|||
};
|
||||
$scope.updateTunnelInfo();
|
||||
|
||||
$scope.updateTunnelsList = function() {
|
||||
var noUpdate = 0
|
||||
|
||||
$scope.updateTunnelsList = function() {
|
||||
if (noUpdate == 0)
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: "api/wg/",
|
||||
|
|
@ -211,11 +225,48 @@ angular.module("AdLinApp")
|
|||
});
|
||||
}
|
||||
|
||||
$scope.editTunnel = function(tunnel) {
|
||||
tunnel.edit = true;
|
||||
noUpdate++;
|
||||
tunnel.newData = {
|
||||
TokenText: tunnel.TokenText,
|
||||
SuffixIP: tunnel.SuffixIP,
|
||||
}
|
||||
};
|
||||
|
||||
$scope.updateTunnel = function(tunnel) {
|
||||
tunnel.pleaseWaitUpdate = true;
|
||||
$http({
|
||||
method: 'PUT',
|
||||
url: "api/wg/" + encodeURIComponent(tunnel.TokenText),
|
||||
data: tunnel.newData
|
||||
}).then(function(response) {
|
||||
noUpdate--;
|
||||
tunnel.SuffixIP = tunnel.newData.SuffixIP;
|
||||
tunnel.TokenText = tunnel.newData.TokenText;
|
||||
tunnel.edit = false;
|
||||
tunnel.pleaseWaitUpdate = false;
|
||||
$scope.updateTunnelsList();
|
||||
$scope.addToast({
|
||||
variant: "success",
|
||||
title: "Maatma Tunnels",
|
||||
msg: "Tunnel mise à jour avec succès !",
|
||||
});
|
||||
}, function(response) {
|
||||
tunnel.pleaseWaitUpdate = false;
|
||||
$scope.addToast({
|
||||
variant: "danger",
|
||||
title: "Maatma Tunnels",
|
||||
msg: (response.data ? response.data.errmsg : "Impossible de contacter le serveur"),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$scope.dropTunnel = function(tunnel) {
|
||||
tunnel.pleaseWaitDrop = true;
|
||||
$http({
|
||||
method: 'DELETE',
|
||||
url: "api/wg/" + tunnel.TokenText,
|
||||
url: "api/wg/" + encodeURIComponent(tunnel.TokenText),
|
||||
data: {}
|
||||
}).then(function(response) {
|
||||
$scope.updateTunnelsList();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
<tr>
|
||||
<th></th>
|
||||
<th>Token</th>
|
||||
<th>Suffix</th>
|
||||
<th>Dernière utilisation</th>
|
||||
<th>Clef publique</th>
|
||||
</tr>
|
||||
|
|
@ -18,10 +19,22 @@
|
|||
<span ng-if="!tunnel.Dump">❌</span>
|
||||
</td>
|
||||
<td><code>{{ tunnel.TokenText }}</code></td>
|
||||
<td ng-if="tunnel.edit">
|
||||
<input class="form-control" ng-model="tunnel.newData.SuffixIP" placeholder="Suffixe d'IP par défaut" autofocus integer>
|
||||
</td>
|
||||
<td ng-if="!tunnel.edit && tunnel.SuffixIP">{{ tunnel.SuffixIP }}</td>
|
||||
<td ng-if="!tunnel.edit && !tunnel.SuffixIP">Par défaut</td>
|
||||
<td>{{ tunnel.Time | date:"medium" }}<span ng-if="tunnel.Version"> (VM TP {{ tunnel.Version }})</span></td>
|
||||
<td><code ng-show="tunnel.PubKey">{{ tunnel.PubKey }}</code><span ng-show="!tunnel.PubKey">(none)</span></td>
|
||||
<td><code class="text-truncate" title="{{ tunnel.PubKey }}" ng-show="tunnel.PubKey">{{ tunnel.PubKey }}</code><span ng-show="!tunnel.PubKey">(none)</span></td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-danger" ng-click="dropTunnel(tunnel)" disabled>
|
||||
<button class="btn btn-sm btn-info" ng-click="editTunnel(tunnel)" ng-if="!tunnel.edit">
|
||||
Éditer
|
||||
</button>
|
||||
<button class="btn btn-sm btn-success" ng-click="updateTunnel(tunnel)" ng-if="tunnel.edit">
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" ng-show="tunnel.pleaseWaitUpdate"></span>
|
||||
Enregistrer
|
||||
</button>
|
||||
<button class="btn btn-sm btn-danger" ng-click="dropTunnel(tunnel)">
|
||||
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" ng-show="tunnel.pleaseWaitDrop"></span>
|
||||
Révoquer
|
||||
</button>
|
||||
|
|
|
|||
Reference in a new issue