Skip to content

Commit

Permalink
- ADD: Added way to get Germinate auth token from user interface for …
Browse files Browse the repository at this point in the history
…API or BrAPI use.
  • Loading branch information
sebastian-raubach committed Feb 6, 2023
1 parent 60c8016 commit 05cb516
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/components/dropdowns/UserSettingsDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,41 @@
</template>
<!-- Settings -->
<b-dropdown-header class="text-center border-bottom mb-2"><strong>{{ $t('dropdownUserSettings') }}<span v-if="storeToken">: {{ storeToken.username }}</span></strong></b-dropdown-header>
<!-- Logout -->
<b-dropdown-item @click="signOut" v-if="storeToken && storeToken.token"><span class="text-danger"><MdiIcon :path="mdiLogoutVariant" /></span> {{ $t('dropdownUserSettingsLogout') }}</b-dropdown-item>
<template v-if="storeToken && storeToken.token">
<b-dropdown-item @click="$refs.tokenModal.show()"><span class="text-info"><MdiIcon :path="mdiCircleMultiple" /></span> {{ $t('dropdownUserSettingsGetToken') }}</b-dropdown-item>
<!-- Logout -->
<b-dropdown-item @click="signOut"><span class="text-danger"><MdiIcon :path="mdiLogoutVariant" /></span> {{ $t('dropdownUserSettingsLogout') }}</b-dropdown-item>
</template>
<!-- Login -->
<b-dropdown-item :to="{ name: Pages.login }" v-else><span class="text-success"><MdiIcon :path="mdiLoginVariant" /></span> {{ $t('dropdownUserSettingsLogin') }}</b-dropdown-item>

<GetTokenModal ref="tokenModal" />
</b-nav-item-dropdown>
</template>

<script>
import { mapGetters } from 'vuex'
import GetTokenModal from '@/components/modals/GetTokenModal'
import MdiIcon from '@/components/icons/MdiIcon'
import { userIsAtLeast, apiDeleteToken, apiPostToken } from '@/mixins/api/auth'
import { mdiAccount, mdiCog, mdiAccountKey, mdiUpload, mdiSetMerge, mdiLogoutVariant, mdiLoginVariant, mdiCommentQuoteOutline } from '@mdi/js'
import { mdiAccount, mdiCog, mdiAccountKey, mdiUpload, mdiCircleMultiple, mdiSetMerge, mdiLogoutVariant, mdiLoginVariant, mdiCommentQuoteOutline } from '@mdi/js'
import { Pages } from '@/mixins/pages'
const emitter = require('tiny-emitter/instance')
export default {
components: {
GetTokenModal,
MdiIcon
},
data: () => {
return {
Pages,
mdiAccount,
mdiCog,
mdiCircleMultiple,
mdiAccountKey,
mdiUpload,
mdiSetMerge,
Expand Down
50 changes: 50 additions & 0 deletions src/components/modals/GetTokenModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<b-modal ref="tokenModal" :title="$t('modalTitleGetToken')" ok-only :ok-title="$t('buttonClose')" @shown="$refs.token.focus()">
<b-form-group :label="$t('formLabelToken')" label-for="token" :description="$t('formDescriptionToken')">
<b-input-group>
<b-input :value="storeToken.token" id="token" autofocus @focus="$event.target.select()" ref="token" />
<b-input-group-append>
<b-button @click="copyToClipboard" v-b-tooltip="$t('tooltipCopyToClipboard')"><MdiIcon :path="mdiClipboardFileOutline" /></b-button>
</b-input-group-append>
</b-input-group>
</b-form-group>
</b-modal>
</template>

<script>
import MdiIcon from '@/components/icons/MdiIcon'
import { mapGetters } from 'vuex'
import { mdiClipboardFileOutline } from '@mdi/js'
export default {
components: {
MdiIcon
},
data: function () {
return {
mdiClipboardFileOutline
}
},
computed: {
...mapGetters([
'storeToken'
])
},
methods: {
copyToClipboard: function () {
navigator.clipboard.writeText(this.storeToken.token)
},
show: function () {
this.$refs.tokenModal.show()
},
hide: function () {
this.$refs.tokenModal.hide()
}
}
}
</script>

<style>
</style>
5 changes: 5 additions & 0 deletions src/plugins/i18n/en_GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"dropdownUserSettingsDataUpload": "Data uploader",
"dropdownUserSettingsGermplasmUnifier": "Germplasm unifier",
"dropdownUserSettingsGerminateSettings": "Germinate settings",
"dropdownUserSettingsGetToken": "Get access token",
"dropdownLabelGermplasmSearch": "{germplasm}, Rep: {rep}, Row: {row}, Column: {column}",
"dublinCoreContributor": "Contributor",
"dublinCoreCoverage": "Coverage",
Expand Down Expand Up @@ -164,6 +165,7 @@
"formDescriptionGroupType": "Select the type of this group.",
"formDescriptionGroupTypeDisabled": "The group type cannot be changed.",
"formDescriptionFileResourceDatasets": "File resources can be linked to existing datasets. Select the button to select the datasets from a table.",
"formDescriptionToken": "This is your session token. It can be used to access Germinate's API and BrAPI implementation. Do not share this token with anyone.",
"formSelectOptionLicenseNone": "No license",
"formLabelExperimentName": "Experiment name",
"formLabelExperimentDescription": "Experiment description",
Expand Down Expand Up @@ -227,6 +229,7 @@
"formLabelTraitTimelineShapefile": "Trial shape file",
"formLabelTraitTimelineGermplasm": "Germplasm search",
"formLabelTraitChartGrouping": "Group box plots by",
"formLabelToken": "Token",
"formLabelDataUploadFile": "Template file",
"formLabelDataUploadDataset": "Associated trials dataset",
"formDescriptionTraitTimelineTimepoint": "Current time point: {timepoint}",
Expand Down Expand Up @@ -435,6 +438,7 @@
"modalTitleFileResourceDataset": "Select linked datasets",
"modalTitleImageUpload": "Image upload",
"modalTitleGenotypeExport": "Additional export formats",
"modalTitleGetToken": "Session token",
"modalTitlePublications": "Publications",
"modalTitlePublicationAddNew": "Add new publication",
"modalTextGenotypeExport": "Please select any additional data formats you would like to receive this data in.",
Expand Down Expand Up @@ -1211,6 +1215,7 @@
"toastUserFeedbackSuccessText": "Your feedback has been submitted successfully.",
"tooltipAddNewComment": "Add new comment",
"tooltipClear": "Clear",
"tooltipCopyToClipboard": "Copy to clipboard",
"tooltipCreateNewGroup": "Create new group",
"tooltipDelete": "Delete",
"tooltipExportFormatLearnMore": "Learn more about export formats",
Expand Down

0 comments on commit 05cb516

Please sign in to comment.