fix: 优化脚本数据集,提供ES查询案例

main
hong.yang 2 years ago
parent 2f7e0ef466
commit 36cd4c4d42

@ -179,12 +179,17 @@
class="sql-config" class="sql-config"
> >
<div> <div>
<codemirror <el-button-group>
ref="targetInSql" <el-button plain type="primary" class="bs-el-button-default" @click="example('es')">ES</el-button>
v-model="dataForm.script" </el-button-group>
:options="cOptions" <div class="code-out">
style="margin-top: 2px" <codemirror
/> ref="targetInSql"
v-model="dataForm.script"
:options="cOptions"
style="margin-top: 2px"
/>
</div>
</div> </div>
<div style="text-align: center; padding: 16px 0;"> <div style="text-align: center; padding: 16px 0;">
<el-button <el-button
@ -563,6 +568,38 @@
>确定</el-button> >确定</el-button>
</span> </span>
</el-dialog> </el-dialog>
<el-dialog
title="脚本案例"
:visible.sync="exampleVisible"
width="1000px"
height="1000px"
append-to-body
:close-on-click-modal="false"
class="bs-dialog-wrap bs-el-dialog"
>
<div class="code-inner">
<codemirror
ref="example"
v-model="currentExample"
:options="cOptions"
style="margin-top: 2px"
/>
</div>
<span
slot="footer"
class="dialog-footer"
>
<el-button
class="bs-el-button-default"
@click="exampleVisible = false"
>关闭</el-button>
<el-button
type="primary"
@click="useExample"
>使用该案例</el-button>
</span>
</el-dialog>
</el-scrollbar> </el-scrollbar>
</div> </div>
</template> </template>
@ -642,7 +679,38 @@ export default {
paramsListCopy: [], paramsListCopy: [],
isSet: false, // isSet: false, //
passTest: false, passTest: false,
fieldDesc: null // fieldDesc: null, //
exampleVisible: false,
currentExample: '',
exampleList: {
es: `import com.gccloud.dataset.utils.ElasticsearchDsService;
def dsl = '''
{
"query":{
"match_all":{}
}
}
'''
def host = "127.0.0.1"
int port = 9200
def username = "elastic"
def password = "pwd"
def path = "/_search"
/**
* query方法的参数说明
* host es的ip
* port es的端口
* username es的用户名如果没有可以不填
* password es的密码如果没有可以不填
* path es的查询路径
* dsl 查询的dsl示例见上面
* return 查询结果List<Map>格式
*/
return ElasticsearchDsService.query(host, port, username, password, path, dsl);
`
}
} }
}, },
computed: { computed: {
@ -906,7 +974,19 @@ export default {
treeFilter (value, data) { treeFilter (value, data) {
if (!value) return true if (!value) return true
return data.name.indexOf(value) !== -1 return data.name.indexOf(value) !== -1
} },
/**
* 获取脚本案例
*/
example(type) {
this.exampleVisible = true
this.currentExample = this.exampleList[type]
console.log(this.currentExample)
},
useExample() {
this.dataForm.script = this.currentExample
this.exampleVisible = false
},
} }
} }
</script> </script>
@ -954,15 +1034,24 @@ export default {
// .codeStyle { // .codeStyle {
// border: 1px solid #EBEEF5; // border: 1px solid #EBEEF5;
// } // }
::v-deep .CodeMirror { .code-out {
height: 180px !important; ::v-deep .CodeMirror {
font-family: Helvetica, Tahoma; height: 180px ;
// .CodeMirror-scroll { font-family: Helvetica, Tahoma;
// background: #fff; // .CodeMirror-scroll {
// .CodeMirror-gutters { // background: #fff;
// background: #f6f7fb; // .CodeMirror-gutters {
// } // background: #f6f7fb;
// } // }
// }
}
}
.code-inner {
::v-deep .CodeMirror {
height: 400px ;
font-family: Helvetica, Tahoma;
}
} }
.no-border { .no-border {

Loading…
Cancel
Save