|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import { computed, onMounted, ref } from "vue"; |
3 | 3 |
|
4 | | - import { useHead } from "@unhead/vue"; |
| 4 | + import { useI18n } from "vue-i18n"; |
| 5 | + const { t } = useI18n(); |
5 | 6 |
|
| 7 | + // Unhead |
| 8 | + import { useHead } from "@unhead/vue"; |
6 | 9 | useHead({ |
7 | | - title: "API Keys | PRUNplanner", |
| 10 | + title: `${t("api_keys.view_title")} | PRUNplanner`, |
8 | 11 | }); |
9 | 12 |
|
10 | 13 | // Composables |
|
72 | 75 | <n-modal |
73 | 76 | v-model:show="showCreateModal" |
74 | 77 | preset="dialog" |
75 | | - title="Create API Key" |
| 78 | + :title="t('api_keys.create.title')" |
76 | 79 | :show-icon="false"> |
77 | | - <template #header>Create API Key</template> |
| 80 | + <template #header>{{ $t("api_keys.create.title") }}</template> |
78 | 81 | <div v-if="creationStep === 'start'"> |
79 | 82 | <PForm> |
80 | | - <PFormItem label="Key Name"> |
| 83 | + <PFormItem :label="t('api_keys.create.form.key_name')"> |
81 | 84 | <PInput v-model:value="creationAPIKeyName" class="w-full" /> |
82 | 85 | </PFormItem> |
83 | 86 | <PFormSeperator> |
84 | 87 | <span class="py-1 text-white/50 text-xs"> |
85 | | - Give your key a descriptive name to help you identify it |
86 | | - later. |
| 88 | + {{ $t("api_keys.create.form.key_description") }} |
87 | 89 | </span> |
88 | 90 | </PFormSeperator> |
89 | 91 | </PForm> |
|
96 | 98 | <CheckSharp class="w-6 h-6" /> |
97 | 99 | </div> |
98 | 100 | <h3 class="text-center text-lg font-bold"> |
99 | | - Key Generated Successfully |
| 101 | + {{ $t("api_keys.create.form.success_title") }} |
100 | 102 | </h3> |
101 | 103 | <div |
102 | 104 | class="flex flex-col gap-2 items-center bg-white/5 border border-dark-gray border-dashed rounded p-3"> |
103 | 105 | <span |
104 | 106 | class="uppercase font-bold text-xs text-center text-white/80"> |
105 | | - Your Secret Key (Save this Now!) |
| 107 | + {{ $t("api_keys.create.form.success_key") }} |
106 | 108 | </span> |
107 | 109 | <span class="font-mono text-prunplanner text-nowrap"> |
108 | 110 | {{ lastCreatedKey }} |
109 | 111 | </span> |
110 | 112 | </div> |
111 | 113 | <div class="text-red-500"> |
112 | | - For security, we cannot show this key again. If you lose it, you |
113 | | - must revoke and create a new one. |
| 114 | + {{ $t("api_keys.create.form.success_note") }} |
114 | 115 | </div> |
115 | 116 | </div> |
116 | 117 | <div v-else-if="creationStep === 'error'"> |
117 | 118 | <div class="text-center text-red-500"> |
118 | | - Error creating your API Key. Please try again later. |
| 119 | + {{ $t("api_keys.create.form.error") }} |
119 | 120 | </div> |
120 | 121 | </div> |
121 | 122 | <template #action> |
|
128 | 129 | showCreateModal = false; |
129 | 130 | } |
130 | 131 | "> |
131 | | - Cancel |
| 132 | + {{ $t("api_keys.create.buttons.cancel") }} |
132 | 133 | </PButton> |
133 | 134 | <PButton |
134 | 135 | :loading="creationLoading" |
135 | 136 | :disabled="!creationHasName" |
136 | 137 | @click="createKey"> |
137 | | - Create Key |
| 138 | + {{ $t("api_keys.create.buttons.create") }} |
138 | 139 | </PButton> |
139 | 140 | </div> |
140 | 141 | <div v-else-if="creationStep === 'key'" class="w-full"> |
|
147 | 148 | resetCreation(); |
148 | 149 | } |
149 | 150 | "> |
150 | | - I've saved my key |
| 151 | + {{ $t("api_keys.create.buttons.saved") }} |
151 | 152 | </PButton> |
152 | 153 | </div> |
153 | 154 | </template> |
|
156 | 157 | <div class="min-h-screen flex flex-col"> |
157 | 158 | <div |
158 | 159 | class="px-6 py-3 border-b border-white/10 flex flex-row justify-between"> |
159 | | - <h1 class="text-2xl font-bold">API Keys</h1> |
| 160 | + <h1 class="text-2xl font-bold">{{ $t("api_keys.title") }}</h1> |
160 | 161 | </div> |
161 | 162 | <div> |
162 | 163 | <div |
163 | 164 | class="grid grid-cols-1 lg:grid-cols-3 divide-x divide-white/10 min-h-screen"> |
164 | 165 | <div class="xl:col-span-2 flex flex-col gap-3 px-6 py-3"> |
165 | | - <div class="text-white/80"> |
166 | | - The |
167 | | - <a |
168 | | - href="https://api.prunplanner.org/docs" |
169 | | - target="_blank" |
170 | | - class="font-bold underline hover:text-prunplanner" |
171 | | - >PRUNplanner REST API</a |
172 | | - > |
173 | | - provides programmatic access to all your planning data, |
174 | | - ingame metadata (buildings, recipes, materials) and |
175 | | - calculated market metrics like VWAP. While public |
176 | | - endpoints remain open for community use, access to |
177 | | - <strong>private planning data</strong> - including your |
178 | | - plan configurations - require secure authentication. |
179 | | - </div> |
| 166 | + <i18n-t keypath="api_keys.info.description.p1" tag="div"> |
| 167 | + <template #link> |
| 168 | + <a |
| 169 | + href="https://api.prunplanner.org/docs" |
| 170 | + target="_blank" |
| 171 | + class="font-bold underline hover:text-prunplanner" |
| 172 | + >{{ $t("api_keys.info.description.link") }}</a |
| 173 | + > |
| 174 | + </template> |
| 175 | + </i18n-t> |
180 | 176 | <div> |
181 | | - By utilizing these endpoints, you can synchronize your |
182 | | - planning operations with external spreadsheets, custom |
183 | | - dashboards, or even optimization algorithms. |
| 177 | + {{ $t("api_keys.info.description.p2") }} |
184 | 178 | </div> |
185 | 179 | <div |
186 | 180 | class="bg-prunplanner/10 border-l-4 border-prunplanner p-3"> |
187 | 181 | <p class="text-white font-mono text-xs"> |
188 | | - API keys grant full access to your account data and |
189 | | - remain valid indefinitely. Treat these credentials |
190 | | - as sensitive as your password. Never commit keys to |
191 | | - public repositories or share them with unverified |
192 | | - third-party services. If a key is compromised, |
193 | | - revoke it immediately and generate a replacement. |
| 182 | + {{ $t("api_keys.info.description.warning") }} |
194 | 183 | </p> |
195 | 184 | </div> |
196 | 185 |
|
197 | 186 | <div> |
198 | 187 | <div |
199 | 188 | class="flex flex-row justify-between items-center pt-6 pb-3"> |
200 | 189 | <h2 class="text-lg font-bold"> |
201 | | - PRUNplanner API Keys |
| 190 | + {{ $t("api_keys.info.manage.title") }} |
202 | 191 | </h2> |
203 | 192 | <div class="flex flex-row gap-3"> |
204 | 193 | <PButton |
|
207 | 196 | showCreateModal = !showCreateModal; |
208 | 197 | } |
209 | 198 | "> |
210 | | - Create New Key |
| 199 | + {{ |
| 200 | + $t("api_keys.manage.buttons.new_apikey") |
| 201 | + }} |
211 | 202 | </PButton> |
212 | 203 | <PButton @click="fetchAPIKeys"> |
213 | 204 | <template #icon> |
|
223 | 214 | striped> |
224 | 215 | <thead> |
225 | 216 | <tr> |
226 | | - <th>Name</th> |
227 | | - <th>Key Prefix</th> |
228 | | - <th>Created</th> |
229 | | - <th>Last Used</th> |
| 217 | + <th> |
| 218 | + {{ |
| 219 | + $t( |
| 220 | + "api_keys.manage.table.apikey_name" |
| 221 | + ) |
| 222 | + }} |
| 223 | + </th> |
| 224 | + <th> |
| 225 | + {{ |
| 226 | + $t( |
| 227 | + "api_keys.manage.table.apikey_prefix" |
| 228 | + ) |
| 229 | + }} |
| 230 | + </th> |
| 231 | + <th> |
| 232 | + {{ |
| 233 | + $t( |
| 234 | + "api_keys.manage.table.apikey_created" |
| 235 | + ) |
| 236 | + }} |
| 237 | + </th> |
| 238 | + <th> |
| 239 | + {{ |
| 240 | + $t( |
| 241 | + "api_keys.manage.table.apikey_lastused" |
| 242 | + ) |
| 243 | + }} |
| 244 | + </th> |
230 | 245 | <th></th> |
231 | 246 | </tr> |
232 | 247 | </thead> |
|
262 | 277 | @click=" |
263 | 278 | deleteAPIKey(apiKey.id) |
264 | 279 | "> |
265 | | - Revoke |
| 280 | + {{ |
| 281 | + $t( |
| 282 | + "api_keys.manage.buttons.revoke_apikey" |
| 283 | + ) |
| 284 | + }} |
266 | 285 | </PButton> |
267 | 286 | </td> |
268 | 287 | </tr> |
|
285 | 304 | <div |
286 | 305 | class="bg-white/5 border border-dark-gray border-dashed rounded flex flex-col gap-3 p-3"> |
287 | 306 | <h3 class="uppercase font-bold"> |
288 | | - Authorization Implementation |
| 307 | + {{ $t("api_keys.implementation.title") }} |
289 | 308 | </h3> |
290 | 309 | <div class="space-y-4"> |
291 | 310 | <div> |
|
314 | 333 | href="https://api.prunplanner.org/docs" |
315 | 334 | target="_blank" |
316 | 335 | class="font-mono text-xs font-bold text-white hover:text-prunplanner underline mt-2"> |
317 | | - View REST API Reference → |
| 336 | + {{ $t("api_keys.implementation.link") }} |
318 | 337 | </a> |
319 | 338 | </div> |
320 | 339 | </div> |
|
0 commit comments