Skip to content

Commit a1568e5

Browse files
committed
add button to generate token to node configuration tab
add info message after node creation about token generation
1 parent 52a395a commit a1568e5

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

app/Http/Controllers/Admin/NodesController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function postNew(Request $request)
8383
'_token',
8484
]));
8585
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();
86+
Alert::info('<strong>To simplify the node setup you can generate a token on the configuration tab.</strong>')->flash();
8687

8788
return redirect()->route('admin.nodes.view', [
8889
'id' => $new,

resources/views/admin/nodes/view.blade.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,12 @@
286286
<div class="alert alert-info">
287287
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.
288288
</div>
289+
<div class="col-md-12">
290+
<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>
291+
<p class="text-center">
292+
<button type="button" id="configTokenBtn" class="btn btn-primary">Generate token</button>
293+
</p>
294+
</div>
289295
<div class="col-md-12">
290296
<pre><code>{{ $node->getConfigurationAsJson(true) }}</code></pre>
291297
</div>
@@ -495,6 +501,27 @@
495501
});
496502
});
497503
504+
$('#configTokenBtn').on('click', function (event) {
505+
$.getJSON('{{ route('admin.nodes.configurationtoken', $node->id) }}')
506+
.done(function (data) {
507+
swal({
508+
type: 'success',
509+
title: 'Token created.',
510+
text: 'Here is your token: <code>'+data.token+'</code><br />' +
511+
'It will expire at <i>' + data.expires_at + '</i><br /><br />' +
512+
'<p>To auto-configure your node run<br /><small><code>npm run configure -- --panel-url {{ config('app.url') }} --token '+data.token+'</code></small></p>',
513+
html: true
514+
})
515+
})
516+
.fail(function () {
517+
swal({
518+
title: 'Error',
519+
text: 'Something went wrong creating your token.',
520+
type: 'error'
521+
});
522+
})
523+
})
524+
498525
$('.cloneElement').on('click', function (event) {
499526
event.preventDefault();
500527
var rnd = randomKey(10);

0 commit comments

Comments
 (0)