-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
279 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export interface Mander { | ||
path: string; | ||
views: string[]; | ||
logs: string[]; | ||
artifacts: { | ||
[key: string]: { | ||
path: string; | ||
}; | ||
}; | ||
info: { | ||
[key: string]: any; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,88 @@ | ||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import FileTree, { type FileTreeNode } from "@/components/FileTree.vue"; | ||
import { getAllManderPaths } from "@/services/api"; | ||
import { computed, ref, watch } from "vue"; | ||
import { useRoute } from "vue-router"; | ||
import { type Mander } from "../models"; | ||
import { fetchAllManderPaths, fetchMander } from "../services/api"; | ||
import FileTree, { type FileTreeNode } from "../components/FileTree.vue"; | ||
import ManderView from "./ManderView.vue"; | ||
const route = useRoute(); | ||
const manderPaths = ref<string[]>([]); | ||
const mander = ref<Mander>(); | ||
const manderPaths = await getAllManderPaths(); | ||
const pathsAsFileTreeNodes = computed(() => { | ||
const tree: FileTreeNode[] = []; | ||
for (let p of manderPaths) { | ||
for (let p of manderPaths.value) { | ||
const slugs = p.split("/"); | ||
const rootSlug = slugs[0]; | ||
let currentNode = tree.find((n) => n.label == rootSlug); | ||
let currentNode = tree.find((n) => n.path == rootSlug); | ||
if (!currentNode) { | ||
currentNode = { label: rootSlug }; | ||
currentNode = { path: rootSlug }; | ||
tree.push(currentNode); | ||
} | ||
let n = currentNode!; | ||
for (let s of slugs.slice(1)) { | ||
n.children = n.children || []; | ||
let childNode = n.children.find((n) => n.label == s); | ||
const path = `${n.path}/${s}`; | ||
let childNode = n.children.find((n) => n.path == path); | ||
if (!childNode) { | ||
childNode = { label: s }; | ||
childNode = { path }; | ||
n.children.push(childNode); | ||
} | ||
n = childNode; | ||
} | ||
} | ||
return tree; | ||
}); | ||
watch( | ||
() => route.params.slug, | ||
async (newSlug) => { | ||
const path = Array.isArray(newSlug) ? newSlug.join("/") : newSlug; | ||
const m = await fetchMander(path); | ||
if (m) { | ||
mander.value = m; | ||
} | ||
// TODO handle error | ||
} | ||
); | ||
manderPaths.value = await fetchAllManderPaths(); | ||
</script> | ||
|
||
<template> | ||
<div class="dashboard"> | ||
<FileTree :nodes="pathsAsFileTreeNodes"></FileTree> | ||
</div> | ||
<main> | ||
<nav> | ||
<FileTree :nodes="pathsAsFileTreeNodes" /> | ||
</nav> | ||
<article> | ||
<ManderView v-if="mander" :mander="mander" /> | ||
</article> | ||
</main> | ||
</template> | ||
|
||
<style scoped> | ||
main { | ||
display: flex; | ||
flex-direction: row; | ||
nav, | ||
article { | ||
overflow: scroll; | ||
height: 100dvh; | ||
} | ||
nav { | ||
width: 285px; | ||
flex-shrink: 0; | ||
padding: 10px; | ||
border-left: 1px solid #e9e9e9; | ||
background-color: #f2f1f1; | ||
} | ||
article { | ||
flex-grow: 1; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<script setup lang="ts"> | ||
import { type Mander } from "../models"; | ||
const props = defineProps<{ mander: Mander }>(); | ||
</script> | ||
|
||
<template> | ||
<h1>{{ props.mander.path }}</h1> | ||
<aside> | ||
<h2>Views</h2> | ||
<div v-for="(value, name, index) in props.mander.views" :key="index"> | ||
<h3>{{ name }}</h3> | ||
<div v-html="value" /> | ||
</div> | ||
</aside> | ||
<aside> | ||
<h2>Logs</h2> | ||
<div v-for="(value, name, index) in props.mander.logs" :key="index"> | ||
<h3>{{ name }}</h3> | ||
<div v-html="value" /> | ||
</div> | ||
</aside> | ||
<aside> | ||
<h2>Artifacts</h2> | ||
<div v-for="(value, name, index) in props.mander.artifacts" :key="index"> | ||
<h3>{{ name }}</h3> | ||
<div v-html="value.path" /> | ||
</div> | ||
</aside> | ||
<aside> | ||
<h2>Info</h2> | ||
<div v-for="(value, name, index) in props.mander.info" :key="index"> | ||
<h3>{{ name }}</h3> | ||
<div v-html="value" /> | ||
</div> | ||
</aside> | ||
</template> | ||
|
||
<style scoped> | ||
aside { | ||
border: 1px solid #e9e9e9; | ||
margin: 5px; | ||
h2 { | ||
background-color: #f2f1f1; | ||
color: #7e7e7e; | ||
} | ||
& > div { | ||
padding: 5px; | ||
} | ||
} | ||
</style> |
Oops, something went wrong.