@@ -47,10 +47,10 @@ function deleteApiKey(apiKey) {
4747
4848 apiAuthDelete ( apiKey )
4949 . then ( data => {
50- document . getElementById ( "row-" + apiKey ) . classList . add ( "rowDeleting" ) ;
51- setTimeout ( ( ) => {
52- document . getElementById ( "row-" + apiKey ) . remove ( ) ;
53- } , 290 ) ;
50+ document . getElementById ( "row-" + apiKey ) . classList . add ( "rowDeleting" ) ;
51+ setTimeout ( ( ) => {
52+ document . getElementById ( "row-" + apiKey ) . remove ( ) ;
53+ } , 290 ) ;
5454 } )
5555 . catch ( error => {
5656 alert ( "Unable to delete API key: " + error ) ;
@@ -81,7 +81,7 @@ function addFriendlyNameChange(apiKey) {
8181 if ( cell . classList . contains ( "isBeingEdited" ) )
8282 return ;
8383 cell . classList . add ( "isBeingEdited" ) ;
84- let currentName = cell . innerHTML ;
84+ let currentName = cell . innerText ;
8585 let input = document . createElement ( "input" ) ;
8686 input . size = 5 ;
8787 input . value = currentName ;
@@ -93,9 +93,9 @@ function addFriendlyNameChange(apiKey) {
9393 allowEdit = false ;
9494 let newName = input . value ;
9595 if ( newName == "" ) {
96- newName = "Unnamed key" ;
96+ newName = "Unnamed key" ;
9797 }
98- cell . innerHTML = newName ;
98+ cell . innerText = newName ;
9999
100100 cell . classList . remove ( "isBeingEdited" ) ;
101101
@@ -114,7 +114,7 @@ function addFriendlyNameChange(apiKey) {
114114 submitEntry ( ) ;
115115 }
116116 } ) ;
117- cell . innerHTML = "" ;
117+ cell . innerText = "" ;
118118 cell . appendChild ( input ) ;
119119 input . focus ( ) ;
120120}
@@ -126,7 +126,7 @@ function addRowApi(apiKey, publicId) {
126126
127127 let table = document . getElementById ( "apitable" ) ;
128128 let row = table . insertRow ( 0 ) ;
129-
129+
130130 row . id = "row-" + publicId ;
131131 let cellCount = 0 ;
132132 let cellFriendlyName = row . insertCell ( cellCount ++ ) ;
@@ -135,13 +135,13 @@ function addRowApi(apiKey, publicId) {
135135 let cellPermissions = row . insertCell ( cellCount ++ ) ;
136136 let cellUserName ;
137137 if ( canViewOtherApiKeys ) {
138- cellUserName = row . insertCell ( cellCount ++ ) ;
139- }
140- let cellButtons = row . insertCell ( cellCount ++ ) ;
141-
138+ cellUserName = row . insertCell ( cellCount ++ ) ;
139+ }
140+ let cellButtons = row . insertCell ( cellCount ++ ) ;
141+
142142 if ( canViewOtherApiKeys ) {
143- cellUserName . classList . add ( "newApiKey" ) ;
144- cellUserName . innerText = userName ;
143+ cellUserName . classList . add ( "newApiKey" ) ;
144+ cellUserName . innerText = userName ;
145145 }
146146
147147 cellFriendlyName . classList . add ( "newApiKey" ) ;
@@ -157,28 +157,115 @@ function addRowApi(apiKey, publicId) {
157157 cellFriendlyName . onclick = function ( ) {
158158 addFriendlyNameChange ( publicId ) ;
159159 } ;
160- cellId . innerHTML = '<div class="font-monospace">' + apiKey + '</div>' ;
160+ cellId . innerText = apiKey ;
161+ cellId . classList . add ( "font-monospace" ) ;
161162 cellLastUsed . innerText = "Never" ;
162- cellButtons . innerHTML = '<button type="button" data-clipboard-text="' + apiKey + '" onclick="showToast(1000)" title="Copy API Key" class="copyurl btn btn-outline-light btn-sm"><i class="bi bi-copy"></i></button> <button id="delete-' + publicId + '" type="button" class="btn btn-outline-danger btn-sm" onclick="deleteApiKey(\'' + publicId + '\')" title="Delete"><i class="bi bi-trash3"></i></button>' ;
163- cellPermissions . innerHTML = `
164- <i id="perm_view_` + publicId + `" class="bi bi-eye perm-granted" title="List Uploads" onclick='changeApiPermission("` + publicId + `","PERM_VIEW", "perm_view_` + publicId + `");'></i>
165- <i id="perm_upload_` + publicId + `" class="bi bi-file-earmark-arrow-up perm-granted" title="Upload" onclick='changeApiPermission("` + publicId + `","PERM_UPLOAD", "perm_upload_` + publicId + `");'></i>
166- <i id="perm_edit_` + publicId + `" class="bi bi-pencil perm-granted" title="Edit Uploads" onclick='changeApiPermission("` + publicId + `","PERM_EDIT", "perm_edit_` + publicId + `");'></i>
167- <i id="perm_delete_` + publicId + `" class="bi bi-trash3 perm-granted" title="Delete Uploads" onclick='changeApiPermission("` + publicId + `","PERM_DELETE", "perm_delete_` + publicId + `");'></i>
168- <i id="perm_replace_` + publicId + `" class="bi bi-recycle perm-notgranted" title="Replace Uploads" onclick='changeApiPermission("` + publicId + `","PERM_REPLACE", "perm_replace_` + publicId + `");'></i>
169- <i id="perm_users_` + publicId + `" class="bi bi-people perm-notgranted" title="Manage Users" onclick='changeApiPermission("` + publicId + `", "PERM_MANAGE_USERS", "perm_users_` + publicId + `");'></i>
170- <i id="perm_logs_` + publicId + `" class="bi bi-card-list perm-notgranted" title="Manage System Logs" onclick='changeApiPermission("` + publicId + `", "PERM_MANAGE_LOGS", "perm_logs_` + publicId + `");'></i>
171- <i id="perm_api_` + publicId + `" class="bi bi-sliders2 perm-notgranted" title="Manage API Keys" onclick='changeApiPermission("` + publicId + `","PERM_API_MOD", "perm_api_` + publicId + `");'></i>` ;
172-
163+
164+
165+ // === Buttons Cell ===
166+ const copyButton = document . createElement ( 'button' ) ;
167+ copyButton . type = 'button' ;
168+ copyButton . dataset . clipboardText = apiKey ;
169+ copyButton . title = 'Copy API Key' ;
170+ copyButton . className = 'copyurl btn btn-outline-light btn-sm' ;
171+ copyButton . setAttribute ( 'onclick' , 'showToast(1000)' ) ;
172+
173+ const copyIcon = document . createElement ( 'i' ) ;
174+ copyIcon . className = 'bi bi-copy' ;
175+ copyButton . appendChild ( copyIcon ) ;
176+
177+ const deleteButton = document . createElement ( 'button' ) ;
178+ deleteButton . type = 'button' ;
179+ deleteButton . id = `delete-${ publicId } ` ;
180+ deleteButton . title = 'Delete' ;
181+ deleteButton . className = 'btn btn-outline-danger btn-sm' ;
182+ deleteButton . setAttribute ( 'onclick' , `deleteApiKey('${ publicId } ')` ) ;
183+
184+ const deleteIcon = document . createElement ( 'i' ) ;
185+ deleteIcon . className = 'bi bi-trash3' ;
186+ deleteButton . appendChild ( deleteIcon ) ;
187+
188+ cellButtons . appendChild ( copyButton ) ;
189+ cellButtons . appendChild ( document . createTextNode ( ' ' ) ) ; // space between buttons
190+ cellButtons . appendChild ( deleteButton ) ;
191+
192+ // === Permissions Cell ===
193+ const perms = [ {
194+ perm : 'PERM_VIEW' ,
195+ icon : 'bi-eye' ,
196+ granted : true ,
197+ title : 'List Uploads'
198+ } ,
199+ {
200+ perm : 'PERM_UPLOAD' ,
201+ icon : 'bi-file-earmark-arrow-up' ,
202+ granted : true ,
203+ title : 'Upload'
204+ } ,
205+ {
206+ perm : 'PERM_EDIT' ,
207+ icon : 'bi-pencil' ,
208+ granted : true ,
209+ title : 'Edit Uploads'
210+ } ,
211+ {
212+ perm : 'PERM_DELETE' ,
213+ icon : 'bi-trash3' ,
214+ granted : true ,
215+ title : 'Delete Uploads'
216+ } ,
217+ {
218+ perm : 'PERM_REPLACE' ,
219+ icon : 'bi-recycle' ,
220+ granted : false ,
221+ title : 'Replace Uploads'
222+ } ,
223+ {
224+ perm : 'PERM_MANAGE_USERS' ,
225+ icon : 'bi-people' ,
226+ granted : false ,
227+ title : 'Manage Users'
228+ } ,
229+ {
230+ perm : 'PERM_MANAGE_LOGS' ,
231+ icon : 'bi-card-list' ,
232+ granted : false ,
233+ title : 'Manage System Logs'
234+ } ,
235+ {
236+ perm : 'PERM_API_MOD' ,
237+ icon : 'bi-sliders2' ,
238+ granted : false ,
239+ title : 'Manage API Keys'
240+ }
241+ ] ;
242+
243+ perms . forEach ( ( {
244+ perm,
245+ icon,
246+ granted,
247+ title
248+ } ) => {
249+ const i = document . createElement ( 'i' ) ;
250+ const id = `perm_${ perm . toLowerCase ( ) . replace ( 'perm_' , '' ) } _${ publicId } ` ;
251+ i . id = id ;
252+ i . className = `bi ${ icon } ${ granted ? 'perm-granted' : 'perm-notgranted' } ` ;
253+ i . title = title ;
254+ i . setAttribute ( 'onclick' , `changeApiPermission("${ publicId } ","${ perm } ", "${ id } ");` ) ;
255+ cellPermissions . appendChild ( i ) ;
256+ cellPermissions . appendChild ( document . createTextNode ( ' ' ) ) ;
257+ } ) ;
258+
259+
173260 if ( ! canReplaceFiles ) {
174- let cell = document . getElementById ( "perm_replace_" + publicId ) ;
175- cell . classList . add ( "perm-unavailable" ) ;
176- cell . classList . add ( "perm-nochange" ) ;
261+ let cell = document . getElementById ( "perm_replace_" + publicId ) ;
262+ cell . classList . add ( "perm-unavailable" ) ;
263+ cell . classList . add ( "perm-nochange" ) ;
177264 }
178265 if ( ! canManageUsers ) {
179- let cell = document . getElementById ( "perm_users_" + publicId ) ;
180- cell . classList . add ( "perm-unavailable" ) ;
181- cell . classList . add ( "perm-nochange" ) ;
266+ let cell = document . getElementById ( "perm_users_" + publicId ) ;
267+ cell . classList . add ( "perm-unavailable" ) ;
268+ cell . classList . add ( "perm-nochange" ) ;
182269 }
183270
184271 setTimeout ( ( ) => {
0 commit comments