Skip to content

Commit

Permalink
Merge pull request #128 from os-checker/feat/cargo-semver-checks
Browse files Browse the repository at this point in the history
feat: 将 info 页面调至主页,原主页移至 diagnostics 页面;在当前页面的按钮上显示不同的颜色;只在相关页面显示 target 下拉框
  • Loading branch information
zjp-CN authored Nov 29, 2024
2 parents ffa0ea9 + dea4249 commit 0319035
Show file tree
Hide file tree
Showing 7 changed files with 742 additions and 686 deletions.
19 changes: 16 additions & 3 deletions os-checks/components/TargetDropDown.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<Select v-model="selected" :options="targets" placeholder="Targets">
<Select v-if="visible" v-model="selected" :options="targets" placeholder="Targets">

<template #option="{ option }">
<Tag severity="danger" class="drop-down-options">{{ tagCount(option) }}</Tag>
Expand All @@ -20,12 +20,14 @@
const defaultTarget = "All-Targets";
const selected = ref(defaultTarget);
const targets = ref<string[]>([defaultTarget]);
const visible = ref(true);
const candidates = useBasicStore();
// 随路由页面变化而下载相应的 basic.json
const route = useRoute();
watch(() => route.params, () => fetch());
change(route.path, route.params);
watch(() => [route.path, route.params], ([path, params]) => change(path as string, params));
const candidates = useBasicStore();
fetch();
watch(selected, (val) => candidates.update_current(val));
Expand All @@ -41,6 +43,17 @@ function fetch() {
});
}
function change(path: string, params: any) {
// console.log("path =", path);
if (path === "/" || path === "/repos" || path === "/charts" || path === "/target" || path === "/workflows") {
visible.value = false;
return;
} else if (params) {
// console.log("path =", path);
fetch();
}
visible.value = true;
}
</script>

<style scoped>
Expand Down
50 changes: 37 additions & 13 deletions os-checks/components/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
<div class="topBarLeft">

<NuxtLink to="/">
<Button title="主页" icon="pi pi-home" />
<Button title="主页" icon="pi pi-box" :style="btnStyle('/')" />
</NuxtLink>

<NuxtLink to="/file-tree">
<Button title="问题文件树" icon="pi pi-sitemap" />
<NuxtLink to="/repos">
<Button title="Repositories Infomation" icon="pi pi-warehouse" :style="btnStyle('/repos')" />
</NuxtLink>

<NuxtLink to="/charts">
<Button title="统计图" icon="pi pi-chart-bar" />
<NuxtLink to="/diagnostics">
<Button title="Diagnostics" icon="pi pi-microchip" :style="btnStyle('/diagnostics')" />
</NuxtLink>

<NuxtLink to="/target">
<Button title="编译目标明细表" icon="pi pi-objects-column" />
<NuxtLink to="/file-tree">
<Button title="问题文件树" icon="pi pi-sitemap" :style="btnStyle('/file-tree')"/>
</NuxtLink>

<NuxtLink to="/workflows">
<Button title="Github Workflows" icon="pi pi-bell" />
<NuxtLink to="/charts">
<Button title="统计图" icon="pi pi-chart-bar" :style="btnStyle('/charts')"/>
</NuxtLink>

<NuxtLink to="/info">
<Button title="Package Infomation" icon="pi pi-microchip" />
<NuxtLink to="/target">
<Button title="编译目标明细表" icon="pi pi-objects-column" :style="btnStyle('/target')"/>
</NuxtLink>

<NuxtLink to="/repos">
<Button title="Repositories Infomation" icon="pi pi-warehouse" />
<NuxtLink to="/workflows">
<Button title="Github Workflows" icon="pi pi-bell" :style="btnStyle('/workflows')"/>
</NuxtLink>

</div>
Expand All @@ -47,6 +47,30 @@
</div>
</template>

<script setup lang="ts">
const { color } = storeToRefs(useStyleStore());
// function bgColor(page: string) {
// return active.value[page] ? color.value.orange: color.value.topButton;
// }
// function borderColor(page: string) {
// return active.value[page] ? color.value.orange_light : color.value.topButton;
// }
const route = useRoute();
const active = computed(() => route.path);
type ButtonStyle = { background: string, "border-color": string, };
function btnStyle(page: string): ButtonStyle {
return (page === active.value) ?
{ background: color.value.orange_light, "border-color": color.value.orange }
:
{ background: color.value.topButton, "border-color": color.value.topButton };
}
</script>

