feat: add widget header

This commit is contained in:
Qiuxia Fan 2021-12-23 20:24:58 +08:00
parent 4992d1567d
commit b39109eae6
5 changed files with 78 additions and 2 deletions

View File

@ -0,0 +1,18 @@
<!-- 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. -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<title>clearclose</title>
<path d="M18.984 6.422l-5.578 5.578 5.578 5.578-1.406 1.406-5.578-5.578-5.578 5.578-1.406-1.406 5.578-5.578-5.578-5.578 1.406-1.406 5.578 5.578 5.578-5.578z"></path>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,18 @@
<!-- 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. -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<title>createmode_editedit</title>
<path d="M20.719 7.031l-1.828 1.828-3.75-3.75 1.828-1.828q0.281-0.281 0.703-0.281t0.703 0.281l2.344 2.344q0.281 0.281 0.281 0.703t-0.281 0.703zM3 17.25l11.063-11.063 3.75 3.75-11.063 11.063h-3.75v-3.75z"></path>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -45,6 +45,9 @@ export const dashboardStore = defineStore({
}); });
this.layout.push(newWidget); this.layout.push(newWidget);
}, },
removeWidget(item: GridItemData) {
this.layout = this.layout.filter((d: GridItemData) => d.i !== item.i);
},
}, },
}); });

View File

@ -17,6 +17,7 @@ limitations under the License. -->
<el-button size="mini" @click="dashboardStore.addWidget"> <el-button size="mini" @click="dashboardStore.addWidget">
Add Widget Add Widget
</el-button> </el-button>
<el-button size="mini">Dashboard Settings</el-button>
<el-button size="mini">Save As</el-button> <el-button size="mini">Save As</el-button>
<el-button size="mini">Discard</el-button> <el-button size="mini">Discard</el-button>
<el-button size="mini" type="primary">Apply</el-button> <el-button size="mini" type="primary">Apply</el-button>

View File

@ -13,15 +13,51 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="header">title</div> <div class="widget">
<div class="body">chart</div> <div class="header flex-h">
<div>title</div>
<div class="operations">
<Icon class="mr-5" size="sm" iconName="createmode_editedit" />
<Icon size="sm" iconName="clearclose" @click="removeWidget" />
</div>
</div>
<div class="body">chart</div>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { defineProps } from "vue"; import { defineProps } from "vue";
import type { PropType } from "vue"; import type { PropType } from "vue";
import { GridItemData } from "@/types/dashboard"; import { GridItemData } from "@/types/dashboard";
import { useDashboardStore } from "@/store/modules/dashboard";
const props = defineProps({ const props = defineProps({
item: { type: Object as PropType<GridItemData> }, item: { type: Object as PropType<GridItemData> },
}); });
const dashboardStore = useDashboardStore();
function removeWidget() {
dashboardStore.removeWidget(props.item);
}
</script> </script>
<style lang="scss" scoped>
.widget {
font-size: 12px;
// position: relative;
}
.header {
height: 30px;
padding: 5px;
width: 100%;
border-bottom: 1px solid #eee;
justify-content: space-between;
}
.operations {
color: #aaa;
cursor: pointer;
}
.body {
padding: 5px;
}
</style>