mirror of
https://github.com/brunofontes/shareit.git
synced 2025-12-13 11:10:42 -03:00
Compare commits
15 Commits
b3c00d388d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
bb01401e0c
|
|||
|
3dddb712c0
|
|||
|
618d91d23b
|
|||
|
720da5a8d1
|
|||
|
3299047fb8
|
|||
|
df08525010
|
|||
|
6bc94d0ec8
|
|||
|
d083d45013
|
|||
|
3d5e484364
|
|||
|
58fe265821
|
|||
|
7c09fc4896
|
|||
|
567adce732
|
|||
|
2cd7ab11fa
|
|||
|
11162a9ffa
|
|||
|
b52f0878c8
|
53
app/Events/RefreshPage.php
Normal file
53
app/Events/RefreshPage.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use \App\Item;
|
||||||
|
|
||||||
|
use Illuminate\Broadcasting\Channel;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Broadcasting\PresenceChannel;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class RefreshPage implements ShouldBroadcastNow
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item
|
||||||
|
*
|
||||||
|
* @var Item
|
||||||
|
*/
|
||||||
|
public $item;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Item $item)
|
||||||
|
{
|
||||||
|
$this->item = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Broadcasting\Channel|array
|
||||||
|
*/
|
||||||
|
public function broadcastOn()
|
||||||
|
{
|
||||||
|
return ['touchedItem'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastAs()
|
||||||
|
{
|
||||||
|
return 'RefreshPage';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,12 +5,20 @@ namespace App\Events;
|
|||||||
use \App\Item;
|
use \App\Item;
|
||||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
use Illuminate\Broadcasting\PrivateChannel;
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||||
use Illuminate\Foundation\Events\Dispatchable;
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
class ReturnItem
|
class ReturnItem
|
||||||
{
|
{
|
||||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Item
|
||||||
|
*
|
||||||
|
* @var Item
|
||||||
|
*/
|
||||||
public $item;
|
public $item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,6 +40,11 @@ class ReturnItem
|
|||||||
*/
|
*/
|
||||||
public function broadcastOn()
|
public function broadcastOn()
|
||||||
{
|
{
|
||||||
return new PrivateChannel('channel-name');
|
return new PrivateChannel('touchedItem');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function broadcastAs()
|
||||||
|
{
|
||||||
|
return 'ReturnItem';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Events\RefreshPage;
|
||||||
use App\Events\ReturnItem;
|
use App\Events\ReturnItem;
|
||||||
use App\Item;
|
use App\Item;
|
||||||
use App\User;
|
use App\User;
|
||||||
@@ -32,6 +33,7 @@ class TakeController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefreshPage::dispatch($item);
|
||||||
return redirect('home');
|
return redirect('home');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +57,8 @@ class TakeController extends Controller
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
event(new ReturnItem($item));
|
RefreshPage::dispatch($item);
|
||||||
|
ReturnItem::dispatch($item);
|
||||||
return redirect('home');
|
return redirect('home');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class Kernel extends HttpKernel
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $routeMiddleware = [
|
protected $middlewareAliases = [
|
||||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Middleware;
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class TrustProxies extends Middleware
|
class TrustProxies extends Middleware
|
||||||
@@ -19,5 +19,10 @@ class TrustProxies extends Middleware
|
|||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
protected $headers =
|
||||||
|
Request::HEADER_X_FORWARDED_FOR |
|
||||||
|
Request::HEADER_X_FORWARDED_HOST |
|
||||||
|
Request::HEADER_X_FORWARDED_PORT |
|
||||||
|
Request::HEADER_X_FORWARDED_PROTO |
|
||||||
|
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->registerPolicies();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,23 +5,24 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3.0",
|
"php": "^8.0.2",
|
||||||
"fideloper/proxy": "^4.4",
|
"inertiajs/inertia-laravel": "^0.6.11",
|
||||||
"laravel/framework": "^8.0",
|
"laravel/framework": "^10.0",
|
||||||
|
"laravel/ui": "^4.0",
|
||||||
"laravel/helpers": "^1.4",
|
"laravel/helpers": "^1.4",
|
||||||
"laravel/tinker": "^2.4.1",
|
"laravel/tinker": "^2.4.1",
|
||||||
"laravel/ui": "^3.0"
|
"pusher/pusher-php-server": "^7.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"beyondcode/laravel-dump-server": "^1.0",
|
"beyondcode/laravel-dump-server": "^1.0",
|
||||||
"filp/whoops": "^2.0",
|
"filp/whoops": "^2.0",
|
||||||
"fzaninotto/faker": "^1.4",
|
"fzaninotto/faker": "^1.4",
|
||||||
"mockery/mockery": "^1.0",
|
"mockery/mockery": "^1.0",
|
||||||
"nunomaduro/collision": "^5.0",
|
"nunomaduro/collision": "^7.0",
|
||||||
"nunomaduro/larastan": "^0.7.4",
|
"nunomaduro/larastan": "^2.9.5",
|
||||||
"nunomaduro/phpinsights": "^1.14",
|
"nunomaduro/phpinsights": "*",
|
||||||
"phpstan/phpstan": "^0.12.85",
|
"phpstan/phpstan": "^1.10.66",
|
||||||
"phpunit/phpunit": "^9.0"
|
"phpunit/phpunit": "^10.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"classmap": [
|
"classmap": [
|
||||||
@@ -63,6 +64,6 @@
|
|||||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "stable",
|
||||||
"prefer-stable": true
|
"prefer-stable": true
|
||||||
}
|
}
|
||||||
|
|||||||
7119
composer.lock
generated
7119
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -156,7 +156,7 @@ return [
|
|||||||
*/
|
*/
|
||||||
App\Providers\AppServiceProvider::class,
|
App\Providers\AppServiceProvider::class,
|
||||||
App\Providers\AuthServiceProvider::class,
|
App\Providers\AuthServiceProvider::class,
|
||||||
// App\Providers\BroadcastServiceProvider::class,
|
App\Providers\BroadcastServiceProvider::class,
|
||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
|
|
||||||
|
|||||||
36
database/migrations/2022_11_13_183613_create_jobs_table.php
Normal file
36
database/migrations/2022_11_13_183613_create_jobs_table.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('jobs', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id');
|
||||||
|
$table->string('queue')->index();
|
||||||
|
$table->longText('payload');
|
||||||
|
$table->unsignedTinyInteger('attempts');
|
||||||
|
$table->unsignedInteger('reserved_at')->nullable();
|
||||||
|
$table->unsignedInteger('available_at');
|
||||||
|
$table->unsignedInteger('created_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('jobs');
|
||||||
|
}
|
||||||
|
};
|
||||||
16930
package-lock.json
generated
16930
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
24
package.json
24
package.json
@@ -1,26 +1,26 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm run development",
|
"dev": "vite",
|
||||||
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
"build": "vite build"
|
||||||
"watch": "npm run development -- --watch",
|
|
||||||
"watch-poll": "npm run watch -- --watch-poll",
|
|
||||||
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
|
|
||||||
"prod": "npm run production",
|
|
||||||
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"axios": "^0.21",
|
"axios": "^1.1.3",
|
||||||
"bootstrap": "^4.6.0",
|
"bootstrap": "^4.6.0",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"jquery": "^3.5.1",
|
"jquery": "^3.5.1",
|
||||||
"laravel-mix": "^6.0.18",
|
"laravel-echo": "^1.14.1",
|
||||||
|
"laravel-vite-plugin": "^0.7.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"popper.js": "^1.16.1",
|
"popper.js": "^1.16.1",
|
||||||
|
"postcss": "^8.4.19",
|
||||||
|
"pusher-js": "^7.4.1",
|
||||||
"resolve-url-loader": "^3.1.3",
|
"resolve-url-loader": "^3.1.3",
|
||||||
"sass": "^1.32.12",
|
"sass": "^1.56.1",
|
||||||
"sass-loader": "^8.0.2",
|
"sass-loader": "^8.0.2",
|
||||||
"vue": "^2.6.12",
|
"vite": "^3.2.3"
|
||||||
"vue-template-compiler": "^2.6.12"
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"moment": "^2.29.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
48
public/build/assets/app.4993c47e.js
vendored
Normal file
48
public/build/assets/app.4993c47e.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
public/build/assets/pusher.a7756fcc.js
vendored
Normal file
1
public/build/assets/pusher.a7756fcc.js
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
import"https://js.pusher.com/7.2/pusher.min.js";var n=new Pusher("93b3e504421787295454",{cluster:"us2"}),o=n.subscribe("touchedItem");o.bind("RefreshPage",function(e){window.location.reload(),console.log(JSON.stringify(e))});
|
||||||
12
public/build/manifest.json
Normal file
12
public/build/manifest.json
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"resources/js/app.js": {
|
||||||
|
"file": "assets/app.4993c47e.js",
|
||||||
|
"src": "resources/js/app.js",
|
||||||
|
"isEntry": true
|
||||||
|
},
|
||||||
|
"resources/js/pusher.js": {
|
||||||
|
"file": "assets/pusher.a7756fcc.js",
|
||||||
|
"src": "resources/js/pusher.js",
|
||||||
|
"isEntry": true
|
||||||
|
}
|
||||||
|
}
|
||||||
9252
public/css/app.css
vendored
9252
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
BIN
public/favicon.png
Normal file
BIN
public/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
46234
public/js/app.js
vendored
46234
public/js/app.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,4 +1 @@
|
|||||||
{
|
{}
|
||||||
"/js/app.js": "/js/app.js",
|
|
||||||
"/css/app.css": "/css/app.css"
|
|
||||||
}
|
|
||||||
|
|||||||
62
resources/js/app.js
vendored
62
resources/js/app.js
vendored
@@ -5,9 +5,10 @@
|
|||||||
* building robust, powerful web applications using Vue and Laravel.
|
* building robust, powerful web applications using Vue and Laravel.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require('./bootstrap');
|
import './bootstrap';
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
window.Vue = require('vue');
|
// window.Vue = require('vue');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Next, we will create a fresh Vue application instance and attach it to
|
* Next, we will create a fresh Vue application instance and attach it to
|
||||||
@@ -15,8 +16,59 @@ window.Vue = require('vue');
|
|||||||
* or customize the JavaScript scaffolding to fit your unique needs.
|
* or customize the JavaScript scaffolding to fit your unique needs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Vue.component('example-component', require('./components/ExampleComponent.vue'));
|
// Vue.component('example-component', require('./components/ExampleComponent.vue'));
|
||||||
|
|
||||||
const app = new Vue({
|
// const app = new Vue({
|
||||||
el: '#app'
|
// el: '#app'
|
||||||
|
// });
|
||||||
|
|
||||||
|
function updateTime() {
|
||||||
|
var dates = document.getElementsByClassName("takenItemDate");
|
||||||
|
for (let i = 0; i < dates.length; i++) {
|
||||||
|
let time = dates.item(i).innerText;
|
||||||
|
let fromNow = moment(time).fromNow();
|
||||||
|
let id = "itemPassedTime_" + dates.item(i).id;
|
||||||
|
document.getElementById(id).innerText = fromNow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateTime();
|
||||||
|
setInterval(updateTime, 1 * 60 * 1000);
|
||||||
|
|
||||||
|
|
||||||
|
function setFaviconNumber(number) {
|
||||||
|
var canvas = document.createElement('canvas'),
|
||||||
|
ctx,
|
||||||
|
img = document.createElement('img'),
|
||||||
|
link = document.getElementById('favicon').cloneNode(true);
|
||||||
|
|
||||||
|
if (canvas.getContext) {
|
||||||
|
canvas.height = canvas.width = 48; // set the size
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
img.onload = function () { // once the image has loaded
|
||||||
|
ctx.drawImage(this, 0, 0);
|
||||||
|
ctx.font = 'bold 35px "helvetica", sans-serif';
|
||||||
|
ctx.fillStyle = '#ffff66';
|
||||||
|
ctx.fillText(number, 3, 25);
|
||||||
|
link.href = canvas.toDataURL('image/png');
|
||||||
|
document.body.appendChild(link);
|
||||||
|
};
|
||||||
|
img.src = 'favicon.png';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
usedItems = document.getElementById("usedItems").innerText;
|
||||||
|
setFaviconNumber(usedItems);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Source:
|
||||||
|
* https://www.designcise.com/web/tutorial/how-to-detect-if-the-browser-tab-is-active-or-not-using-javascript
|
||||||
|
*/
|
||||||
|
document.addEventListener('visibilitychange', function (event) {
|
||||||
|
if (document.hidden) {
|
||||||
|
console.log('not visible');
|
||||||
|
} else {
|
||||||
|
updateTime();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
54
resources/js/bootstrap.js
vendored
54
resources/js/bootstrap.js
vendored
@@ -1,18 +1,5 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
window._ = require('lodash');
|
window._ = _;
|
||||||
window.Popper = require('popper.js').default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We'll load jQuery and the Bootstrap jQuery plugin which provides support
|
|
||||||
* for JavaScript based Bootstrap features such as modals and tabs. This
|
|
||||||
* code may be modified to fit the specific needs of your application.
|
|
||||||
*/
|
|
||||||
|
|
||||||
try {
|
|
||||||
window.$ = window.jQuery = require('jquery');
|
|
||||||
|
|
||||||
require('bootstrap');
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We'll load the axios HTTP library which allows us to easily issue requests
|
* We'll load the axios HTTP library which allows us to easily issue requests
|
||||||
@@ -20,37 +7,28 @@ try {
|
|||||||
* CSRF token as a header based on the value of the "XSRF" token cookie.
|
* CSRF token as a header based on the value of the "XSRF" token cookie.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
window.axios = require('axios');
|
import axios from 'axios';
|
||||||
|
window.axios = axios;
|
||||||
|
|
||||||
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
|
||||||
|
|
||||||
/**
|
|
||||||
* Next we will register the CSRF Token as a common header with Axios so that
|
|
||||||
* all outgoing HTTP requests automatically have it attached. This is just
|
|
||||||
* a simple convenience so we don't have to attach every token manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
let token = document.head.querySelector('meta[name="csrf-token"]');
|
|
||||||
|
|
||||||
if (token) {
|
|
||||||
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
|
|
||||||
} else {
|
|
||||||
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Echo exposes an expressive API for subscribing to channels and listening
|
* Echo exposes an expressive API for subscribing to channels and listening
|
||||||
* for events that are broadcast by Laravel. Echo and event broadcasting
|
* for events that are broadcast by Laravel. Echo and event broadcasting
|
||||||
* allows your team to easily build robust real-time web applications.
|
* allows your team to easily build robust real-time web applications.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// import Echo from 'laravel-echo'
|
import Echo from 'laravel-echo';
|
||||||
|
|
||||||
// window.Pusher = require('pusher-js');
|
import Pusher from 'pusher-js';
|
||||||
|
window.Pusher = Pusher;
|
||||||
|
|
||||||
// window.Echo = new Echo({
|
window.Echo = new Echo({
|
||||||
// broadcaster: 'pusher',
|
broadcaster: 'pusher',
|
||||||
// key: process.env.MIX_PUSHER_APP_KEY,
|
key: import.meta.env.VITE_PUSHER_APP_KEY,
|
||||||
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
|
wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`,
|
||||||
// encrypted: true
|
wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80,
|
||||||
// });
|
wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443,
|
||||||
|
forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https',
|
||||||
|
enabledTransports: ['ws', 'wss'],
|
||||||
|
});
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="container">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-8">
|
|
||||||
<div class="card card-default">
|
|
||||||
<div class="card-header">Example Component</div>
|
|
||||||
|
|
||||||
<div class="card-body">
|
|
||||||
I'm an example component.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
mounted() {
|
|
||||||
console.log('Component mounted.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
10
resources/js/pusher.js
vendored
Normal file
10
resources/js/pusher.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import 'https://js.pusher.com/7.2/pusher.min.js';
|
||||||
|
var pusher = new Pusher('93b3e504421787295454', {
|
||||||
|
cluster: 'us2'
|
||||||
|
});
|
||||||
|
|
||||||
|
var channel = pusher.subscribe('touchedItem');
|
||||||
|
channel.bind('RefreshPage', function(data) {
|
||||||
|
window.location.reload();
|
||||||
|
console.log(JSON.stringify(data));
|
||||||
|
});
|
||||||
@@ -2,15 +2,7 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
<script type="text/javascript">
|
@vite('resources/js/pusher.js')
|
||||||
setInterval(
|
|
||||||
function() {
|
|
||||||
if (!document.hasFocus() ) {
|
|
||||||
window.location.reload(true);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
2*60000); //NOTE: period is passed in milliseconds
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
@@ -53,4 +45,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
@if ($item->used_by == \Auth::id())
|
@if ($item->used_by == \Auth::id())
|
||||||
<form action="/take" method="POST" class="form-inline">
|
<form action="/take" method="POST" class="form-inline">
|
||||||
<em class="pr-sm-2 ml-auto">{{\Carbon\Carbon::parse($item->updated_at)->diffForHumans()}}</em>
|
<em id="itemPassedTime_{{$item->id}}" class="pr-sm-2 ml-auto">{{\Carbon\Carbon::parse($item->updated_at)->diffForHumans()}}</em>
|
||||||
|
<div hidden class="takenItemDate" id="{{$item->id}}">{{\Carbon\Carbon::parse($item->updated_at)->format('Y-m-d\TH:i:s.uP')}}</div>
|
||||||
<div class="w-100 d-xm-block d-sm-none"></div>
|
<div class="w-100 d-xm-block d-sm-none"></div>
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
@method('DELETE')
|
@method('DELETE')
|
||||||
@@ -16,8 +17,9 @@
|
|||||||
@if ($item->waiting_user_id && $item->waiting_user_id != \Auth::id())
|
@if ($item->waiting_user_id && $item->waiting_user_id != \Auth::id())
|
||||||
<strong>> {{str_limit($users[$item->waiting_user_id], 15, '...')}}</strong>
|
<strong>> {{str_limit($users[$item->waiting_user_id], 15, '...')}}</strong>
|
||||||
@endif
|
@endif
|
||||||
<small>({{$item->updated_at->diffForHumans()}})</small>
|
<small id="itemPassedTime_{{$item->id}}">({{$item->updated_at->diffForHumans()}})</small>
|
||||||
</em>
|
</em>
|
||||||
|
<div hidden class="takenItemDate" id="{{$item->id}}">{{$item->updated_at->format('Y-m-d\TH:i:s.uP')}}</div>
|
||||||
<div class="w-100 d-xm-block d-sm-none"></div>
|
<div class="w-100 d-xm-block d-sm-none"></div>
|
||||||
{{ csrf_field() }}
|
{{ csrf_field() }}
|
||||||
<input type="hidden" name="item" value="{{$item->id}}">
|
<input type="hidden" name="item" value="{{$item->id}}">
|
||||||
@@ -28,4 +30,4 @@
|
|||||||
<button type="submit" class="btn btn-sm btn-outline-secondary ml-auto">@lang('home.alert_me')</button>
|
<button type="submit" class="btn btn-sm btn-outline-secondary ml-auto">@lang('home.alert_me')</button>
|
||||||
@endif
|
@endif
|
||||||
</form>
|
</form>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<title>{{ config('app.name', 'Laravel') }} {{ isset($usedItems) && $usedItems > 0 ? "(${usedItems})" : '' }}</title>
|
<title>{{ config('app.name', 'Laravel') }} {{ isset($usedItems) && $usedItems > 0 ? "(${usedItems})" : '' }}</title>
|
||||||
|
|
||||||
<!-- Scripts -->
|
<!-- Scripts -->
|
||||||
<script src="{{ asset('js/app.js') }}" defer></script>
|
@vite('resources/js/app.js')
|
||||||
|
|
||||||
<!-- Fonts -->
|
<!-- Fonts -->
|
||||||
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
|
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
|
||||||
@@ -19,9 +19,12 @@
|
|||||||
|
|
||||||
<!-- Styles -->
|
<!-- Styles -->
|
||||||
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
|
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
|
||||||
|
|
||||||
|
<link id="favicon" rel="icon" type="image/png" href="favicon.png" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div hidden id="usedItems">{{ isset($usedItems) && $usedItems > 0 ? $usedItems : '' }}</div>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<nav class="navbar navbar-expand-md navbar-light navbar-laravel">
|
<nav class="navbar navbar-expand-md navbar-light navbar-laravel">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -88,4 +91,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<title>Share It</title>
|
<title>Share It</title>
|
||||||
|
<link id="favicon" rel="icon" type="image/png" href="favicon.png" />
|
||||||
|
|
||||||
<!-- Fonts -->
|
<!-- Fonts -->
|
||||||
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet" type="text/css">
|
<link href="https://fonts.googleapis.com/css?family=Nunito:200,600" rel="stylesheet" type="text/css">
|
||||||
|
|||||||
@@ -14,3 +14,8 @@
|
|||||||
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
||||||
return (int) $user->id === (int) $id;
|
return (int) $user->id === (int) $id;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Broadcast::channel('touchedItem', function ($user) {
|
||||||
|
return true;
|
||||||
|
/* return $user->id === Item::findOrNew($itemId)->users->find($user->id)->id; */
|
||||||
|
});
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
ssh homestead -t "cd code/Bruno\ Fontes/shareit; bash --login"
|
echo "Homestead password is: vagrant"
|
||||||
|
ssh homestead -t "cd shareit; bash --login"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
export VAGRANT_CWD=/home/bruno/development/Homestead/
|
export VAGRANT_CWD=/home/bruno/development/Homestead/
|
||||||
vagrant up
|
vagrant up
|
||||||
#builtin cd ~/development/laravelHomestead && /usr/bin/vagrant up && builtin cd -
|
eval $DEV_BROWSER http://shareit.test \
|
||||||
#~/Apps/firefox/firefox-bin http://shareit.test
|
https://mailtrap.io/inboxes/455614/messages \
|
||||||
#~/Apps/firefox/firefox-bin https://mailtrap.io/inboxes/455614/messages
|
https://dashboard.pusher.com/apps/1505830/console \
|
||||||
|
&
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
ssh homestead -t 'cd shareit; php7.3 /usr/local/bin/composer update; npm update; echo; echo -n "Press enter to exit..."; read'
|
ssh homestead -t 'cd shareit; /usr/local/bin/composer update; npm update; echo; echo -n "Press enter to exit..."; read'
|
||||||
|
|||||||
28
vite.config.js
vendored
Normal file
28
vite.config.js
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import laravel from 'laravel-vite-plugin';
|
||||||
|
// import react from '@vitejs/plugin-react';
|
||||||
|
// import vue from '@vitejs/plugin-vue';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
laravel([
|
||||||
|
// 'resources/css/app.css',
|
||||||
|
'resources/js/app.js',
|
||||||
|
'resources/js/pusher.js',
|
||||||
|
]),
|
||||||
|
// react(),
|
||||||
|
// vue({
|
||||||
|
// template: {
|
||||||
|
// transformAssetUrls: {
|
||||||
|
// base: null,
|
||||||
|
// includeAbsolute: false,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// }),
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': '/resources/js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
15
webpack.mix.js
vendored
15
webpack.mix.js
vendored
@@ -1,15 +0,0 @@
|
|||||||
const mix = require('laravel-mix');
|
|
||||||
|
|
||||||
/*
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
| Mix Asset Management
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| Mix provides a clean, fluent API for defining some Webpack build steps
|
|
||||||
| for your Laravel application. By default, we are compiling the Sass
|
|
||||||
| file for the application as well as bundling up all the JS files.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
mix.js('resources/js/app.js', 'public/js')
|
|
||||||
.sass('resources/sass/app.scss', 'public/css');
|
|
||||||
Reference in New Issue
Block a user