<style scoped>
.topBarLeft,
.topBarRight {
Expand Down
158 changes: 158 additions & 0 deletions os-checks/pages/diagnostics.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<script setup lang="ts">
import type { FetchError } from 'ofetch';
import type { TreeNode } from 'primevue/treenode';
import type { Columns, PassCountRepo, PassCountRepos } from '~/shared/types';
// fetch JSON data from content dir
const nodes = ref<TreeNode[]>([])
const dataColumns = ref<Columns>([]);
// 无诊断的仓库数量和具有 target 的总仓库
const selectedPassCountRepo = ref<PassCountRepo>({ pass: 0, total: 0 });
const passCountRepos = ref<PassCountRepos>({ "": { pass: 0, total: 0 } });
githubFetch<PassCountRepos>({
path: "ui/pass_count_repo/_targets_.json"
}).then(data => passCountRepos.value = data);
// pick data columns
const selectedColumns = ref(dataColumns.value);
// Label to display after exceeding max selected labels.
const selectedItemsLabel = computed(() => `${selectedColumns.value.length} checkers are selected; click to customize columns displayed`);
const onToggle = (val: any) => selectedColumns.value = dataColumns.value.filter(col => val.includes(col));
const basic = useBasicStore();
basic.init_with_and_subscribe_to_current_and_columns((target, columns) => {
// 更新进度条
const selected_pass_count_repo = passCountRepos.value[target]
if (selected_pass_count_repo) {
selectedPassCountRepo.value = selected_pass_count_repo;
}
dataColumns.value = columns;
selectedColumns.value = columns;
const path = `ui/home/split/${target}.json`;
githubFetch<TreeNode[]>({ path })
.then((value) => {
// const value = data as TreeNode[];
// const value = JSON.parse(data as string) as TreeNode[];
// 展平单仓库单项目成一行数据
for (let i = 0; i < value.length; i++) {
let node = value[i];
if (!node.children) {
continue;
}
if (node.children.length === 1) {
const idx = node.data.idx;
node = node.children[0];
node.data.idx = idx; // 恢复仓库序号
value[i] = node;
continue;
}
}
nodes.value = value
}).catch((err: FetchError) => {
if (err.statusCode === 404) {
nodes.value = [{ key: "0", data: { user: "ALL", repo: "ALL", pkg: "ALL", total_count: 0 } }];
}
});
});
// interactive filter/search inputs
const filters = ref<any>({});
// a single selected row
const selectedKey = ref();
// 计算通过率
const progressRatio = computed(() => {
const count = selectedPassCountRepo.value;
if (count.total !== 0) {
return Math.round(count.pass / count.total * 100.0);
} else {
return 0;
}
});
</script>

<template>
<div class="home-table">

<div style="display: flex; justify-content: center; align-content: center">
<div style="padding-right: 10px">
<span class="pass-repo"> Pass </span>/ Total Repos:
<span class="pass-repo"> {{ selectedPassCountRepo.pass }}
</span>
/ {{ selectedPassCountRepo.total }}
<span v-if="progressRatio < 5">
<Tag severity="danger" rounded>({{ progressRatio }}%)</Tag>
</span>
</div>
<ProgressBar :value="progressRatio" style="flex-grow: 1; height: auto;" />
</div>

<TreeTable :value="nodes" tableStyle="min-width: 50rem" :filters="filters" removableSort sortMode="multiple"
scrollable scrollHeight="82vh" v-model:selectionKeys="selectedKey" selectionMode="single">

<template #header>
<div class="header">

<div>
<MultiSelect :modelValue="selectedColumns" @update:modelValue="onToggle" :options="dataColumns"
:maxSelectedLabels="8" :selectedItemsLabel="selectedItemsLabel" optionLabel="header"
class="w-full sm:w-64" display="chip" />
</div>

<div>
<IconField>
<InputIcon class="pi pi-search" />
<InputText v-model="filters['global']" placeholder="Global Search" />
</IconField>
</div>

</div>
</template>

<Column field="idx" header="序号" expander frozen style="min-width: 80px" />

<Column field="user" header="User" sortable frozen style="min-width: 160px" />

<Column field="repo" header="Repo" sortable frozen style="min-width: 200px">
<!-- PrimeVue 的 bug,不支持 #body="{data}" https://github.com/primefaces/primevue/issues/5855 -->
<template #body="{ node: { data } }">
<NuxtLink :to="`/${data.user}/${data.repo}`" class="nav-link">
{{ data.repo }}
</NuxtLink>
</template>
</Column>

<Column field="pkg" header="Package" frozen sortable style="min-width: 180px" />

<Column field="total_count" header="报告数量" sortable style="min-width: 120px; word-break: keep-all;" />

<Column v-for="col in selectedColumns" :field="col.field" :header="col.header" sortable
style="min-width: 120px; word-break: keep-all;" />

</TreeTable>
</div>
</template>

<style scoped>
.header {
display: flex;
flex-wrap: wrap;
/* 允许子元素换行 */
justify-content: space-between;
}
.home-table {
margin: 2px 10px;
height: 50%;
}
.pass-repo {
color: var(--p-button-primary-background);
font-weight: bold;
}
</style>
Loading

0 comments on commit 0319035

Please sign in to comment.