config.blade.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. @extends('admin.partial.template')
  2. @include('admin.settings.sidebar')
  3. @section('section')
  4. <div class="title">
  5. <h3 class="font-weight-bold">Configuration Settings</h3>
  6. @if($editor == false)
  7. <hr>
  8. <div class="card bg-light shadow-none rounded-0">
  9. <div class="card-body text-center py-5">
  10. <p class="lead text-muted font-weight-bold">Configuration Editor is disabled</p>
  11. <p class="mb-0">To enable it, add <code>ADMIN_ENV_EDITOR=true</code> to <code>.env</code><br>then run <code>php artisan config:cache</code></p>
  12. </div>
  13. </div>
  14. @else
  15. <p class="lead">Edit configuration settings</p>
  16. <p class="alert alert-warning">
  17. <strong>Warning:</strong> If you have opcache enabled, you may need to restart php for the changes to take effect.
  18. </p>
  19. </div>
  20. <hr>
  21. <div>
  22. <div id="editor">{{$config}}</div>
  23. <hr>
  24. <div class="d-flex justify-content-between px-3">
  25. @if($backup)
  26. <button class="btn btn-outline-secondary font-weight-bold py-1 btn-restore">Restore backup .env</button>
  27. @else
  28. <div></div>
  29. @endif
  30. <button class="btn btn-primary font-weight-bold py-1 btn-save">Save</button>
  31. </div>
  32. </div>
  33. @endif
  34. @endsection
  35. @if($editor == true)
  36. @push('scripts')
  37. <script src="{{mix('js/ace.js')}}"></script>
  38. <script>
  39. let editor = ace.edit("editor");
  40. editor.session.setUseWrapMode(true);
  41. editor.setTheme("ace/theme/monokai");
  42. editor.session.setMode("ace/mode/dot");
  43. $('.btn-restore').on('click', function(e) {
  44. e.preventDefault();
  45. let confirm = window.confirm('Are you sure you want to restore your backup .env?');
  46. if(!confirm) {
  47. swal('Cancelled', 'You have cancelled the .env backup restore.', 'warning');
  48. return;
  49. }
  50. axios.post('/i/admin/settings/config/restore', {
  51. }).then(res => {
  52. swal('Success', 'Configuration successfully restored!', 'success');
  53. setTimeout(function() {
  54. window.location.href = window.location.href;
  55. }, 3000);
  56. });
  57. })
  58. $('.btn-save').on('click', function(e) {
  59. e.preventDefault();
  60. let confirm = window.confirm('Are you sure you want to overwrite your current .env?');
  61. if(!confirm) {
  62. swal('Cancelled', 'You have cancelled the .env update.', 'warning');
  63. return;
  64. }
  65. axios.post('/i/admin/settings/config', {
  66. res: editor.getValue()
  67. }).then(res => {
  68. swal('Success', 'Configuration successfully updated!', 'success');
  69. setTimeout(function() {
  70. window.location.href = window.location.href;
  71. }, 3000);
  72. });
  73. })
  74. </script>
  75. @endpush
  76. @push('styles')
  77. <style type="text/css" media="screen">
  78. #editor {
  79. display: block;
  80. top: 0;
  81. right: 0;
  82. bottom: 0;
  83. left: 0;
  84. width: 100%;
  85. min-height: 400px;
  86. }
  87. </style>
  88. @endpush
  89. @endif