Skip to content

Commit

Permalink
- CHG: Moved user type strings to constants.
Browse files Browse the repository at this point in the history
- CHG: Adjusted imports.
  • Loading branch information
sebastian-raubach committed Feb 29, 2024
1 parent 1881b1a commit ebe4a80
Show file tree
Hide file tree
Showing 24 changed files with 150 additions and 103 deletions.
12 changes: 7 additions & 5 deletions src/components/dropdowns/UserSettingsDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
</template>

<!-- Administrators get to see additional items -->
<template v-if="storeToken && userIsAtLeast(storeToken.userType, 'Data Curator')">
<template v-if="storeToken && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)">
<b-dropdown-header class="text-center border-bottom mb-2"><strong>{{ $t('dropdownUserSettingsAdvancedSettings') }}</strong></b-dropdown-header>
<b-dropdown-item :to="{ name: Pages.germinateSettings }" v-if="userIsAtLeast(storeToken.userType, 'Administrator')"><span class="text-warning"><MdiIcon :path="mdiCog"/></span> {{ $t('dropdownUserSettingsGerminateSettings') }}</b-dropdown-item>
<b-dropdown-item :to="{ name: Pages.userPermissions }" v-if="userIsAtLeast(storeToken.userType, 'Administrator')"><span class="text-warning"><MdiIcon :path="mdiAccountKey"/></span> {{ $t('dropdownUserSettingsUserPermissions') }}</b-dropdown-item>
<b-dropdown-item :to="{ name: Pages.germinateSettings }" v-if="userIsAtLeast(storeToken.userType, USER_TYPE_ADMINISTRATOR)"><span class="text-warning"><MdiIcon :path="mdiCog"/></span> {{ $t('dropdownUserSettingsGerminateSettings') }}</b-dropdown-item>
<b-dropdown-item :to="{ name: Pages.userPermissions }" v-if="userIsAtLeast(storeToken.userType, USER_TYPE_ADMINISTRATOR)"><span class="text-warning"><MdiIcon :path="mdiAccountKey"/></span> {{ $t('dropdownUserSettingsUserPermissions') }}</b-dropdown-item>
<b-dropdown-item v-if="storeServerSettings.dataImportMode !== 'NONE'" :to="{ name: Pages.importUpload }"><span class="text-warning"><MdiIcon :path="mdiUpload"/></span> {{ $t('dropdownUserSettingsDataUpload') }}</b-dropdown-item>
<b-dropdown-item :to="{ name: Pages.germplasmUnifier }"><span class="text-warning"><MdiIcon :path="mdiSetMerge"/></span> {{ $t('dropdownUserSettingsGermplasmUnifier') }}</b-dropdown-item>
<b-dropdown-item :to="{ name: Pages.userFeedback }" v-if="storeServerSettings.supportsFeedback"><span class="text-warning"><MdiIcon :path="mdiCommentQuoteOutline"/></span> {{ $t('dropdownUserSettingsUserFeedback') }}</b-dropdown-item>
Expand All @@ -32,7 +32,7 @@ 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 { userIsAtLeast, apiDeleteToken, apiPostToken, USER_TYPE_ADMINISTRATOR, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth'
import { mdiAccount, mdiCog, mdiAccountKey, mdiUpload, mdiCircleMultiple, mdiSetMerge, mdiLogoutVariant, mdiLoginVariant, mdiCommentQuoteOutline } from '@mdi/js'
import { Pages } from '@/mixins/pages'
Expand All @@ -56,7 +56,9 @@ export default {
mdiLogoutVariant,
mdiLoginVariant,
mdiCommentQuoteOutline,
enabled: true
enabled: true,
USER_TYPE_ADMINISTRATOR,
USER_TYPE_DATA_CURATOR
}
},
computed: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/germplasm/SpecificPassport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ import PedigreeChart from '@/components/charts/PedigreeChart'
import PedigreeTable from '@/components/tables/PedigreeTable'
import PedigreeDefinitionTable from '@/components/tables/PedigreeDefinitionTable'
import PublicationsWidget from '@/components/util/PublicationsWidget'
import { userIsAtLeast } from '@/mixins/api/auth'
import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth'
import { apiPostGermplasmTable, apiPostGermplasmGroupTable, apiPostGermplasmDatasetTable, apiPostGermplasmAttributeTable, apiPostPedigreeTable, apiPostEntityTable, apiPatchGermplasmLocation, apiPostPedigreedefinitionTable } from '@/mixins/api/germplasm'
import { apiPostGermplasmInstitutionTable, apiPostCommentsTable } from '@/mixins/api/misc'
import { entityTypes } from '@/mixins/types'
Expand Down Expand Up @@ -301,7 +301,7 @@ export default {
]),
isAtLeastDataCurator: function () {
if (this.storeToken) {
return userIsAtLeast(this.storeToken.userType, 'Data Curator')
return userIsAtLeast(this.storeToken.userType, USER_TYPE_DATA_CURATOR)
} else {
return false
}
Expand Down
7 changes: 4 additions & 3 deletions src/components/images/ImageCarousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</b-carousel-slide>
</b-carousel>

<div v-if="storeToken && userIsAtLeast(storeToken.userType, 'Administrator')">
<div v-if="storeToken && userIsAtLeast(storeToken.userType, USER_TYPE_ADMINISTRATOR)">
<b-button @click="$refs.carouselEditModal.show()">{{ $t('buttonEditCarousel') }}</b-button>

<CarouselEditModal ref="carouselEditModal" @change="update" />
Expand All @@ -34,7 +34,7 @@ import CarouselEditModal from '@/components/modals/CarouselEditModal'
import { mapGetters } from 'vuex'
import { userIsAtLeast } from '@/mixins/api/auth'
import { userIsAtLeast, USER_TYPE_ADMINISTRATOR } from '@/mixins/api/auth'
import { getImageUrl } from '@/mixins/image'
import { apiGetTemplateCarouselConfig } from '@/mixins/api/misc'
Expand All @@ -51,7 +51,8 @@ export default {
data: function () {
return {
slide: 0,
images: null
images: null,
USER_TYPE_ADMINISTRATOR
}
},
methods: {
Expand Down
9 changes: 5 additions & 4 deletions src/components/images/ImageGallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

<b-button-group>
<b-button @click="download" v-if="images && images.length > 0"><MdiIcon :path="mdiDownload" /> {{ $t('buttonDownloadImages') }}</b-button>
<b-button @click="$refs.imageUploadModal.show()" v-if="storeToken && userIsAtLeast(storeToken.userType, 'Data Curator')"><MdiIcon :path="mdiUpload" /> {{ $t('buttonUpload') }}</b-button>
<b-button @click="$refs.imageUploadModal.show()" v-if="storeToken && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)"><MdiIcon :path="mdiUpload" /> {{ $t('buttonUpload') }}</b-button>
</b-button-group>

<ImageUploadModal :foreignId="foreignId" :referenceTable="referenceTable" v-on:images-updated="refresh()" ref="imageUploadModal" v-if="storeToken && userIsAtLeast(storeToken.userType, 'Data Curator')" />
<ImageUploadModal :foreignId="foreignId" :referenceTable="referenceTable" v-on:images-updated="refresh()" ref="imageUploadModal" v-if="storeToken && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)" />
</div>
</template>

Expand All @@ -46,7 +46,7 @@ import ImageTags from '@/components/images/ImageTags'
import ImageUploadModal from '@/components/modals/ImageUploadModal'
import { getImageUrl } from '@/mixins/image'
import { apiPostImages, apiPostImagesExport } from '@/mixins/api/misc.js'
import { userIsAtLeast } from '@/mixins/api/auth'
import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth'
import { mdiDownload, mdiUpload } from '@mdi/js'
Expand All @@ -63,7 +63,8 @@ export default {
images: [],
imageCount: -1,
imageTags: [],
selectedTag: null
selectedTag: null,
USER_TYPE_DATA_CURATOR
}
},
props: {
Expand Down
11 changes: 6 additions & 5 deletions src/components/images/ImageNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<div style="height: 6px;" v-else />
</div>
</a>
<b-button class="position-absolute image-delete-button" variant="danger" v-b-tooltip="$t('buttonDelete')" @click="deleteImage" v-if="storeToken && storeToken.userType && userIsAtLeast(storeToken.userType, 'Data Curator')">
<b-button class="position-absolute image-delete-button" variant="danger" v-b-tooltip="$t('buttonDelete')" @click="deleteImage" v-if="storeToken && storeToken.userType && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)">
<MdiIcon :path="mdiDelete" />
</b-button>
<b-card-body class="card-image-details">
<b-input-group v-if="storeToken && storeToken.userType && userIsAtLeast(storeToken.userType, 'Data Curator')" class="mb-2">
<b-input-group v-if="storeToken && storeToken.userType && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)" class="mb-2">
<b-textarea rows="3" max-rows="10" class="image-description" v-model="image.imageDescription"/>
<b-input-group-append>
<b-button variant="success" @click="updateImageDescription"><MdiIcon :path="mdiContentSave" /></b-button>
Expand All @@ -30,7 +30,7 @@
{{ tag.tagName }}
</b-badge>
</template>
<div v-if="storeToken && storeToken.userType && userIsAtLeast(storeToken.userType, 'Data Curator')">
<div v-if="storeToken && storeToken.userType && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)">
<b-badge class="bg-info"
v-b-tooltip.hover
href="#"
Expand Down Expand Up @@ -64,7 +64,7 @@ import ImageExifModal from '@/components/modals/ImageExifModal'
import { imageTypes } from '@/mixins/types'
import { apiDeleteImage, apiPatchImage } from '@/mixins/api/misc'
import { getImageUrl } from '@/mixins/image'
import { userIsAtLeast } from '@/mixins/api/auth'
import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth'
import { mdiDelete, mdiContentSave, mdiCalendarClock, mdiPencil, mdiImageText } from '@mdi/js'
Expand All @@ -89,7 +89,8 @@ export default {
mdiImageText,
src: null,
largeSrc: null,
imageLoaded: false
imageLoaded: false,
USER_TYPE_DATA_CURATOR
}
},
components: {
Expand Down
11 changes: 6 additions & 5 deletions src/components/news/NewsSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div v-html="selectedNews.newsContent" />
<b-button-group class="mt-3">
<b-button v-if="selectedNews.newsHyperlink && selectedNews.newsHyperlink.lastIndexOf('#', 0) !== 0" :href="selectedNews.newsHyperlink" target="_blank" rel="noopener noreferrer">{{ $t('pageNewsReadMore') }} <MdiIcon :path="mdiOpenInNew" /></b-button>
<b-button v-if="storeToken && userIsAtLeast(storeToken.userType, 'Data Curator')" @click="deleteNewsItem(selectedNews.newsId)" variant="danger"><MdiIcon :path="mdiDelete" /> {{ $t('buttonDelete') }}</b-button>
<b-button v-if="storeToken && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)" @click="deleteNewsItem(selectedNews.newsId)" variant="danger"><MdiIcon :path="mdiDelete" /> {{ $t('buttonDelete') }}</b-button>
</b-button-group>
</b-modal>
</b-col>
Expand All @@ -59,7 +59,7 @@
<b-button variant="primary" :href="project.newsHyperlink" rel="noopener noreferrer" v-if="project.newsHyperlink">
<MdiIcon :path="mdiOpenInNew" /> {{ $t('pageNewsReadMore') }}
</b-button>
<b-button v-if="storeToken && userIsAtLeast(storeToken.userType, 'Data Curator')" @click="deleteNewsItem(project.newsId)" variant="danger">
<b-button v-if="storeToken && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)" @click="deleteNewsItem(project.newsId)" variant="danger">
<MdiIcon :path="mdiDelete" /> {{ $t('buttonDelete') }}
</b-button>
</b-button-group>
Expand All @@ -76,7 +76,7 @@
@change="updateProjects" />
</b-col>
</b-row>
<div v-if="storeToken && userIsAtLeast(storeToken.userType, 'Data Curator')">
<div v-if="storeToken && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)">
<b-button @click="$refs.addNewsModal.show()">{{ $t('buttonAddNews') }}</b-button>
<AddNewsModal ref="addNewsModal" v-on:news-added="update()" />
</div>
Expand All @@ -89,7 +89,7 @@ import { mapGetters } from 'vuex'
import MdiIcon from '@/components/icons/MdiIcon'
import DataImportJobs from '@/components/dataimport/DataImportJobs'
import AddNewsModal from '@/components/modals/AddNewsModal'
import { userIsAtLeast } from '@/mixins/api/auth'
import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth'
import { apiPostNewsTable, apiDeleteNews } from '@/mixins/api/misc'
import { getImageUrl } from '@/mixins/image'
import { MAX_JAVA_INTEGER } from '@/mixins/api/base'
Expand Down Expand Up @@ -184,7 +184,8 @@ export default {
text: () => this.$t('widgetNewsTypeGeneralNews'),
path: mdiNewspaper
}
}
},
USER_TYPE_DATA_CURATOR
}
},
watch: {
Expand Down
7 changes: 4 additions & 3 deletions src/components/structure/SidebarAsyncJobs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<!-- Show a button to view the feedback -->
<span class="text-danger" v-if="job.feedback.length > 0"><MdiIcon :path="mdiAlertCircle" />&nbsp;<small><a href="#" @click.prevent="showFeedback(job)">{{ $t('widgetAsyncJobPanelFeedback') }}</a></small></span>
</div>
<div v-if="storeToken && userIsAtLeast(storeToken.userType, 'Data Curator')">
<div v-if="storeToken && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)">
<span class="text-info"><MdiIcon :path="mdiFileDocumentAlert" />&nbsp;<small><a href="#" @click.prevent="downloadImportJobLog(job)">{{ $t('widgetAsyncJobPanelDownloadLog') }}</a></small></span>
</div>
</div>
Expand Down Expand Up @@ -148,7 +148,7 @@ import { mdiDelete, mdiDownload, mdiUpload, mdiRefresh, mdiDatabase, mdiClose, m
import UploadStatusTable from '@/components/tables/UploadStatusTable'
import { apiPostDatasetAsyncExport, apiDeleteDatasetAsyncExport } from '@/mixins/api/dataset'
import { userIsAtLeast } from '@/mixins/api/auth'
import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth'
import { apiPostDataAsyncImport, apiDeleteDataAsyncImport, apiGetDataAsyncImportStart, apiGetDataAsyncImportLog } from '@/mixins/api/misc'
import { templateImportTypes } from '@/mixins/types'
import { downloadBlob } from '@/mixins/util'
Expand Down Expand Up @@ -258,7 +258,8 @@ export default {
path: mdiImageMultiple,
color: () => this.storeServerSettings ? this.storeServerSettings.colorsTemplate[5 % this.storeServerSettings.colorsTemplate.length] : null
}
}
},
USER_TYPE_DATA_CURATOR
}
},
computed: {
Expand Down
52 changes: 35 additions & 17 deletions src/components/structure/SidebarComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import 'vue-sidebar-menu/dist/vue-sidebar-menu.css'
import { getNumberWithSuffix } from '@/mixins/formatting'
import { mdiArrowCollapseLeft, mdiArrowCollapseRight, mdiChartAreaspline, mdiBookOpenPageVariant, mdiChartGantt, mdiChartSankey, mdiChevronRight, mdiDatabase, mdiDna, mdiEarth, mdiFileDownload, mdiFileExport, mdiFolderTable, mdiFormatIndentIncrease, mdiGroup, mdiHarddisk, mdiHome, mdiImageMultiple, mdiInformation, mdiInformationOutline, mdiMagnify, mdiMap, mdiMapSearch, mdiNewspaperVariant, mdiPulse, mdiReorderVertical, mdiShovel, mdiSprout, mdiTagMultiple, mdiTagTextOutline, mdiWeatherSnowyRainy } from '@mdi/js'
import { mdiArrowCollapseLeft, mdiArrowCollapseRight, mdiViewGridPlusOutline, mdiChartAreaspline, mdiBookOpenPageVariant, mdiChartGantt, mdiChartSankey, mdiChevronRight, mdiDatabase, mdiDna, mdiEarth, mdiFileDownload, mdiFileExport, mdiFolderTable, mdiFormatIndentIncrease, mdiGroup, mdiHarddisk, mdiHome, mdiImageMultiple, mdiInformation, mdiInformationOutline, mdiMagnify, mdiMap, mdiMapSearch, mdiNewspaperVariant, mdiPulse, mdiReorderVertical, mdiShovel, mdiSprout, mdiTagMultiple, mdiTagTextOutline, mdiWeatherSnowyRainy } from '@mdi/js'
import { apiGetOverviewStats } from '@/mixins/api/stats'
import { Pages } from '@/mixins/pages'
import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth'
const emitter = require('tiny-emitter/instance')
const germinateLogo = 'M 11.999836,0 C 5.384778,0 -3.9999998e-7,5.38515 0,12.00026 -3.9999998e-7,18.61531 5.384778,24.00011 11.999836,24.00011 18.614894,24.00011 24,18.61531 24,12.00026 24,5.38515 18.614894,0 11.999836,0 Z m 0,2.09227 c 5.484271,0 9.907984,4.42367 9.907984,9.90799 0,5.48425 -4.423713,9.90754 -9.907984,9.90754 -5.4842703,0 -9.9076558,-4.42329 -9.9076558,-9.90754 0,-5.48432 4.4233855,-9.90799 9.9076558,-9.90799 z M 9.5003025,5.50579 c -2.4997191,0 -2.4997043,0 -3.7494633,2.16472 L 4.500991,9.83539 c -1.2498943,2.16476 -1.2498943,2.16487 0,4.32945 l 1.2498482,2.16476 c 1.261759,2.16476 1.2617442,2.16476 3.7494633,2.16476 2.4996545,0 2.4997185,0 3.7495455,-2.16476 h -8.1e-5 c 1.249812,-2.16476 1.249787,-2.16469 0,-4.32934 v -1.1e-4 H 10.750152 8.2505363 l 1.2497662,2.16469 H 12 L 10.750152,16.3296 H 8.2505363 L 7.0006881,14.16484 5.7508392,12.00015 7.0006881,9.83539 8.2505363,7.67051 h 2.4996157 2.499696 L 12,5.50579 Z m 4.9993125,0 1.249849,2.16472 1.249848,2.16488 h -2.499697 l -1.249767,2.16476 h 2.499616 l 1.249848,2.16469 -1.249848,2.16476 -1.249849,2.16476 h 2.499697 l 1.249849,-2.16476 1.249766,-2.16476 c 1.249826,-2.16476 1.249826,-2.16469 0,-4.32945 L 18.249161,7.67051 16.999312,5.50579 Z'
Expand Down Expand Up @@ -58,7 +59,8 @@ export default {
},
computed: {
...mapGetters([
'storeServerSettings'
'storeServerSettings',
'storeToken'
]),
menu: function () {
const tempNav = [
Expand Down Expand Up @@ -206,6 +208,18 @@ export default {
path: mdiShovel
}
}
},
{
title: this.$t('menuTrialsCreate'),
identifiers: ['trial-creation'],
href: { name: Pages.trialCreation },
icon: {
element: SidebarIcon,
attributes: {
path: mdiViewGridPlusOutline
}
},
hidden: !userIsAtLeast(this.storeToken ? this.storeToken.userType : null, USER_TYPE_DATA_CURATOR)
}
]
},
Expand Down Expand Up @@ -474,25 +488,29 @@ export default {
}
]
if (this.storeServerSettings && this.storeServerSettings.hiddenPages && this.storeServerSettings.hiddenPages.length > 0) {
const hiddenPages = this.storeServerSettings.hiddenPages
const hiddenPages = (this.storeServerSettings && this.storeServerSettings.hiddenPages && this.storeServerSettings.hiddenPages.length > 0) ? this.storeServerSettings.hiddenPages : []
return tempNav.filter(function f (o) {
if (o.identifiers) {
if (o.identifiers.some(i => hiddenPages.includes(i))) {
return false
}
}
// const currentUserType = this.storeToken ? this.storeToken.userType : null
if (o.child && o.child.length > 0) {
return (o.child = o.child.filter(f)).length
return tempNav.filter(function f (o) {
if (o.identifiers) {
if (o.identifiers.some(i => hiddenPages.includes(i))) {
return false
}
}
return true
})
} else {
return tempNav
}
// if (o.minUserType) {
// if (!userIsAtLeast(currentUserType, o.minUserType)) {
// return false
// }
// }
if (o.child && o.child.length > 0) {
return (o.child = o.child.filter(f)).length
}
return true
})
}
},
methods: {
Expand Down
7 changes: 4 additions & 3 deletions src/components/structure/StoryNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<b-dropdown-item @click="closeStory" variant="danger"><MdiIcon :path="mdiClose" /> {{ $t('buttonCloseStory') }}</b-dropdown-item>
</b-nav-item-dropdown>

<b-nav-item-dropdown class="active" v-if="storeActiveStory.isEdit && storeToken && userIsAtLeast(storeToken.userType, 'Data Curator')" @show="showPopover = false">
<b-nav-item-dropdown class="active" v-if="storeActiveStory.isEdit && storeToken && userIsAtLeast(storeToken.userType, USER_TYPE_DATA_CURATOR)" @show="showPopover = false">
<template v-slot:button-content>
<MdiIcon :path="mdiPencil" /> {{ $t('buttonEdit') }}
</template>
Expand Down Expand Up @@ -78,7 +78,7 @@ import MdiIcon from '@/components/icons/MdiIcon'
import AddStoryStepModal from '@/components/modals/AddStoryStepModal'
import { mdiChevronLeft, mdiChevronRight, mdiClose, mdiArrowDown, mdiArrowDownRight, mdiFormatListNumbered, mdiDelete, mdiPencil } from '@mdi/js'
import { getImageUrlById } from '@/mixins/image'
import { userIsAtLeast } from '@/mixins/api/auth'
import { userIsAtLeast, USER_TYPE_DATA_CURATOR } from '@/mixins/api/auth'
import { apiDeleteStoryStep, apiPostStoryTable } from '@/mixins/api/misc'
export default {
Expand All @@ -97,7 +97,8 @@ export default {
mdiChevronLeft,
mdiChevronRight,
showPopover: true,
stepIndexOffset: 0
stepIndexOffset: 0,
USER_TYPE_DATA_CURATOR
}
},
computed: {
Expand Down
Loading

0 comments on commit ebe4a80

Please sign in to comment.