mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-09 04:03:31 +00:00
add color
This commit is contained in:
parent
7804945146
commit
534d020f51
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "skywalking-booster-ui",
|
"name": "skywalking-booster-ui",
|
||||||
"version": "9.4.0",
|
"version": "10.2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
@ -17,6 +17,7 @@ limitations under the License. -->
|
|||||||
:data="option.legend.data"
|
:data="option.legend.data"
|
||||||
:show="legendSelector.isSelector"
|
:show="legendSelector.isSelector"
|
||||||
:isConfigPage="legendSelector.isConfigPage"
|
:isConfigPage="legendSelector.isConfigPage"
|
||||||
|
:colors="option.color"
|
||||||
@change="changeLegend"
|
@change="changeLegend"
|
||||||
/>
|
/>
|
||||||
<div class="chart" ref="chartRef" :style="`height:${height};width:${width};`">
|
<div class="chart" ref="chartRef" :style="`height:${height};width:${width};`">
|
107
src/components/Graph/Selector.vue
Normal file
107
src/components/Graph/Selector.vue
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
<!-- 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>
|
||||||
|
<el-select
|
||||||
|
:size="size"
|
||||||
|
v-model="selected"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
@change="changeSelected"
|
||||||
|
:multiple="multiple"
|
||||||
|
:disabled="disabled"
|
||||||
|
:style="{ borderRadius }"
|
||||||
|
:clearable="clearable"
|
||||||
|
:remote="isRemote"
|
||||||
|
:reserve-keyword="isRemote"
|
||||||
|
:remote-method="remoteMethod"
|
||||||
|
:filterable="filterable"
|
||||||
|
:collapse-tags="collapseTags"
|
||||||
|
:collapse-tags-tooltip="collapseTagsTooltip"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(item, index) in options"
|
||||||
|
:key="`${item.value}${index}`"
|
||||||
|
:label="item.label || ''"
|
||||||
|
:value="item.value || ''"
|
||||||
|
:disabled="item.disabled || false"
|
||||||
|
>
|
||||||
|
<div class="flex items-center">
|
||||||
|
<el-tag :color="item.color" class="mr-5" size="small" />
|
||||||
|
<span :style="{ color: item.color }">{{ item.label }}</span>
|
||||||
|
</div>
|
||||||
|
</el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, watch } from "vue";
|
||||||
|
import type { PropType } from "vue";
|
||||||
|
|
||||||
|
/*global defineProps, defineEmits, Indexable*/
|
||||||
|
const emit = defineEmits(["change", "query"]);
|
||||||
|
const props = defineProps({
|
||||||
|
options: {
|
||||||
|
type: Array as PropType<
|
||||||
|
({
|
||||||
|
label: string | number;
|
||||||
|
value: string | number;
|
||||||
|
color: string;
|
||||||
|
} & { disabled?: boolean })[]
|
||||||
|
>,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
value: {
|
||||||
|
type: [Array, String, Number, undefined] as PropType<any>,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
size: { type: null, default: "default" },
|
||||||
|
placeholder: {
|
||||||
|
type: [String, undefined] as PropType<string>,
|
||||||
|
default: "Select a option",
|
||||||
|
},
|
||||||
|
borderRadius: { type: Number, default: 3 },
|
||||||
|
multiple: { type: Boolean, default: false },
|
||||||
|
disabled: { type: Boolean, default: false },
|
||||||
|
clearable: { type: Boolean, default: false },
|
||||||
|
isRemote: { type: Boolean, default: false },
|
||||||
|
filterable: { type: Boolean, default: true },
|
||||||
|
collapseTags: { type: Boolean, default: false },
|
||||||
|
collapseTagsTooltip: { type: Boolean, default: false },
|
||||||
|
});
|
||||||
|
|
||||||
|
const selected = ref<string[] | string>(props.value);
|
||||||
|
function changeSelected() {
|
||||||
|
const options = props.options.filter((d: Indexable) =>
|
||||||
|
props.multiple ? selected.value.includes(d.value) : selected.value === d.value,
|
||||||
|
);
|
||||||
|
emit("change", options);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remoteMethod(query: string) {
|
||||||
|
if (props.isRemote) {
|
||||||
|
emit("query", query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.value,
|
||||||
|
(data) => {
|
||||||
|
selected.value = data;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.el-input__inner {
|
||||||
|
border-radius: unset !important;
|
||||||
|
}
|
||||||
|
</style>
|
@ -30,12 +30,17 @@ limitations under the License. -->
|
|||||||
import { computed, ref, watch } from "vue";
|
import { computed, ref, watch } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import type { Option } from "@/types/app";
|
import type { Option } from "@/types/app";
|
||||||
|
import Selector from "./Selector.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
type: Array as PropType<{ name: string }[]>,
|
type: Array as PropType<{ name: string }[]>,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
colors: {
|
||||||
|
type: Array as PropType<string[]>,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
show: {
|
show: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
@ -46,7 +51,13 @@ limitations under the License. -->
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const emits = defineEmits(["change"]);
|
const emits = defineEmits(["change"]);
|
||||||
const Options = computed(() => props.data.map((d: { name: string }) => ({ label: d.name, value: d.name })));
|
const Options = computed(() =>
|
||||||
|
props.data.map((d: { name: string }, index: number) => ({
|
||||||
|
label: d.name,
|
||||||
|
value: d.name,
|
||||||
|
color: props.colors[index],
|
||||||
|
})),
|
||||||
|
);
|
||||||
const legend = ref<string[]>([]);
|
const legend = ref<string[]>([]);
|
||||||
|
|
||||||
function changeLegend(opt: Option[]) {
|
function changeLegend(opt: Option[]) {
|
@ -18,7 +18,7 @@ import type { App } from "vue";
|
|||||||
import Icon from "./Icon.vue";
|
import Icon from "./Icon.vue";
|
||||||
import TimePicker from "./TimePicker.vue";
|
import TimePicker from "./TimePicker.vue";
|
||||||
import Selector from "./Selector.vue";
|
import Selector from "./Selector.vue";
|
||||||
import Graph from "./Graph.vue";
|
import Graph from "./Graph/Graph.vue";
|
||||||
import Radio from "./Radio.vue";
|
import Radio from "./Radio.vue";
|
||||||
import SelectSingle from "./SelectSingle.vue";
|
import SelectSingle from "./SelectSingle.vue";
|
||||||
import Tags from "./Tags.vue";
|
import Tags from "./Tags.vue";
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
html {
|
html {
|
||||||
--el-color-primary: #409eff;
|
--el-color-primary: #409eff;
|
||||||
|
--el-color-info-light-9: #666;
|
||||||
--theme-background: #fff;
|
--theme-background: #fff;
|
||||||
--font-color: #3d444f;
|
--font-color: #3d444f;
|
||||||
--disabled-color: #ccc;
|
--disabled-color: #ccc;
|
||||||
@ -74,6 +75,7 @@ html {
|
|||||||
|
|
||||||
html.dark {
|
html.dark {
|
||||||
--el-color-primary: #409eff;
|
--el-color-primary: #409eff;
|
||||||
|
--el-color-info-light-9: #333;
|
||||||
--theme-background: #212224;
|
--theme-background: #212224;
|
||||||
--font-color: #fafbfc;
|
--font-color: #fafbfc;
|
||||||
--disabled-color: #999;
|
--disabled-color: #999;
|
||||||
|
4
src/types/components.d.ts
vendored
4
src/types/components.d.ts
vendored
@ -44,13 +44,13 @@ declare module 'vue' {
|
|||||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||||
ElTag: typeof import('element-plus/es')['ElTag']
|
ElTag: typeof import('element-plus/es')['ElTag']
|
||||||
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
ElTooltip: typeof import('element-plus/es')['ElTooltip']
|
||||||
Graph: typeof import('./../components/Graph.vue')['default']
|
Graph: typeof import('./../components/Graph/Graph.vue')['default']
|
||||||
Icon: typeof import('./../components/Icon.vue')['default']
|
Icon: typeof import('./../components/Icon.vue')['default']
|
||||||
Radio: typeof import('./../components/Radio.vue')['default']
|
Radio: typeof import('./../components/Radio.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
Selector: typeof import('./../components/Selector.vue')['default']
|
Selector: typeof import('./../components/Selector.vue')['default']
|
||||||
SelectorLegend: typeof import('./../components/SelectorLegend.vue')['default']
|
SelectorLegend: typeof import('./../components/Graph/SelectorLegend.vue')['default']
|
||||||
SelectSingle: typeof import('./../components/SelectSingle.vue')['default']
|
SelectSingle: typeof import('./../components/SelectSingle.vue')['default']
|
||||||
Tags: typeof import('./../components/Tags.vue')['default']
|
Tags: typeof import('./../components/Tags.vue')['default']
|
||||||
TimePicker: typeof import('./../components/TimePicker.vue')['default']
|
TimePicker: typeof import('./../components/TimePicker.vue')['default']
|
||||||
|
Loading…
Reference in New Issue
Block a user