Add breadcrumb menu (#25)

* Add breadcrumbs
This commit is contained in:
Jonas Plum
2022-01-19 12:05:06 +01:00
committed by GitHub
parent 5653ecb5b0
commit a152b6663b
2 changed files with 56 additions and 1 deletions

View File

@@ -109,6 +109,19 @@
<v-icon color="primary">mdi-menu</v-icon> <v-icon color="primary">mdi-menu</v-icon>
</v-btn> </v-btn>
<v-breadcrumbs :items="crumbs">
<template v-slot:item="{ item }">
<v-breadcrumbs-item
:to="item.to"
class="text-subtitle-2 crumb-item"
:disabled="item.disabled"
exact
>
{{ item.text }}
</v-breadcrumbs-item>
</template>
</v-breadcrumbs>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn :to="{ name: 'Profile' }" icon> <v-btn :to="{ name: 'Profile' }" icon>
@@ -172,6 +185,25 @@ export default Vue.extend({
}, },
showAlert: function (): boolean { showAlert: function (): boolean {
return this.$store.state.showAlert return this.$store.state.showAlert
},
crumbs: function() {
let pathArray = this.$route.path.split("/")
pathArray.shift()
return this.lodash.reduce(pathArray, (breadcrumbs, path, idx) => {
let to = {};
let text = path;
let toPath = breadcrumbs[idx - 1] ? "/" + breadcrumbs[idx - 1].xpath + "/" + path : "/" + path;
let resolved = this.$router.resolve(toPath);
if (resolved) {
to = { name: resolved.resolved.name, params: resolved.resolved.params };
text = resolved.resolved.meta && resolved.resolved.meta.title ? resolved.resolved.meta.title : text;
}
breadcrumbs.push({ xpath: path, to: to, text: text });
return breadcrumbs;
}, [] as Array<any>);
} }
}, },

View File

@@ -62,16 +62,25 @@ const routes: Array<RouteConfig> = [
path: "/dashboard", path: "/dashboard",
name: "Dashboard", name: "Dashboard",
component: Dashboard, component: Dashboard,
meta: { title: "Dashboard" },
}, },
{ {
path: "/profile", path: "/profile",
name: "Profile", name: "Profile",
component: Profile, component: Profile,
meta: { title: "Profile" },
}, },
{ {
path: "/tickets/:type?", path: "/tickets",
name: "TicketListAll",
component: TicketList,
meta: { title: "Tickets" },
props: true,
},
{
path: "/tickets/:type",
name: "TicketList", name: "TicketList",
component: TicketList, component: TicketList,
props: true, props: true,
@@ -84,17 +93,20 @@ const routes: Array<RouteConfig> = [
{ {
path: "/tickets/:type/new", path: "/tickets/:type/new",
name: "TicketNew", name: "TicketNew",
meta: { title: "New Ticket" },
component: TicketNew, component: TicketNew,
}, },
{ {
path: "/tickets/:type?/:id/artifact/:artifact", path: "/tickets/:type?/:id/artifact/:artifact",
name: "ArtifactPopup", name: "ArtifactPopup",
meta: { title: "Artifact" },
component: ArtifactPopup, component: ArtifactPopup,
}, },
{ {
path: "/tasks", path: "/tasks",
name: "TaskList", name: "TaskList",
meta: { title: "Tasks" },
component: TaskList, component: TaskList,
}, },
@@ -102,6 +114,7 @@ const routes: Array<RouteConfig> = [
path: "/templates", path: "/templates",
name: "TemplateList", name: "TemplateList",
component: TemplateList, component: TemplateList,
meta: { title: "Templates" },
children: [ children: [
{ {
path: ":id", path: ":id",
@@ -115,6 +128,7 @@ const routes: Array<RouteConfig> = [
path: "/tickettype", path: "/tickettype",
name: "TicketTypeList", name: "TicketTypeList",
component: TicketTypeList, component: TicketTypeList,
meta: { title: "Ticket Types" },
children: [ children: [
{ {
path: ":id", path: ":id",
@@ -128,6 +142,7 @@ const routes: Array<RouteConfig> = [
path: "/playbooks", path: "/playbooks",
name: "PlaybookList", name: "PlaybookList",
component: PlaybookList, component: PlaybookList,
meta: { title: "Playbooks" },
children: [ children: [
{ {
path: ":id", path: ":id",
@@ -141,6 +156,7 @@ const routes: Array<RouteConfig> = [
path: "/userdata", path: "/userdata",
name: "UserDataList", name: "UserDataList",
component: UserDataList, component: UserDataList,
meta: { title: "User Data" },
children: [ children: [
{ {
path: ":id", path: ":id",
@@ -154,6 +170,7 @@ const routes: Array<RouteConfig> = [
path: "/jobs", path: "/jobs",
name: "JobList", name: "JobList",
component: JobList, component: JobList,
meta: { title: "Jobs" },
children: [ children: [
{ {
path: ":id", path: ":id",
@@ -167,6 +184,7 @@ const routes: Array<RouteConfig> = [
path: "/automations", path: "/automations",
name: "AutomationList", name: "AutomationList",
component: AutomationList, component: AutomationList,
meta: { title: "Automations" },
children: [ children: [
{ {
path: ":id", path: ":id",
@@ -180,6 +198,7 @@ const routes: Array<RouteConfig> = [
path: "/rules", path: "/rules",
name: "RuleList", name: "RuleList",
component: RuleList, component: RuleList,
meta: { title: "Rules" },
children: [ children: [
{ {
path: ":id", path: ":id",
@@ -193,6 +212,7 @@ const routes: Array<RouteConfig> = [
path: "/users", path: "/users",
name: "UserList", name: "UserList",
component: UserList, component: UserList,
meta: { title: "Users" },
children: [ children: [
{ {
path: ":id", path: ":id",
@@ -206,6 +226,7 @@ const routes: Array<RouteConfig> = [
path: "/groups", path: "/groups",
name: "GroupList", name: "GroupList",
component: GroupList, component: GroupList,
meta: { title: "Groups" },
children: [ children: [
{ {
path: ":id", path: ":id",
@@ -219,12 +240,14 @@ const routes: Array<RouteConfig> = [
path: "/apidocs", path: "/apidocs",
name: "API", name: "API",
component: API, component: API,
meta: { title: "API" },
}, },
{ {
path: "/graph/:col/:id", path: "/graph/:col/:id",
name: "Graph", name: "Graph",
component: Graph, component: Graph,
meta: { title: "Graph" },
}, },
]; ];