3
3
< head >
4
4
< meta charset ="UTF-8 ">
5
5
< link rel ="stylesheet " type ="text/css " href ="css/styles.css ">
6
- < style >
7
- body {
8
- background-color : # f2f2f2 ;
9
- font-family : Arial, sans-serif;
10
- padding : 0 15px ;
11
- max-width : 1200px ;
12
- margin : auto;
13
- }
14
- table {
15
- border-collapse : collapse;
16
- width : 100% ;
17
- margin-top : 50px ;
18
- box-shadow : 0px 0px 20px rgba (0 , 0 , 0 , 0.15 );
19
- border-radius : 10px ;
20
- overflow : hidden;
21
- }
22
- th , td {
23
- text-align : left;
24
- padding : 8px ;
25
- }
26
- .actions {
27
- display : flex;
28
- justify-content : space-between;
29
- align-items : center;
30
- }
31
- .clear {
32
- color : # f44336 ;
33
- }
34
- </ style >
35
6
< script th:inline ="javascript ">
36
7
/*<![CDATA[*/
37
8
window . enableSearchFeature = /*[[${enableSearchFeature}]]*/ 'default' ;
@@ -57,53 +28,17 @@ <h1>Inventory Records</h1>
57
28
</ form >
58
29
< label for ="csvFile " class ="modern-button "> Import from CSV</ label >
59
30
< div id ="errorMessage " style ="color: red; "> </ div >
60
- < script >
61
- document . getElementById ( 'csvFile' ) . addEventListener ( 'change' , function ( ) {
62
- if ( this . value ) {
63
- document . getElementById ( 'uploadForm' ) . style . display = 'block' ;
64
- } else {
65
- document . getElementById ( 'uploadForm' ) . style . display = 'none' ;
66
- }
67
- } ) ;
68
-
69
- document . getElementById ( 'uploadForm' ) . addEventListener ( 'submit' , function ( e ) {
70
- e . preventDefault ( ) ;
71
-
72
- var formData = new FormData ( ) ;
73
- formData . append ( 'file' , document . getElementById ( 'csvFile' ) . files [ 0 ] ) ;
74
-
75
- fetch ( '/import' , {
76
- method : 'POST' ,
77
- body : formData
78
- } ) . then ( response => {
79
- if ( ! response . ok ) {
80
- throw new Error ( 'Network response was not ok' ) ;
81
- }
82
- return response . text ( ) ;
83
- } ) . then ( data => {
84
- console . log ( 'File uploaded successfully: ' + data ) ;
85
- // clear the file input and hide the form
86
- document . getElementById ( 'csvFile' ) . value = '' ;
87
- document . getElementById ( 'uploadForm' ) . style . display = 'none' ;
88
-
89
- // Wait for 1 second before reloading the page
90
- setTimeout ( function ( ) {
91
- location . reload ( ) ;
92
- } , 1000 ) ;
93
- } ) . catch ( error => {
94
- console . error ( 'There has been a problem with your fetch operation: ' , error ) ;
95
- document . getElementById ( 'errorMessage' ) . textContent = 'Error: ' + error . message ;
96
- } ) ;
97
- } ) ;
98
- </ script >
31
+ < script src ="js/upload_csv.js "> </ script >
32
+ < script src ="js/search.js "> </ script >
99
33
< br > < br >
100
34
< div id ="searchFeature ">
101
- < form action ="/search " method ="get ">
102
- < label for ="search "> Search for item:</ label >
103
- < input type ="text " id ="search " name ="q " />
104
- < button type ="submit "> Search</ button >
35
+ < form id =" searchForm " action ="/search " method ="get ">
36
+ < label for ="search "> Search for item:</ label >
37
+ < input type ="text " id ="search " name ="q " />
38
+ < button type ="submit "> Search</ button >
105
39
</ form >
106
40
</ div >
41
+ < div id ="searchResults "> </ div >
107
42
< br />
108
43
< div >
109
44
< a th:if ="${currentPage > 0} " th:href ="@{/?(page=${currentPage - 1})} "> Previous</ a >
0 commit comments