Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2f770eb
feat(Chart): 可以记录状态,但是所有分块同时打开或关闭
little1d Mar 4, 2024
2769f5c
feat(ChartsPage.vue): dashboard Charts页面实现
little1d Mar 4, 2024
882f34e
feat:(ChatsPage): dashboard 界面响应式更新状态
little1d Mar 5, 2024
0d4c0d7
feat(ChartPage): 单个实验页面实现记忆图表展开关闭
little1d Mar 5, 2024
97969ae
feat(ChartPage): comment format
little1d Mar 5, 2024
2df86b8
bugfix(ChartPage.vue): 以实验名称构造二级对象,控制开关
little1d Mar 5, 2024
e899e51
Update ChartsContainer.vue
little1d Mar 5, 2024
6ead436
Update ChartsPage.vue
little1d Mar 5, 2024
b7795cb
Update ChartsContainer.vue
little1d Mar 5, 2024
28344dc
Update ChartPage.vue
little1d Mar 5, 2024
fd6b346
Update ChartPage.vue
little1d Mar 5, 2024
545fc70
Update ChartsPage.vue
little1d Mar 5, 2024
b10870e
migrate: add opened
SAKURA-CAT Mar 5, 2024
89db644
Merge branch 'main' into bugfix/group-folding
SAKURA-CAT Mar 7, 2024
4763761
refactor opened status
SAKURA-CAT Mar 7, 2024
fd95ff4
feat(experiment.py): namespace router and methods
little1d Mar 8, 2024
d5a7f0b
feat(ChartsDashboard): patch
little1d Mar 8, 2024
b4225a9
feat(namespace.py): add files
little1d Mar 8, 2024
eb95c18
feat(app.py): add namespace router
little1d Mar 8, 2024
9760171
bugfix(app.py): prefix refactor
little1d Mar 8, 2024
c01f455
feat(namespace): interface set properly
little1d Mar 8, 2024
3e5f396
feat(namespace): comment fixed
little1d Mar 8, 2024
30f4c06
Update ChartsPage.vue
SAKURA-CAT Mar 8, 2024
ba7c059
Merge branch 'bugfix/group-folding' of https://github.com/SwanHubX/sw…
SAKURA-CAT Mar 8, 2024
69e70b6
Update namespace.py
SAKURA-CAT Mar 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions vue/src/charts/ChartsContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ const props = defineProps({
charts: {
type: Array,
required: true
},
isExpand: {
type: Boolean,
required: true
}
})

// ---------------------------------- 控制展开和关闭的状态 ----------------------------------

const isExpand = ref(true)
const emit = defineEmits(['update:isExpanded'])

const handleExpand = () => {
isExpand.value = !isExpand.value
emit('update:isExpanded', !props.isExpand)
}

// ---------------------------------- charts组件列表 ----------------------------------
Expand Down
33 changes: 31 additions & 2 deletions vue/src/views/charts/components/ChartsPage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<template>
<ChartsContainer v-for="group in groups" :key="group.name" :label="group.name" :charts="group.charts" />
<ChartsContainer
v-for="group in groups"
:key="group.name"
:label="group.name"
:charts="group.charts"
:isExpand="groupsExpand[group.name] !== undefined ? groupsExpand[group.name] : true"
@update:isExpanded="(value) => handleExpand(group.name, value)"
/>
</template>

<script setup>
Expand All @@ -11,8 +18,9 @@
**/
import ChartsContainer from '@swanlab-vue/charts/ChartsContainer.vue'
import { useProjectStore } from '@swanlab-vue/store'
import { provide, onUnmounted } from 'vue'
import { provide, onUnmounted, onMounted, reactive } from 'vue'
import http from '@swanlab-vue/api/http'

const props = defineProps({
// 图表组
groups: {
Expand All @@ -25,8 +33,29 @@ const props = defineProps({
required: true
}
})

const projectStore = useProjectStore()

// ---------------------------------- 控制charts的展开关闭 ----------------------------------
// 使用对象来跟踪每个group的展开状态
const groupsExpand = reactive(JSON.parse(localStorage.getItem('groupsExpand')) || {})

// 初始化每个group的展开状态
onMounted(() => {
console.log(props.groups)
const storedStates = JSON.parse(localStorage.getItem('groupsExpand')) || {}
Object.keys(storedStates).forEach((groupName) => {
groupsExpand[groupName] = storedStates[groupName]
})
})

// 处理展开状态改变
const handleExpand = (groupName, newValue) => {
groupsExpand[groupName] = newValue
// 更新localStorage
localStorage.setItem('groupsExpand', JSON.stringify(groupsExpand))
}

// ---------------------------------- 轮询器 ----------------------------------
const intervalMap = new Map()
const createInterval = (exp_name, cid, callback) => {
Expand Down
35 changes: 34 additions & 1 deletion vue/src/views/experiment/pages/chart/ChartPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
:key="group.name"
:label="getGroupName(group.name)"
:charts="getCharts(group)"
:isExpand="
groupExpand[experimentName] && groupExpand[experimentName][group.name] !== undefined
? groupExpand[experimentName][group.name]
: true
"
@update:isExpanded="(value) => handleExpand(experimentName, group.name, value)"
/>
<!-- 图表不存在 -->
<p class="font-semibold pt-5 text-center" v-if="groups.length === 0">Empty Chart</p>
Expand All @@ -20,7 +26,7 @@
**/
import { useExperimentStore, useProjectStore } from '@swanlab-vue/store'
import http from '@swanlab-vue/api/http'
import { ref, provide } from 'vue'
import { ref, provide, onMounted, reactive } from 'vue'
import ChartsContainer from '@swanlab-vue/charts/ChartsContainer.vue'
import { t } from '@swanlab-vue/i18n'
import { useRoute } from 'vue-router'
Expand Down Expand Up @@ -120,6 +126,33 @@ const parseCharts = (data) => {
groups.value = temp
}

// ---------------------------------- 控制charts的展开关闭 ----------------------------------

// 获取实验名称
const experimentName = ref(experimentStore.experiment.name)

// 使用对象跟踪单个实验图表group的展开状态
const groupExpand = reactive(JSON.parse(localStorage.getItem('groupExpand')) || {})

// 初始化每个group的展开状态
onMounted(() => {
console.log(groups.value)
const storedStates = JSON.parse(localStorage.getItem('groupExpand')) || {}
if (!groupExpand[experimentName]) {
groupExpand[experimentName] = storedStates[experimentName] || {}
}
})

// 处理展开状态改变
const handleExpand = (experimentName, groupName, newValue) => {
if (!groupExpand[experimentName]) {
groupExpand[experimentName] = {}
}
groupExpand[experimentName][groupName] = newValue
// 更新Localstorage
localStorage.setItem('groupExpand', JSON.stringify(groupExpand))
}

// ---------------------------------- 发布、订阅模型 ----------------------------------
// 请求映射表,反映映射状态
class RequestMap {
Expand Down