From e425cf4ec0da6214656bb16b60f022108f7e24b3 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 26 Jun 2022 13:23:48 +0200 Subject: [PATCH] Client - add icon to copy client id & secret in clipboard --- .../src/components/User/UserApps/UserApp.vue | 49 ++++++++++++++++++- fittrackee_client/src/locales/en/oauth2.json | 1 + fittrackee_client/src/locales/fr/oauth2.json | 1 + 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/fittrackee_client/src/components/User/UserApps/UserApp.vue b/fittrackee_client/src/components/User/UserApps/UserApp.vue index a7f40980..a003973f 100644 --- a/fittrackee_client/src/components/User/UserApps/UserApp.vue +++ b/fittrackee_client/src/components/User/UserApps/UserApp.vue @@ -22,11 +22,30 @@
{{ $t('oauth2.APP.CLIENT_ID') }}:
-
{{ client.client_id }}
+
+ {{ client.client_id }} + +
{{ $t('oauth2.APP.CLIENT_SECRET') }}:
-
{{ client.client_secret }}
+
+ {{ client.client_secret }} + +
{{ capitalize($t('oauth2.APP.ISSUE_AT')) }}:
{{ @@ -125,6 +144,8 @@ ) const displayModal: Ref = ref(false) const messageToDisplay: Ref = ref(null) + const idCopied: Ref = ref(false) + const secretCopied: Ref = ref(false) onBeforeMount(() => { loadClient() @@ -159,6 +180,24 @@ store.dispatch(OAUTH2_STORE.ACTIONS.REVOKE_ALL_TOKENS, clientId) } } + function copyIdToClipboard() { + navigator.clipboard.writeText(client.value.client_id) + idCopied.value = true + secretCopied.value = false + setTimeout(() => { + idCopied.value = false + }, 3000) + } + function copySecretToClipboard() { + if (client.value.client_secret) { + navigator.clipboard.writeText(client.value.client_secret) + secretCopied.value = true + idCopied.value = false + setTimeout(() => { + secretCopied.value = false + }, 3000) + } + } onUnmounted(() => { store.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES) store.commit(OAUTH2_STORE.MUTATIONS.EMPTY_CLIENT) @@ -183,6 +222,9 @@ flex-wrap: wrap; gap: $default-padding; } + .app-secret { + word-break: break-word; + } .client-scopes { display: flex; flex-wrap: wrap; @@ -190,6 +232,9 @@ padding-right: $default-padding * 1.5; } } + .fa-copy { + font-size: 0.9em; + } .no-description { font-style: italic; } diff --git a/fittrackee_client/src/locales/en/oauth2.json b/fittrackee_client/src/locales/en/oauth2.json index 34839728..5dfe92fc 100644 --- a/fittrackee_client/src/locales/en/oauth2.json +++ b/fittrackee_client/src/locales/en/oauth2.json @@ -24,6 +24,7 @@ "APP_REQUESTING_ACCESS": "The application {0} is requesting:", "APPS_LIST": "OAuth2 applications", "AUTHORIZE_APP": "Authorize {0} to use your account?", + "COPY_TO_CLIPBOARD": "copy to the clipboard", "DELETE_APP": "Delete application", "NEW_APP": "New OAuth App", "NO_DESCRIPTION": "no description", diff --git a/fittrackee_client/src/locales/fr/oauth2.json b/fittrackee_client/src/locales/fr/oauth2.json index 048b2c95..864e20c8 100644 --- a/fittrackee_client/src/locales/fr/oauth2.json +++ b/fittrackee_client/src/locales/fr/oauth2.json @@ -24,6 +24,7 @@ "APP_REQUESTING_ACCESS": "L'application {0} demande les accès suivants :", "APPS_LIST": "Applications OAuth2", "AUTHORIZE_APP": "Autoriser {0} à utiliser votre compte ?", + "COPY_TO_CLIPBOARD": "copier dans le presse papier", "DELETE_APP": "Supprimer l'application", "NEW_APP": "Ajouter une App OAuth", "NO_DESCRIPTION": "pas de description",