Dashboard sipadu mbip
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

index.blade.php 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. @extends('layout.master', ['uid' => $user->_id, 'token' => $user->token_firebase])
  2. @section('page_title', 'Halaman Utama')
  3. @section('sub_page_title', 'Selamat Datang ke Papan Pemuka Pegawai')
  4. @section('name', $user->StaffDetail->full_name)
  5. @section('img_profile', $user->StaffDetail->profile_img)
  6. @section('content')
  7. <style type="text/css">
  8. html, body {
  9. height: 100% !important;
  10. }
  11. body { overflow-y:hidden !important; }
  12. .pcoded-inner-content { padding-left: 0px !important; padding-right: 0px !important; }
  13. .main-body .page-wrapper { padding: 0px !important; }
  14. #map {
  15. height: 100%;
  16. width: 100%;
  17. }
  18. #dataS {
  19. position: absolute;
  20. left: 10px;
  21. top: 0px;
  22. z-index: 999;
  23. margin: 10px 15px 0px 15px;
  24. border-radius: 8px 8px 0 0;
  25. border-bottom: 1px solid #DADCE0;
  26. box-shadow: 0 2px 4px rgba(0,0,0,0.2), 0 -1px 0px rgba(0,0,0,0.02);
  27. }
  28. #dataEmer {
  29. position: absolute;
  30. left: 50%;
  31. top: 30px;
  32. z-index: 999;
  33. margin: 10px 15px -50px 15px;
  34. border-radius: 8px 8px 0 0;
  35. border-bottom: 1px solid #DADCE0;
  36. box-shadow: 0 2px 4px rgba(0,0,0,0.2), 0 -1px 0px rgba(0,0,0,0.02);
  37. }
  38. .searchbox-shadow {
  39. box-shadow: 0 2px 4px rgba(0,0,0,0.2), 0 -1px 0px rgba(0,0,0,0.02);
  40. }
  41. #dataS .card { height: 100%; }
  42. @media (max-width: 765px) {
  43. .pcoded .pcoded-inner-content {
  44. padding: 0px !important;
  45. }
  46. body.horizontal-icon .pcoded .main-body, body.horizontal-icon-fixed .pcoded .main-body {
  47. margin-top: 0px !important;
  48. }
  49. #map {
  50. height: 100%;
  51. width: 100%;
  52. }
  53. }
  54. </style>
  55. <div class="row">
  56. <div class="col-xl-12 col-md-12">
  57. <audio id="myAudio">
  58. <source src="{{ url('siren.mp3') }}" type="audio/mpeg">
  59. Your browser does not support the audio element.
  60. </audio>
  61. <div id="map"></div>
  62. <div id="dataS">
  63. <div class="card" style="margin-bottom: 0px">
  64. <div class="card-header">
  65. <h5>Senarai PenguatKuasa</h5>
  66. </div>
  67. <div class="card-block">
  68. <form class="form-inline">
  69. <div class="form-group" style="padding-right: 10px;">
  70. <select id="pg" name="pg" class="form-control">
  71. <option selected value="null">Sila pilih penguatkuasa</option>
  72. </select>
  73. </div>
  74. <div class="form-group">
  75. <button type="button" id="tapis" class="btn btn-primary btn-sm waves-effect waves-light" style="padding: 6px 14px !important;">Tapis</button>
  76. </div>
  77. </form>
  78. </div>
  79. </div>
  80. </div>
  81. <div id="dataEmer">
  82. <button id="closeEmergency">Tutup Amaran Kecemasan</button>
  83. </div>
  84. </div>
  85. </div>
  86. @endsection
  87. @section('external_js')
  88. @parent
  89. <script type="text/javascript">
  90. var origin = window.location.origin;
  91. var param = 'null', map, infowindow, markers = [], markerStore = [], infoWindowContent = [];
  92. var focusCenter = '', stateMap = 'init', focus = true;
  93. function initialize(latit, logit) {
  94. infowindow = new google.maps.InfoWindow();
  95. var myLatlng = new google.maps.LatLng(1.5371973,103.6602123);
  96. var myOptions = {
  97. zoom: 17,
  98. center: myLatlng,
  99. mapTypeId: google.maps.MapTypeId.TERRAIN
  100. }
  101. map = new google.maps.Map(document.getElementById("map"), myOptions);
  102. setMarkers(param);
  103. }
  104. // Sets the map on all markers in the array.
  105. function setMapOnAll(map) {
  106. for (var i = 0; i < markers.length; i++) {
  107. markers[i].setMap(map);
  108. }
  109. }
  110. // Removes the markers from the map, but keeps them in the array.
  111. function clearMarkers() {
  112. setMapOnAll(null);
  113. }
  114. // Shows any markers currently in the array.
  115. function showMarkers() {
  116. setMapOnAll(map);
  117. }
  118. // Deletes all markers in the array by removing references to them.
  119. function deleteMarkers() {
  120. clearMarkers();
  121. markerStore = [];
  122. }
  123. function setMarkers(data){
  124. var bounds = new google.maps.LatLngBounds();
  125. $.ajax({
  126. type: "GET",
  127. url: origin+"/api/track/coordinates/"+data+"/list",
  128. success: function(result){
  129. if(result.success == true){
  130. if(stateMap == 'normal' && focus == false){
  131. if(map.getZoom() == 17){
  132. focus = true;
  133. }
  134. }
  135. for(var i=0, len=result.data.length; i<len; i++) {
  136. var lati = parseFloat(result.data[i].latitude);
  137. var logi = parseFloat(result.data[i].longitude);
  138. var iconM = result.data[i].icon;
  139. //Do we have this marker already?
  140. if(markerStore.hasOwnProperty(result.data[i]._id)) {
  141. var marker = markerStore[result.data[i]._id];
  142. markerStore[result.data[i]._id].setPosition(new google.maps.LatLng(lati,logi));
  143. if(result.data[i].status == 'emergency'){
  144. stateMap = 'emergency';
  145. bounds.extend(new google.maps.LatLng(lati,logi));
  146. markerStore[result.data[i]._id].setIcon(result.data[i].icon);
  147. markerStore[result.data[i]._id].setAnimation(google.maps.Animation.BOUNCE);
  148. map.fitBounds(bounds);
  149. }else if(result.data[i].status == 'normal'){
  150. markerStore[result.data[i]._id].setIcon(result.data[i].icon);
  151. markerStore[result.data[i]._id].setAnimation(null);
  152. if(result.data[i]._id == data){
  153. focusSelectionStaff(lati,logi);
  154. }
  155. }
  156. } else {
  157. var html = "<b>" + result.data[i].title + "</b> <br/>" + result.data[i].content + "<br> <a target='_blank ' href='https://www.google.com/maps/search/?api=1&query="+lati+","+logi+"'>Lihat di google map</a>";
  158. var location = new google.maps.LatLng(lati, logi);
  159. var marker = new google.maps.Marker({
  160. position: location,
  161. map: map,
  162. icon: iconM,
  163. });
  164. markerStore[result.data[i]._id] = marker;
  165. google.maps.event.addListener(markerStore[result.data[i]._id], 'click', getInfoCallback(map, html), eventP());
  166. }
  167. }
  168. }else if(result.success == false){
  169. swal("Tiada Rekod", "Tiada data yang ditemui", "error");
  170. }
  171. }
  172. });
  173. }
  174. function getInfoCallback(map, content) {
  175. var infowindow = new google.maps.InfoWindow({ content: content });
  176. return function () {
  177. infowindow.setContent(content);
  178. infowindow.open(map, this);
  179. };
  180. };
  181. function focusSelectionStaff(newLat,newLng) {
  182. map.setCenter({
  183. lat : newLat,
  184. lng : newLng
  185. });
  186. }
  187. function eventP(){
  188. var passiveEvent = false;
  189. try {
  190. var opts = Object.defineProperty({}, 'passive', {
  191. get: function () {
  192. passiveEvent = true;
  193. }
  194. });
  195. window.addEventListener("test", null, opts);
  196. } catch (e) { }
  197. // in my case I need both passive and capture set to true, change as you need it.
  198. passiveEvent = passiveEvent ? { capture: true, passive: true } : true;
  199. return passiveEvent;
  200. }
  201. </script>
  202. <script type="text/javascript">
  203. var ellipsis = "...";
  204. function TrimLength(text, maxLength)
  205. {
  206. text = $.trim(text);
  207. if (text.length > maxLength)
  208. {
  209. text = text.substring(0, maxLength - ellipsis.length)
  210. return text.substring(0, text.lastIndexOf(" ")) + ellipsis;
  211. }
  212. else
  213. return text;
  214. }
  215. $.ajaxSetup({
  216. headers: {
  217. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  218. }
  219. });
  220. function setSelectedIndex(s, i){
  221. s.options[i-1].selected = true;
  222. return;
  223. }
  224. function checkStateMap(audio, callback){
  225. callback(param);
  226. setTimeout(function () {
  227. if(stateMap == 'emergency'){
  228. $('#dataS').hide();
  229. $('#dataEmer').show();
  230. audio.play();
  231. }else if(stateMap == 'normal'){
  232. $('#dataS').show();
  233. $('#dataEmer').hide();
  234. audio.pause();
  235. audio.currentTime = 0;
  236. if(focus == false){
  237. param = 'null';
  238. setSelectedIndex(document.getElementById("pg"),1);
  239. focusSelectionStaff(4.4695721,101.376383);
  240. map.setZoom(17);
  241. }
  242. }
  243. }, 5000);
  244. }
  245. function fill_staff_list(){
  246. $.ajax({
  247. type: "GET",
  248. url: "{{ url('api/track/staff/list') }}",
  249. success: function(result){
  250. $.each(result.data, function(i, d) {
  251. var full_sentences = '[' + d.no_badan + '] '+ d.nama;
  252. $('#pg').append('<option value="' + d.id + '">' + TrimLength(full_sentences, 30) +'</option>');
  253. $('#pg').prop('required',true);
  254. });
  255. }
  256. });
  257. }
  258. $(document).ready(function() {
  259. $('#dataEmer').hide();
  260. $(".theme-loader").animate({
  261. opacity: "0"
  262. },1000);
  263. setTimeout(function() {
  264. $(".theme-loader").remove();
  265. }, 800);
  266. $('[data-toggle="tooltip"]').tooltip();
  267. var nav = $(".pcoded-navbar").height();
  268. var navbar = $(".navbar").height();
  269. $('#map').css('height', $(window).height() - (nav+navbar) );
  270. fill_staff_list();
  271. var audio = document.getElementById("myAudio");
  272. $("#tapis").click(function(){
  273. var pg = $('#pg').val();
  274. if(pg == 'null'){
  275. focus = false;
  276. stateMap = 'normal';
  277. }else{
  278. param = pg;
  279. stateMap = 'init';
  280. }
  281. $('#dataEmer').hide();
  282. });
  283. $("#closeEmergency").click(function(){
  284. $.ajax({
  285. type: "POST",
  286. url: origin+"/api/update/normal/status",
  287. success: function(result){
  288. if(result.success == true){
  289. focus = false;
  290. stateMap = 'normal';
  291. }else if(result.success == false){
  292. swal("Tiada Rekod", "Tiada data yang ditemui", "error");
  293. }
  294. }
  295. });
  296. });
  297. setInterval(function() {
  298. checkStateMap(audio,setMarkers);
  299. var navbars = $("#map").width();
  300. $('#map').css('height', $(window).height() - (nav+navbar) );
  301. if(navbars <= 765){
  302. $('#map').css('height', $(window).height() - (nav) );
  303. }
  304. }, 4000);
  305. });
  306. </script>
  307. @endsection