You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

319 lines
14 KiB

  1. <div class="h-full lg:min-w-full xl:min-w-0" x-data="UI.createTable({db:'{arguments:db}'})">
  2. <div class="border-base-200 flex items-center justify-between px-5 mb-[10px] space-x-3">
  3. <div>
  4. <span class="text-2xl text-[#008EED] leading-[80px]">{arguments:db}s</span>
  5. </div>
  6. <div role="alert" class="alert alert-info alert-soft hidden lg:flex">
  7. <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-info h-6 w-6 shrink-0 stroke-[#008EED]">
  8. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
  9. </svg>
  10. <span class="text-[#008EED]" js-data="texts tables info track">This is the log of the events related to trackers with their latest status</span>
  11. </div>
  12. <div class="flex items-center gap-2">
  13. <label class="input input-primary w-[200px]">
  14. <span
  15. class="iconify lucide--search text-base-content/70 size-4.5 "></span>
  16. <input
  17. class="text-base placeholder:text-sm"
  18. type="search"
  19. x-model="search"
  20. @input="updateSearch"
  21. placeholder="Search" />
  22. </label>
  23. <!-- <div class="dropdown dropdown-bottom dropdown-end">
  24. <div
  25. tabindex="0"
  26. role="button"
  27. class="btn btn-outline btn-primary">
  28. <span
  29. class="iconify lucide--columns-3-cog size-4"></span>
  30. </div>
  31. <div tabindex="0" class="dropdown-content bg-base-100 rounded-box w-44 shadow">
  32. <ul class="menu w-full">
  33. <template
  34. x-for="column in allLeafColumns"
  35. :key="column.id">
  36. <li @click="toggleColumn(column)">
  37. <div
  38. class="group gap-2.5"
  39. :data-visible="isColumnVisible(column) ? true : null">
  40. <span
  41. class="iconify lucide--check size-4 scale-50 opacity-0 transition-all duration-300 group-data-visible:scale-100 group-data-visible:opacity-100"></span>
  42. <span
  43. class="font-medium"
  44. x-text="column.columnDef.header"></span>
  45. </div>
  46. </li>
  47. </template>
  48. </ul>
  49. </div>
  50. </div> -->
  51. <div class="dropdown dropdown-bottom dropdown-end">
  52. <div
  53. aria-label="More actions"
  54. tabindex="0"
  55. role="button"
  56. class="btn btn-outline btn-primary">
  57. <span
  58. class="iconify lucide--ellipsis-vertical size-4"></span>
  59. </div>
  60. <div
  61. tabindex="0"
  62. class="dropdown-content bg-base-100 rounded-box w-44 shadow">
  63. <ul class="menu w-full">
  64. <li class="update{arguments:db}" @click="updateData()">
  65. <div>
  66. <span
  67. class="iconify lucide--refresh-cw size-4"></span>
  68. Refresh Data
  69. </div>
  70. </li>
  71. <li>
  72. <div>
  73. <span
  74. class="iconify lucide--download size-4"></span>
  75. Export
  76. </div>
  77. </li>
  78. </ul>
  79. </div>
  80. </div>
  81. <button type="submit" class="btn btn-outline btn-primary" style="cursor: pointer;" onclick="js.part({'do':'{arguments:new}',arguments:{db:'{arguments:db}'}})">Add</button>
  82. </div>
  83. </div>
  84. <div class="flex w-full px-[30px]">
  85. <div class=" max-h-[calc(100vh-260px)] overflow-y-scroll overflow-x-auto w-full border-solid border-1 border-[#008EED] rounded-none">
  86. <div class="min-w-[480px] px-[20px] py-[20px] border-base-200 flex flex-wrap items-center justify-between gap-2">
  87. <div class="join border-solid border-1 border-[#008EED] rounded-md">
  88. <button
  89. class="btn btn-square btn-sm btn-outline border-base-300 join-item"
  90. aria-label="Pagination controls"
  91. :disabled="!table.getCanPreviousPage()"
  92. @click="prevPage()">
  93. <span class="iconify lucide--arrow-left"></span>
  94. </button>
  95. <input
  96. aria-label="Page number"
  97. min="1"
  98. :max="table.getPageCount()"
  99. :value="pageIndex + 1"
  100. @input="setPageIndex($event.target.value - 1)"
  101. class="input input-sm join-item w-10 text-center border-0" />
  102. <button
  103. class="btn btn-square btn-sm btn-outline border-base-300 join-item"
  104. aria-label="Pagination controls"
  105. :disabled="!table.getCanNextPage()"
  106. @click="nextPage()">
  107. <span class="iconify lucide--arrow-right"></span>
  108. </button>
  109. </div>
  110. <p class="text-base-content/70 text-sm max-md:hidden">
  111. <span
  112. class="text-base-content font-medium"
  113. x-text="`${start}–${end}`"></span>
  114. out of
  115. <span
  116. class="text-base-content font-medium"
  117. x-text="rowCount"></span>
  118. </p>
  119. <div class="flex items-center gap-2">
  120. <p class="text-base-content/70 text-sm max-md:hidden">
  121. Per page
  122. </p>
  123. <select
  124. aria-label="Items per page"
  125. class="select select-sm w-16 border-solid border-1 border-[#008EED]"
  126. @change="changePageSize(Number($event.target.value))">
  127. <template x-for="size in pageSizes" :key="size">
  128. <option
  129. :value="size"
  130. :selected="size === pageSize"
  131. x-text="size"></option>
  132. </template>
  133. </select>
  134. </div>
  135. </div>
  136. <table class="table">
  137. <thead>
  138. <template
  139. x-for="headerGroup in table.getHeaderGroups()"
  140. :key="headerGroup.id">
  141. <tr>
  142. <template
  143. x-for="header in headerGroup.headers"
  144. :key="header.id">
  145. <th
  146. class="text-[#008EED]",
  147. x-show="!header.isPlaceholder"
  148. x-text="flexRender(header.column.columnDef.header, header.getContext())"></th>
  149. </template>
  150. </tr>
  151. </template>
  152. </thead>
  153. <tbody>
  154. <template x-if="!visibleRows.length">
  155. <tr>
  156. <td
  157. :colspan="columns.length"
  158. class="h-24 text-center">
  159. <p>
  160. No results.
  161. <span
  162. @click="clearFilters"
  163. class="text-primary cursor-pointer hover:underline">
  164. Clear filters
  165. </span>
  166. </p>
  167. </td>
  168. </tr>
  169. </template>
  170. <template x-if="visibleRows.length">
  171. <template
  172. x-for="row in visibleRows"
  173. :key="row.id"
  174. >
  175. <tr>
  176. <template
  177. x-for="cell in getVisibleCells(row)"
  178. :key="cell.id"
  179. >
  180. <td>
  181. <template
  182. x-if="cell.column.id === 'subject'">
  183. <div
  184. class="flex items-center gap-2">
  185. <div>
  186. <p
  187. class="leading-none font-medium"
  188. x-text="cell.row.original.subject"></p>
  189. <p
  190. class="text-base-content/70 mt-0.5 text-xs/none"
  191. x-text="cell.row.original.trackerMac"></p>
  192. </div>
  193. </div>
  194. </template>
  195. <template
  196. x-if="cell.column.id === 'id'">
  197. <span
  198. class="text-base-content/70 font-mono text-xs uppercase"
  199. x-text="cell.row.original.id"></span>
  200. </template>
  201. <template
  202. x-if="cell.column.id === 'status'">
  203. <span
  204. :class="{
  205. 'badge badge-success badge-sm badge-soft': cell.row.original.status === 'detected',
  206. 'badge badge-info badge-sm badge-soft': cell.row.original.status === 'help',
  207. 'badge badge-error badge-sm badge-soft': cell.row.original.status === 'away',
  208. 'badge badge-ghost badge-sm': ['lost', null, undefined].includes(cell.row.original.status)
  209. }"
  210. x-text="cell.row.original.status.charAt(0).toUpperCase() + cell.row.original.status.slice(1)"></span>
  211. </template>
  212. <template
  213. x-if="cell.column.id === 'time'">
  214. <p
  215. class="space-x-1 whitespace-nowrap">
  216. <span
  217. x-text="new Date(cell.row.original.time).toLocaleDateString('it-IT', {day: 'numeric', month: 'short', year: '2-digit'})"></span>
  218. <span
  219. class="text-base-content/60 text-xs"
  220. x-text="new Date(cell.row.original.time).toLocaleTimeString([], {hour: '2-digit', minute: '2-digit', second: '2-digit'})"></span>
  221. </p>
  222. </template>
  223. <template
  224. x-if="cell.column.id === 'gateway'">
  225. <div
  226. class="flex items-center gap-2">
  227. <div>
  228. <p
  229. class="leading-none font-medium"
  230. x-text="cell.row.original.gatewayName"></p>
  231. <p
  232. class="text-base-content/70 mt-0.5 text-xs/none"
  233. x-text="cell.row.original.gatewayMac"></p>
  234. </div>
  235. </div>
  236. </template>
  237. <template
  238. x-if="cell.column.id === 'model'">
  239. <span
  240. class="text-base font-medium"
  241. x-text="cell.row.original.model"></span>
  242. </template>
  243. <template
  244. x-if="cell.column.id === 'signal'">
  245. <span
  246. class="text-base font-medium"
  247. x-text="cell.row.original.signal + '%'"></span>
  248. </template>
  249. <template
  250. x-if="cell.column.id === 'actions'">
  251. <div
  252. class="gap-2 text-right">
  253. <button
  254. aria-label="Show"
  255. class="saveButton btn btn-outline btn-primary"
  256. @click="viewRow(cell.row)"
  257. >Open</button>
  258. </div>
  259. </template>
  260. <template
  261. x-if="!
  262. ['id', 'time', 'subject', 'gateway', 'status', 'signal', 'actions'].includes(cell.column.id)">
  263. <span
  264. x-html="cell.column.columnDef.cell
  265. ? cell.column.columnDef.cell(cell.getContext())
  266. : cell.getValue()"></span>
  267. </template>
  268. </td>
  269. </template>
  270. </tr>
  271. </template>
  272. </template>
  273. </tbody>
  274. </table>
  275. </div>
  276. <div class="post min-w-[400px] max-w-[600px] max-h-[calc(100vh-260px)] overflow-y-scroll border-solid border-1 border-[#008EED] rounded-none post{arguments:id} ml-[30px] mb-[30px] hidden"></div>
  277. </div>
  278. </div>