@@ -47,20 +47,20 @@ $(() => {
47
47
48
48
// Update examples when API key changes
49
49
$ ( '#api-key-input' ) . on ( 'input' , function ( ) {
50
- const apiKey = $ ( this ) . val ( ) || 'your-api-key-here' ;
50
+ const apiKey = $ ( this ) . val ( ) || ( window . trans . api . your_api_key_here || 'your-api-key-here' ) ;
51
51
updateExamplesWithApiKey ( apiKey ) ;
52
52
53
53
// Show/hide copy button based on whether there's a value
54
54
const copyButton = $ ( '#copy-api-key' ) ;
55
- if ( apiKey && apiKey !== 'your-api-key-here' ) {
55
+ if ( apiKey && apiKey !== ( window . trans . api . your_api_key_here || 'your-api-key-here' ) ) {
56
56
copyButton . show ( ) ;
57
57
} else {
58
58
copyButton . hide ( ) ;
59
59
}
60
60
} ) ;
61
61
62
62
// Initialize examples on page load
63
- const currentApiKey = $ ( '#api-key-input' ) . val ( ) || 'your-api-key-here' ;
63
+ const currentApiKey = $ ( '#api-key-input' ) . val ( ) || ( window . trans . api . your_api_key_here || 'your-api-key-here' ) ;
64
64
updateExamplesWithApiKey ( currentApiKey ) ;
65
65
66
66
// Handle service account file upload
@@ -80,7 +80,7 @@ $(() => {
80
80
81
81
// Validate file size (max 2MB)
82
82
if ( file . size > 2 * 1024 * 1024 ) {
83
- Botble . showError ( 'File size must be less than 2MB.' ) ;
83
+ Botble . showError ( window . trans . api . file_size_too_large || 'File size must be less than 2MB.' ) ;
84
84
return ;
85
85
}
86
86
@@ -92,7 +92,7 @@ $(() => {
92
92
$ ( '#remove-service-account-btn' ) . on ( 'click' , function ( e ) {
93
93
e . preventDefault ( ) ;
94
94
95
- if ( confirm ( 'Are you sure you want to remove the service account file?' ) ) {
95
+ if ( confirm ( window . trans . api . confirm_remove_service_account || 'Are you sure you want to remove the service account file?' ) ) {
96
96
removeServiceAccountFile ( ) ;
97
97
}
98
98
} ) ;
@@ -175,7 +175,7 @@ $(() => {
175
175
const removeBtn = $ ( '#remove-service-account-btn' ) ;
176
176
const originalHtml = removeBtn . html ( ) ;
177
177
178
- removeBtn . prop ( 'disabled' , true ) . html ( '<i class="ti ti-loader"></i >' ) ;
178
+ removeBtn . prop ( 'disabled' , true ) . html ( '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 6l0 -3" /><path d="M16.25 7.75l2.15 -2.15" /><path d="M18 12l3 0" /><path d="M16.25 16.25l2.15 2.15" /><path d="M12 18l0 3" /><path d="M7.75 16.25l-2.15 2.15" /><path d="M6 12l-3 0" /><path d="M7.75 7.75l-2.15 -2.15" /></svg >' ) ;
179
179
180
180
$ . ajax ( {
181
181
url : '/admin/settings/api/remove-service-account' ,
@@ -226,16 +226,16 @@ $(() => {
226
226
if ( path && filename ) {
227
227
statusDiv . html ( `
228
228
<small class="text-success">
229
- <i class="ti ti-file-check me-1"></i >
230
- Service account file: <strong>${ filename } </strong>
231
- <span class="text-muted">(Just uploaded)</span>
229
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=" me-1"><path d="M14 3v4a1 1 0 0 0 1 1h4" /><path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" /><path d="M9 15l2 2l4 -4" /></svg >
230
+ ${ window . trans . api . service_account_file_label || ' Service account file:' } <strong>${ filename } </strong>
231
+ <span class="text-muted">${ window . trans . api . just_uploaded || ' (Just uploaded)' } </span>
232
232
</small>
233
233
` ) ;
234
234
} else {
235
235
statusDiv . html ( `
236
236
<small class="text-warning">
237
- <i class="ti ti-file-x me-1"></i >
238
- Service account file is <strong>not uploaded</strong>. Please upload your service account JSON file.
237
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class=" me-1"><path d="M14 3v4a1 1 0 0 0 1 1h4" /><path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z" /><path d="M10 12l4 4m0 -4l-4 4" /></svg >
238
+ ${ window . trans . api . service_account_not_uploaded || ' Service account file is <strong>not uploaded</strong>. Please upload your service account JSON file.' }
239
239
</small>
240
240
` ) ;
241
241
}
@@ -253,13 +253,13 @@ $(() => {
253
253
const message = $ ( '#notification-message' ) . val ( ) . trim ( ) ;
254
254
255
255
if ( ! title ) {
256
- Botble . showError ( 'Please enter a notification title.' ) ;
256
+ Botble . showError ( window . trans . api . please_enter_notification_title || 'Please enter a notification title.' ) ;
257
257
$ ( '#notification-title' ) . focus ( ) ;
258
258
return ;
259
259
}
260
260
261
261
if ( ! message ) {
262
- Botble . showError ( 'Please enter a notification message.' ) ;
262
+ Botble . showError ( window . trans . api . please_enter_notification_message || 'Please enter a notification message.' ) ;
263
263
$ ( '#notification-message' ) . focus ( ) ;
264
264
return ;
265
265
}
@@ -301,7 +301,7 @@ $(() => {
301
301
}
302
302
} ,
303
303
error : function ( xhr ) {
304
- let errorMessage = 'An error occurred while sending the notification.' ;
304
+ let errorMessage = window . trans . api . notification_error_occurred || 'An error occurred while sending the notification.' ;
305
305
306
306
if ( xhr . responseJSON && xhr . responseJSON . message ) {
307
307
errorMessage = xhr . responseJSON . message ;
@@ -339,12 +339,12 @@ $(() => {
339
339
function generateRandomApiKey ( ) {
340
340
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' ;
341
341
let result = '' ;
342
-
342
+
343
343
// Generate a 32-character random string
344
344
for ( let i = 0 ; i < 32 ; i ++ ) {
345
345
result += chars . charAt ( Math . floor ( Math . random ( ) * chars . length ) ) ;
346
346
}
347
-
347
+
348
348
return result ;
349
349
}
350
350
@@ -354,16 +354,16 @@ $(() => {
354
354
*/
355
355
function updateExamplesWithApiKey ( apiKey ) {
356
356
const baseUrl = window . location . origin + '/api/v1' ;
357
-
357
+
358
358
// Update cURL example
359
- const curlExample = `curl -X GET "${ baseUrl } /products " \\
359
+ const curlExample = `curl -X GET "${ baseUrl } /pages " \\
360
360
-H "Accept: application/json" \\
361
361
-H "X-API-KEY: ${ apiKey } "` ;
362
-
362
+
363
363
$ ( '#curl-example' ) . text ( curlExample ) ;
364
-
364
+
365
365
// Update JavaScript example
366
- const jsExample = `fetch("${ baseUrl } /products ", {
366
+ const jsExample = `fetch("${ baseUrl } /pages ", {
367
367
method: "GET",
368
368
headers: {
369
369
"Accept": "application/json",
@@ -372,7 +372,7 @@ $(() => {
372
372
})
373
373
.then(response => response.json())
374
374
.then(data => console.log(data));` ;
375
-
375
+
376
376
$ ( '#js-example' ) . text ( jsExample ) ;
377
377
}
378
378
@@ -385,27 +385,32 @@ $(() => {
385
385
function showNotificationResult ( type , message , data = null ) {
386
386
const resultDiv = $ ( '#notification-result' ) ;
387
387
const alertClass = type === 'success' ? 'alert-success' : 'alert-danger' ;
388
- const iconClass = type === 'success' ? 'ti-check-circle' : 'ti-alert-circle' ;
388
+ const iconSvg = type === 'success'
389
+ ? '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2"><path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" /><path d="M9 12l2 2l4 -4" /></svg>'
390
+ : '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-2"><path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0" /><path d="M12 8v4" /><path d="M12 16h.01" /></svg>' ;
389
391
390
392
let content = `
391
393
<div class="alert ${ alertClass } alert-dismissible fade show" role="alert">
392
- <i class=" ${ iconClass } me-2"></i>
394
+ ${ iconSvg }
393
395
<strong>${ message } </strong>
394
396
` ;
395
397
396
398
if ( data && type === 'success' ) {
399
+ const sentText = ( window . trans . api . sent_to_devices || 'Sent to: :count devices' ) . replace ( ':count' , data . sent_count || 0 ) ;
400
+ const failedText = ( window . trans . api . failed_devices || 'Failed: :count devices' ) . replace ( ':count' , data . failed_count || 0 ) ;
401
+
397
402
content += `
398
403
<div class="mt-2">
399
404
<small>
400
- Sent to: ${ data . sent_count || 0 } devices <br>
401
- Failed: ${ data . failed_count || 0 } devices
405
+ ${ sentText } <br>
406
+ ${ failedText }
402
407
</small>
403
408
</div>
404
409
` ;
405
410
}
406
411
407
412
content += `
408
- <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
413
+ <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="${ window . trans . api . close || ' Close' } "></button>
409
414
</div>
410
415
` ;
411
416
@@ -445,10 +450,15 @@ $(() => {
445
450
// Update the notification send info text
446
451
const infoText = $ ( '#notification-send-info' ) ;
447
452
if ( infoText . length && stats . total > 0 ) {
453
+ const deviceText = ( window . trans . api . will_send_to_devices || 'Will send to :total active devices (:android Android, :ios iOS, :customers customers)' )
454
+ . replace ( ':total' , stats . total )
455
+ . replace ( ':android' , stats . android )
456
+ . replace ( ':ios' , stats . ios )
457
+ . replace ( ':customers' , stats . customers ) ;
458
+
448
459
infoText . html ( `
449
- <i class="ti ti-info-circle me-1"></i>
450
- Will send to ${ stats . total } active devices
451
- (${ stats . android } Android, ${ stats . ios } iOS, ${ stats . customers } customers)
460
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="me-1"><path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0" /><path d="M12 9h.01" /><path d="M11 12h1v4h1" /></svg>
461
+ ${ deviceText }
452
462
` ) ;
453
463
}
454
464
}
0 commit comments