Skip to content

Commit bac830c

Browse files
committed
first commit
0 parents  commit bac830c

29 files changed

+2696
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
phpunit.phar
3+
/vendor
4+
composer.phar
5+
composer.lock
6+
*.project
7+
.idea/

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Jens Segers
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Redis manager for laravel-admin
2+
========================
3+
4+
[![StyleCI](https://styleci.io/repos/97667375/shield?branch=master)](https://styleci.io/repos/97667375)
5+
[![Packagist](https://img.shields.io/packagist/l/laravel-admin-ext/redis-manager.svg?maxAge=2592000)](https://packagist.org/packages/laravel-admin-ext/redis-manager)
6+
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-admin-ext/redis-manager.svg?style=flat-square)](https://packagist.org/packages/laravel-admin-ext/redis-manager)
7+
[![Pull request welcome](https://img.shields.io/badge/pr-welcome-green.svg?style=flat-square)]()
8+
9+
## Screenshot
10+
11+
![wx20180413-100502](https://user-images.githubusercontent.com/1479100/38713113-23d561a2-3f02-11e8-9a24-9ecba5f1ea17.png)
12+
13+
## Installation
14+
15+
```
16+
$ composer require laravel-admin-ext/redis-manager
17+
18+
$ php artisan admin:import redis-manager
19+
```
20+
21+
Open `http://your-host/admin/redis` in your browser.
22+
23+
License
24+
------------
25+
Licensed under [The MIT License (MIT)](LICENSE).

composer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "laravel-admin-ext/redis-manager",
3+
"description": "Redis manager for laravel-admin",
4+
"type": "library",
5+
"keywords": ["laravel-admin", "redis", "manager"],
6+
"homepage": "https://github.com/laravel-admin-extensions/redis-manager",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "z-song",
11+
"email": "[email protected]"
12+
}
13+
],
14+
"require": {
15+
"php": ">=7.0.0",
16+
"laravel/framework": "5.5.*",
17+
"encore/laravel-admin": "1.5.*",
18+
"predis/predis": "~1.0"
19+
},
20+
"require-dev": {
21+
"phpunit/phpunit": "~6.0",
22+
"laravel/laravel": "5.*"
23+
},
24+
"autoload": {
25+
"psr-4": {
26+
"Encore\\Admin\\RedisManager\\": "src/"
27+
}
28+
},
29+
"extra": {
30+
"laravel": {
31+
"providers": [
32+
"Encore\\Admin\\RedisManager\\RedisManagerServiceProvider"
33+
]
34+
35+
}
36+
}
37+
}

resources/views/console.blade.php

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
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 = '&#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>
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

resources/views/create/hash.blade.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
@extends('laravel-admin-redis-manager::layout')
2+
3+
@section('page')
4+
5+
<div class="box box-primary">
6+
<div class="box-header with-border">
7+
<h3 class="box-title">Edit</h3> <small></small>
8+
</div>
9+
10+
11+
<form class="form-horizontal" method="post" action="{{ route('redis-store-key') }}" pjax-container>
12+
13+
<div class="box-body">
14+
15+
<div class="form-group">
16+
<label for="inputKey" class="col-sm-2 control-label">Key</label>
17+
18+
<div class="col-sm-10">
19+
<input type="text" class="form-control" id="inputKey" placeholder="key" name="key">
20+
</div>
21+
</div>
22+
23+
<div class="form-group">
24+
<label for="inputExpire" class="col-sm-2 control-label">Expires</label>
25+
26+
<div class="col-sm-10">
27+
<input type="number" class="form-control" name="ttl" id="inputExpire" value="-1">
28+
</div>
29+
</div>
30+
31+
<div class="form-group">
32+
<label class="col-sm-2 control-label">Field</label>
33+
34+
<div class="col-sm-10">
35+
<input class="form-control" name="field">
36+
</div>
37+
</div>
38+
39+
<div class="form-group">
40+
<label class="col-sm-2 control-label">Value</label>
41+
42+
<div class="col-sm-10">
43+
<input class="form-control" name="value">
44+
</div>
45+
</div>
46+
47+
{{ csrf_field() }}
48+
<input type="hidden" name="conn" value="{{ $conn }}">
49+
<input type="hidden" name="type" value="hash">
50+
</div>
51+
52+
<div class="box-footer">
53+
<button type="reset" class="btn btn-default pull-right">Reset</button>
54+
<button class="btn btn-info col-sm-offset-2">Submit</button>
55+
</div>
56+
57+
</form>
58+
59+
</div>
60+
<!-- /.box-body -->
61+
62+
@endsection

resources/views/create/list.blade.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
@extends('laravel-admin-redis-manager::layout')
2+
3+
@section('page')
4+
5+
<div class="box box-primary">
6+
<div class="box-header with-border">
7+
<h3 class="box-title">Edit</h3> <small></small>
8+
</div>
9+
10+
11+
<form class="form-horizontal" method="post" action="{{ route('redis-store-key') }}" pjax-container>
12+
13+
<div class="box-body">
14+
15+
<div class="form-group">
16+
<label for="inputKey" class="col-sm-2 control-label">Key</label>
17+
18+
<div class="col-sm-10">
19+
<input type="text" class="form-control" id="inputKey" placeholder="key" name="key">
20+
</div>
21+
</div>
22+
23+
<div class="form-group">
24+
<label for="inputExpire" class="col-sm-2 control-label">Expires</label>
25+
26+
<div class="col-sm-10">
27+
<input type="number" class="form-control" id="inputExpire" value="-1" name="ttl">
28+
</div>
29+
</div>
30+
31+
<div class="form-group">
32+
<label for="inputItem" class="col-sm-2 control-label">Item</label>
33+
34+
<div class="col-sm-10">
35+
<input type="text" class="form-control" name="item" id="inputItem">
36+
</div>
37+
</div>
38+
39+
{{ csrf_field() }}
40+
<input type="hidden" name="conn" value="{{ $conn }}">
41+
<input type="hidden" name="type" value="list">
42+
</div>
43+
44+
<div class="box-footer">
45+
<button type="reset" class="btn btn-default pull-right">Reset</button>
46+
<button class="btn btn-info col-sm-offset-2">Submit</button>
47+
</div>
48+
49+
</form>
50+
51+
</div>
52+
<!-- /.box-body -->
53+
54+
@endsection

resources/views/create/nil.blade.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@extends('laravel-admin-redis-manager::layout')
2+
3+
@section('page')
4+
5+
<div class="alert alert-warning alert-dismissible">
6+
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
7+
<h4><i class="icon fa fa-warning"></i>Key [{{ request('key') }}] not exists.</h4>
8+
9+
</div>
10+
<!-- /.box-body -->
11+
12+
@endsection

0 commit comments

Comments
 (0)