1
+ @extends (' laravel-admin-redis-manager::layout' )
2
+
3
+ @section (' page' )
4
+
5
+ <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 = '▼'; newClass = 'sf-dump-expanded'; } else if ('sf-dump-expanded' == oldClass) { arrow = '▶'; 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>▼</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>▶</span>'; } else { elt.innerHTML = '<span>▶</span>'; elt.className = 'sf-dump-ref'; } elt.className += ' sf-dump-toggle'; } catch (e) { if ('&' == elt.innerHTML.charAt(0)) { elt.innerHTML = '…'; 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>
6
+
7
+ <script >
8
+
9
+ $ (function () {
10
+ $ (' #console-box' ).slimScroll ({
11
+ height: $ (' #pjax-container' ).height () - 205 + ' px'
12
+ });
13
+
14
+ var storageKey = function () {
15
+ return ' redis-history'
16
+ };
17
+
18
+ function History () {
19
+ this .index = this .count () - 1 ;
20
+ }
21
+
22
+ History .prototype .store = function () {
23
+ var history = localStorage .getItem (storageKey ());
24
+ if (! history) {
25
+ history = [];
26
+ } else {
27
+ history = JSON .parse (history);
28
+ }
29
+ return history;
30
+ };
31
+
32
+ History .prototype .push = function (record ) {
33
+ var history = this .store ();
34
+ history .push (record);
35
+ localStorage .setItem (storageKey (), JSON .stringify (history));
36
+
37
+ this .index = this .count () - 1 ;
38
+ };
39
+
40
+ History .prototype .count = function () {
41
+ return this .store ().length ;
42
+ };
43
+
44
+ History .prototype .up = function () {
45
+ if (this .index > 0 ) {
46
+ this .index -- ;
47
+ }
48
+
49
+ return this .store ()[this .index ];
50
+ };
51
+
52
+ History .prototype .down = function () {
53
+ if (this .index < this .count () - 1 ) {
54
+ this .index ++ ;
55
+ }
56
+
57
+ return this .store ()[this .index ];
58
+ };
59
+
60
+ History .prototype .clear = function () {
61
+ localStorage .removeItem (storageKey ());
62
+ };
63
+
64
+ var history = new History ;
65
+
66
+ var send = function () {
67
+
68
+ var $input = $ (' #console-query' );
69
+
70
+ $ .ajax ({
71
+ url: ' {{ route (' redis-execute' , [' conn' => $conn ]) } }' ,
72
+ method: ' post' ,
73
+ data: {
74
+ conn: ' {{ $conn } }' ,
75
+ command: $input .val (),
76
+ _token: LA .token
77
+ },
78
+ success : function (response ) {
79
+
80
+ history .push ($input .val ());
81
+
82
+ $ (' #console-box' )
83
+ .append (' <div class="item"><small class="label label-default">' + $ (' #connections' ).val ()+ ' > ' + $input .val ()+ ' <\/ small><\/ div>' )
84
+ .append (' <div class="item">' + response+ ' <\/ div>' )
85
+ .slimScroll ({ scrollTo: $ (" #console-box" )[0 ].scrollHeight });
86
+
87
+ $input .val (' ' );
88
+ }
89
+ });
90
+ };
91
+
92
+ $ (' #console-query' ).on (' keyup' , function (e ) {
93
+ if (e .keyCode == 13 && $ (this ).val ()) {
94
+ send ();
95
+ }
96
+
97
+ if (e .keyCode == 38 ) {
98
+ $ (this ).val (history .up ());
99
+ }
100
+
101
+ if (e .keyCode == 40 ) {
102
+ $ (this ).val (history .down ());
103
+ }
104
+ });
105
+
106
+ $ (' #console-send' ).click (function () {
107
+ send ();
108
+ });
109
+
110
+ $ (' #console-clear' ).click (function () {
111
+ $ (' #console-box' ).text (' ' );
112
+ });
113
+
114
+ });
115
+
116
+ </script >
117
+
118
+ <div class =" box box-primary" >
119
+ <div class =" box-header with-border" >
120
+ <h3 class =" box-title" >Redis Console</h3 > <small ></small >
121
+ </div >
122
+
123
+ <div class =" box-body chat" id =" console-box" ></div >
124
+
125
+ <div class =" box-footer with-border" >
126
+ <div class =" input-group" >
127
+
128
+ <input class =" form-control input-lg" id =" console-query" placeholder =" Type command" >
129
+
130
+ <div class =" input-group-btn" >
131
+ <button type =" button" class =" btn btn-primary btn-lg" id =" console-send" ><i class =" fa fa-paper-plane" ></i ></button >
132
+ </div >
133
+
134
+ <div class =" input-group-btn" >
135
+ <button type =" button" class =" btn btn-warning btn-lg" id =" console-clear" ><i class =" fa fa-trash" ></i ></button >
136
+ </div >
137
+ </div >
138
+ </div >
139
+
140
+ </div >
141
+ <!-- /.box-body -->
142
+
143
+ @endsection
0 commit comments