@@ -88,6 +88,10 @@ const logNames = [
88
88
{ id: ' posts' , name: ' Posts' , color: ' pink' },
89
89
{ id: ' comments' , name: ' Comments' , color: ' rose' },
90
90
{ id: ' media' , name: ' Media' , color: ' amber' },
91
+ { id: ' deployment' , name: ' Deployment' , color: ' emerald' },
92
+ { id: ' server' , name: ' Server' , color: ' cyan' },
93
+ { id: ' commerce' , name: ' Commerce' , color: ' orange' },
94
+ { id: ' blog' , name: ' Blog' , color: ' violet' },
91
95
]
92
96
93
97
// Sample subject types
@@ -98,6 +102,11 @@ const subjectTypes = [
98
102
{ type: ' App\\ Models\\ Media' , name: ' Media' },
99
103
{ type: ' App\\ Models\\ Role' , name: ' Role' },
100
104
{ type: ' App\\ Models\\ Permission' , name: ' Permission' },
105
+ { type: ' App\\ Models\\ Order' , name: ' Order' },
106
+ { type: ' App\\ Services\\ Deployment' , name: ' Deployment' },
107
+ { type: ' App\\ Services\\ Server' , name: ' Server' },
108
+ { type: ' App\\ Services\\ Api' , name: ' API' },
109
+ { type: ' App\\ Services\\ Backup' , name: ' Backup' },
101
110
]
102
111
103
112
// Sample activity logs in Laravel Spatie Activity Log format
@@ -307,7 +316,106 @@ const sampleActivityLogs: ActivityLog[] = [
307
316
created_at: new Date (Date .now () - 420000 ).toISOString (),
308
317
updated_at: new Date (Date .now () - 420000 ).toISOString (),
309
318
event: ' completed' ,
310
- }
319
+ },
320
+ {
321
+ id: ' 11' ,
322
+ log_name: ' deployment' ,
323
+ description: ' Production deployment successful' ,
324
+ subject_type: ' App\\ Services\\ Deployment' ,
325
+ subject_id: ' 123' ,
326
+ causer_type: ' App\\ Models\\ User' ,
327
+ causer_id: ' 1' ,
328
+ properties: {
329
+ environment: ' production' ,
330
+ branch: ' main' ,
331
+ commit: ' 7829abc' ,
332
+ duration: ' 45s' ,
333
+ status: ' success' ,
334
+ },
335
+ created_at: new Date (Date .now () - 10 * 60000 ).toISOString (), // 10 minutes ago
336
+ updated_at: new Date (Date .now () - 10 * 60000 ).toISOString (),
337
+ event: ' completed' ,
338
+ },
339
+ {
340
+ id: ' 12' ,
341
+ log_name: ' blog' ,
342
+ description: ' New blog post published' ,
343
+ subject_type: ' App\\ Models\\ Post' ,
344
+ subject_id: ' 45' ,
345
+ causer_type: ' App\\ Models\\ User' ,
346
+ causer_id: ' 3' ,
347
+ properties: {
348
+ attributes: {
349
+ title: ' Getting Started with Activity Logs' ,
350
+ slug: ' getting-started-with-activity-logs' ,
351
+ status: ' published' ,
352
+ created_at: new Date (Date .now () - 60 * 60000 ).toISOString (), // 1 hour ago
353
+ },
354
+ status: ' success' ,
355
+ },
356
+ created_at: new Date (Date .now () - 60 * 60000 ).toISOString (),
357
+ updated_at: new Date (Date .now () - 60 * 60000 ).toISOString (),
358
+ event: ' published' ,
359
+ },
360
+ {
361
+ id: ' 13' ,
362
+ log_name: ' server' ,
363
+ description: ' Server maintenance completed' ,
364
+ subject_type: ' App\\ Services\\ Server' ,
365
+ subject_id: ' 2' ,
366
+ causer_type: ' App\\ Models\\ User' ,
367
+ causer_id: ' 4' ,
368
+ properties: {
369
+ server: ' app-server-01' ,
370
+ maintenance_type: ' scheduled' ,
371
+ duration: ' 120m' ,
372
+ status: ' success' ,
373
+ },
374
+ created_at: new Date (Date .now () - 3 * 60 * 60000 ).toISOString (), // 3 hours ago
375
+ updated_at: new Date (Date .now () - 3 * 60 * 60000 ).toISOString (),
376
+ event: ' maintained' ,
377
+ },
378
+ {
379
+ id: ' 14' ,
380
+ log_name: ' default' ,
381
+ description: ' API rate limit exceeded' ,
382
+ subject_type: ' App\\ Services\\ Api' ,
383
+ subject_id: ' 1' ,
384
+ causer_type: null ,
385
+ causer_id: null ,
386
+ properties: {
387
+ endpoint: ' /api/v1/users' ,
388
+ limit: 1000 ,
389
+ period: ' 1 hour' ,
390
+ ip: ' 192.168.1.50' ,
391
+ status: ' error' ,
392
+ },
393
+ created_at: new Date (Date .now () - 5 * 60 * 60000 ).toISOString (), // 5 hours ago
394
+ updated_at: new Date (Date .now () - 5 * 60 * 60000 ).toISOString (),
395
+ event: ' exceeded' ,
396
+ },
397
+ {
398
+ id: ' 15' ,
399
+ log_name: ' commerce' ,
400
+ description: ' New order received' ,
401
+ subject_type: ' App\\ Models\\ Order' ,
402
+ subject_id: ' 1001' ,
403
+ causer_type: ' App\\ Models\\ User' ,
404
+ causer_id: ' 2' ,
405
+ properties: {
406
+ attributes: {
407
+ order_number: ' ORD-1001' ,
408
+ total: ' $129.99' ,
409
+ items: 3 ,
410
+ status: ' pending' ,
411
+ created_at: new Date (Date .now () - 12 * 60 * 60000 ).toISOString (), // 12 hours ago
412
+ },
413
+ status: ' success' ,
414
+ },
415
+ created_at: new Date (Date .now () - 12 * 60 * 60000 ).toISOString (),
416
+ updated_at: new Date (Date .now () - 12 * 60 * 60000 ).toISOString (),
417
+ event: ' created' ,
418
+ },
311
419
]
312
420
313
421
// Process logs to add computed properties
@@ -326,48 +434,80 @@ const processLogs = (logs: ActivityLog[]) => {
326
434
subject_name = log .properties .attributes .filename
327
435
} else if (log .subject_type === ' App\\ Services\\ Backup' ) {
328
436
subject_name = ' System Backup'
437
+ } else if (log .subject_type === ' App\\ Services\\ Deployment' ) {
438
+ subject_name = ` Deployment to ${log .properties ?.environment || ' unknown' } `
439
+ } else if (log .subject_type === ' App\\ Services\\ Server' ) {
440
+ subject_name = log .properties ?.server || ' Server'
441
+ } else if (log .subject_type === ' App\\ Services\\ Api' ) {
442
+ subject_name = log .properties ?.endpoint || ' API'
443
+ } else if (log .subject_type === ' App\\ Models\\ Order' && log .properties ?.attributes ?.order_number ) {
444
+ subject_name = log .properties .attributes .order_number
329
445
} else {
330
446
// Get the last part of the subject type as a fallback
331
447
const parts = log .subject_type .split (' \\ ' )
332
448
subject_name = ` ${parts [parts .length - 1 ]} #${log .subject_id } `
333
449
}
334
450
335
- // Determine icon and color based on event
451
+ // Determine icon and color based on event and status
336
452
let icon = ' i-hugeicons-information-circle'
337
453
let color = ' text-blue-500'
338
454
339
- switch (log .event ) {
340
- case ' created' :
341
- icon = ' i-hugeicons-plus-sign-circle'
342
- color = ' text-green-500'
343
- break
344
- case ' updated' :
345
- icon = ' i-hugeicons-edit-01'
346
- color = ' text-blue-500'
347
- break
348
- case ' deleted' :
349
- icon = ' i-hugeicons-waste'
350
- color = ' text-red-500'
351
- break
352
- case ' login' :
353
- icon = ' i-hugeicons-login-03'
354
- color = ' text-indigo-500'
355
- break
356
- case ' login_failed' :
357
- icon = ' i-hugeicons-login-03'
358
- color = ' text-amber-500'
359
- break
360
- case ' uploaded' :
361
- icon = ' i-hugeicons-upload-03'
362
- color = ' text-purple-500'
363
- break
364
- case ' completed' :
365
- icon = ' i-hugeicons-checkmark-circle-02'
366
- color = ' text-green-500'
367
- break
368
- default :
369
- icon = ' i-hugeicons-information-circle'
370
- color = ' text-gray-500'
455
+ // Check if there's a status in properties
456
+ const status = log .properties ?.status
457
+
458
+ if (status === ' error' ) {
459
+ icon = ' i-hugeicons-alert-02'
460
+ color = ' text-red-500'
461
+ } else if (status === ' warning' ) {
462
+ icon = ' i-hugeicons-alert-02'
463
+ color = ' text-amber-500'
464
+ } else {
465
+ // If no status, use event to determine icon/color
466
+ switch (log .event ) {
467
+ case ' created' :
468
+ icon = ' i-hugeicons-plus-sign-circle'
469
+ color = ' text-green-500'
470
+ break
471
+ case ' updated' :
472
+ icon = ' i-hugeicons-edit-01'
473
+ color = ' text-blue-500'
474
+ break
475
+ case ' deleted' :
476
+ icon = ' i-hugeicons-waste'
477
+ color = ' text-red-500'
478
+ break
479
+ case ' login' :
480
+ icon = ' i-hugeicons-login-03'
481
+ color = ' text-indigo-500'
482
+ break
483
+ case ' login_failed' :
484
+ icon = ' i-hugeicons-login-03'
485
+ color = ' text-amber-500'
486
+ break
487
+ case ' uploaded' :
488
+ icon = ' i-hugeicons-upload-03'
489
+ color = ' text-purple-500'
490
+ break
491
+ case ' completed' :
492
+ icon = ' i-hugeicons-checkmark-circle-02'
493
+ color = ' text-green-500'
494
+ break
495
+ case ' published' :
496
+ icon = ' i-hugeicons-book-open-01'
497
+ color = ' text-violet-500'
498
+ break
499
+ case ' maintained' :
500
+ icon = ' i-hugeicons-settings-01'
501
+ color = ' text-cyan-500'
502
+ break
503
+ case ' exceeded' :
504
+ icon = ' i-hugeicons-alert-02'
505
+ color = ' text-red-500'
506
+ break
507
+ default :
508
+ icon = ' i-hugeicons-information-circle'
509
+ color = ' text-gray-500'
510
+ }
371
511
}
372
512
373
513
return {
@@ -699,6 +839,9 @@ watch(timeRange, async () => {
699
839
<option value =" login_failed" >Failed Login</option >
700
840
<option value =" uploaded" >Uploaded</option >
701
841
<option value =" completed" >Completed</option >
842
+ <option value =" published" >Published</option >
843
+ <option value =" maintained" >Maintained</option >
844
+ <option value =" exceeded" >Rate Limited</option >
702
845
</select >
703
846
704
847
<select
0 commit comments