|
| 1 | +<script lang="ts" setup> |
| 2 | +import { ref, computed } from "vue"; |
| 3 | +import DatasourceCard from "./DatasourceCard.vue"; |
| 4 | +
|
| 5 | +const props = withDefaults( |
| 6 | + defineProps<{ |
| 7 | + datasourceList: Array<any>; |
| 8 | + }>(), |
| 9 | + { |
| 10 | + datasourceList: () => [], |
| 11 | + } |
| 12 | +); |
| 13 | +
|
| 14 | +const datasourceName = ref(""); |
| 15 | +const datasourceListComputed = computed(() => |
| 16 | + props.datasourceList.filter((val) => |
| 17 | + val.name.toLowerCase.includes(datasourceName.value.toLowerCase()) |
| 18 | + ) |
| 19 | +); |
| 20 | +
|
| 21 | +const dialogVisible = ref(false); |
| 22 | +</script> |
| 23 | + |
| 24 | +<template> |
| 25 | + <div class="chat-init_tip"> |
| 26 | + <div class="hello-sqlbot">Hello, I'm SQLBot, happy to serve you!</div> |
| 27 | + <div class="function-sqlbot"> |
| 28 | + I can help you query data, generate charts, detect data anomalies, predict |
| 29 | + data, etc. Please select a data source and start intelligent data query~ |
| 30 | + </div> |
| 31 | + <div class="select-datasource"> |
| 32 | + <span class="title">Select data source</span> |
| 33 | + <el-button @click="dialogVisible = true" text>View more</el-button> |
| 34 | + </div> |
| 35 | + <div class="datasource-content"> |
| 36 | + <DatasourceCard |
| 37 | + name="1" |
| 38 | + v-for="ele in datasourceList" |
| 39 | + :key="ele.id" |
| 40 | + ></DatasourceCard> |
| 41 | + </div> |
| 42 | + <el-button type="primary">Create a new data source</el-button> |
| 43 | + </div> |
| 44 | + <el-dialog |
| 45 | + v-model="dialogVisible" |
| 46 | + title="Select data source" |
| 47 | + width="800" |
| 48 | + modal-class="select-datasource_dialog" |
| 49 | + > |
| 50 | + <div class="search-datasource"> |
| 51 | + <el-input |
| 52 | + v-model="datasourceName" |
| 53 | + style="width: 240px" |
| 54 | + placeholder="Please input" |
| 55 | + /> |
| 56 | + </div> |
| 57 | + <div class="datasource-content"> |
| 58 | + <DatasourceCard |
| 59 | + name="1" |
| 60 | + v-for="ele in datasourceListComputed" |
| 61 | + :key="ele.id" |
| 62 | + ></DatasourceCard> |
| 63 | + </div> |
| 64 | + <template #footer> |
| 65 | + <div class="dialog-footer"> |
| 66 | + <el-button @click="dialogVisible = false">Cancel</el-button> |
| 67 | + <el-button type="primary" @click="dialogVisible = false"> |
| 68 | + Confirm |
| 69 | + </el-button> |
| 70 | + </div> |
| 71 | + </template> |
| 72 | + </el-dialog> |
| 73 | +</template> |
| 74 | + |
| 75 | +<style lang="less" scoped> |
| 76 | +.chat-init_tip { |
| 77 | + width: 780px; |
| 78 | + padding: 16px; |
| 79 | + .hello-sqlbot { |
| 80 | + margin-bottom: 12px; |
| 81 | + font-size: 16px; |
| 82 | + font-weight: 500; |
| 83 | + } |
| 84 | + .function-sqlbot { |
| 85 | + margin-bottom: 12px; |
| 86 | + } |
| 87 | +
|
| 88 | + .select-datasource { |
| 89 | + display: flex; |
| 90 | + align-items: center; |
| 91 | + justify-content: space-between; |
| 92 | + } |
| 93 | +
|
| 94 | + .datasource-content { |
| 95 | + margin: 12px 0; |
| 96 | + display: grid; |
| 97 | + grid-template-columns: 1fr 1fr; |
| 98 | + gap: 16px; |
| 99 | + } |
| 100 | +} |
| 101 | +</style> |
| 102 | + |
| 103 | +<style lang="less"> |
| 104 | +.select-datasource_dialog { |
| 105 | + .search-datasource { |
| 106 | + text-align: right; |
| 107 | + } |
| 108 | +
|
| 109 | + .datasource-content { |
| 110 | + display: grid; |
| 111 | + grid-template-columns: 1fr 1fr 1fr; |
| 112 | + gap: 16px; |
| 113 | + margin-top: 16px; |
| 114 | + } |
| 115 | +} |
| 116 | +</style> |
0 commit comments