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.

437 lines
19 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
3 years ago
​
3 years ago
​
​
​
3 years ago
​
​
​
​
​
3 years ago
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
3 years ago
3 years ago
​
3 years ago
​
3 years ago
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
3 years ago
​
3 years ago
​
​
​
​
​
​
3 years ago
​
​
​
​
​
​
​
  1. <!doctype html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3. <head th:replace="fragments/head :: head"></head>
  4. <body>
  5. <!-- Page Container -->
  6. <div id="page-container" class="sidebar-o sidebar-dark enable-page-overlay side-scroll page-header-fixed page-header-dark">
  7. <!-- Side Overlay aside (right)-->
  8. <aside th:replace="fragments/aside-right :: aside"></aside>
  9. <!-- END Side Overlay (right)-->
  10. <!-- Sidebar Nav-->
  11. <nav th:replace="fragments/nav :: nav"></nav>
  12. <!-- END Sidebar -->
  13. <!-- Header -->
  14. <header th:replace="fragments/header :: header"></header>
  15. <!-- END Header -->
  16. <!-- Main Container -->
  17. <main id="main-container">
  18. <!-- Hero -->
  19. <div class="">
  20. <div class="content content-full">
  21. <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
  22. <h3 class="flex-grow-1 fs-5 fw-semibold my-2 my-sm-3">Master</h3>
  23. <nav class="flex-shrink-0 my-2 my-sm-0 ms-sm-3" aria-label="breadcrumb">
  24. <ol class="breadcrumb">
  25. <li class="breadcrumb-item">Home</li>
  26. <li class="breadcrumb-item">Assets</li>
  27. <li class="breadcrumb-item active" aria-current="page">Asset List<li>
  28. </ol>
  29. </nav>
  30. </div>
  31. </div>
  32. </div>
  33. <!-- END Hero -->
  34. <!-- Page Content -->
  35. <div class="content">
  36. <div class="block block-rounded">
  37. <div class="block-header block-header-default">
  38. <h3 class="block-title">Asset List</h3>
  39. <div class="block-options">
  40. <button type="button" class="btn-block-option" onclick="callAdd();"><i class="far fa-plus-square"></i> Add New Asset</button>
  41. </div>
  42. </div>
  43. <div class="block-content p-0">
  44. <div class="p-sm-4 p-0">
  45. <div class="table-responsive">
  46. <table class="table table-bordered table-striped table-vcenter js-dataTable-buttons">
  47. <thead class="thead-light">
  48. <tr class="table-bordered">
  49. <th class="text-center no-sort">S.No</th>
  50. <th class="text-center" width="20%">Category</th>
  51. <th class="text-center" width="20%">Department Name</th>
  52. <th class="text-center" width="20%">Assign Person </th>
  53. <th class="text-center" width="20%">Asset Name </th>
  54. <th class="text-center" width="20%">Room/Position/Floor</th>
  55. <th class="text-center" width="20%">QRcode</th>
  56. <th class="text-center" width="10%">IsActive</th>
  57. <th class="text-center" width="10%">Action</th>>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. <tr th:each="assetlist, i : ${assetdetailslist}" class="${assetdetailslist}">
  62. <td th:text="${i.count}">0</td>
  63. <td class="text-center" th:text="${assetlist.assetCategory?.catName}"></td>
  64. <td class="text-center" th:text="${assetlist.departmentName}"></td>
  65. <td th:text="${assetlist.person}"></td>
  66. <td th:text="${assetlist.assetId}"></td>
  67. <td th:text="${assetlist.position}"></td>
  68. <td>
  69. <a tabindex="0" class="text-danger" data-bs-toggle="popover" data-bs-trigger="focus" title="" th:attr="data-bs-content=${'&lt;img src=&quot;data:image/png;base64,' + assetlist.qrcodeimg + '&quot; width=&quot;100%&quot; /&gt;'}" data-bs-html="true" th:text="${assetlist.assetCode}" style="font-size:10px;cursor:pointer"></a>
  70. </td>
  71. <td th:if="${assetlist.isActive}"><span class="badge bg-success">Active</span></td>
  72. <td th:unless="${assetlist.isActive}"><span class="badge bg-warning">InActive</span></td>
  73. <td class="text-center">
  74. <a th:onclick="views( [[${assetlist}]] );" data-bs-toggle="tooltip" data-bs-animation="true" data-bs-placement="top" title=""> <i class="fa fa-pen-to-square" id="showModalButton" style="font-size: 18px;"></i></a>
  75. <!-- <a th:href="@{#}" th:onclick="return false;" data-bs-toggle="tooltip" data-bs-animation="true" data-bs-placement="top" title="Edit"><i class="far fa-pen-to-square" style="font-size: 18px;"></i></a>&nbsp;&nbsp; -->
  76. <a th:href="@{#}" th:onclick="return callDelete([[${assetlist.assetName}]], [[${assetlist.assetId}]] );;" data-bs-toggle="tooltip" data-bs-animation="true" data-bs-placement="top" title="Delete"><i class="far fa-trash-can" style="font-size: 18px;"></i></a>
  77. <a tabindex="0" class="text-danger" data-bs-toggle="popover" data-bs-trigger="focus" title="" th:attr="data-bs-content=${'&lt;img src=&quot;data:image/png;base64,' + assetlist.assetimg + '&quot; width=&quot;100%&quot; /&gt;'}" data-bs-html="true" style="font-size:10px;cursor:pointer"><i class="far fa-image" style="font-size: 18px;"></i></a>
  78. </td>
  79. </tr>
  80. </tbody>
  81. </table>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <div class="modal fade" id="addForm" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  87. <div class="modal-dialog modal-lg" role="document">
  88. <div class="modal-content">
  89. <form action="#" th:action="@{/saveAsset}" th:object="${saveAsset}" method="post" enctype="multipart/form-data">
  90. <div class="block block-rounded block-themed block-transparent mb-0">
  91. <div class="block-header bg-primary-dark">
  92. <h3 class="block-title">Master Asset Add Form</h3>
  93. <div class="block-options">
  94. <button type="button" class="btn-block-option" data-bs-dismiss="modal" aria-label="Close">
  95. <i class="fa fa-fw fa-times"></i>
  96. </button>
  97. </div>
  98. </div>
  99. <div class="block-content">
  100. <div class="row">
  101. <div class="col-md-6 alert-light border-0">
  102. <div class="mb-3">
  103. <label class="form-check-label" for="assetCategory">Asset Catergory</label>
  104. <select class="form-select" name="assetCategory" id="assetCategory" required onchange="getParameter()">
  105. <option value="">Select</option>
  106. <option th:each="category: ${assetcategorylist}" th:value="${category.cId}" th:text="${category.catName}">-</option>
  107. </select>
  108. </div>
  109. </div>
  110. <div class="col-md-6 alert-light border-0">
  111. <label class="col-md-9 control-label">Asset Parameters</label>
  112. <div class="col-mb-9" id="parameterOpetionHtml">
  113. <p class="text-info">Select Asset Categeory to load Parameters.</p>
  114. </div>
  115. </div>
  116. <div class="col-md-12 alert-light border-0">
  117. <div class="mb-3">
  118. <label class="form-check-label" for="assetName">Name of the Asset</label>
  119. <input type="text" class="form-control" id="AssetName" required="" name="assetName">
  120. </div>
  121. </div>
  122. <div class="col-md-6 alert-light border-0">
  123. <div class="mb-3">
  124. <label class="form-check-label" for="departmentname">Department Name</label>
  125. <input type="text" class="form-control" name="departmentName" id="departmentname" required>
  126. </div>
  127. </div>
  128. <div class="col-md-6 alert-light border-0">
  129. <div class="mb-3">
  130. <label class="form-check-label" for="person">Assign person</label>
  131. <input type="text" class="form-control" name="person" id="Person" required>
  132. </div>
  133. </div>
  134. <div class="col-md-6 alert-light border-0">
  135. <div class="mb-3">
  136. <label class="form-check-label" for="position">Room/Position/Floor</label>
  137. <input type="text" class="form-control" name="position" id="Position" required>
  138. </div>
  139. </div>
  140. <div class="col-md-3 alert-light border-0">
  141. <div class="mb-3">
  142. <label class="form-check-label" for="assetLatitude">Latitude</label>
  143. <input type="text" class="form-control" id="AssetLatitude" name="assetLatitude">
  144. </div>
  145. </div>
  146. <div class="col-md-3 alert-light border-0">
  147. <div class="mb-3">
  148. <label class="form-check-label" for="assetLongitude">Longitude</label>
  149. <input type="text" class="form-control" id="assetLongitude" name="assetLongitude">
  150. </div>
  151. </div>
  152. <div class="col-md-12a alert-light border-0">
  153. <div class="mb-3">
  154. <label class="form-check-label" for="assetfile">Asset File</label>
  155. <input type="file" accept="image/*" class="form-control" name="assetFile" id="assetFile">
  156. </div>
  157. </div>
  158. <div id="viewimg"></div>
  159. </div><!--end row-->
  160. </div><!--end modal-body-->
  161. </div>
  162. <div class="block-content block-content-full text-end bg-body">
  163. <button type="button" class="btn btn-de-secondary btn-sm" data-bs-dismiss="modal">Close</button>
  164. <button type="submit" class="btn btn-primary btn-sm">Save</button>
  165. </div><!--end modal-footer-->
  166. </form>
  167. </div><!--end modal-content-->
  168. </div><!--end modal-dialog-->
  169. </div><!--end modal-->
  170. <div class="modal fade" id="views" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  171. <div class="modal-dialog modal-lg" role="document">
  172. <div class="modal-content">
  173. <div class="modal-content">
  174. <form action="#" th:action="@{/updateAsset}" th:object="${asset}" method="post">
  175. <div class="block block-rounded block-themed block-transparent mb-0">
  176. <div class="block-header bg-primary-dark">
  177. <h3 class="block-title">Edit/Save Gcc Assetlist</h3>
  178. <div class="block-options">
  179. <button type="button" class="btn-block-option" data-bs-dismiss="modal" aria-label="Close">
  180. <i class="fa fa-fw fa-times"></i>
  181. </button>
  182. </div>
  183. </div>
  184. <div class="block-content">
  185. <input type="hidden" class="form-control" name="assetId" id="PopAssetId" d>
  186. <div class="row">
  187. <div class="col-md-6 alert-light border-0">
  188. <div class="mb-3">
  189. <label class="form-check-label" for="catName">Category</label>
  190. <input type="text" class="form-control" name="catName" id="catName" required>
  191. </div>
  192. </div>
  193. <div class="col-md-6 alert-light border-0">
  194. <div class="mb-3">
  195. <label class="form-check-label" for="departmentName">Department Name</label>
  196. <input type="text" class="form-control" name="departmentName" id="departmentName" required >
  197. </div>
  198. </div>
  199. <div class="col-md-6 alert-light border-0">
  200. <div class="mb-3">
  201. <label class="for1m-check-label" for="person">Assign Person</label>
  202. <input type="text" class="form-control" name="person" id="person" required>
  203. </div>
  204. </div>
  205. <div class="col-md-3 alert-light border-0">
  206. <div class="mb-3">
  207. <label class="form-check-label" for="assetId">Asset Id</label>
  208. <input type="text" class="form-control" name="assetId" id="assetId" required>
  209. </div>
  210. </div>
  211. <!-- <div class="col-md-6 alert-light border-0">
  212. <div class="mb-3">
  213. <label class="form-check-label" for="assetName">Asset Id</label>
  214. <input type="text" class="form-control" name="assetName" id="assetName" required>
  215. </div>
  216. </div>-->
  217. <div class="col-md-3 alert-light border-0">
  218. <div class="mb-3">
  219. <label class="form-check-label" for="position">Room/Position/Floor</label>
  220. <input type="text" class="form-control" id="position" name="position">
  221. </div>
  222. </div>
  223. <div id="viewimg"></div>
  224. <div class="block-content block-content-full text-end bg-body">
  225. <button type="submit" class="btn btn-sm btn-primary" data-bs-dismiss="modal">Update</button>
  226. <button type="button" class="btn btn-de-secondary btn-sm" data-bs-dismiss="modal">Close</button>
  227. </div><!--end modal-footer-->
  228. </div><!--end row-->
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. </div>
  234. </form>
  235. </div>
  236. </div>
  237. <!-- END Page Content -->
  238. </main>
  239. <!-- END Main Container -->
  240. <!-- Footer -->
  241. <footer th:replace="fragments/footer :: footer"></footer>
  242. <!-- END Footer -->
  243. </div>
  244. <!-- END Page Container -->
  245. <!-- Scripts -->
  246. <script th:replace="fragments/script :: script"></script>
  247. <script>
  248. document.getElementById("showModalButton").addEventListener("click", function() {
  249. $('#views').modal('show');
  250. });
  251. function callAdd(){
  252. $('#addForm').modal({
  253. backdrop: 'static',
  254. keyboard: false
  255. })
  256. $('#addForm').modal('show');
  257. }
  258. // /*
  259. // function callEdit( id )
  260. // {
  261. // $.ajax({
  262. // type: "GET",
  263. // dataType: 'json',
  264. // url: "/api/category/"+id,
  265. // //data: "id=" + id + "&name=" + name,
  266. // success: function(data){
  267. // activeVal=0;
  268. // if(data[0].isActive){
  269. // activeVal=1;
  270. // }
  271. // $("#editformrow").html('<div class="row"><input type="hidden" name="cId" id="cId" value="'+data[0].cId+'"><div class="mb-3"><label for="catName">Asset Category Name</label><input type="text" class="form-control" name="catName" id="catName" value="'+data[0].catName+'" placeholder="Category Name" required> <!--<small id="emailHelp" class="form-text text-muted">Set of assets grouped under this unique category</small>--></div><div class="mb-3"> <label class="form-check-label">IsActive</label><select class="form-select" name="isActive" id="<strong></strong>"> <option value="1">Yes</option><option value="0">No</option></select></div></div><!--end row-->');
  272. // $("#editformrow select[name=isActive]").val(activeVal);
  273. // $('#editForm').modal({
  274. // backdrop: 'static',
  275. // keyboard: false
  276. // })
  277. // $('#editForm').modal('show');
  278. // }
  279. // });
  280. // return false;
  281. // }
  282. // */
  283. function callDelete(name,id){
  284. Swal.fire({
  285. title: 'Are you sure you want to delete the catergory question?<br> `'+name+'`',
  286. text: "You won't be able to revert this!",
  287. icon: 'warning',
  288. showCancelButton: true,
  289. confirmButtonColor: '#3085d6',
  290. cancelButtonColor: '#d33',
  291. confirmButtonText: 'Yes, delete it!',
  292. }).then(function(result) {
  293. if (result.isConfirmed) {
  294. $.ajax({
  295. type: "GET",
  296. dataType: 'json',
  297. url: "/api/asset/"+id+"/delete",
  298. //data: "id=" + id + "&name=" + name,
  299. success: function(data){
  300. Swal.fire(
  301. 'Deleted!',
  302. 'Category `'+name+'` has been deleted.',
  303. 'success'
  304. ).then(() => {
  305. location.reload();
  306. });
  307. }
  308. })
  309. }
  310. })
  311. return false;
  312. }
  313. // javascript file image
  314. const $file = document.querySelector("#assetFile");
  315. $file.addEventListener("change", (event) => {
  316. const selectedfile = event.target.files;
  317. if (selectedfile.length > 0) {
  318. const [imageFile] = selectedfile;
  319. const allowedExtensions = ["jpg", "jpeg", "png"];
  320. const maxSizeMB = 2;
  321. // Check file extension
  322. const fileExtension = imageFile.name.split('.').pop().toLowerCase();
  323. if (!allowedExtensions.includes(fileExtension)) {
  324. alert("Only JPEG, JPG, and PNG images are allowed.");
  325. $file.value = ""; // Clear the file input
  326. return;
  327. }
  328. // Check file size
  329. if (imageFile.size > maxSizeMB * 1024 * 1024) {
  330. alert("Image size must be less than 2MB.");
  331. $file.value = ""; // Clear the file input
  332. return;
  333. }
  334. const fileReader = new FileReader();
  335. fileReader.onload = () => {
  336. const srcData = fileReader.result;
  337. console.log('base64:', srcData);
  338. $("#viewimg").html('<img src="' + srcData + '" alt="" width="150px"/>');
  339. };
  340. fileReader.readAsDataURL(imageFile);
  341. }
  342. });
  343. function getParameter(){
  344. var catid = $('#assetCategory').val();//$('#catId').find(":selected").val();
  345. var paramHTML=''
  346. if(catid!='' || catid>0){
  347. $.ajax({
  348. type: "GET",
  349. dataType: 'json',
  350. url: "/api/parameter/category/"+catid,
  351. //data: "id=" + id + "&name=" + name,
  352. success: function(data){
  353. for(var k in data) {
  354. paramHTML+='<div class="form-check form-check-inline">'+
  355. '<input class="form-check-input" type="checkbox" name="paramId[]" id="param'+data[k].paramId+'" value="'+data[k].paramId+'">'+
  356. '<label class="form-check-label" for="param'+data[k].paramId+'">'+data[k].paramName+'</label>'+
  357. '</div>';
  358. }
  359. $('#parameterOpetionHtml').html(paramHTML);
  360. }
  361. });
  362. }
  363. else{
  364. $('#parameterOpetionHtml').html('<p class="text-info">Select Asset Categeory to load Parameters.</p>');
  365. }
  366. return false;
  367. }
  368. function views(assetlist) {
  369. console.log(assetlist)
  370. $('#views').modal({
  371. backdrop: 'static',
  372. keyboard: false
  373. });
  374. $('#views').modal('show');
  375. document.getElementById("PopAssetId").value = assetlist.assetId;
  376. /* document.getElementById("catName").value = assetlist.assetCategory.catName;*/
  377. document.getElementById("departmentName").value = assetlist.departmentName;
  378. document.getElementById("person").value = assetlist.person;
  379. document.getElementById("position").value = assetlist.position;
  380. document.getElementById("assetId").value = assetlist.assetId;
  381. }
  382. </script>
  383. </body>
  384. </html>