|
| 1 | +<script setup lang="ts"> |
| 2 | +import { computed } from 'vue' |
| 3 | +import { useRouter } from 'vue-router' |
| 4 | +import { useConfirm } from 'primevue/useconfirm' |
| 5 | +import { useToast } from 'primevue/usetoast' |
| 6 | +import Button from 'primevue/button' |
| 7 | +import ConfirmDialog from 'primevue/confirmdialog' |
| 8 | +import { usePrivacyConsentStore } from '@/stores/privacyConsentStore' |
| 9 | +import { useSrToastStore } from '@/stores/srToastStore' |
| 10 | +import { cleanupDelAllRequests } from '@/utils/storageUtils' |
| 11 | +
|
| 12 | +const router = useRouter() |
| 13 | +const confirm = useConfirm() |
| 14 | +const toast = useToast() |
| 15 | +const privacyConsentStore = usePrivacyConsentStore() |
| 16 | +const srToastStore = useSrToastStore() |
| 17 | +
|
| 18 | +const consentStatus = computed(() => privacyConsentStore.consentStatus) |
| 19 | +const consentDate = computed(() => { |
| 20 | + if (!privacyConsentStore.consentTimestamp) return null |
| 21 | + return new Date(privacyConsentStore.consentTimestamp).toLocaleDateString() |
| 22 | +}) |
| 23 | +
|
| 24 | +function goToPrivacyPolicy() { |
| 25 | + void router.push('/privacy') |
| 26 | +} |
| 27 | +
|
| 28 | +function confirmClearData() { |
| 29 | + confirm.require({ |
| 30 | + message: |
| 31 | + 'This will clear your authentication, preferences, and consent settings. You will need to log in again. Your science data (records and parquet files) will be preserved. Are you sure?', |
| 32 | + header: 'Clear All Data', |
| 33 | + icon: 'pi pi-exclamation-triangle', |
| 34 | + rejectLabel: 'Cancel', |
| 35 | + acceptLabel: 'Clear All Data', |
| 36 | + rejectClass: 'p-button-secondary', |
| 37 | + acceptClass: 'p-button-danger', |
| 38 | + accept: async () => { |
| 39 | + await privacyConsentStore.clearAllUserData() |
| 40 | + toast.add({ |
| 41 | + severity: 'success', |
| 42 | + summary: 'Data Cleared', |
| 43 | + detail: 'Authentication and preferences cleared. Science data preserved.', |
| 44 | + life: srToastStore.getLife() |
| 45 | + }) |
| 46 | + // Redirect to home page after clearing |
| 47 | + void router.push('/') |
| 48 | + } |
| 49 | + }) |
| 50 | +} |
| 51 | +
|
| 52 | +function confirmClearScienceData() { |
| 53 | + confirm.require({ |
| 54 | + message: |
| 55 | + 'This will delete all your request records and cached parquet data files. Your authentication and preferences will be preserved. Are you sure?', |
| 56 | + header: 'Clear Science Data', |
| 57 | + icon: 'pi pi-exclamation-triangle', |
| 58 | + rejectLabel: 'Cancel', |
| 59 | + acceptLabel: 'Clear Science Data', |
| 60 | + rejectClass: 'p-button-secondary', |
| 61 | + acceptClass: 'p-button-warning', |
| 62 | + accept: async () => { |
| 63 | + await cleanupDelAllRequests() |
| 64 | + toast.add({ |
| 65 | + severity: 'success', |
| 66 | + summary: 'Science Data Cleared', |
| 67 | + detail: 'All request records and parquet files have been removed.', |
| 68 | + life: srToastStore.getLife() |
| 69 | + }) |
| 70 | + } |
| 71 | + }) |
| 72 | +} |
| 73 | +</script> |
| 74 | + |
| 75 | +<template> |
| 76 | + <div class="sr-privacy-settings"> |
| 77 | + <ConfirmDialog /> |
| 78 | + |
| 79 | + <!-- Current Status --> |
| 80 | + <div class="sr-privacy-status"> |
| 81 | + <div class="sr-privacy-status-row"> |
| 82 | + <span class="sr-privacy-label">Privacy notice:</span> |
| 83 | + <span class="sr-privacy-value">{{ consentStatus }}</span> |
| 84 | + </div> |
| 85 | + <div v-if="consentDate" class="sr-privacy-status-row"> |
| 86 | + <span class="sr-privacy-label">Acknowledged:</span> |
| 87 | + <span class="sr-privacy-value">{{ consentDate }}</span> |
| 88 | + </div> |
| 89 | + </div> |
| 90 | + |
| 91 | + <!-- Actions --> |
| 92 | + <div class="sr-privacy-actions"> |
| 93 | + <Button |
| 94 | + label="Clear All My Data" |
| 95 | + icon="pi pi-trash" |
| 96 | + severity="danger" |
| 97 | + outlined |
| 98 | + title="Clears authentication, preferences, and consent settings. Preserves your science data (records and parquet files)." |
| 99 | + @click="confirmClearData" |
| 100 | + /> |
| 101 | + <Button |
| 102 | + label="Clear Science Data" |
| 103 | + icon="pi pi-database" |
| 104 | + severity="warning" |
| 105 | + outlined |
| 106 | + title="Clears all request records and cached parquet files. Preserves your authentication and preferences." |
| 107 | + @click="confirmClearScienceData" |
| 108 | + /> |
| 109 | + </div> |
| 110 | + |
| 111 | + <!-- Privacy Policy Link --> |
| 112 | + <div class="sr-privacy-link-section"> |
| 113 | + <Button |
| 114 | + label="View Privacy Policy" |
| 115 | + icon="pi pi-external-link" |
| 116 | + link |
| 117 | + @click="goToPrivacyPolicy" |
| 118 | + /> |
| 119 | + </div> |
| 120 | + </div> |
| 121 | +</template> |
| 122 | + |
| 123 | +<style scoped> |
| 124 | +.sr-privacy-settings { |
| 125 | + display: flex; |
| 126 | + flex-direction: column; |
| 127 | + gap: 1rem; |
| 128 | +} |
| 129 | +
|
| 130 | +.sr-privacy-status { |
| 131 | + display: flex; |
| 132 | + flex-direction: column; |
| 133 | + gap: 0.5rem; |
| 134 | + padding: 1rem; |
| 135 | + background: var(--p-surface-800, #1e1e1e); |
| 136 | + border: 1px solid var(--p-surface-600, #3e3e3e); |
| 137 | + border-radius: 8px; |
| 138 | +} |
| 139 | +
|
| 140 | +.sr-privacy-status-row { |
| 141 | + display: flex; |
| 142 | + justify-content: space-between; |
| 143 | + align-items: center; |
| 144 | +} |
| 145 | +
|
| 146 | +.sr-privacy-label { |
| 147 | + color: var(--p-text-muted-color, #888); |
| 148 | +} |
| 149 | +
|
| 150 | +.sr-privacy-value { |
| 151 | + font-weight: 500; |
| 152 | +} |
| 153 | +
|
| 154 | +.sr-privacy-actions { |
| 155 | + display: flex; |
| 156 | + gap: 0.75rem; |
| 157 | + flex-wrap: wrap; |
| 158 | + justify-content: center; |
| 159 | +} |
| 160 | +
|
| 161 | +.sr-privacy-link-section { |
| 162 | + display: flex; |
| 163 | + justify-content: center; |
| 164 | + border-top: 1px solid var(--p-surface-600, #3e3e3e); |
| 165 | + padding-top: 1rem; |
| 166 | +} |
| 167 | +</style> |
0 commit comments