database.blade.php 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <script> Sfdump = window.Sfdump || (function (doc) { var refStyle = doc.createElement('style'), rxEsc = /([.*+?^${}()|\[\]\/\\])/g, idRx = /\bsf-dump-\d+-ref[012]\w+\b/, keyHint = 0 <= navigator.platform.toUpperCase().indexOf('MAC') ? 'Cmd' : 'Ctrl', addEventListener = function (e, n, cb) { e.addEventListener(n, cb, false); }; (doc.documentElement.firstElementChild || doc.documentElement.children[0]).appendChild(refStyle); if (!doc.addEventListener) { addEventListener = function (element, eventName, callback) { element.attachEvent('on' + eventName, function (e) { e.preventDefault = function () {e.returnValue = false;}; e.target = e.srcElement; callback(e); }); }; } function toggle(a, recursive) { var s = a.nextSibling || {}, oldClass = s.className, arrow, newClass; if ('sf-dump-compact' == oldClass) { arrow = '&#9660;'; newClass = 'sf-dump-expanded'; } else if ('sf-dump-expanded' == oldClass) { arrow = '&#9654;'; newClass = 'sf-dump-compact'; } else { return false; } a.lastChild.innerHTML = arrow; s.className = newClass; if (recursive) { try { a = s.querySelectorAll('.'+oldClass); for (s = 0; s < a.length; ++s) { if (a[s].className !== newClass) { a[s].className = newClass; a[s].previousSibling.lastChild.innerHTML = arrow; } } } catch (e) { } } return true; }; return function (root) { root = doc.getElementById(root); function a(e, f) { addEventListener(root, e, function (e) { if ('A' == e.target.tagName) { f(e.target, e); } else if ('A' == e.target.parentNode.tagName) { f(e.target.parentNode, e); } }); }; function isCtrlKey(e) { return e.ctrlKey || e.metaKey; } addEventListener(root, 'mouseover', function (e) { if ('' != refStyle.innerHTML) { refStyle.innerHTML = ''; } }); a('mouseover', function (a) { if (a = idRx.exec(a.className)) { try { refStyle.innerHTML = 'pre.sf-dump .'+a[0]+'{background-color: #B729D9; color: #FFF !important; border-radius: 2px}'; } catch (e) { } } }); a('click', function (a, e) { if (/\bsf-dump-toggle\b/.test(a.className)) { e.preventDefault(); if (!toggle(a, isCtrlKey(e))) { var r = doc.getElementById(a.getAttribute('href').substr(1)), s = r.previousSibling, f = r.parentNode, t = a.parentNode; t.replaceChild(r, a); f.replaceChild(a, s); t.insertBefore(s, r); f = f.firstChild.nodeValue.match(indentRx); t = t.firstChild.nodeValue.match(indentRx); if (f && t && f[0] !== t[0]) { r.innerHTML = r.innerHTML.replace(new RegExp('^'+f[0].replace(rxEsc, '\\$1'), 'mg'), t[0]); } if ('sf-dump-compact' == r.className) { toggle(s, isCtrlKey(e)); } } if (doc.getSelection) { try { doc.getSelection().removeAllRanges(); } catch (e) { doc.getSelection().empty(); } } else { doc.selection.empty(); } } }); var indentRx = new RegExp('^('+(root.getAttribute('data-indent-pad') || ' ').replace(rxEsc, '\\$1')+')+', 'm'), elt = root.getElementsByTagName('A'), len = elt.length, i = 0, t = []; while (i < len) t.push(elt[i++]); elt = root.getElementsByTagName('SAMP'); len = elt.length; i = 0; while (i < len) t.push(elt[i++]); root = t; len = t.length; i = t = 0; while (i < len) { elt = root[i]; if ("SAMP" == elt.tagName) { elt.className = "sf-dump-expanded"; a = elt.previousSibling || {}; if ('A' != a.tagName) { a = doc.createElement('A'); a.className = 'sf-dump-ref'; elt.parentNode.insertBefore(a, elt); } else { a.innerHTML += ' '; } a.title = (a.title ? a.title+'\n[' : '[')+keyHint+'+click] Expand all children'; a.innerHTML += '<span>&#9660;</span>'; a.className += ' sf-dump-toggle'; if ('sf-dump' != elt.parentNode.className) { toggle(a); } } else if ("sf-dump-ref" == elt.className && (a = elt.getAttribute('href'))) { a = a.substr(1); elt.className += ' '+a; if (/[\[{]$/.test(elt.previousSibling.nodeValue)) { a = a != elt.nextSibling.id && doc.getElementById(a); try { t = a.nextSibling; elt.appendChild(a); t.parentNode.insertBefore(a, t); if (/^[@#]/.test(elt.innerHTML)) { elt.innerHTML += ' <span>&#9654;</span>'; } else { elt.innerHTML = '<span>&#9654;</span>'; elt.className = 'sf-dump-ref'; } elt.className += ' sf-dump-toggle'; } catch (e) { if ('&' == elt.innerHTML.charAt(0)) { elt.innerHTML = '&hellip;'; elt.className = 'sf-dump-ref'; } } } } ++i; } }; })(document); </script><style> pre.sf-dump { display: block; white-space: pre; padding: 5px; } pre.sf-dump span { display: inline; } pre.sf-dump .sf-dump-compact { display: none; } pre.sf-dump abbr { text-decoration: none; border: none; cursor: help; } pre.sf-dump a { text-decoration: none; cursor: pointer; border: 0; outline: none; }pre.sf-dump{ color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; word-break: normal}pre.sf-dump .sf-dump-num{font-weight:bold; color:#1299DA}pre.sf-dump .sf-dump-const{font-weight:bold}pre.sf-dump .sf-dump-str{font-weight:bold; color:#56DB3A}pre.sf-dump .sf-dump-note{color:#1299DA}pre.sf-dump .sf-dump-ref{color:#A0A0A0}pre.sf-dump .sf-dump-public{color:#FFFFFF}pre.sf-dump .sf-dump-protected{color:#FFFFFF}pre.sf-dump .sf-dump-private{color:#FFFFFF}pre.sf-dump .sf-dump-meta{color:#B729D9}pre.sf-dump .sf-dump-key{color:#56DB3A}pre.sf-dump .sf-dump-index{color:#1299DA}</style>
  2. <script>
  3. $(function () {
  4. var storageKey = function () {
  5. var connection = $('#connections').val();
  6. return 'la-'+connection+'-history'
  7. };
  8. $('#terminal-box').slimScroll({
  9. height: $('#pjax-container').height() - 205 +'px'
  10. });
  11. function History () {
  12. this.index = this.count() - 1;
  13. }
  14. History.prototype.store = function () {
  15. var history = localStorage.getItem(storageKey());
  16. if (!history) {
  17. history = [];
  18. } else {
  19. history = JSON.parse(history);
  20. }
  21. return history;
  22. };
  23. History.prototype.push = function (record) {
  24. var history = this.store();
  25. history.push(record);
  26. localStorage.setItem(storageKey(), JSON.stringify(history));
  27. this.index = this.count() - 1;
  28. };
  29. History.prototype.count = function () {
  30. return this.store().length;
  31. };
  32. History.prototype.up = function () {
  33. if (this.index > 0) {
  34. this.index--;
  35. }
  36. return this.store()[this.index];
  37. };
  38. History.prototype.down = function () {
  39. if (this.index < this.count() - 1) {
  40. this.index++;
  41. }
  42. return this.store()[this.index];
  43. };
  44. History.prototype.clear = function () {
  45. localStorage.removeItem(storageKey());
  46. };
  47. var history = new History;
  48. var send = function () {
  49. var $input = $('#terminal-query');
  50. $.ajax({
  51. url:location.pathname,
  52. method: 'post',
  53. data: {
  54. c: $('#connections').val(),
  55. q: $input.val(),
  56. _token: LA.token
  57. },
  58. success: function (response) {
  59. history.push($input.val());
  60. $('#terminal-box')
  61. .append('<div class="item"><small class="label label-default">'+$('#connections').val()+'> '+$input.val()+'<\/small><\/div>')
  62. .append('<div class="item">'+response+'<\/div>')
  63. .slimScroll({ scrollTo: $("#terminal-box")[0].scrollHeight });
  64. $input.val('');
  65. }
  66. });
  67. };
  68. $('#terminal-query').on('keyup', function (e) {
  69. if (e.keyCode == 13 && $(this).val()) {
  70. send();
  71. }
  72. if (e.keyCode == 38) {
  73. $(this).val(history.up());
  74. }
  75. if (e.keyCode == 40) {
  76. $(this).val(history.down());
  77. }
  78. });
  79. $('#terminal-send').click(function () {
  80. send();
  81. });
  82. $('#terminal-clear').click(function () {
  83. $('#terminal-box').text('');
  84. //history.clear();
  85. });
  86. });
  87. </script>
  88. <!-- Chat box -->
  89. <div class="box box-primary">
  90. <div class="box-header with-border">
  91. <i class="fa fa-terminal"></i>
  92. <div class="box-tools pull-right" data-toggle="tooltip" title="Status">
  93. <div class="input-group input-group-sm" style="width: 150px;">
  94. <select name="connection" id="connections" class="form-control pull-right" style="margin-right: 10px;">
  95. @if(!empty($connections['dbs']))
  96. <optgroup label="dbs">
  97. @foreach($connections['dbs'] as $db)
  98. <option value="{{$db['value']}}" {{ $db['selected'] ? 'selected':'' }}>{{$db['option']}}</option>
  99. @endforeach
  100. </optgroup>
  101. @endif
  102. @if(!empty($connections['redis']))
  103. <optgroup label="redis">
  104. @foreach($connections['redis'] as $redis)
  105. <option value="{{$redis['value']}}">{{$redis['option']}}</option>
  106. @endforeach
  107. </optgroup>
  108. @endif
  109. </select>
  110. </div>
  111. </div>
  112. </div>
  113. <div class="box-body chat" id="terminal-box">
  114. <!-- chat item -->
  115. <!-- /.item -->
  116. </div>
  117. <!-- /.chat -->
  118. <div class="box-footer with-border">
  119. <div class="input-group">
  120. <input class="form-control input-lg" id="terminal-query" placeholder="Type query...">
  121. <div class="input-group-btn">
  122. <button type="button" class="btn btn-primary btn-lg" id="terminal-send"><i class="fa fa-paper-plane"></i></button>
  123. </div>
  124. <div class="input-group-btn">
  125. <button type="button" class="btn btn-warning btn-lg" id="terminal-clear"><i class="fa fa-trash"></i></button>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. <!-- /.box (chat box) -->