diff options
Diffstat (limited to 'resources')
-rw-r--r-- | resources/assets/js/app.js | 15 | ||||
-rw-r--r-- | resources/assets/js/bootstrap.js | 22 | ||||
-rw-r--r-- | resources/assets/js/chat.js | 26 | ||||
-rw-r--r-- | resources/assets/js/chatServer.js | 26 | ||||
-rw-r--r-- | resources/assets/sass/app.scss | 14 | ||||
-rw-r--r-- | resources/views/auth/login.blade.php | 69 | ||||
-rw-r--r-- | resources/views/auth/passwords/email.blade.php | 47 | ||||
-rw-r--r-- | resources/views/auth/passwords/reset.blade.php | 65 | ||||
-rw-r--r-- | resources/views/auth/register.blade.php | 77 | ||||
-rw-r--r-- | resources/views/layouts/app.blade.php | 79 | ||||
-rw-r--r-- | resources/views/welcome.blade.php | 27 | ||||
-rw-r--r-- | resources/views/writeMessage.blade.php | 33 |
12 files changed, 441 insertions, 59 deletions
diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 98eca79..8400475 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -1,4 +1,3 @@ - /** * First we will load all of this project's JavaScript dependencies which * includes Vue and other libraries. It is a great starting point when @@ -6,17 +5,7 @@ */ require('./bootstrap'); - window.Vue = require('vue'); +// window.jQueryMigrate = require('jquery-migrate'); +require('./chat'); -/** - * Next, we will create a fresh Vue application instance and attach it to - * the page. Then, you may begin adding components to this application - * or customize the JavaScript scaffolding to fit your unique needs. - */ - -Vue.component('example-component', require('./components/ExampleComponent.vue')); - -const app = new Vue({ - el: '#app' -}); diff --git a/resources/assets/js/bootstrap.js b/resources/assets/js/bootstrap.js index fb0f1ed..a919262 100644 --- a/resources/assets/js/bootstrap.js +++ b/resources/assets/js/bootstrap.js @@ -1,4 +1,3 @@ - window._ = require('lodash'); window.Popper = require('popper.js').default; @@ -10,7 +9,6 @@ window.Popper = require('popper.js').default; try { window.$ = window.jQuery = require('jquery'); - require('bootstrap'); } catch (e) {} @@ -43,14 +41,12 @@ if (token) { * for events that are broadcast by Laravel. Echo and event broadcasting * allows your team to easily build robust real-time web applications. */ - -// import Echo from 'laravel-echo' - -// window.Pusher = require('pusher-js'); - -// window.Echo = new Echo({ -// broadcaster: 'pusher', -// key: process.env.MIX_PUSHER_APP_KEY, -// cluster: process.env.MIX_PUSHER_APP_CLUSTER, -// encrypted: true -// }); +// import Echo from "laravel-echo" +// window.io = require('socket.io-client'); + +// if (typeof io !== 'undefined') { +// window.Echo = new Echo({ +// broadcaster: 'socket.io', +// host: window.location.hostname + ':6001', +// }); +// }
\ No newline at end of file diff --git a/resources/assets/js/chat.js b/resources/assets/js/chat.js new file mode 100644 index 0000000..5f634d2 --- /dev/null +++ b/resources/assets/js/chat.js @@ -0,0 +1,26 @@ +var socket = io('http://127.0.0.1:8890', { + transports: ['websocket'] +}); +socket.on('message', function (data) { + data = JSON.parse(data); + $("#messages").append("<p>" + data.user + " : " + data.message + "</p>"); +}); + +$('input.send').click(function (e) { + e.preventDefault(); + sendMessage(); +}); + +function sendMessage() { + var message = $('input.message').val(); + $.ajax({ + type: "POST", + url: "sendMessage", + data: { + "_token": $('meta[name="csrf-token"]').attr('content'), + "message": message + }, + cache: false, + success: function (results) {} + }); +}
\ No newline at end of file diff --git a/resources/assets/js/chatServer.js b/resources/assets/js/chatServer.js new file mode 100644 index 0000000..fb6c7fc --- /dev/null +++ b/resources/assets/js/chatServer.js @@ -0,0 +1,26 @@ +var app = require('express')(); +var server = require('http').Server(app); +var io = require('socket.io')(server); +var redis = require('redis'); +var port = 8890; + +server.listen(port, function () { + console.log("Listening on " + port) +}); + +io.on('connection', function (socket) { + + console.log("new client connected"); + var redisClient = redis.createClient(); + redisClient.subscribe('message'); + + redisClient.on("message", function (channel, message) { + console.log("new message" + message); + socket.emit(channel, message); + }); + + socket.on('disconnect', function () { + console.log("client connected"); + redisClient.quit(); + }); +}); diff --git a/resources/assets/sass/app.scss b/resources/assets/sass/app.scss index 0077cb1..c58e2db 100644 --- a/resources/assets/sass/app.scss +++ b/resources/assets/sass/app.scss @@ -1,14 +1,16 @@ - // Fonts @import url("https://fonts.googleapis.com/css?family=Raleway:300,400,600"); - // Variables @import "variables"; - // Bootstrap @import '~bootstrap/scss/bootstrap'; - .navbar-laravel { - background-color: #fff; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04); + background-color: #fff; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04); } + +.MessagesWindow { + height: 250px; + overflow-y: scroll; + padding: 15px; +}
\ No newline at end of file diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php new file mode 100644 index 0000000..9fd12a7 --- /dev/null +++ b/resources/views/auth/login.blade.php @@ -0,0 +1,69 @@ +@extends('layouts.app') + +@section('content') +<div class="container"> + <div class="row justify-content-center"> + <div class="col-md-8"> + <div class="card"> + <div class="card-header">{{ __('Login') }}</div> + + <div class="card-body"> + <form method="POST" action="{{ route('login') }}" aria-label="{{ __('Login') }}"> + @csrf + + <div class="form-group row"> + <label for="email" class="col-sm-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label> + + <div class="col-md-6"> + <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus> + + @if ($errors->has('email')) + <span class="invalid-feedback" role="alert"> + <strong>{{ $errors->first('email') }}</strong> + </span> + @endif + </div> + </div> + + <div class="form-group row"> + <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label> + + <div class="col-md-6"> + <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required> + + @if ($errors->has('password')) + <span class="invalid-feedback" role="alert"> + <strong>{{ $errors->first('password') }}</strong> + </span> + @endif + </div> + </div> + + <div class="form-group row"> + <div class="col-md-6 offset-md-4"> + <div class="checkbox"> + <label> + <input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> {{ __('Remember Me') }} + </label> + </div> + </div> + </div> + + <div class="form-group row mb-0"> + <div class="col-md-8 offset-md-4"> + <button type="submit" class="btn btn-primary"> + {{ __('Login') }} + </button> + + <a class="btn btn-link" href="{{ route('password.request') }}"> + {{ __('Forgot Your Password?') }} + </a> + </div> + </div> + </form> + </div> + </div> + </div> + </div> +</div> +@endsection diff --git a/resources/views/auth/passwords/email.blade.php b/resources/views/auth/passwords/email.blade.php new file mode 100644 index 0000000..12e8083 --- /dev/null +++ b/resources/views/auth/passwords/email.blade.php @@ -0,0 +1,47 @@ +@extends('layouts.app') + +@section('content') +<div class="container"> + <div class="row justify-content-center"> + <div class="col-md-8"> + <div class="card"> + <div class="card-header">{{ __('Reset Password') }}</div> + + <div class="card-body"> + @if (session('status')) + <div class="alert alert-success" role="alert"> + {{ session('status') }} + </div> + @endif + + <form method="POST" action="{{ route('password.email') }}" aria-label="{{ __('Reset Password') }}"> + @csrf + + <div class="form-group row"> + <label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label> + + <div class="col-md-6"> + <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required> + + @if ($errors->has('email')) + <span class="invalid-feedback" role="alert"> + <strong>{{ $errors->first('email') }}</strong> + </span> + @endif + </div> + </div> + + <div class="form-group row mb-0"> + <div class="col-md-6 offset-md-4"> + <button type="submit" class="btn btn-primary"> + {{ __('Send Password Reset Link') }} + </button> + </div> + </div> + </form> + </div> + </div> + </div> + </div> +</div> +@endsection diff --git a/resources/views/auth/passwords/reset.blade.php b/resources/views/auth/passwords/reset.blade.php new file mode 100644 index 0000000..3557662 --- /dev/null +++ b/resources/views/auth/passwords/reset.blade.php @@ -0,0 +1,65 @@ +@extends('layouts.app') + +@section('content') +<div class="container"> + <div class="row justify-content-center"> + <div class="col-md-8"> + <div class="card"> + <div class="card-header">{{ __('Reset Password') }}</div> + + <div class="card-body"> + <form method="POST" action="{{ route('password.request') }}" aria-label="{{ __('Reset Password') }}"> + @csrf + + <input type="hidden" name="token" value="{{ $token }}"> + + <div class="form-group row"> + <label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label> + + <div class="col-md-6"> + <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ $email ?? old('email') }}" required autofocus> + + @if ($errors->has('email')) + <span class="invalid-feedback" role="alert"> + <strong>{{ $errors->first('email') }}</strong> + </span> + @endif + </div> + </div> + + <div class="form-group row"> + <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label> + + <div class="col-md-6"> + <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required> + + @if ($errors->has('password')) + <span class="invalid-feedback" role="alert"> + <strong>{{ $errors->first('password') }}</strong> + </span> + @endif + </div> + </div> + + <div class="form-group row"> + <label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label> + + <div class="col-md-6"> + <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required> + </div> + </div> + + <div class="form-group row mb-0"> + <div class="col-md-6 offset-md-4"> + <button type="submit" class="btn btn-primary"> + {{ __('Reset Password') }} + </button> + </div> + </div> + </form> + </div> + </div> + </div> + </div> +</div> +@endsection diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php new file mode 100644 index 0000000..f9dd662 --- /dev/null +++ b/resources/views/auth/register.blade.php @@ -0,0 +1,77 @@ +@extends('layouts.app') + +@section('content') +<div class="container"> + <div class="row justify-content-center"> + <div class="col-md-8"> + <div class="card"> + <div class="card-header">{{ __('Register') }}</div> + + <div class="card-body"> + <form method="POST" action="{{ route('register') }}" aria-label="{{ __('Register') }}"> + @csrf + + <div class="form-group row"> + <label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Name') }}</label> + + <div class="col-md-6"> + <input id="name" type="text" class="form-control{{ $errors->has('name') ? ' is-invalid' : '' }}" name="name" value="{{ old('name') }}" required autofocus> + + @if ($errors->has('name')) + <span class="invalid-feedback" role="alert"> + <strong>{{ $errors->first('name') }}</strong> + </span> + @endif + </div> + </div> + + <div class="form-group row"> + <label for="email" class="col-md-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label> + + <div class="col-md-6"> + <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required> + + @if ($errors->has('email')) + <span class="invalid-feedback" role="alert"> + <strong>{{ $errors->first('email') }}</strong> + </span> + @endif + </div> + </div> + + <div class="form-group row"> + <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label> + + <div class="col-md-6"> + <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required> + + @if ($errors->has('password')) + <span class="invalid-feedback" role="alert"> + <strong>{{ $errors->first('password') }}</strong> + </span> + @endif + </div> + </div> + + <div class="form-group row"> + <label for="password-confirm" class="col-md-4 col-form-label text-md-right">{{ __('Confirm Password') }}</label> + + <div class="col-md-6"> + <input id="password-confirm" type="password" class="form-control" name="password_confirmation" required> + </div> + </div> + + <div class="form-group row mb-0"> + <div class="col-md-6 offset-md-4"> + <button type="submit" class="btn btn-primary"> + {{ __('Register') }} + </button> + </div> + </div> + </form> + </div> + </div> + </div> + </div> +</div> +@endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php new file mode 100644 index 0000000..f6e81e3 --- /dev/null +++ b/resources/views/layouts/app.blade.php @@ -0,0 +1,79 @@ +<!DOCTYPE html> +<html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> +<head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + + <!-- CSRF Token --> + <meta name="csrf-token" content="{{ csrf_token() }}"> + + <title>{{ config('app.name', 'Laravel') }}</title> + + <!-- Scripts --> + <script src="{{ asset('js/app.js') }}" defer></script> + + <!-- Fonts --> + <link rel="dns-prefetch" href="https://fonts.gstatic.com"> + <link href="https://fonts.googleapis.com/css?family=Raleway:300,400,600" rel="stylesheet" type="text/css"> + + <!-- Styles --> + <link href="{{ asset('css/app.css') }}" rel="stylesheet"> +</head> +<body> + <div id="app"> + <nav class="navbar navbar-expand-md navbar-light navbar-laravel"> + <div class="container"> + <a class="navbar-brand" href="{{ url('/') }}"> + {{ config('app.name', 'Laravel') }} + </a> + <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="{{ __('Toggle navigation') }}"> + <span class="navbar-toggler-icon"></span> + </button> + + <div class="collapse navbar-collapse" id="navbarSupportedContent"> + <!-- Left Side Of Navbar --> + <ul class="navbar-nav mr-auto"> + + </ul> + + <!-- Right Side Of Navbar --> + <ul class="navbar-nav ml-auto"> + <!-- Authentication Links --> + @guest + <li class="nav-item"> + <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a> + </li> + <li class="nav-item"> + <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a> + </li> + @else + <li class="nav-item dropdown"> + <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre> + {{ Auth::user()->name }} <span class="caret"></span> + </a> + + <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown"> + <a class="dropdown-item" href="{{ route('logout') }}" + onclick="event.preventDefault(); + document.getElementById('logout-form').submit();"> + {{ __('Logout') }} + </a> + + <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;"> + @csrf + </form> + </div> + </li> + @endguest + </ul> + </div> + </div> + </nav> + + <main class="py-4"> + @yield('content') + </main> + </div> +</body> +</html> diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php deleted file mode 100644 index 0d11569..0000000 --- a/resources/views/welcome.blade.php +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<head> - <title>Pusher Test</title> - <script src="https://js.pusher.com/4.1/pusher.min.js"></script> - <script> - - // Enable pusher logging - don't include this in production - Pusher.logToConsole = true; - - var pusher = new Pusher('6d5f2075a9c7df361239', { - cluster: 'eu', - encrypted: true - }); - - var channel = pusher.subscribe('my-channel'); - channel.bind('my-event', function(data) { - alert(JSON.stringify(data)); - }); - </script> -</head> -<body> - <h1>Pusher Test</h1> - <p> - Try publishing an event to channel <code>my-channel</code> - with event name <code>my-event</code>. - </p> -</body> diff --git a/resources/views/writeMessage.blade.php b/resources/views/writeMessage.blade.php new file mode 100644 index 0000000..0136ba9 --- /dev/null +++ b/resources/views/writeMessage.blade.php @@ -0,0 +1,33 @@ +@extends('layouts.app') @section('content') + +<script src="https://cdn.socket.io/socket.io-1.3.4.js"></script> + +<div class="container"> + <div class="row"> + <div class="col-lg-8 col-lg-offset-2"> + <div class="panel panel-default"> + <div class="panel-heading">Messages Received</div> + <div id="messages" class="MessagesWindow"> + @foreach ($messages as $key => $message) + <p>{{$message->name}}: {{$message->message}}</p> + @endforeach + + </div> + </div> + </div> + </div> + <div class="row"> + <div class="col-md-10 col-md-offset-1"> + <div class="panel panel-default"> + <div class="panel-heading">Send message</div> + <form action="sendmessage" method="POST"> + {{ csrf_field() }} + <input type="text" name="message" class="message"> + <input type="submit" value="send" class="send"> + </form> + </div> + </div> + </div> +</div> + +@endsection |