|
| 1 | +<script setup lang="ts"> |
| 2 | +interface AuthToken { |
| 3 | + authId: string |
| 4 | + ua: string |
| 5 | + origin: string |
| 6 | + timestamp: number |
| 7 | +} |
| 8 | +
|
| 9 | +defineProps<{ |
| 10 | + tokens: AuthToken[] |
| 11 | +}>() |
| 12 | +
|
| 13 | +const emit = defineEmits<{ |
| 14 | + revoke: [authId: string] |
| 15 | +}>() |
| 16 | +
|
| 17 | +function formatDate(timestamp: number): string { |
| 18 | + return new Date(timestamp).toLocaleString() |
| 19 | +} |
| 20 | +</script> |
| 21 | + |
| 22 | +<template> |
| 23 | + <div flex="~ col gap-3" p4> |
| 24 | + <div flex="~ items-center gap-3" text-xs> |
| 25 | + <span op60> |
| 26 | + {{ tokens.length }} trusted client{{ tokens.length !== 1 ? 's' : '' }} |
| 27 | + </span> |
| 28 | + </div> |
| 29 | + |
| 30 | + <div v-if="tokens.length === 0" op40 text-sm py4 text-center> |
| 31 | + No auth tokens found. |
| 32 | + </div> |
| 33 | + |
| 34 | + <table v-else w-full text-sm> |
| 35 | + <thead> |
| 36 | + <tr border="b base" text-left> |
| 37 | + <th px2 py1 font-medium op60 text-xs> |
| 38 | + Auth ID |
| 39 | + </th> |
| 40 | + <th px2 py1 font-medium op60 text-xs> |
| 41 | + User Agent |
| 42 | + </th> |
| 43 | + <th px2 py1 font-medium op60 text-xs> |
| 44 | + Origin |
| 45 | + </th> |
| 46 | + <th px2 py1 font-medium op60 text-xs> |
| 47 | + Trusted At |
| 48 | + </th> |
| 49 | + <th px2 py1 font-medium op60 text-xs text-center> |
| 50 | + Actions |
| 51 | + </th> |
| 52 | + </tr> |
| 53 | + </thead> |
| 54 | + <tbody> |
| 55 | + <tr |
| 56 | + v-for="token in tokens" :key="token.authId" |
| 57 | + border="b base" hover:bg-active |
| 58 | + > |
| 59 | + <td px2 py1.5 font-mono text-xs> |
| 60 | + {{ token.authId }} |
| 61 | + </td> |
| 62 | + <td px2 py1.5 text-xs op75 max-w-60 truncate> |
| 63 | + {{ token.ua || '-' }} |
| 64 | + </td> |
| 65 | + <td px2 py1.5 text-xs op75> |
| 66 | + {{ token.origin || '-' }} |
| 67 | + </td> |
| 68 | + <td px2 py1.5 text-xs op75> |
| 69 | + {{ formatDate(token.timestamp) }} |
| 70 | + </td> |
| 71 | + <td px2 py1.5 text-center> |
| 72 | + <button |
| 73 | + text-xs px2 py0.5 rounded |
| 74 | + text-red border="~ red/30" |
| 75 | + hover:bg-red:10 |
| 76 | + @click="emit('revoke', token.authId)" |
| 77 | + > |
| 78 | + Revoke |
| 79 | + </button> |
| 80 | + </td> |
| 81 | + </tr> |
| 82 | + </tbody> |
| 83 | + </table> |
| 84 | + </div> |
| 85 | +</template> |
0 commit comments