Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ajax call tube problem when laravel installed in subdirectory #14

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Controllers/TubesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public function __construct(PheanstalkInterface $pheanstalk, JobRepository $jobs
*/
public function index()
{
$tubeNames = collect($this->pheanstalk->listTubes());
$tubeNames = $this->pheanstalk->listTubes();

// its better if tubes sorted by alphabet so we can find them faster
sort($tubeNames);

// Adam Wathan give me your strength!
$tubes = collect($tubeNames)->map(function ($tube) {
Expand All @@ -58,7 +61,7 @@ public function showTube($tube)
$nextReady = $this->jobs->nextReady($tube, true);
$nextBuried = $this->jobs->nextBuried($tube);
$nextDelayed = $this->jobs->nextDelayed($tube, true);
$prefix = config('beanstalkdui.prefix');
$prefix = url()->to('/'.config('beanstalkdui.prefix'));

return view('beanstalkdui::tubes.show', compact(
'nextReady',
Expand Down
4 changes: 1 addition & 3 deletions src/Resources/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ new Vue({

methods: {
prefixUrl: function (url){
return this.prefix.length > 0
? '/' + this.prefix + url
: url
return this.prefix + url;
},
fetchData: function () {
$.get(this.prefixUrl('/beanstalkd/api/tubes/' + this.tube), function (response) {
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/assets/js/components/job-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ var JobAction = Vue.extend({
fire: function () {
$.ajax({
url: this.prefixUrl(this.url + this.job.id),
type: this.method,
type: 'POST',
data :{'_method':this.method},
success: function (response) {
this.$dispatch('notify', response);
}.bind(this)
Expand Down
4 changes: 1 addition & 3 deletions src/Resources/assets/js/failed-jobs-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ new Vue({

methods: {
prefixUrl: function (url){
return this.prefix.length > 0
? '/' + this.prefix + url
: url
return this.prefix + url;
},
refresh: function (notify) {
$.get(this.prefixUrl('/beanstalkd/api/tubes/' + this.tube + '/failed'), function (response) {
Expand Down