File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 4444
4545 <main class =" flex-fill d-flex flex-column" >
4646 <div style =" margin : 16px 0 ;" >
47+ <button id =" purgeTable" type =" button" class =" btn btn-warning" >Purge table</button >
4748 <button id =" deleteTable" type =" button" class =" btn btn-danger" >Delete table</button >
4849 </div >
4950 <div
5455 </div >
5556 </main >
5657 <script >
58+ document .querySelector (' #purgeTable' ).addEventListener (' click' , () => {
59+ if (! confirm (` Are you sure you want to purge all records from table "<%= Table.TableName %>"?` )) {
60+ return
61+ }
62+ fetch (' /tables/<%= encodeURIComponent(Table.TableName) %>/all' , {
63+ method: ' delete'
64+ }).then (async (response ) => {
65+ if (! response .ok ) {
66+ const responseText = await response .text ()
67+ throw new Error (JSON .parse (responseText).message )
68+ }
69+ window .location .href = ' /tables/<%= encodeURIComponent(Table.TableName) %>'
70+ }).catch ((error ) => {
71+ handleError (error .message )
72+ })
73+ });
74+
5775 document .querySelector (' #deleteTable' ).addEventListener (' click' , () => {
76+ if (! confirm (` Are you sure you want to delete table "<%= Table.TableName %>"?` )) {
77+ return
78+ }
5879 fetch (' /tables/<%= encodeURIComponent(Table.TableName) %>' , {
5980 method: ' delete'
6081 }).then (async (response ) => {
Original file line number Diff line number Diff line change 5454 }
5555
5656 function deleteTable (TableName ) {
57- if (! confirm (` Are you sure you want to delete table "${ TableName} " ?` )) {
57+ if (! confirm (` Are you sure you want to delete table "${ TableName} "?` )) {
5858 return
5959 }
6060
61- fetch (` /tables/${ TableName} ` , {
61+ fetch (` /tables/${ encodeURIComponent ( TableName) } ` , {
6262 method: ' delete'
6363 })
6464 .then (async (response ) => {
7474 }
7575
7676 function purgeTable (TableName ) {
77- if (! confirm (` Are you sure you want to purge all records from table "${ TableName} " ?` )) {
77+ if (! confirm (` Are you sure you want to purge all records from table "${ TableName} "?` )) {
7878 return
7979 }
8080
81- fetch (` /tables/${ TableName} /all` , {
81+ fetch (` /tables/${ encodeURIComponent ( TableName) } /all` , {
8282 method: ' delete'
8383 }).then (async (response ) => {
8484 if (! response .ok ) {
You can’t perform that action at this time.
0 commit comments