refs #5989 redirect and home
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Satorres 2023-08-08 12:11:27 +02:00
parent dbd5715c13
commit d7bc166df7
3 changed files with 61 additions and 45 deletions

View File

@ -1,34 +1,23 @@
<script setup> <script setup>
import { onMounted } from 'vue'; import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useSession } from 'src/composables/useSession'; import { useSession } from 'src/composables/useSession';
import UserPanel from 'components/UserPanel.vue';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useQuasar } from 'quasar';
import PinnedModules from './PinnedModules.vue'; import PinnedModules from './PinnedModules.vue';
import { getUrl } from 'src/composables/getUrl'; import UserPanel from 'components/UserPanel.vue';
import { useRoute } from 'vue-router';
const { t } = useI18n(); const { t } = useI18n();
const session = useSession(); const session = useSession();
const stateStore = useStateStore(); const stateStore = useStateStore();
const quasar = useQuasar();
const state = useState(); const state = useState();
const user = state.getUser(); const user = state.getUser();
const token = session.getToken(); const token = session.getToken();
const route = useRoute();
onMounted(() => stateStore.setMounted()); onMounted(() => stateStore.setMounted());
async function redirect() { const pinnedModulesRef = ref();
let section = route.path.substring(1);
if (!route.path.includes('/')) return (window.location.href = await getUrl(section));
section = section.substring(0, section.indexOf('/'));
if (route?.params?.id) {
window.location.href = await getUrl(`${section}/${route.params.id}/summary`);
} else {
window.location.href = await getUrl(section + '/index');
}
}
</script> </script>
<template> <template>
@ -69,11 +58,18 @@ async function redirect() {
<QSpace /> <QSpace />
<div class="q-pl-sm q-gutter-sm row items-center no-wrap"> <div class="q-pl-sm q-gutter-sm row items-center no-wrap">
<div id="actions-prepend"></div> <div id="actions-prepend"></div>
<QBtn @click="redirect($route.params.id)" icon="open_in_new"> </QBtn> <QBtn
flat
v-if="!quasar.platform.is.mobile"
@click="pinnedModulesRef.redirect($route.params.id)"
icon="launch"
>
</QBtn>
<QBtn id="pinnedModules" icon="apps" flat dense rounded> <QBtn id="pinnedModules" icon="apps" flat dense rounded>
<QTooltip bottom> <QTooltip bottom>
{{ t('globals.pinnedModules') }} {{ t('globals.pinnedModules') }}
</QTooltip> </QTooltip>
<PinnedModules ref="pinnedModulesRef" />
</QBtn> </QBtn>
<QBtn rounded dense flat no-wrap id="user"> <QBtn rounded dense flat no-wrap id="user">
<QAvatar size="lg"> <QAvatar size="lg">

View File

@ -2,69 +2,91 @@
import { onMounted, computed } from 'vue'; import { onMounted, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useNavigationStore } from 'src/stores/useNavigationStore'; import { useNavigationStore } from 'src/stores/useNavigationStore';
import { getUrl } from 'src/composables/getUrl';
import { useRoute } from 'vue-router';
const navigation = useNavigationStore(); const navigation = useNavigationStore();
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute();
onMounted(() => { onMounted(() => {
navigation.fetchPinned(); navigation.fetchPinned();
}); });
defineExpose({
redirect,
});
const pinnedModules = computed(() => navigation.getPinnedModules()); const pinnedModules = computed(() => navigation.getPinnedModules());
console.log(pinnedModules.value);
async function redirect() {
let section = route.path.substring(1);
if (!route.path.includes('/')) return (window.location.href = await getUrl(section));
section = section.substring(0, section.indexOf('/'));
if (route?.params?.id) {
window.location.href = await getUrl(`${section}/${route.params.id}/summary`);
} else {
window.location.href = await getUrl(section + 'dashboard');
}
}
</script> </script>
<template> <template>
<QMenu <QMenu anchor="bottom left" max-width="300px" max-height="400px">
anchor="bottom left" <div v-if="pinnedModules.length" class="row justify-around q-pa-md">
class="row q-pa-md q-col-gutter-lg" <QBtn
max-width="350px" flat
max-height="400px" stack
> size="lg"
<template v-if="pinnedModules.length"> icon="more_up"
<div class="col-5"
v-for="item of pinnedModules" @click="redirect($route.params.id)"
:key="item.title"
class="row no-wrap q-pa-xs flex-item"
> >
<div class="text-center button-text">Salix</div>
</QBtn>
<QBtn flat stack size="lg" icon="home" class="col-5" to="/">
<div class="text-center button-text">{{ t('Home') }}</div>
</QBtn>
<div class="row col-12 justify-around q-mt-md">
<QBtn <QBtn
align="evenly"
padding="16px"
flat flat
stack stack
size="lg" size="lg"
:icon="item.icon" :icon="item.icon"
color="primary" color="primary"
class="col-4 button" class="col-5"
:to="{ name: item.name }" :to="{ name: item.name }"
v-for="item of pinnedModules"
:key="item.title"
> >
<div class="text-center text-primary button-text"> <div class="text-center text-primary button-text">
{{ t(item.title) }} {{ t(item.title) }}
</div> </div>
</QBtn> </QBtn>
</div> </div>
</template> </div>
<template v-else> <div v-else>
<div <div
class="row no-wrap q-pa-xs flex-item text-center text-grey-5" class="row no-wrap q-pa-xs flex-item text-center text-grey-5"
style="min-width: 200px" style="min-width: 200px"
> >
{{ t('globals.noPinnedModules') }} {{ t('globals.noPinnedModules') }}
</div> </div>
</template> </div>
</QMenu> </QMenu>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.flex-item {
width: 100px;
}
.button {
width: 100%;
line-height: normal;
align-items: center;
}
.button-text { .button-text {
font-size: 10px; font-size: 10px;
margin-top: 5px; margin-top: 5px;
} }
</style> </style>
<i18n>
en:
Home: Home
es:
Home: Inicio
</i18n>

View File

@ -36,9 +36,7 @@ const pinnedModules = computed(() => navigation.getPinnedModules());
<div class="text-grey-5" v-if="pinnedModules.length === 0"> <div class="text-grey-5" v-if="pinnedModules.length === 0">
{{ t('pinnedInfo') }} {{ t('pinnedInfo') }}
</div> </div>
<QBtn @click="redirect($route.params.id)" icon="open_in_new"> <template v-if="pinnedModules.length">
</QBtn>
<template v-if="pinnedModules.length >= 0">
<div <div
v-for="item of pinnedModules" v-for="item of pinnedModules"
:key="item.title" :key="item.title"