Compare commits

...

6 commits

Author SHA1 Message Date
Eduardo Navarro
04708c2f02
Merge 2674226ce3 into a65a9f5549 2025-01-02 00:37:03 +01:00
ESPGranEdu
2674226ce3 Fix linter errors 2024-08-16 23:26:09 +02:00
ESPGranEdu
59d941f128 Conditionally display stacks with its respective agent 2024-08-16 22:59:20 +02:00
ESPGranEdu
b9f135bdaa Add JSDoc and clean comments 2024-08-16 22:58:21 +02:00
ESPGranEdu
bd4a012404 Group stacks by agent 2024-08-16 22:53:23 +02:00
ESPGranEdu
f08ba9b889 Create new component to gruop agents 2024-08-16 22:51:42 +02:00
3 changed files with 86 additions and 1 deletions

View file

@ -8,6 +8,7 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
About: typeof import('./src/components/settings/About.vue')['default']
AgentStackList: typeof import('./src/components/AgentStackList.vue')['default']
Appearance: typeof import('./src/components/settings/Appearance.vue')['default']
ArrayInput: typeof import('./src/components/ArrayInput.vue')['default']
ArraySelect: typeof import('./src/components/ArraySelect.vue')['default']

View file

@ -0,0 +1,46 @@
<template>
<div class="wrapper">
<div class="group-header">
{{ agentName }}
</div>
<slot />
</div>
<hr>
</template>
<script setup lang="ts">
interface AgentStackListProps {
agentName: string;
}
defineProps<AgentStackListProps>();
</script>
<style lang="scss" scoped>
@import "../styles/vars.scss";
.group-header {
border-bottom: 1px solid #dee2e6;
border-radius: 10px;
margin-bottom: 10px;
font-size: 1.25rem;
font-weight: 500;
padding: 10px;
.dark & {
background-color: darken($color: $dark-header-bg, $amount: 1.90);
border-bottom: 0;
}
}
@media (max-width: 770px) {
.group-header {
margin: -20px;
margin-bottom: 10px;
padding: 5px;
}
}
</style>

View file

@ -42,7 +42,22 @@
</span>
</div>
</div>
<div ref="stackList" class="stack-list" :class="{ scrollbar: scrollbar }" :style="stackListStyle">
<div v-if="searchText === '' && $root.agentCount > 1" ref="stackList" :style="stackListStyle" class="stack-list">
<AgentStackList v-for="[agentName, stacks] in stackListByAgent" :agentName="agentName" :key="agentName">
<StackListItem
v-for="(stack, index) in stacks"
:key="index"
:stack="stack"
:isSelectMode="selectMode"
:isSelected="isSelected"
:select="select"
:deselect="deselect"
/>
</AgentStackList>
</div>
<div v-else ref="stackList" class="stack-list" :class="{ scrollbar: scrollbar }" :style="stackListStyle">
<div v-if="Object.keys(sortedStackList).length === 0" class="text-center mt-3">
<router-link to="/compose">{{ $t("addFirstStackMsg") }}</router-link>
</div>
@ -189,7 +204,30 @@ export default {
return result;
},
/**
* Groups all stacks by it's agent
* @returns {Map<string, object} A map containing all agents with their stacks
*/
stackListByAgent() {
const stacksByAgent = new Map();
const stacks = this.$root.completeStackList;
for (const key of Object.keys(stacks)) {
// Handle stacks with no suffix (from the current endpoint)
let [ stackName, agent ] = key.split("_");
const stackHasEndpoint = agent !== "";
agent = stackHasEndpoint ? agent : this.$t("currentEndpoint");
if (!stacksByAgent.has(agent)) {
stacksByAgent.set(agent, []);
}
const stack = stacks[!stackHasEndpoint ? `${stackName}_` : `${stackName}_${agent}`];
stacksByAgent.get(agent).push(stack);
}
return stacksByAgent;
},
isDarkTheme() {
return document.body.classList.contains("dark");
},