add button to generate token to node configuration tab

add info message after node creation about token generation
This commit is contained in:
Jakob Schrettenbrunner 2017-01-07 18:27:19 +01:00
parent 52a395ac9a
commit a1568e5acb
2 changed files with 28 additions and 0 deletions

View file

@ -83,6 +83,7 @@ class NodesController extends Controller
'_token', '_token',
])); ]));
Alert::success('Successfully created new node. <strong>Before you can add any servers you need to first assign some IP addresses and ports.</strong>')->flash(); Alert::success('Successfully created new node. <strong>Before you can add any servers you need to first assign some IP addresses and ports.</strong>')->flash();
Alert::info('<strong>To simplify the node setup you can generate a token on the configuration tab.</strong>')->flash();
return redirect()->route('admin.nodes.view', [ return redirect()->route('admin.nodes.view', [
'id' => $new, 'id' => $new,

View file

@ -286,6 +286,12 @@
<div class="alert alert-info"> <div class="alert alert-info">
Below is the configuration file for your daemon on this node. We recommend <strong>not</strong> simply copy and pasting the code below unless you know what you are doing. You should run the <code>auto-installer</code> or <code>auto-updater</code> to setup the daemon. Below is the configuration file for your daemon on this node. We recommend <strong>not</strong> simply copy and pasting the code below unless you know what you are doing. You should run the <code>auto-installer</code> or <code>auto-updater</code> to setup the daemon.
</div> </div>
<div class="col-md-12">
<p>You can generate a token for automatic setups. Pressing the button below will generate a token. It can only be used once and is valid for 5 minutes. It will also provide the necessary commands to auto-configure the node.</p>
<p class="text-center">
<button type="button" id="configTokenBtn" class="btn btn-primary">Generate token</button>
</p>
</div>
<div class="col-md-12"> <div class="col-md-12">
<pre><code>{{ $node->getConfigurationAsJson(true) }}</code></pre> <pre><code>{{ $node->getConfigurationAsJson(true) }}</code></pre>
</div> </div>
@ -495,6 +501,27 @@ $(document).ready(function () {
}); });
}); });
$('#configTokenBtn').on('click', function (event) {
$.getJSON('{{ route('admin.nodes.configurationtoken', $node->id) }}')
.done(function (data) {
swal({
type: 'success',
title: 'Token created.',
text: 'Here is your token: <code>'+data.token+'</code><br />' +
'It will expire at <i>' + data.expires_at + '</i><br /><br />' +
'<p>To auto-configure your node run<br /><small><code>npm run configure -- --panel-url {{ config('app.url') }} --token '+data.token+'</code></small></p>',
html: true
})
})
.fail(function () {
swal({
title: 'Error',
text: 'Something went wrong creating your token.',
type: 'error'
});
})
})
$('.cloneElement').on('click', function (event) { $('.cloneElement').on('click', function (event) {
event.preventDefault(); event.preventDefault();
var rnd = randomKey(10); var rnd = randomKey(10);