Skip to content

Commit

Permalink
feat(apache#238):
Browse files Browse the repository at this point in the history
Issue about incorporating custom components within a tab layout.
  • Loading branch information
Helltab committed Mar 31, 2024
1 parent 821c62b commit 9be10c9
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 42 deletions.
20 changes: 14 additions & 6 deletions ui-vue3/src/base/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
* limitations under the License.
*/

import type { Component } from 'vue'
import { computed, h, reactive, ref } from 'vue'
import type { RouteRecordType } from '@/router/defaultRoutes'
import type { RouteLocationNormalizedLoaded } from 'vue-router'

// 2aacb8
export const PRIMARY_COLOR_DEFAULT = '#17b392'

export const LOCAL_STORAGE_LOCALE = 'LOCAL_STORAGE_LOCALE'
Expand All @@ -31,13 +35,17 @@ export const INSTANCE_REGISTER_COLOR: { [key: string]: string } = {
HEALTHY: 'green'
}

export const TAB_HEADER_TITLE_VNODE = reactive({
vnode: h('div', 'something')
})
export const TAB_HEADER_TITLE = {
export const TAB_HEADER_TITLE: Component = {
functional: true,
render: () => {
return TAB_HEADER_TITLE_VNODE.vnode
props: ['route'],
render: (
a: any,
b: any,
c: { [key: string]: RouteRecordType & RouteLocationNormalizedLoaded }
) => {
let route = c.route
let header: any = route.meta?.slots?.header
return h(header) || h('div', route.params?.pathId)
// console.log(h)
// return h("div", "foo")
}
Expand Down
1 change: 0 additions & 1 deletion ui-vue3/src/components/SearchTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ searchDomain.table.columns.forEach((column: any) => {
}
})
const pagination = computed(() => {
console.log(pagination)
return {
pageSize: searchDomain.paged.pageSize,
current: searchDomain.paged.curPage,
Expand Down
4 changes: 3 additions & 1 deletion ui-vue3/src/layout/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ router.beforeEach((to, from, next) => {
transitionFlag.value = true
}, 500)
})
TAB_HEADER_TITLE_VNODE.vnode = h('div', route.params?.pathId)
</script>
<style lang="less" scoped>
.__container_layout_index {
:deep(.ant-layout-content) {
padding: 16px !important;
}
.logo {
height: 40px;
width: auto;
Expand Down
2 changes: 1 addition & 1 deletion ui-vue3/src/layout/tab/layout_tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ router.beforeEach((to, from, next) => {
}
.back {
font-size: 20px;
font-size: 24px;
margin-bottom: -2px;
color: v-bind('PRIMARY_COLOR');
}
Expand Down
2 changes: 2 additions & 0 deletions ui-vue3/src/router/RouterMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
import type { RouteMeta } from 'vue-router'
import type { RouteRecordType } from '@/router/defaultRoutes'
import type { Component } from 'vue'

export interface RouterMeta extends RouteMeta {
icon?: string
Expand All @@ -25,4 +26,5 @@ export interface RouterMeta extends RouteMeta {
tab?: boolean
_router_key?: string
parent?: RouteRecordType
slots?: { [key: string]: Component }
}
6 changes: 5 additions & 1 deletion ui-vue3/src/router/defaultRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type { RouterMeta } from '@/router/RouterMeta'
import type { RouteRecordRaw } from 'vue-router'
import LayoutTab from '../layout/tab/layout_tab.vue'
import _ from 'lodash'
import AppTabHeaderSlot from '@/views/resources/applications/slots/AppTabHeaderSlot.vue'

export declare type RouteRecordType = RouteRecordRaw & {
key?: string
Expand Down Expand Up @@ -58,7 +59,10 @@ export const routes: Readonly<RouteRecordType[]> = [
component: LayoutTab,
redirect: 'index',
meta: {
tab_parent: true
tab_parent: true,
slots: {
header: AppTabHeaderSlot
}
},
children: [
{
Expand Down
71 changes: 40 additions & 31 deletions ui-vue3/src/views/home/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,43 @@
</a-flex>
</a-card>
</a-flex>
<a-descriptions
title=" "
bordered
:column="{ xxl: 2, xl: 2, lg: 2, md: 2, sm: 1, xs: 1 }"
layout="horizontal"
>
<a-descriptions-item label="versions">
<a-tag :color="PRIMARY_COLOR" v-for="v in metricsMetadata.info.versions">{{ v }}</a-tag>
</a-descriptions-item>
<a-descriptions-item label="protocols">
<a-tag :color="PRIMARY_COLOR" v-for="v in metricsMetadata.info.protocols">{{ v }}</a-tag>
</a-descriptions-item>
<a-descriptions-item label="configCenter">{{
metricsMetadata.info.configCenter
}}</a-descriptions-item>
<a-descriptions-item label="registry">{{
metricsMetadata.info.registry
}}</a-descriptions-item>
<a-descriptions-item label="metadataCenter">{{
metricsMetadata.info.metadataCenter
}}</a-descriptions-item>
<a-descriptions-item label="grafana">{{ metricsMetadata.info.grafana }}</a-descriptions-item>
<a-descriptions-item label="prometheus">{{
metricsMetadata.info.prometheus
}}</a-descriptions-item>
<a-descriptions-item label="Remark">empty</a-descriptions-item>
<a-descriptions-item label="rules">
<a-tag :color="PRIMARY_COLOR" v-for="v in metricsMetadata.info.rules">{{ v }}</a-tag>
</a-descriptions-item>
</a-descriptions>
<div id="report_container"></div>
<a-card class="card">
<a-descriptions
title=" "
bordered
:column="{ xxl: 2, xl: 2, lg: 2, md: 2, sm: 1, xs: 1 }"
layout="horizontal"
>
<a-descriptions-item label="versions">
<a-tag :color="PRIMARY_COLOR" v-for="v in metricsMetadata.info.versions">{{ v }}</a-tag>
</a-descriptions-item>
<a-descriptions-item label="protocols">
<a-tag :color="PRIMARY_COLOR" v-for="v in metricsMetadata.info.protocols">{{ v }}</a-tag>
</a-descriptions-item>
<a-descriptions-item label="configCenter">{{
metricsMetadata.info.configCenter
}}</a-descriptions-item>
<a-descriptions-item label="registry">{{
metricsMetadata.info.registry
}}</a-descriptions-item>
<a-descriptions-item label="metadataCenter">{{
metricsMetadata.info.metadataCenter
}}</a-descriptions-item>
<a-descriptions-item label="grafana">{{
metricsMetadata.info.grafana
}}</a-descriptions-item>
<a-descriptions-item label="prometheus">{{
metricsMetadata.info.prometheus
}}</a-descriptions-item>
<a-descriptions-item label="Remark">empty</a-descriptions-item>
<a-descriptions-item label="rules">
<a-tag :color="PRIMARY_COLOR" v-for="v in metricsMetadata.info.rules">{{ v }}</a-tag>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card class="card">
<div id="report_container"></div>
</a-card>
</div>
</template>

Expand Down Expand Up @@ -165,5 +171,8 @@ onMounted(async () => {
font-size: 20px;
color: white;
}
.card {
margin-top: 10px;
}
}
</style>
2 changes: 1 addition & 1 deletion ui-vue3/src/views/resources/applications/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<search-table :search-domain="searchDomain">
<template #bodyCell="{ text, record, index, column }">
<template v-if="column.dataIndex === 'registerClusters'">
<a-tag v-for="t in text" color="grey">
<a-tag v-for="t in text">
{{ t }}
</a-tag>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<template>
<!-- example like blow-->
<div class="__container_AppTabHeaderSlot">
<a-row>
<a-col :span="12">
<span class="header-desc"
>{{ $t('applicationDomain.name') }}: {{ route.params?.pathId }}</span
>
</a-col>
<!-- <a-col :span="12">-->
<!-- <a-button>custom function</a-button>-->
<!-- </a-col>-->
</a-row>
</div>
</template>

<script setup lang="ts">
import { useRoute } from 'vue-router'
const route = useRoute()
</script>
<style lang="less" scoped>
.__container_AppTabHeaderSlot {
.header-desc {
line-height: 30px;
vertical-align: center;
}
}
</style>

0 comments on commit 9be10c9

Please sign in to comment.