Skip to content

Commit 51384a0

Browse files
author
songzou
committed
first commit
0 parents  commit 51384a0

18 files changed

+2021
-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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
laravel-admin-helpers
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/encore/laravel-admin-helpers.svg?maxAge=2592000)](https://packagist.org/packages/encore/laravel-admin-helpers)
6+
[![Total Downloads](https://img.shields.io/packagist/dt/encore/laravel-admin-helpers.svg?style=flat-square)](https://packagist.org/packages/encore/laravel-admin-helpers)
7+
8+
[Demo](http://120.26.143.106/admin) use `username/password:admin/admin`
9+
10+
## Installation
11+
12+
```
13+
$ composer require encore/laravel-admin-helpers
14+
15+
$ php artisan admin:import encore/laravel-admin-helpers
16+
```
17+
18+
## Usage
19+
20+
See [wiki](http://z-song.github.io/laravel-admin/#/en/helpers)
21+
22+
License
23+
------------
24+
Licensed under [The MIT License (MIT)](LICENSE).

composer.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "laravel-admin-ext/helpers",
3+
"description": "Helpers extension for laravel-admin",
4+
"type": "library",
5+
"keywords": ["laravel-admin", "helpers"],
6+
"homepage": "https://github.com/laravel-admin-extensions/helpers",
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+
},
19+
"require-dev": {
20+
"phpunit/phpunit": "~6.0",
21+
"laravel/laravel": "5.5.*"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"Encore\\Admin\\Helpers\\": "src/"
26+
}
27+
},
28+
"extra": {
29+
"laravel": {
30+
"providers": [
31+
"Encore\\Admin\\Helpers\\HelpersServiceProvider"
32+
]
33+
}
34+
}
35+
}

resources/views/artisan.blade.php

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
<script>
2+
$(function () {
3+
4+
var storageKey = function () {
5+
var connection = $('#connections').val();
6+
return 'la-'+connection+'-history'
7+
};
8+
9+
$('#terminal-box').slimScroll({
10+
height: $('#pjax-container').height() - 247 +'px'
11+
});
12+
13+
function History () {
14+
this.index = this.count() - 1;
15+
}
16+
17+
History.prototype.store = function () {
18+
var history = localStorage.getItem(storageKey());
19+
if (!history) {
20+
history = [];
21+
} else {
22+
history = JSON.parse(history);
23+
}
24+
return history;
25+
};
26+
27+
History.prototype.push = function (record) {
28+
var history = this.store();
29+
history.push(record);
30+
localStorage.setItem(storageKey(), JSON.stringify(history));
31+
32+
this.index = this.count() - 1;
33+
};
34+
35+
History.prototype.count = function () {
36+
return this.store().length;
37+
};
38+
39+
History.prototype.up = function () {
40+
if (this.index > 0) {
41+
this.index--;
42+
}
43+
44+
return this.store()[this.index];
45+
};
46+
47+
History.prototype.down = function () {
48+
if (this.index < this.count() - 1) {
49+
this.index++;
50+
}
51+
52+
return this.store()[this.index];
53+
};
54+
55+
History.prototype.clear = function () {
56+
localStorage.removeItem(storageKey());
57+
};
58+
59+
var history = new History;
60+
61+
var send = function () {
62+
63+
var $input = $('#terminal-query');
64+
65+
$.ajax({
66+
url:location.pathname,
67+
method: 'post',
68+
data: {
69+
c: $input.val(),
70+
_token: LA.token
71+
},
72+
success: function (response) {
73+
74+
history.push($input.val());
75+
76+
$('#terminal-box')
77+
.append('<div class="item"><small class="label label-default"> > artisan '+$input.val()+'<\/small><\/div>')
78+
.append('<div class="item">'+response+'<\/div>')
79+
.slimScroll({ scrollTo: $("#terminal-box")[0].scrollHeight });
80+
81+
$input.val('');
82+
}
83+
});
84+
};
85+
86+
$('#terminal-query').on('keyup', function (e) {
87+
88+
e.preventDefault();
89+
90+
if (e.keyCode == 13) {
91+
send();
92+
}
93+
94+
if (e.keyCode == 38) {
95+
$(this).val(history.up());
96+
}
97+
98+
if (e.keyCode == 40) {
99+
$(this).val(history.down());
100+
}
101+
});
102+
103+
$('#terminal-clear').click(function () {
104+
$('#terminal-box').text('');
105+
//history.clear();
106+
});
107+
108+
$('.loaded-command').click(function () {
109+
$('#terminal-query').val($(this).html() + ' ');
110+
$('#terminal-query').focus();
111+
});
112+
113+
$('#terminal-send').click(function () {
114+
send();
115+
});
116+
117+
});
118+
</script>
119+
<!-- Chat box -->
120+
<div class="box box-primary">
121+
<div class="box-header with-border">
122+
<i class="fa fa-terminal"></i>
123+
</div>
124+
<div class="box-body chat" id="terminal-box">
125+
<!-- chat item -->
126+
127+
<!-- /.item -->
128+
</div>
129+
<!-- /.chat -->
130+
<div class="box-footer with-border">
131+
132+
<div style="margin-bottom: 10px;">
133+
134+
@foreach($commands['groups'] as $group => $command)
135+
<div class="btn-group dropup">
136+
<button type="button" class="btn btn-default btn-flat">{{ $group }}</button>
137+
<button type="button" class="btn btn-default btn-flat dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
138+
<span class="caret"></span>
139+
<span class="sr-only">Toggle Dropdown</span>
140+
</button>
141+
<ul class="dropdown-menu" role="menu">
142+
@foreach($command as $item)
143+
<li><a href="#" class="loaded-command">{{$item}}</a></li>
144+
@endforeach
145+
</ul>
146+
</div>
147+
@endforeach
148+
149+
<div class="btn-group dropup">
150+
<button type="button" class="btn btn-twitter btn-flat">Other</button>
151+
<button type="button" class="btn btn-twitter btn-flat dropdown-toggle" data-toggle="dropdown">
152+
<span class="caret"></span>
153+
<span class="sr-only">Toggle Dropdown</span>
154+
</button>
155+
<ul class="dropdown-menu" role="menu">
156+
@foreach($commands['others'] as $item)
157+
<li><a href="#" class="loaded-command">{{$item}}</a></li>
158+
@endforeach
159+
</ul>
160+
</div>
161+
162+
<button type="button" class="btn btn-success" id="terminal-send"><i class="fa fa-paper-plane"></i> send</button>
163+
164+
<button type="button" class="btn btn-warning" id="terminal-clear"><i class="fa fa-refresh"></i> clear</button>
165+
</div>
166+
167+
<div class="input-group">
168+
<span class="input-group-addon" style="font-size: 18px; line-height: 1.3333333;">artisan</span>
169+
<input class="form-control input-lg" id="terminal-query" placeholder="command" style="border-left: 0px;padding-left: 0px;">
170+
</div>
171+
</div>
172+
</div>
173+
<!-- /.box (chat box) -->

0 commit comments

Comments
 (0)