Add back manage and delete tabs to server view

Will come back to deal with Startup and Database tabs at a later date.
This commit is contained in:
Dane Everitt 2017-02-25 14:14:07 -05:00
parent fb21bf9282
commit 9f54ff236a
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
4 changed files with 97 additions and 6 deletions

View file

@ -0,0 +1,23 @@
// Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
$.urlParam=function(name){var results=new RegExp("[\\?&]"+name+"=([^&#]*)").exec(decodeURIComponent(window.location.href));if(results==null){return null}else{return results[1]||0}};function getPageName(url){var index=url.lastIndexOf("/")+1;var filenameWithExtension=url.substr(index);var filename=filenameWithExtension.split(".")[0];return filename}
// Remeber Active Tab and Navigate to it on Reload
for(var queryParameters={},queryString=location.search.substring(1),re=/([^&=]+)=([^&]*)/g,m;m=re.exec(queryString);)queryParameters[decodeURIComponent(m[1])]=decodeURIComponent(m[2]);$("a[data-toggle='tab']").click(function(){queryParameters.tab=$(this).attr("href").substring(1),window.history.pushState(null,null,location.pathname+"?"+$.param(queryParameters))});
if($.urlParam('tab') != null){$('.nav.nav-tabs a[href="#' + $.urlParam('tab') + '"]').tab('show');}

View file

@ -293,13 +293,70 @@
{{-- End Database / Start Manage --}}
@if($server->installed !== 2)
<div class="tab-pane" id="tab_manage">
Manage
<div class="row">
<div class="col-sm-6 col-md-4 text-center">
<form action="/admin/servers/view/{{ $server->id }}/installed" method="POST">
{!! csrf_field() !!}
<button type="submit" class="btn btn-primary">Toggle Install Status</button>
<p class="text-muted small">This will toggle the install status for the server.</p>
</form>
</div>
<div class="col-sm-6 col-md-4 text-center">
<form action="/admin/servers/view/{{ $server->id }}/rebuild" method="POST">
{!! csrf_field() !!}
<button type="submit" class="btn btn-primary">Rebuild Server Container</button>
<p class="text-muted small">This will trigger a rebuild of the server container when it next starts up. This is useful if you modified the server configuration file manually, or something just didn't work out correctly.</p>
</form>
</div>
<div class="col-sm-6 col-md-4 text-center">
@if(! $server->suspended)
<form action="/admin/servers/view/{{ $server->id }}/suspend" method="POST">
{!! csrf_field() !!}
<button type="submit" class="btn btn-warning">Suspend Server</button>
<p class="text-muted small">This will suspend the server, stop any running processes, and immediately block the user from being able to access their files or otherwise manage the server through the panel or API.</p>
</form>
@else
<form action="/admin/servers/view/{{ $server->id }}/unsuspend" method="POST">
{!! csrf_field() !!}
<button type="submit" class="btn btn-success">Unsuspend Server</button>
<p class="text-muted small">This will unsuspend the server and restore normal user access.</p>
</form>
@endif
</div>
</div>
</div>
@endif
{{-- End Manage / Start Delete --}}
@if(! $server->trashed())
<div class="tab-pane" id="tab_delete">
Delete
<div class="row">
@if($server->installed)
<div class="col-sm-6">
<form action="/admin/servers/view/{{ $server->id }}" class="text-center" method="POST" data-attr="deleteServer">
{!! csrf_field() !!}
{!! method_field('DELETE') !!}
<button type="submit" class="btn btn-danger">Delete Server</button>
</form>
<p>
<div class="callout callout-danger">
Deleting a server is an irreversible action. <strong>All data will be immediately removed relating to this server.</strong>
</div>
</p>
</div>
@endif
<div class="col-sm-6">
<form action="/admin/servers/view/{{ $server->id }}/force" class="text-center" method="POST" data-attr="deleteServer">
{!! csrf_field() !!}
{!! method_field('DELETE') !!}
<button type="submit" class="btn btn-danger">Force Delete Server</button>
</form>
<p>
<div class="callout callout-danger">
This is the same as deleting a server, however, if an error is returned by the daemon it is ignored and the server is still removed from the panel.
</div>
</p>
</div>
</div>
</div>
@endif
{{-- End Delete --}}
@ -312,6 +369,20 @@
@section('footer-scripts')
@parent
<script>
$('form[data-attr="deleteServer"]').submit(function (event) {
event.preventDefault();
swal({
title: '',
type: 'warning',
text: 'Are you sure that you want to delete this server? There is no going back, all data will immediately be removed.',
showCancelButton: true,
confirmButtonText: 'Delete',
confirmButtonColor: '#d9534f',
closeOnConfirm: false
}, function () {
event.target.submit();
});
});
$('#pAddAllocations').select2();
$('#pRemoveAllocations').select2();
$('#pAllocation').select2();

View file

@ -193,6 +193,7 @@
{!! Theme::js('js/vendor/socketio/socket.io.min.js') !!}
{!! Theme::js('vendor/bootstrap-notify/bootstrap-notify.min.js') !!}
{!! Theme::js('vendor/select2/select2.full.min.js') !!}
{!! Theme::js('js/admin/functions.js') !!}
@show
</body>
</html>

View file

@ -212,10 +212,6 @@
</div>
<script>
$(document).ready(function () {
// Remeber Active Tab and Navigate to it on Reload
for(var queryParameters={},queryString=location.search.substring(1),re=/([^&=]+)=([^&]*)/g,m;m=re.exec(queryString);)queryParameters[decodeURIComponent(m[1])]=decodeURIComponent(m[2]);$("a[data-toggle='tab']").click(function(){queryParameters.tab=$(this).attr("href").substring(1),window.history.pushState(null,null,location.pathname+"?"+$.param(queryParameters))});
if($.urlParam('tab') != null){$('.nav.nav-tabs a[href="#' + $.urlParam('tab') + '"]').tab('show');}
@if (count($errors) > 0)
@foreach ($errors->all() as $error)
<?php preg_match('/^The\s(.*?)\sfield/', $error, $matches) ?>