0% found this document useful (0 votes)
69 views14 pages

Completa Modo TV: Commit Authored 2 Weeks Ago by

The commit updates the frontend codebase of a transit/queue management system. It refactors code related to turn/queue states to use constants for state values and events for state changes. Over 20 files were changed with hundreds of lines added and removed. The changes complete the implementation of a "TV mode" feature by centralizing state handling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views14 pages

Completa Modo TV: Commit Authored 2 Weeks Ago by

The commit updates the frontend codebase of a transit/queue management system. It refactors code related to turn/queue states to use constants for state values and events for state changes. Over 20 files were changed with hundreds of lines added and removed. The changes complete the implementation of a "TV mode" feature by centralizing state handling.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

Please ensure your account's recovery settings are up to date.

Commit 9a612e96 authored 2 weeks ago by Guillermo Agudelo

Completa modo tv

parent c64a5d4d master

No related merge requests found

Showing 22 changed files  with 324 additions and 113 deletions

  app/Events/TurnCalled.php → app/Events/TurnStateChanged.php
... ... @@ -2,6 +2,7 @@
2 2
3 3 namespace App\Events;
4 4
5 + use App\PendingTurn;
5 6 use Illuminate\Broadcasting\Channel;
6 7 use Illuminate\Broadcasting\InteractsWithSockets;
7 8 use Illuminate\Broadcasting\PresenceChannel;
... ... @@ -10,20 +11,20 @@ use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
10 11 use Illuminate\Foundation\Events\Dispatchable;
11 12 use Illuminate\Queue\SerializesModels;
12 13
13 - class TurnCalled implements ShouldBroadcast
14 + class TurnStateChanged implements ShouldBroadcast
14 15 {
15 16 use Dispatchable, InteractsWithSockets, SerializesModels;
16 17
17 - public $data;
18 + public $pendingTurn;
18 19
19 20 /**
20 21 * Create a new event instance.
21 22 *
22 23 * @return void
23 24 */
24 - public function __construct($data)
25 + public function __construct($pendingTurn)
25 26 {
26 - $this->data = $data;
27 + $this->pendingTurn = is_array($pendingTurn) ? $pendingTurn : $pendingTurn->toArray();
27 28 }
28 29
29 30 /**
... ...

  app/Http/Controllers/API/PendingTurnController.php 0 → 100644

1 + <?php
2 +
3 + namespace App\Http\Controllers\API;
4 +
5 + use App\Http\Controllers\Controller;
6 + use App\PendingTurn;
7 + use Illuminate\Http\Request;
8 +
9 + class PendingTurnController extends Controller
10 +{
11 + public function allFromToday()
12 + {
13 + $pendingTurns = PendingTurn::getAllFromToday();
14 + return response()->json(['status' => 'success', 'data' => compact('pendingTurns')]);
15 + }
16 +

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 1/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

17 +}

  app/Http/Controllers/API/TurnController.php

... ... @@ -3,13 +3,14 @@


3 3 namespace App\Http\Controllers\API;
4 4
5 5 use App\Client;
6 - use App\Events\TurnCalled;
6 + use App\Events\TurnStateChanged;
7 7 use App\Http\Controllers\Controller;
8 8 use App\PendingTurn;
9 9 use App\Queue;
10 10 use App\Turn;
11 11 use App\User;
12 12 use Illuminate\Http\Request;
13 + use TurnState;
13 14
14 15 class TurnController extends Controller
15 16 {
... ... @@ -24,21 +25,21 @@ class TurnController extends Controller
24 25 $client = Client::first('uid', '=', $queue->field('uid'));
25 26
26 27 $turn = Turn::create([
27 - 'createdAt' => date_create(),
28 - 'createdBy' => \LfAuth::id(),
28 + 'createAt' => date_create(),
29 + 'creteBy' => \LfAuth::id(),
29 30 'dateFin' => null,
30 31 'dateIni' => null,
31 32 'idBranch' => \State::get('branch.id'),
32 33 'idClient' => $client->id(),
33 34 'idCompany' => \State::get('company.id'),
34 - 'idEmployee' => \LfAuth::id(),
35 + 'idEmployee' => \State::get('employee.id'),
35 36 'idQueue' => $queue->id(),
36 37 'idService' => $queue->field('idService'),
37 - 'state' => 'Esperando'
38 + 'state' => TurnState::ESPERANDO
38 39 ]);
39 40
40 41 Queue::update($queue->id(), [
41 - ['path' => 'state', 'value' => 'Llamado'],
42 + ['path' => 'state', 'value' => TurnState::ESPERANDO],
42 43 ]);
43 44
44 45 $userClient = User::find($client->field('uid'));
... ... @@ -47,21 +48,16 @@ class TurnController extends Controller
47 48 'order' => $queue->field('order'),
48 49 'name' => $userClient->field('displayName'),
49 50 'label' => \State::get('employee.label'),
50 - 'state' => 'Esperando',
51 - 'createdAt' => date_create(),
51 + 'state' => TurnState::ESPERANDO,
52 + 'createAt' => date_create(),
53 + 'idTurn' => $turn->id(),
52 54 ]);
53 55
54 - event(new TurnCalled($pendingTurn->toArray()));
56 + event(new TurnStateChanged($pendingTurn));
55 57
56 58 return response()->json(['status' => 'success', 'data' => compact('queue', 'turn', 'client',
'userClient')]);
57 59 }
58 60
59 - public function state()
60 - {
61 - $pendingTurns = PendingTurn::all();
62 - return response()->json(['status' => 'success', 'data' => compact('pendingTurns')]);
63 - }
64 -
65 61 public function start(Request $request, $id)
66 62 {
67 63 $data = $request->validate([
... ... @@ -69,12 +65,23 @@ class TurnController extends Controller

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 2/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

69 65 ]);
70 66
71 67 $dateIni = date_create(\Carbon\Carbon::make($data['dateIni'])->subHours(5));
72 - $recorData = [
73 - ['path' => 'state', 'value' => 'Atendiendo'],
68 +
69 + $turn = Turn::update($id, [
70 + ['path' => 'state', 'value' => TurnState::ATENDIENDO],
74 71 ['path' => 'dateIni', 'value' => $dateIni]
75 - ];
72 + ]);
73 +
74 + Queue::update($turn->field('idQueue'), [
75 + ['path' => 'state', 'value' => TurnState::ATENDIENDO],
76 + ]);
77 +
78 + $pendingTurn = PendingTurn::first('idTurn', '=', $turn->id());
79 + $pendingTurn = $pendingTurn->updateInstance([
80 + ['path' => 'state', 'value' => TurnState::ATENDIENDO],
81 + ]);
82 +
83 + event(new TurnStateChanged($pendingTurn));
76 84
77 - $turn = Turn::update($id, $recorData);
78 85 return response()->json(['status' => 'success', 'data' => compact('turn')]);
79 86 }
80 87
... ... @@ -85,16 +92,41 @@ class TurnController extends Controller
85 92 ]);
86 93
87 94 $dateFin = date_create(\Carbon\Carbon::make($data['dateFin'])->subHours(5));
88 - $recorData = [
89 - ['path' => 'state', 'value' => 'Terminado'],
95 +
96 + $turn = Turn::update($id, [
97 + ['path' => 'state', 'value' => TurnState::TERMINADO],
90 98 ['path' => 'dateFin', 'value' => $dateFin]
91 - ];
99 + ]);
92 100
93 - $turn = Turn::update($id, $recorData);
94 101 $queue = Queue::update($turn->field('idQueue'), [
95 - ['path' => 'state', 'value' => 'Terminado'],
102 + ['path' => 'state', 'value' => TurnState::TERMINADO],
96 103 ]);
97 104
105 + $pendingTurn = PendingTurn::first('idTurn', '=', $turn->id());
106 + $pendingTurnData = $pendingTurn->deleteInstance();
107 + $pendingTurnData['state'] = TurnState::TERMINADO;
108 +
109 + event(new TurnStateChanged($pendingTurnData));
110 +
111 + return response()->json(['status' => 'success', 'data' => compact('turn', 'queue')]);
112 + }
113 +
114 + public function cancel(Request $request, $id)
115 + {
116 + $turn = Turn::update($id, [
117 + ['path' => 'state', 'value' => TurnState::CANCELADO],
118 + ]);
119 +
120 + $queue = Queue::update($turn->field('idQueue'), [
121 + ['path' => 'state', 'value' => TurnState::CANCELADO],
122 + ]);
123 +
124 + $pendingTurn = PendingTurn::first('idTurn', '=', $turn->id());
125 + $pendingTurnData = $pendingTurn->deleteInstance();
126 + $pendingTurnData['state'] = TurnState::CANCELADO;
127 +
128 + event(new TurnStateChanged($pendingTurnData));
129 +
98 130 return response()->json(['status' => 'success', 'data' => compact('turn', 'queue')]);
99 131 }
100 132 }

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 3/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

  app/Http/Controllers/HomeController.php
... ... @@ -2,8 +2,6 @@
2 2
3 3 namespace App\Http\Controllers;
4 4
5 - use App\Events\TurnCalled;
6 -
7 5 class HomeController extends Controller
8 6 {
9 7
... ...

  app/Http/Controllers/QueueController.php
... ... @@ -47,8 +47,8 @@ class QueueController extends Controller
47 47 ]);
48 48
49 49 $client = Client::create([
50 - 'createdAt' => date_create(),
51 - 'createdBy' => \LfAuth::id(),
50 + 'createAt' => date_create(),
51 + 'creteBy' => \LfAuth::id(),
52 52 'state' => 'Activo',
53 53 'identification' => $data['identification'],
54 54 'location' => [
... ... @@ -63,25 +63,28 @@ class QueueController extends Controller
63 63 $client = Client::first('identification', '=', $data['identification']);
64 64 }
65 65
66 + // Crear la queue
66 67 $recordData = [
67 68 'idBranch' => $data['id-branch'],
68 69 'idCompany' => $data['id-company'],
69 70 'idService' => $data['id-service'],
70 71 'isPriority' => (bool)$request->has('is-priority'),
71 72 'uid' => $client->field('uid'),
72 - 'createdBy' => \LfAuth::id(),
73 - 'createdAt' => date_create(),
73 + 'createAt' => date_create(),
74 + 'creteBy' => \LfAuth::id(),
74 75 ];
75 76
76 77 if ($request->has('scheduled')) {
77 78 $recordData['date'] = date_create($data['date']);
78 79 $recordData['state'] = 'Agendado';
80 + notify()->success('', 'Se creó el turno');
79 81 $queue = Queue::create($recordData);
80 82 return redirect()->route('queue.index');
81 83 } else {
82 84 $recordData['order'] = Queue::getNextOrder();
83 85 $recordData['state'] = 'Activo';
84 86 $queue = Queue::create($recordData);
87 + notify()->success('', 'Se creó el turno');
85 88 return redirect()->route('queue.index', ['queue' => $queue->id()]);
86 89 }
87 90
... ...

  app/Http/Controllers/TurnController.php
... ... @@ -4,12 +4,14 @@ namespace App\Http\Controllers;
4 4
5 5 use App\Client;
6 6 use App\Queue;
7 + use App\Turn;
7 8 use Illuminate\Http\Request;
8 9
9 10 class TurnController extends Controller
10 11 {
11 12 public function index()
12 13 {
13 - return view('turns.index');
14 + $unfinishedTurn = Turn::getUnfinishedTurnByEmployee(\State::get('employee.id')); //TODO: Completar
esto. recuperar el turno sin termninar cuando recarga pagina turnos
15 + return view('turns.index', compact('unfinishedTurn'));

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 4/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

14 16 }
15 17 }

  app/PendingTurn.php
... ... @@ -8,4 +8,8 @@ class PendingTurn extends LarafireModel
8 8 {
9 9 protected $collectionName = 'pendingTurns';
10 10
11 + public static function getAllFromToday()
12 + {
13 + return static::rowsToInstances(static::createdToday()->documents()->rows());
14 + }
11 15 }

  app/Queue.php

... ... @@ -10,9 +10,8 @@ class Queue extends LarafireModel


10 10
11 11 public static function getNextOrder()
12 12 {
13 - $result = Queue::where('createdAt', '>', date_create(now()->toDateString()))
14 - ->where('createdAt', '<', date_create(now()->addDays(1)->toDateString()))
15 - ->orderBy('createdAt', 'DESC')
13 + $result = Queue::createdToday()
14 + ->orderBy('createAt', 'DESC')
16 15 ->orderBy('order', 'DESC')
17 16 ->documents()->rows();
18 17
... ... @@ -22,9 +21,9 @@ class Queue extends LarafireModel
22 21 public static function getNextToBeAttended()
23 22 {
24 23 $rows = Queue::where('state','=','Activo')
25 - ->where('createdAt', '>', date_create(now()->toDateString()))
26 - ->where('createdAt', '<', date_create(now()->addDays(1)->toDateString()))
27 - ->orderBy('createdAt')
24 + ->where('createAt', '>', date_create(now()->toDateString()))
25 + ->where('createAt', '<', date_create(now()->addDays(1)->toDateString()))
26 + ->orderBy('createAt')
28 27 ->orderBy('order', 'asc')->documents()->rows();
29 28
30 29 if (count($rows) == 0) throw new \Exception('No hay mas turnos pendientes');
... ...

  app/Support/Functions.php → app/Support/Globals.php
... ... @@ -7,3 +7,17 @@ if (!function_exists('fixCreateIndexUrl')) {
7 7 }
8 8 }
9 9
10 + if (!function_exists('feedback')) {
11 + function feedback($type, $message)
12 + {
13 + session()->put('feedback', ['type' => $type, 'message' => $message]);
14 + }
15 +}
16 +
17 + abstract class TurnState
18 +{
19 + const ESPERANDO = 'Esperando';
20 + const ATENDIENDO = 'Atendiendo';
21 + const TERMINADO = 'Terminado';
22 + const CANCELADO = 'Cancelado';
23 +}

  app/Support/LarafireModel.php
... ... @@ -14,16 +14,12 @@ class LarafireModel implements JsonSerializable
14 14 private $collection;
15 15 private $firebaseObject;
16 16 protected $collectionName;
17 - private static $isInstance = false;
18 - public static $instance;
19 17
20 18 public function __construct()
21 19 {

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 5/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

22 20 $this->firestore = app('firebase.firestore');
23 21 $this->collection = $this->firestore->database()->collection($this->collectionName);
24 22 $this->firebaseObject = null;
25 - self::$isInstance = true;
26 - self::$instance = $this;
27 23 }
28 24
29 25
... ... @@ -31,11 +27,11 @@ class LarafireModel implements JsonSerializable
31 27
32 28 public static function rowsToInstances(array $rows)
33 29 {
34 - return array_map(function($row) {
30 + return collect(array_map(function($row) {
35 31 $instance = self::getNewInstance();
36 32 $instance->firebaseObject = $row;
37 33 return $instance;
38 - }, $rows);
34 + }, $rows));
39 35 }
40 36
41 37
... ... @@ -47,19 +43,11 @@ class LarafireModel implements JsonSerializable
47 43 return new $className;
48 44 }
49 45
50 - private static function getInstance()
51 - {
52 - if (self::$instance === null) {
53 - self::$instance = self::getNewInstance();
54 - }
55 - return self::$instance;
56 - }
57 -
58 46 public static function all()
59 47 {
60 48 $instance = self::getNewInstance();
61 49 $rows = $instance->collection->documents()->rows();
62 - return collect(self::rowsToInstances($rows));
50 + return self::rowsToInstances($rows);
63 51 }
64 52
65 53 public static function find($id)
... ... @@ -74,6 +62,13 @@ class LarafireModel implements JsonSerializable
74 62 return $instance;
75 63 }
76 64
65 + public static function findOrFail($id)
66 + {
67 + $instance = self::find($id);
68 + if (!$instance) throw new ModelNotFoundException('Model not found');
69 + return $instance;
70 + }
71 +
77 72 public static function where($field, $operation, $value)
78 73 {
79 74 $instance = self::getNewInstance();
... ... @@ -120,13 +115,6 @@ class LarafireModel implements JsonSerializable
120 115 return $instance;
121 116 }
122 117
123 - public static function findOrFail($id)
124 - {
125 - $instance = self::find($id);
126 - if (!$instance) throw new ModelNotFoundException('Model not found');
127 - return $instance;
128 - }
129 -
130 118 public static function orderBy($field, $direction = 'ASC') //PERO
131 119 {
132 120 // $instance = self::getInstance();
... ... @@ -144,8 +132,8 @@ class LarafireModel implements JsonSerializable
144 132 {
145 133 $instance = self::getNewInstance();
146 134 // dd('le',$instance);

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 6/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

147 - return $instance->where('createdAt', '>', date_create(now()->toDateString()))


148 - ->where('createdAt', '<', date_create(now()->addDays(1)->toDateString()));
135 + return $instance->where('createAt', '>', date_create(now()->toDateString()))
136 + ->where('createAt', '<', date_create(now()->addDays(1)->toDateString()));
149 137
150 138 }
151 139
... ... @@ -179,7 +167,7 @@ class LarafireModel implements JsonSerializable
179 167 {
180 168 $this->checkFirebaseObjectIsQuery();
181 169 $rows = $this->firebaseObject->documents()->rows();
182 - return collect(self::rowsToInstances($rows));
170 + return self::rowsToInstances($rows);
183 171 }
184 172
185 173 public function field($field)
... ... @@ -205,10 +193,18 @@ class LarafireModel implements JsonSerializable
205 193 return $this->fields();
206 194 }
207 195
208 - public function jsonSerialize() {
196 + public function jsonSerialize()
197 + {
209 198 return $this->fields();
210 199 }
211 200
201 + public function nullifyInstance()
202 + {
203 + $this->firestore = null;
204 + $this->collection = null;
205 + $this->firebaseObject = null;
206 + $this->collectionName = null;
207 + }
212 208
213 209
214 210 // MUTATION
... ... @@ -227,4 +223,37 @@ class LarafireModel implements JsonSerializable
227 223 $instance->firebaseObject = $instance->collection->document($id)->snapshot();
228 224 return $instance;
229 225 }
226 +
227 + public function updateInstance($data)
228 + {
229 + $this->collection->document($this->id())->update($data);
230 + $this->firebaseObject = $this->collection->document($this->id())->snapshot();
231 + return $this;
232 + }
233 +
234 + public static function delete($id)
235 + {
236 + $instance = self::findOrFail($id);
237 + try {
238 + $instance->collection->document($id)->delete();
239 + $data = $instance->toArray();
240 + return $data;
241 + } catch(\Exception $ex) {
242 + return false;
243 + }
244 + }
245 +
246 + public function deleteInstance()
247 + {
248 + try {
249 + $this->collection->document($this->id())->delete();
250 + $data = $this->toArray();
251 + $this->nullifyInstance();
252 + return $data;
253 + } catch(\Exception $ex) {
254 + return false;
255 + }
256 + }
257 +
258 +
230 259 }

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 7/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

  app/Turn.php
... ... @@ -3,6 +3,7 @@
3 3 namespace App;
4 4
5 5 use App\Support\LarafireModel;
6 + use TurnState;
6 7
7 8 class Turn extends LarafireModel
8 9 {
... ... @@ -16,5 +17,11 @@ class Turn extends LarafireModel
16 17 return count($records) > 0;
17 18 }
18 19
19 -
20 + public static function getUnfinishedTurnByEmployee($employeeId)
21 + {
22 + $turns = Turn::where('idEmployee', '=', $employeeId)
23 + ->where('state', 'in', [TurnState::ESPERANDO, TurnState::ATENDIENDO])
24 + ->documents()->rows();
25 + return count($turns) > 0 ? Turn::rowsToInstances($turns)[0] : null;
26 + }
20 27 }

  bootstrap/cache/config.php

... ... @@ -522,7 +522,7 @@


522 522 ),
523 523 'notify' =>
524 524 array (
525 - 'default' => 'toastr',
525 + 'default' => 'sweetalert2',
526 526 'toastr' =>
527 527 array (
528 528 'class' => 'Yoeunes\\Notify\\Notifiers\\Toastr',
... ... @@ -595,6 +595,8 @@
595 595 ),
596 596 'options' =>
597 597 array (
598 + 'showConfirmButton' => false,
599 + 'timer' => 4000,
598 600 ),
599 601 ),
600 602 ),
... ...

  composer.json
... ... @@ -51,7 +51,7 @@
51 51 "app/Support/LarafireCollection.php",
52 52 "app/Support/LarafireFunctions.php",
53 53 "app/Support/State.php",
54 - "app/Support/Functions.php"
54 + "app/Support/Globals.php"
55 55 ]
56 56 },
57 57 "autoload-dev": {
... ...

  config/notify.php
... ... @@ -2,7 +2,7 @@
2 2
3 3 return [
4 4
5 - 'default' => 'toastr',
5 + 'default' => 'sweetalert2',
6 6
7 7 'toastr' => [
8 8
... ... @@ -74,6 +74,6 @@ return [
74 74 'warning',
75 75 ],
76 76
77 - 'options' => [],
77 + 'options' => ['showConfirmButton' => false, 'timer' => 4000],

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 8/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

78 78 ],
79 79 ];

  public/images/educacion-vial.jpg 0 → 100644

72.4 KB

  public/js/master.js
... ... @@ -9,9 +9,21 @@ window.Progress = {
9 9 }
10 10 }
11 11
12 -
13 12 window.addEventListener("beforeunload", function (e) {
14 13 const loader = document.getElementById("loader");
15 14 loader.classList.add('d-flex');
16 15 loader.classList.remove('d-none');
17 16 })
17 +
18 + const Toast = Swal.mixin({
19 + toast: true,
20 + position: 'center',
21 + showConfirmButton: false,
22 + timer: 4000,
23 + timerProgressBar: true,
24 + onOpen: (toast) => {
25 + toast.addEventListener('mouseenter', Swal.stopTimer)
26 + toast.addEventListener('mouseleave', Swal.resumeTimer)
27 + }
28 + })
29 +

  public/videos/educacion-vial.mp4 0 → 100644

File added

  resources/views/layouts/app.blade.php
... ... @@ -21,7 +21,8 @@
21 21 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/pretty-
checkbox.min.css">
22 22 <link rel="stylesheet" href="https://unpkg.com/[email protected]/nprogress.css">
23 23
24 - @notify_css

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 9/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

24 + <!-- @notify_css -->


25 +
25 26 <link rel="stylesheet" href="{{ asset('css/master.css') }}">
26 27 </head>
27 28 <body class="{{ $class ?? '' }}">
... ... @@ -47,8 +48,9 @@
47 48 @include('layouts.footers.guest')
48 49 @endlfguest
49 50
50 - @notify_js
51 - @notify_render
51 + <!-- @notify_js -->
52 + <!-- @notify_render -->
53 + <script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
52 54 <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
53 55 <!-- <script src="https://cdn.jsdelivr.net/npm/vue"></script> -->
54 56 <script src="{{ asset('argon') }}/vendor/jquery/dist/jquery.min.js"></script>
... ... @@ -59,6 +61,12 @@
59 61 <script src="{{ asset('js/app.js') }}"></script>
60 62 <script src="{{ asset('js/master.js') }}"></script>
61 63
64 + @if (session()->has('feedback'))
65 + <script>
66 + Toast.fire({ icon: 'success', title: 'Signed in successfully' })
67 + </script>
68 + @endif
69 +
62 70 @stack('js')
63 71
64 72 <!-- Argon JS -->
... ...

  resources/views/pages/tv.blade.php
... ... @@ -13,7 +13,13 @@
13 13
14 14 <div class="col-lg-6 d-flex align-items-center" style="height:80vh">
15 15 <div class="w-100">
16 - <img src="http://placehold.it/600x400" style="max-width:100%">
16 + {{-- <img src="{{asset('images/educacion-vial.jpg')}}" style="max-width:100%"> --}}
17 + <video src="{{ asset('videos/educacion-vial.mp4') }}"
18 + autoplay
19 + muted
20 + poster="{{ asset('images/educacion-vial.jpg') }}">
21 + Tu navegador no admite el elemento <code>video</code>.
22 + </video>
17 23 </div>
18 24 </div>
19 25
... ... @@ -33,10 +39,12 @@
33 39 <table class="table">
34 40 <thead>
35 41 <th class="text-center">Turno</th>
42 + <th class="text-center">Nombre</th>
36 43 <th class="text-center">Lugar</th>
37 44 </thead>
38 45 <tr v-for="turn in calledTurns">
39 46 <td class="text-center">@{{ turn.order }}</td>
47 + <td class="text-center">@{{ turn.name }}</td>
40 48 <td class="text-center">@{{ turn.label }}</td>
41 49 </tr>
42 50 </table>
... ... @@ -94,9 +102,31 @@
94 102 }
95 103 },
96 104 methods: {
97 - handleNewTurn(data) {
98 - this.callingTurns.push(data)
99 - this.calledTurns.push(data)
105 + handleNewTurn(turn) {
106 + this.callingTurns.push(turn)
107 + this.calledTurns.push(turn)
108 + },
109 + handleStartedAttendingTurn(turn) {
110 + const callingTurnsFiltered = this.callingTurns.filter(callingTurn => {

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 10/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

111 + return callingTurn.order != turn.order


112 + })
113 + this.callingTurns = callingTurnsFiltered
114 + },
115 + handleFinishedTurn(turn) {
116 + const calledTurnsFiltered = this.calledTurns.filter(calledTurn => {
117 + return calledTurn.order != turn.order
118 + })
119 + this.calledTurns = calledTurnsFiltered
120 + },
121 + handleCanceledTurn(turn) {
122 + const calledTurnsFiltered = this.calledTurns.filter(calledTurn => {
123 + return calledTurn.order != turn.order
124 + })
125 + const callingTurnsFiltered = this.callingTurns.filter(callingTurn => {
126 + return callingTurn.order != turn.order
127 + })
128 + this.callingTurns = callingTurnsFiltered
129 + this.calledTurns = calledTurnsFiltered
100 130 },
101 131 speakTurn() {
102 132 const t = this.currentCallingTurn
... ... @@ -108,7 +138,7 @@
108 138 },
109 139 loadTurnsState() {
110 140 Progress.start()
111 - axios.get('/api/turns/state')
141 + axios.get('/api/pending-turns/all-from-today')
112 142 .then(res => {
113 143 if (res.data.status == 'success') {
114 144 const callingTurns = res.data.data.pendingTurns.filter(turn => {
... ... @@ -123,29 +153,46 @@
123 153 }).catch(err => {
124 154 bootbox.alert('<p>Error al cargar el estado de turnos</p>.\n')
125 155 console.log(err.response)
126 - }).then(() => Progress.done())
156 + }).then(() => {
157 + Progress.done()
158 + bootbox.alert('Este software usa su sistema de sonido.', () => {
159 + this.activateSpeech()
160 + Echo.channel('turns')
161 + .listen('TurnStateChanged', e => {
162 + switch (e.pendingTurn['state']) {
163 + case @json(TurnState::ESPERANDO):
164 + this.handleNewTurn(e.pendingTurn)
165 + break
166 + case @json(TurnState::ATENDIENDO):
167 + this.handleStartedAttendingTurn(e.pendingTurn)
168 + break
169 + case @json(TurnState::TERMINADO):
170 + this.handleFinishedTurn(e.pendingTurn)
171 + break
172 + case @json(TurnState::CANCELADO):
173 + this.handleCanceledTurn(e.pendingTurn)
174 + break
175 + }
176 + })
177 + this.startCallingTurnCicle()
178 + })
179 + })
180 + },
181 + startCallingTurnCicle() {
182 + const callingTurnsCicleCounterInterval = setInterval(() => {
183 + if (this.callingTurns.length && !this.currentCallingTurn) {
184 + if (++this.callingTurnsCicleCounter == 7) {
185 + const index = !this.lastCalledTurn ? 0 : this.callingTurns.map(t =>
t.order).indexOf(this.lastCalledTurn.order)
186 + let indexToCall = this.callingTurns.length > 1 ? index+1 : index
187 + indexToCall = indexToCall > this.callingTurns.length-1 ? 0 : indexToCall
188 + this.currentCallingTurn = this.callingTurns[indexToCall]
189 + }
190 + }
191 + }, 1000)
127 192 }
128 193 },

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 11/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

129 194 mounted() {


130 - Echo.channel('turns')
131 - .listen('TurnCalled', e => {
132 - this.handleNewTurn(e.data)
133 - })
134 -
135 - const callingTurnsCicleCounterInterval = setInterval(() => {
136 - if (this.callingTurns.length && !this.currentCallingTurn) {
137 - if (++this.callingTurnsCicleCounter == 7) {
138 - const index = !this.lastCalledTurn ? 0 : this.callingTurns.map(t =>
t.order).indexOf(this.lastCalledTurn.order)
139 - let indexToCall = this.callingTurns.length > 1 ? index+1 : index
140 - indexToCall = indexToCall > this.callingTurns.length-1 ? 0 : indexToCall
141 - this.currentCallingTurn = this.callingTurns[indexToCall]
142 - }
143 - }
144 - }, 1000)
145 -
146 195 this.loadTurnsState()
147 -
148 - bootbox.alert('Este software usa su sistema de sonido.', () => this.activateSpeech())
149 196 },
150 197
151 198 })
... ...

  resources/views/queue/index.blade.php

... ... @@ -158,6 +158,8 @@


158 158 },
159 159 fetchClient() {
160 160 if (!this.queue.identification) return false
161 + this.isNewClient = true
162 + this.queue.name = ''
161 163 Progress.start()
162 164 axios.get('/api/clients/find-by-identification/'+this.queue.identification)
163 165 .then(res => {
... ...

  resources/views/turns/index.blade.php
1 1 @extends('layouts.app', ['title' => 'Turnos'])
2 2 @section('content')
3 3 <div class="container" id="turns">
4 -
5 4 <div class="row">
6 5 <div class="col text-center d-flex flex-column align-items-center">
6 +
7 7 <a href="#"
8 8 class="btn mb-4 btn-primary btn-xl"
9 9 v-show="status == 'idling'"
... ... @@ -13,8 +13,8 @@
13 13 <a href="#"
14 14 class="btn mb-4 btn-warning btn-xl"
15 15 v-show="status == 'waiting'"
16 - @click.prevent="cancelTurnAndCallNext">
17 - CANCELAR TURNO Y LLAMAR A SIGUIENTE
16 + @click.prevent="cancelTurn">
17 + CANCELAR TURNO
18 18 </a>
19 19
20 20 <div v-show="status != 'idling'">
... ... @@ -67,9 +67,6 @@
67 67 Progress.start()
68 68 axios.get(@json(route('api.turns.create')))
69 69 .then((res) => {
70 - if (res.data.status == 'failed') {
71 - return bootbox.alert('Hay un turno en llamada. Por favor, intente
cuando el turno haya sido respondido.')
72 - }
73 70 if (res.data.status == 'success') {
74 71 this.client = res.data.data.client
75 72 this.queue = res.data.data.queue
... ... @@ -96,7 +93,8 @@
96 93 this.startTimer()

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 12/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

97 94 }
98 95 }).catch(err => {
99 - bootbox.alert('Ocurrió un error al comunicarse con el servidor.')
96 + bootbox.alert("<p>Ocurrió un error al llamar al siguiente turno.</p>"
97 + +err.response.data?.message?.toUpperCase())
100 98 console.log('err',err)
101 99 }).then(() => Progress.done())
102 100 },
... ... @@ -104,19 +102,39 @@
104 102 Progress.start()
105 103 axios.put('/api/turns/'+this.turn.id+'/finish', {
106 104 _token: $('[name=csrf-token]').attr('content'),
107 - state: 'Terminado',
108 105 dateFin: new Date()
109 106 }).then(res => {
110 107 if (res.data.status == 'success') {
111 108 this.status = 'idling'
112 - this.startTimer()
109 + this.stopTimer()
110 + this.resetAppData()
113 111 }
114 112 }).catch(err => {
115 - bootbox.alert('Ocurrió un error al comunicarse con el servidor.')
113 + bootbox.alert("<p>Ocurrió un error al llamar al siguiente turno.</p>"
114 + +err.response.data?.message?.toUpperCase())
116 115 console.log('err',err)
117 116 }).then(() => Progress.done())
118 - this.status = 'idling'
119 - this.stopTimer()
117 + },
118 + cancelTurn() {
119 + Progress.start()
120 + axios.put('/api/turns/'+this.turn.id+'/cancel', {
121 + _token: $('[name=csrf-token]').attr('content'),
122 + }).then(res => {
123 + if (res.data.status == 'success') {
124 + this.status = 'idling'
125 + this.resetAppData()
126 + }
127 + }).catch(err => {
128 + bootbox.alert("<p>Ocurrió un error al llamar al siguiente turno.</p>"
129 + +err.response.data?.message?.toUpperCase())
130 + console.log('err',err)
131 + }).then(() => Progress.done())
132 + },
133 + resetAppData() {
134 + this.client = null
135 + this.queue = null
136 + this.turn = null
137 + this.userClient = null
120 138 },
121 139 startTimer() {
122 140 this.timer.start(/* config */)
... ...

  routes/web.php
... ... @@ -73,9 +73,16 @@ Route::group([
73 73 'as' => 'turns.'
74 74 ], function() {
75 75 Route::get('create','TurnController@create')->name('create'); //TODO: Debe ser post
76 - Route::get('state','TurnController@state')->name('state');
77 76 Route::put('{id}/start','TurnController@start')->name('start');
78 77 Route::put('{id}/finish','TurnController@finish')->name('finish');
78 + Route::put('{id}/cancel','TurnController@cancel')->name('cancel');
79 + });
80 +
81 + Route::group([
82 + 'prefix' => 'pending-turns',
83 + 'as' => 'prending-turns.'
84 + ], function() {
85 + Route::get('all-from-today','PendingTurnController@allFromToday')->name('all-from-today');
79 86 });
80 87 });
81 88

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 13/14
29/6/2020 Completa modo tv (9a612e96) · Commits · Guillermo Agudelo / transito-frontend · GitLab

Write a comment or drag your files here…

Markdown and quick actions are supported

https://gitlab.com/guille.agudelo/transito-frontend/-/commit/9a612e9693e682f8d8795dfab19b572e5fa78413 14/14

You might also like