Bladeren bron

Merge branch 'master' of rav.triplestart.com:TigerPHP/stagfe into dev-vj

Josh Kamau 5 jaren geleden
bovenliggende
commit
8c45ec29bb

+ 24 - 0
app/Http/Controllers/AppSessionController.php

@@ -48,6 +48,30 @@ class AppSessionController extends Controller
         return redirect(route('pro-request-sms-login-token'))->withCookie($cookie);
     }
 
+    public function clientLogIn(){
+        return view('public.client-log-in');
+    }
+
+    public function processClientLogIn(Request $request){
+        $loginUrl = env('BACKEND_URL', 'http://localhost:8080') . '/api/session/proLogIn';
+
+        $response = Http::asForm()->post($loginUrl, [
+            'cellNumber' => $request->get('cellNumber'),
+            'token' => $request->get('token'),
+        ])->json();
+
+        if(!$response['success']){
+            return back()->with("message", $response['message']);
+        }
+
+        $sessionKey = $response['data']["sessionKey"];
+        $request->session()->put("authID", $response['data']["proId"]);
+
+        $cookie = cookie()->forever('sessionKey', $sessionKey, '/');
+
+        return redirect("/mc/dashboard")->withCookie($cookie);
+    }
+
     public function postToAPI(Request $request) {
 
         session()->remove('message');

+ 35 - 2
app/Http/Controllers/ClientController.php

@@ -15,8 +15,41 @@ use App\Models\Lobby;
 class ClientController extends Controller
 {
 
-	// GET /care_months
-	public function entrance(Request $request, Lobby $lobby) {
+    // GET /care_months
+    public function entranceNormal(Request $request) {
+        /* $sessionKey = Cookie::get('sessionKey');
+
+        if(!$sessionKey){
+            $loginUrl = env('BACKEND_URL', 'http://localhost:8080') . '/api/session/createStrangerSession';
+
+            $httpResponse = Http::asForm()->post($loginUrl)->json();
+
+            if(!$httpResponse['success']){
+                return back()->with("message", $httpResponse['message']);
+            }
+
+            $sessionKey = $httpResponse['data'];
+
+            // $cookie = cookie()->forever('sessionKey', $sessionKey, '/');
+
+            cookie()->queue('sessionKey', $sessionKey, 1440, '/');
+
+            // $response = new \Illuminate\Http\Response(view('client/index'));
+            // $response->withCookie($cookie);
+            // return $response;
+        }
+
+        $session = AppSession::where("session_key",$sessionKey)->first();
+
+        $meeting = null;
+        if ($session->meetingParticipant && $session->meetingParticipant->meeting->lobby_id === $lobby->id) {
+            $meeting = new MeetingModel($session->meetingParticipant->meeting);
+        }
+        return view('client/index',compact('lobbyModel','meeting','sessionKey')); */
+        return view('client/index');
+	}
+
+	public function entranceLobby(Request $request, Lobby $lobby) {
         if (!$lobby->id) {
             \abort(404);
             return;

+ 13 - 0
resources/js/components/elements/Message.vue

@@ -0,0 +1,13 @@
+<template>
+  
+</template>
+
+<script>
+export default {
+
+}
+</script>
+
+<style>
+
+</style>

+ 21 - 7
resources/js/components/pages/ClientEntrance.vue

@@ -25,11 +25,6 @@
                     <v-card class="mb-12" color="grey lighten-1" height="200px">
                         <div class="checkin-form d-flex justify-content-center align-items-center">
                             <form ref="baseForm">
-                                <!-- <input type="hidden" name="lobbyUid" value />
-                                <input type="hidden" name="_api" value="/api/meeting/createAsStrangerPerformer" />
-                                <input type="hidden" name="_success" value="/pro/login" />
-                                <input type="hidden" name="_return" value="/" />-->
-
                                 <div class="row mb-3">
                                     <div class="col">
                                         <input type="text" name="strangerFirstName" class="form-control" placeholder="First Name" v-model="user.firstName" required />
@@ -42,6 +37,13 @@
                                 <div class="input-group mb-3">
                                     <input type="date" name="strangerDob" class="form-control" placeholder="Date of Birth" v-model="user.dateOfBirth" required />
                                 </div>
+
+                                <div class="form-group mt-5 mb-3">
+                                    <select class="form-control custom-select" v-model="user.targetLobbyProUid" name="targetLobbyProUid">
+                                        <option value="">Do you wish to speak with particular Doctor?</option>
+                                        <option v-for="pro in prosList" :value="pro.uid" :key="pro.uid">{{pro.name}} - {{pro.type}}</option>
+                                    </select>
+                                </div>
                             </form>
                         </div>
                     </v-card>
@@ -136,12 +138,22 @@ export default {
             required: true
         }
     },
+    computed: {
+        prosList(){
+            return [{
+                name: 'Test',
+                type: 'Cardiologist',
+                uid: 'someuid'
+            }]
+        }
+    },
     data() {
         return {
             user: {
                 firstName: "",
                 lastName: "",
-                dateOfBirth: null
+                dateOfBirth: null,
+                targetLobbyProUid: ""
             },
             meetingUid: "",
             meetingName: sessionStorage.getItem("meeting_name") || "",
@@ -221,7 +233,8 @@ export default {
                     title: this.meetingName,
                     strangerFirstName: this.user.firstName,
                     strangerLastName: this.user.lastName,
-                    strangerDob: this.user.dateOfBirth
+                    strangerDob: this.user.dateOfBirth,
+                    targetLobbyProUid: this.user.targetLobbyProUid
                 },
                 success: data => {
                     if (!data.success) {
@@ -651,6 +664,7 @@ export default {
         }
     },
     mounted() {
+        console.log(this.lobbyProp)
         if (this.meetingProp) {
             this.meetingUid = this.meetingProp.uid;
             this.$nextTick(this.initializePublisher);

+ 1 - 0
resources/js/components/pages/MeetingsAppRoot.vue

@@ -80,6 +80,7 @@ export default {
                 if (newVal && newVal.uid) {
                     this.$socket.emit("meetingJoined", { lobby_uid: newVal.lobby_uid, meeting_name: newVal.name, meeting_uid: newVal.uid, user: this.user });
 
+                    this.$eventBus.$emit("updateMeetingMessages")
                     /* axios
                         .get(`/meeting/${this.meeting.id}/messages`)
                         .then(response => {

+ 1 - 1
resources/js/components/partials/LobbyList.vue

@@ -118,7 +118,7 @@ export default {
                         return;
                     }
                     if (this.meeting.uid === lobby.selected_meeting.uid) {
-                        this.$eventBus.$emit("meetingRejoin");
+                        this.$eventBus.$emit("meetingRejoin")
                     } else {
                         lobby.selected_meeting.lobby = lobby;
                         this.$store.commit("setCurrentMeeting", { lobby_uid: lobby.uid, ...lobby.selected_meeting });

+ 43 - 0
resources/js/components/partials/Messenger.vue

@@ -5,8 +5,51 @@
 </template>
 
 <script>
+import { mapState } from "vuex";
+import axios from "axios";
+
 export default {
+  computed: {
+    ...mapState(["meeting", "user"])
+  },
+  sockets: {},
+  data() {
+    return {
+      messages: []
+    };
+  },
+  methods: {
+    getMessages(){
+      axios.get(`/meeting/${this.meeting.id}/messages`)
+          .then(response => {
+              /* this.messages = response.data.map(cur => {
+                  cur.timestamp_formatted = timeago.format(cur.timestamp);
+                  cur.sent = this.user.UID == cur.user.UID ? true : false;
+                  return cur;
+              }); */
+          })
+          .catch(e => {
+              console.log(e);
+          });
+    }
+  },
+  mounted() {
+    this.sockets.subscribe('chat-message', data => {
+      let msg = this.messages.filter(cur => cur.id == data.id);
+
+      if (msg.length) {
+          let date = new Date();
+
+          msg[0].text = data.text;
+          msg[0].timestamp = date;
+          //msg[0].timestamp_formatted = timeago.format(date);
+      } else {
+          this.messages.push(data);
+      }
+    })
 
+    this.$eventBus.$on("updateMeetingMessages", this.getMessages)
+  }
 }
 </script>
 

+ 73 - 0
resources/views/layouts/client-login.blade.php

@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <title>Stag | Client</title>
+    <!-- Tell the browser to be responsive to screen width -->
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+
+    <!-- Font Awesome -->
+    <link rel="stylesheet" href="/AdminLTE-3.0.5/plugins/fontawesome-free/css/all.min.css">
+    <!-- Ionicons -->
+    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
+    <!-- icheck bootstrap -->
+    <link rel="stylesheet"
+          href="/AdminLTE-3.0.5/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
+    <!-- Theme style -->
+    <link rel="stylesheet" href="/AdminLTE-3.0.5/dist/css/adminlte.css">
+    <!-- Google Font: Source Sans Pro -->
+    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
+</head>
+<body class="hold-transition login-page">
+
+<style>
+    .auth-branding {
+        background: #444343 !important;
+        box-shadow: none !important;
+        border-bottom: 1px solid #262626;
+        padding: 0.5rem 0;
+        margin: 0;
+        border-top-left-radius: 8px;
+        border-top-right-radius: 8px;
+        font-size: 1.4rem;
+    }
+
+    .auth-branding img {
+        line-height: .8;
+        margin-left: 0;
+        margin-right: .5rem;
+        margin-top: -3px;
+        max-height: 33px;
+    }
+
+    .login-card-body {
+        border-bottom-left-radius: 8px;
+        border-bottom-right-radius: 8px;
+    }
+</style>
+<div class="login-box">
+    <div class="login-logo auth-branding text-center border-0">
+        <img src="/AdminLTE-3.0.5/dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3"
+             style="opacity: .8">
+        <span class="brand-text font-weight-light text-white"><b>Stag</b> Guest</span>
+    </div>
+    <!-- /.login-logo -->
+    <div class="card">
+        <div class="card-body login-card-body">
+            @yield('content')
+        </div>
+        <!-- /.login-card-body -->
+    </div>
+</div>
+<!-- /.login-box -->
+
+<!-- jQuery -->
+<script src="/AdminLTE-3.0.5/plugins/jquery/jquery.min.js"></script>
+<!-- Bootstrap 4 -->
+<script src="/AdminLTE-3.0.5/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
+<!-- AdminLTE App -->
+<script src="/AdminLTE-3.0.5/dist/js/adminlte.js"></script>
+
+</body>
+</html>

+ 32 - 0
resources/views/public/client-log-in.blade.php

@@ -0,0 +1,32 @@
+@extends('layouts.login')
+@section('content')
+    <form action="{{ route('process-pro-login') }}"
+          method="post"
+          enctype="multipart/form-data">
+        @csrf
+
+        <p class="login-box-msg">Enter the code received on your phone</p>
+
+        @if (session('message'))
+            <div class="alert alert-danger">{{ session('message') }}</div>
+        @endif
+
+        <div class="input-group mb-3">
+            <input type="text" name="cellNumber" class="form-control" placeholder="Cell Number" required>
+            <div class="input-group-append">
+                <div class="input-group-text">
+                    <span class="fas fa-phone"></span>
+                </div>
+            </div>
+        </div>
+        <div class="input-group mb-3">
+            <input type="text" name="token" class="form-control" placeholder="Token" required>
+            <div class="input-group-append">
+                <div class="input-group-text">
+                    <span class="fas fa-key"></span>
+                </div>
+            </div>
+        </div>
+        <button type="submit" class="btn btn-primary btn-block mx-auto w-50 mt-4 mb-2">Log In</button>
+    </form>
+@endsection

+ 5 - 1
routes/web.php

@@ -35,6 +35,8 @@ Route::middleware('ensureNoValidSession')->group(function(){
     Route::get('/', 'AppSessionController@proRequestSmsLogInToken')->name('pro-request-sms-login-token');
     Route::get('/pro/login', 'AppSessionController@proLogIn')->name('pro-login');
     Route::post('/pro/login', 'AppSessionController@processProLogIn')->name('process-pro-login');
+    Route::get('/client/login', 'AppSessionController@clientLogIn')->name('client-login');
+    Route::get('/client/login', 'AppSessionController@clientLogIn')->name('process-client-login');
 });
 
 Route::middleware('ensureValidSession')->group(function(){
@@ -60,7 +62,9 @@ Route::middleware('ensureValidSession')->group(function(){
 Route::post('/post-to-api', 'AppSessionController@postToAPI')->name('post-to-api');
 Route::post('/post-to-api-ajax', 'AppSessionController@postToAPIAjax')->name('post-to-api-ajax');
 
-Route::get('/client/{url_slug}', 'ClientController@entrance')->name('client-entrance');
+Route::get('/client', 'ClientController@entranceNormal')->name('client-entrance');
+Route::get('/client/{url_slug}', 'ClientController@entranceLobby')->name('client-lobby');
+Route::get('/client/meeting/{meeting_uid}', 'ClientController@entranceLobby')->name('join-meeting');
 
 Route::bind('url_slug', function($value, $route)
 {