config.blade.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. @extends('admin.layouts')
  2. @section('css')
  3. <link href="/assets/global/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
  4. <link href="/assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
  5. @endsection
  6. @section('title', '控制面板')
  7. @section('content')
  8. <!-- BEGIN CONTENT BODY -->
  9. <div class="page-content">
  10. <!-- BEGIN PAGE BREADCRUMB -->
  11. <ul class="page-breadcrumb breadcrumb">
  12. <li>
  13. <a href="javascript:;">设置</a>
  14. <i class="fa fa-circle"></i>
  15. </li>
  16. <li>
  17. <a href="{{url('admin/config')}}">通用配置</a>
  18. </li>
  19. </ul>
  20. <!-- END PAGE BREADCRUMB -->
  21. <!-- BEGIN PAGE BASE CONTENT -->
  22. <div class="row">
  23. <div class="col-md-12">
  24. <!-- BEGIN EXAMPLE TABLE PORTLET-->
  25. <div class="portlet light bordered">
  26. <div class="portlet-title">
  27. <div class="caption font-dark">
  28. <i class="icon-info font-dark"></i>
  29. <span class="caption-subject bold uppercase"> 通用配置 </span>
  30. </div>
  31. <div class="actions">
  32. <div class="btn-group">
  33. <button class="btn sbold blue" data-toggle="modal" data-target="#add_config_modal"> 新增 <i class="fa fa-plus"></i> </button>
  34. </div>
  35. </div>
  36. </div>
  37. <div class="portlet-body">
  38. <ul class="nav nav-tabs">
  39. <li @if(Request::get('tab') == '' || Request::get('tab') == '1') class="active" @endif>
  40. <a href="#tab1" data-toggle="tab"> 加密方式 </a>
  41. </li>
  42. <li @if(Request::get('tab') == '2') class="active" @endif>
  43. <a href="#tab2" data-toggle="tab"> 协议 </a>
  44. </li>
  45. <li @if(Request::get('tab') == '3') class="active" @endif>
  46. <a href="#tab3" data-toggle="tab"> 混淆 </a>
  47. </li>
  48. </ul>
  49. <div class="tab-content">
  50. <div class="tab-pane fade {{Request::get('tab') == '' || Request::get('tab') == '1' ? 'active in' : ''}}" id="tab1">
  51. <div class="table-scrollable">
  52. <table class="table table-striped table-bordered table-hover table-checkable order-column">
  53. <thead>
  54. <tr>
  55. <th> ID </th>
  56. <th> 名称 </th>
  57. <th> 操作 </th>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. @if($method_list->isEmpty())
  62. <tr>
  63. <td colspan="4">暂无数据</td>
  64. </tr>
  65. @else
  66. @foreach($method_list as $method)
  67. <tr class="odd gradeX">
  68. <td> {{$method->id}} </td>
  69. <td> {{$method->name}} @if($method->is_default) <small><span class='label label-info label-sm'>默认</span></small> @endif </td>
  70. <td>
  71. @if(!$method->is_default)
  72. <button type="button" class="btn btn-sm blue btn-outline" onclick="setDefault('1', '{{$method->id}}')">默认</button>
  73. <button type="button" class="btn btn-sm red btn-outline" onclick="delConfig('1', '{{$method->id}}')">删除</button>
  74. @endif
  75. </td>
  76. </tr>
  77. @endforeach
  78. @endif
  79. </tbody>
  80. </table>
  81. </div>
  82. </div>
  83. <div class="tab-pane fade {{Request::get('tab') == '2' ? 'active in' : ''}}" id="tab2">
  84. <div class="table-scrollable">
  85. <table class="table table-striped table-bordered table-hover table-checkable order-column">
  86. <thead>
  87. <tr>
  88. <th> ID </th>
  89. <th> 名称 </th>
  90. <th> 操作 </th>
  91. </tr>
  92. </thead>
  93. <tbody>
  94. @if($method_list->isEmpty())
  95. <tr>
  96. <td colspan="4">暂无数据</td>
  97. </tr>
  98. @else
  99. @foreach($protocol_list as $protocol)
  100. <tr class="odd gradeX">
  101. <td> {{$protocol->id}} </td>
  102. <td> {{$protocol->name}} @if($protocol->is_default) <small><span class='label label-info label-sm'>默认</span></small> @endif </td>
  103. <td>
  104. @if(!$protocol->is_default)
  105. <button type="button" class="btn btn-sm blue btn-outline" onclick="setDefault('2', '{{$protocol->id}}')">默认</button>
  106. <button type="button" class="btn btn-sm red btn-outline" onclick="delConfig('2', '{{$protocol->id}}')">删除</button>
  107. @endif
  108. </td>
  109. </tr>
  110. @endforeach
  111. @endif
  112. </tbody>
  113. </table>
  114. </div>
  115. </div>
  116. <div class="tab-pane fade {{Request::get('tab') == '3' ? 'active in' : ''}}" id="tab3">
  117. <div class="table-scrollable">
  118. <table class="table table-striped table-bordered table-hover table-checkable order-column">
  119. <thead>
  120. <tr>
  121. <th> ID </th>
  122. <th> 名称 </th>
  123. <th> 操作 </th>
  124. </tr>
  125. </thead>
  126. <tbody>
  127. @if($obfs_list->isEmpty())
  128. <tr>
  129. <td colspan="4">暂无数据</td>
  130. </tr>
  131. @else
  132. @foreach($obfs_list as $obfs)
  133. <tr class="odd gradeX">
  134. <td> {{$obfs->id}} </td>
  135. <td> {{$obfs->name}} @if($obfs->is_default) <small><span class='label label-info label-sm'>默认</span></small> @endif </td>
  136. <td>
  137. @if(!$obfs->is_default)
  138. <button type="button" class="btn btn-sm blue btn-outline" onclick="setDefault('3', '{{$obfs->id}}')">默认</button>
  139. <button type="button" class="btn btn-sm red btn-outline" onclick="delConfig('3', '{{$obfs->id}}')">删除</button>
  140. @endif
  141. </td>
  142. </tr>
  143. @endforeach
  144. @endif
  145. </tbody>
  146. </table>
  147. </div>
  148. </div>
  149. </div>
  150. <div class="clearfix margin-top-20"></div>
  151. <div id="add_config_modal" class="modal fade" tabindex="-1" data-focus-on="input:first" data-backdrop="static" data-keyboard="false">
  152. <div class="modal-dialog">
  153. <div class="modal-content">
  154. <div class="modal-header">
  155. <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
  156. <h4 class="modal-title">新增配置</h4>
  157. </div>
  158. <div class="modal-body">
  159. <div class="alert alert-danger" style="display: none;" id="msg"></div>
  160. <!-- BEGIN FORM-->
  161. <form action="#" method="post" class="form-horizontal">
  162. <div class="form-body">
  163. <div class="form-group">
  164. <label for="type" class="col-md-4 control-label">类型</label>
  165. <div class="col-md-6">
  166. <select class="form-control" name="type" id="type">
  167. <option value="1" selected>加密方式</option>
  168. <option value="2">协议</option>
  169. <option value="3">混淆</option>
  170. </select>
  171. </div>
  172. </div>
  173. <div class="form-group">
  174. <label for="name" class="col-md-4 control-label"> 名称 </label>
  175. <div class="col-md-6">
  176. <input type="text" class="form-control" name="name" id="name" placeholder="">
  177. </div>
  178. </div>
  179. </div>
  180. </form>
  181. <!-- END FORM-->
  182. </div>
  183. <div class="modal-footer">
  184. <button type="button" data-dismiss="modal" class="btn dark btn-outline">关闭</button>
  185. <button type="button" class="btn red btn-outline" onclick="return addConfig();">提交</button>
  186. </div>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. <!-- END EXAMPLE TABLE PORTLET-->
  193. </div>
  194. </div>
  195. <!-- END PAGE BASE CONTENT -->
  196. </div>
  197. <!-- END CONTENT BODY -->
  198. @endsection
  199. @section('script')
  200. <script src="/assets/global/plugins/bootbox/bootbox.min.js" type="text/javascript"></script>
  201. <script type="text/javascript">
  202. // modal关闭时刷新页面
  203. $(".modal").on("hidden.bs.modal", function () {
  204. window.location.reload();
  205. });
  206. // 添加配置
  207. function addConfig() {
  208. var _token = '{{csrf_token()}}';
  209. var name = $("#name").val();
  210. var type = $("#type").val();
  211. if (name == '') {
  212. $("#msg").show().html("名称不能为空");
  213. $("#name").focus();
  214. return false;
  215. }
  216. $.ajax({
  217. url:'{{url('admin/config')}}',
  218. type:"POST",
  219. data:{_token:_token, name:name, type:type},
  220. beforeSend:function(){
  221. $("#msg").show().html("正在添加");
  222. },
  223. success:function(ret){
  224. if (ret.status == 'fail') {
  225. $("#msg").show().html(ret.message);
  226. return false;
  227. }
  228. $("#add_config_modal").modal("hide");
  229. },
  230. error:function(){
  231. $("#msg").show().html("请求错误,请重试");
  232. },
  233. complete:function(){}
  234. });
  235. }
  236. // 删除配置
  237. function delConfig(tabId, id) {
  238. var _token = '{{csrf_token()}}';
  239. bootbox.confirm({
  240. message: "确定删除配置?",
  241. buttons: {
  242. confirm: {
  243. label: '确定',
  244. className: 'btn-success'
  245. },
  246. cancel: {
  247. label: '取消',
  248. className: 'btn-danger'
  249. }
  250. },
  251. callback: function (result) {
  252. if (result) {
  253. $.post("{{url('admin/delConfig')}}", {id:id, _token:_token}, function(ret){
  254. if (ret.status == 'success') {
  255. bootbox.alert(ret.message, function(){
  256. window.location.href = '{{url('admin/config?tab=')}}' + tabId;
  257. });
  258. } else {
  259. bootbox.alert(ret.message);
  260. }
  261. });
  262. }
  263. }
  264. });
  265. }
  266. // 置为默认
  267. function setDefault(tabId, id) {
  268. var _token = '{{csrf_token()}}';
  269. $.ajax({
  270. type: "POST",
  271. url: "{{url('admin/setDefaultConfig')}}",
  272. async: false,
  273. data: {_token:_token, id: id},
  274. dataType: 'json',
  275. success: function (ret) {
  276. if (ret.status == 'success') {
  277. window.location.href = '{{url('admin/config?tab=')}}' + tabId;
  278. } else {
  279. bootbox.alert(ret.message);
  280. }
  281. }
  282. });
  283. }
  284. </script>
  285. @endsection