Skip to content

Commit

Permalink
[KNOWAGE-8123] Added usage tab and changed error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Redjaw committed Nov 4, 2024
1 parent 6b38f0e commit 43cb691
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/helpers/themeHelper/themeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,7 @@ export default class themeHelper {

setQuasarPreset(variables): void {
document.documentElement.style.setProperty('--q-primary', variables['--kn-button-primary-background-color'])
document.documentElement.style.setProperty('--q-secondary', variables['--kn-button-secondary-background-color'])

}
}
14 changes: 13 additions & 1 deletion src/i18n/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3124,9 +3124,13 @@
"roleTypeID": "Role Type",
"title": "Detail"
},
"errors": {
"delete": "Impossible to delete the role. It may be used by some element, please check the usage tab"
},
"hint": "Roles allows you to specify different users properties and authorizations. It's possible to change the role name, the roles authorizations and dataset visibility. Click on one existing item from the list on the side, or press the \"+\" button to add one.",
"kpiCategories": "KPI Categories",
"noResults": "No roles available for the selected filter",
"noUsages": "The current role is not in use",
"publicRoleWarning1": "If you continue saving the public role will be removed from ",
"publicRoleWarning2": " to the selected one. Are you sure?",
"rolesDropdown": {
Expand All @@ -3136,7 +3140,15 @@
"TEST_ROLE": "Test User",
"USER": "User"
},
"title": "Roles Management"
"title": "Roles Management",
"usageCategories": {
"metaModel": "Meta Model Categories",
"functionalities": "Functionalities",
"drivers": "Drivers",
"news": "News",
"layers": "Layers",
"menu": "Menu"
}
},
"schedulationAgendaManagement": {
"detail": {
Expand Down
14 changes: 13 additions & 1 deletion src/i18n/it_IT/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2839,9 +2839,13 @@
"roleTypeID": "Role Type",
"title": "Detail"
},
"errors": {
"delete": "Non è possibile cancellare il ruolo. Potrebbe essere utilizzato da qualche funzionalità, controllare il tab \"utilizzo\""
},
"hint": "Roles allows you to specify different users properties and authorizations. It's possible to change the role name, the roles authorizations and dataset visibility. Click on one existing item from the list on the side, or press the \"+\" button to add one.",
"kpiCategories": "KPI Categories",
"noResults": "No roles available for the selected filter",
"noUsages": "Questo ruolo non è utilizzato",
"publicRoleWarning1": "If you continue saving the public role will be removed from ",
"publicRoleWarning2": " to the selected one. Are you sure?",
"rolesDropdown": {
Expand All @@ -2851,7 +2855,15 @@
"TEST_ROLE": "Test User",
"USER": "User"
},
"title": "Roles Management"
"title": "Roles Management",
"usageCategories": {
"drivers": "Driver",
"functionalities": "Funzionalità",
"layers": "Layer",
"menu": "Menu",
"metaModel": "Meta Modelli",
"news": "News"
}
},
"schedulationAgendaManagement": {
"detail": {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/managers/rolesManagement/RolesManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default defineComponent({
if (error) {
this.store.setError({
title: this.$t('common.toast.deleteTitle'),
msg: this.$t('common.error.deleting')
msg: this.$t('managers.rolesManagement.errors.delete')
})
}
})
Expand Down
18 changes: 16 additions & 2 deletions src/modules/managers/rolesManagement/RolesManagementTabView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@

<DomainCategoryTab :title="$t('managers.rolesManagement.kpiCategories')" :category-list="kpiCategoriesList" :selected="selectedKPICategories" @changed="setSelectedKPICategories($event)"></DomainCategoryTab>
</TabPanel>

<TabPanel>
<template #header> Usage </template>

<RolesManagementUsageTab :id="id" />
</TabPanel>
</TabView>
</template>
<script lang="ts">
Expand All @@ -60,6 +66,7 @@ import useValidate from '@vuelidate/core'
import DomainCategoryTab from './tabs/DomainCategoryTab/DomainCategoryTab.vue'
import RoleDetailTab from './tabs/RoleDetailTab/RoleDetailTab.vue'
import RoleAuthorizationsTab from './tabs/RoleAuthorizationsTab/RoleAuthorizationsTab.vue'
import RolesManagementUsageTab from './tabs/RolesManagementUsageTab/RolesManagementUsageTab.vue'
import mainStore from '../../../App.store'
export default defineComponent({
Expand All @@ -68,7 +75,8 @@ export default defineComponent({
RoleDetailTab,
TabView,
TabPanel,
RoleAuthorizationsTab
RoleAuthorizationsTab,
RolesManagementUsageTab
},
props: { id: { type: String, required: false }, publicRole: { type: Object, required: false } },
emits: ['touched', 'closed', 'inserted'],
Expand Down Expand Up @@ -298,7 +306,13 @@ export default defineComponent({
position: absolute;
}
.roles-tabview,
.roles-tabview {
overflow: auto;
flex: 1;
display: flex;
flex-direction: column;
}
.roles-tabview .p-tabview-panels,
.roles-tabview .p-tabview-panel {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<Card class="domainCard" style="height: calc(100vh - 75px)">
<Card class="domainCard" style="height: calc(100vh - 85px)">
<template #header>
<Toolbar class="kn-toolbar kn-toolbar--secondary">
<template #start>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<template>
<q-banner v-if="noUsage" class="bg-grey-3 q-ma-sm text-center">
<template v-slot:avatar>
<q-icon name="info" color="primary" />
</template>
<span>{{ $t('managers.rolesManagement.noUsages') }}</span>
</q-banner>
<div class="rolesManagementUsage">
<template v-for="category in descriptor.categories">
<div class="card q-pa-none" v-if="elements[category.name] && elements[category.name].length > 0">
<q-toolbar class="kn-toolbar kn-toolbar--secondary">
<q-toolbar-title shrink>
{{ $t(category.label) }}
</q-toolbar-title>
</q-toolbar>
<q-list dense separator class="overflow-auto" style="height: 250px">
<q-item v-for="element in elements[category.name]">
<q-item-section> {{ element }} </q-item-section>
</q-item>
</q-list>
</div>
</template>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, onUpdated, computed } from 'vue'
import descriptor from './RolesManagementUsageTabDescriptor.json'
import axios from '@/axios.js'
const props = defineProps(['id'])
const tempId = ref<number | undefined>()
const elements = ref<any>({})
onMounted(async () => {
if (props.id) {
loadElements(props.id)
}
})
onUpdated(async () => {
if (props.id != tempId.value) {
loadElements(props.id)
}
})
const noUsage = computed(() => {
let count = 0
descriptor.categories.forEach((cat) => {
if (elements[cat.name] && elements[cat.name].length > 0) count++
})
return count === 0
})
async function loadElements(id) {
tempId.value = id
await axios.get(`${import.meta.env.VITE_KNOWAGE_CONTEXT}/knowage/restful-services/2.0/roles/${props.id}/allElement`).then((response) => {
elements.value = response.data
})
}
</script>
<style lang="scss" scoped>
.rolesManagementUsage {
display: grid;
margin: 8px;
grid-template-columns: repeat(3, 1fr);
gap: 8px;
.card {
border: 1px solid var(--kn-color-borders);
}
}
.q-toolbar__title {
font-size: inherit;
}
@media all and (max-width: 1200px) {
.rolesManagementUsage {
grid-template-columns: repeat(2, 1fr);
}
}
@media all and (max-width: 800px) {
.rolesManagementUsage {
grid-template-columns: repeat(1, 1fr);
}
}
</style>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"categories": [
{
"label": "managers.rolesManagement.usageCategories.metaModel",
"name": "roleMetaModelCategories"
},
{
"label": "managers.rolesManagement.usageCategories.functionalities",
"name": "roleFunctionalities"
},
{
"label": "managers.rolesManagement.usageCategories.drivers",
"name": "roleAnaliticalDrivers"
},
{
"label": "managers.rolesManagement.usageCategories.news",
"name": "roleNews"
},
{
"label": "managers.rolesManagement.usageCategories.layers",
"name": "roleLayers"
},
{
"label": "managers.rolesManagement.usageCategories.users",
"name": "roleUsers"
},
{
"label": "managers.rolesManagement.usageCategories.menu",
"name": "roleMenu"
}
]
}

0 comments on commit 43cb691

Please sign in to comment.