forked from barryvdh/laravel-debugbar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a forget button in the cache panel (barryvdh#728)
* feat: add a forget button in the cache panel * LaravelCacheWidget now extends TimelineWidget * fix: escape value
- Loading branch information
Showing
6 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php namespace Barryvdh\Debugbar\Controllers; | ||
|
||
use Illuminate\Http\Response; | ||
|
||
class CacheController extends BaseController | ||
{ | ||
/** | ||
* Forget a cache key | ||
* | ||
*/ | ||
public function delete($key, $tags = '') | ||
{ | ||
$cache = app('cache'); | ||
|
||
if (!empty($tags)) { | ||
$tags = json_decode($tags, true); | ||
$cache = $cache->tags($tags); | ||
} else { | ||
unset($tags); | ||
} | ||
|
||
$success = $cache->forget($key); | ||
|
||
return response()->json(compact('success')); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
(function($) { | ||
|
||
var csscls = PhpDebugBar.utils.makecsscls('phpdebugbar-widgets-'); | ||
|
||
/** | ||
* Widget for the displaying cache events | ||
* | ||
* Options: | ||
* - data | ||
*/ | ||
var LaravelCacheWidget = PhpDebugBar.Widgets.LaravelCacheWidget = PhpDebugBar.Widgets.TimelineWidget.extend({ | ||
|
||
tagName: 'ul', | ||
|
||
className: csscls('timeline cache'), | ||
|
||
onForgetClick: function(e, el) { | ||
e.stopPropagation(); | ||
|
||
$.ajax({ | ||
url: $(el).attr("data-url"), | ||
type: 'DELETE', | ||
success: function(result) { | ||
$(el).fadeOut(200); | ||
} | ||
}); | ||
}, | ||
|
||
render: function() { | ||
LaravelCacheWidget.__super__.render.apply(this); | ||
|
||
this.bindAttr('data', function(data) { | ||
|
||
if (data.measures) { | ||
var self = this; | ||
var lines = this.$el.find('.'+csscls('measure')); | ||
|
||
for (var i = 0; i < data.measures.length; i++) { | ||
var measure = data.measures[i]; | ||
var m = lines[i]; | ||
|
||
if (measure.params && !$.isEmptyObject(measure.params)) { | ||
|
||
if (measure.params.delete && measure.params.key) { | ||
$('<a />') | ||
.addClass(csscls('forget')) | ||
.text('forget') | ||
.attr('data-url', measure.params.delete) | ||
.one('click', function(e) { self.onForgetClick(e, this); }) | ||
.appendTo(m); | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
})(PhpDebugBar.$); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters