Skip to content

Commit

Permalink
Merge pull request #4 from WeDataSphere/fix-api-service
Browse files Browse the repository at this point in the history
Fix api-service
  • Loading branch information
zqburde authored Jul 18, 2022
2 parents 8fe0ce7 + 1dc9d99 commit 8d53b7f
Show file tree
Hide file tree
Showing 8 changed files with 1,419 additions and 0 deletions.
8 changes: 8 additions & 0 deletions web/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
}
},
"exts": {
"dss-plugin-open": {
"module": "exts/open-source/index.js",
"i18n": {
"en": "exts/open-source/i18n/en.json",
"zh-CN": "exts/open-source/i18n/zh.json"
},
"options": null
}
},
"conf": {
"app_name": "DataSphere Studio",
Expand Down
77 changes: 77 additions & 0 deletions web/packages/exts/open-source/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"message": {
"scripts": {
"apiPublish": {
"title": "PublishAPI",
"button": {
"addApi": "API Add",
"updateApi": "API Update"
},
"addApiModal": {
"modalTitle": "Add API",
"contentTitle": "Base Info",
"paramConfirmTitle": "Params Confirm",
"apiName": "API Name",
"apiPath": "API Path",
"protocol": "Protocol",
"requestType": "Request Type",
"tag": "Tag",
"visible": "Visible",
"describe": "Describe",
"nextStep": "Next",
"back": "Back",
"cancel": "Cancel",
"approvalName": "Approval Name",
"applyUser": "Apply User",
"proxyUser": "Proxy User",
"confirm": "Confirm",
"comment": "Comment"
},
"updateApiModal": {
"modalTitle": "Update API",
"apiVersionUpgrade": "New Version",
"paramConfirm": "Please confirm param"
},
"paramTable": {
"paramName": "Param Name",
"paramType": "Param Type",
"require": {
"title": "Require",
"yes": "Yes",
"no": "No",
"hide": "Hide"
},
"defaultValue": "Default Value",
"displayName": "Display Name",
"describe": "Describe"
},
"rule": {
"nameRule": "Please input api name!",
"approvalName": "Please input name!",
"pathRule": "Please input api path!",
"pathRegRule": "Api path illegal!",
"requestTypeRule": "Please select request type!",
"protocolRule": "Please select protocol!",
"valueRule": "Started with alphabetic characters, only alphanumeric and underscore are allowed!",
"contentLengthLimit": "Length limit 155",
"contentLengthLimit50": "Length limit 50",
"contentLengthLimitTwo": "Length limit 200",
"pathRepeat": "Api path exists",
"nameRepeat": "Api name exists",
"chineseCheck": "Chainese only",
"chineseName": "Chinese name of API"
},
"visible": {
"workspace": "Workspace",
"personal": "Personal",
"public": "Public",
"grantView": "Grant View"
},
"notice": {
"publishSuccess": "Publish Success"
},
"tagPlaceholder": "tag,click enter add"
}
}
}
}
77 changes: 77 additions & 0 deletions web/packages/exts/open-source/i18n/zh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"message": {
"scripts": {
"apiPublish": {
"title": "发布为数据API",
"button": {
"addApi": "新建数据API",
"updateApi": "更新数据API"
},
"addApiModal": {
"modalTitle": "数据服务API新增",
"contentTitle": "基本信息补充",
"paramConfirmTitle": "参数确认",
"apiName": "API 名称",
"apiPath": "API Path",
"protocol": "协议",
"requestType": "请求方式",
"tag": "标签",
"visible": "可见范围",
"describe": "描述",
"cancel": "取消",
"nextStep": "下一步",
"approvalName": "审批单名称",
"applyUser": "申请用户",
"proxyUser": "代理执行用户",
"back": "上一步",
"confirm": "确认",
"comment": "备注"
},
"updateApiModal": {
"modalTitle": "数据服务API更新",
"apiVersionUpgrade": "生成新版本",
"paramConfirm": "请确认参数"
},
"paramTable": {
"paramName": "参数名称",
"paramType": "参数类型",
"require": {
"title": "是否必填",
"yes": "",
"no": "",
"hide": "隐藏"
},
"defaultValue": "默认值",
"displayName": "展示名",
"describe": "描述"
},
"rule": {
"nameRule": "请填写API名称",
"approvalName": "请填写名称",
"pathRule": "请填写API路径",
"pathRegRule": "API路径不合法",
"requestTypeRule": "请选择请求方式",
"protocolRule": "请选择协议",
"valueRule": "必须以字母开头,且只支持字母、数字、下划线!",
"contentLengthLimit": "长度不能大于150",
"contentLengthLimit50": "长度不能大于50",
"contentLengthLimitTwo": "长度不能大于200",
"pathRepeat": "API路径已存在",
"nameRepeat": "API名称已存在",
"chineseCheck": "只支持中文",
"chineseName": "API中文名称"
},
"visible": {
"workspace": "工作空间",
"personal": "个人",
"public": "公开",
"grantView": "授权可见"
},
"notice": {
"publishSuccess": "发布成功"
},
"tagPlaceholder": "标签,按 enter 创建"
}
}
}
}
20 changes: 20 additions & 0 deletions web/packages/exts/open-source/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import ApiPublish from './scriptis/apiPublish/index.vue'

/**
* 插件绑定
*/
export default function () {
// // 插件通过on方法绑定事件,响应应用通过plugin.emit触发的事件
// this.on('event-app', function(arg) {
// console.log('event from app', arg)
// })
// 插件钩子type: component, 提供组件

// 发布数据服务API
this.bindHook('script_editor_top_tools', function () {
return {
name: 'ApiPublish',
component: ApiPublish
}
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@import '@dataspherestudio/shared/common/style/variables.scss';
.tags-wrap{
width: 100%;
height: 100%;
outline: none;
&::after{
content: "";
display: block;
height: 0;
clear: both;
}
}
.tags, .tags-input{
position: relative;
float: left;
color: #fff;
line-height: 28px;
margin: 0 4px 4px 0;
padding: 0 22px 0 10px;
border-radius: $border-radius-base;
.content{
line-height: 28px;
}
.del{
width: 22px;
height: 28px;
text-align: center;
cursor: pointer;
position: absolute;
top: -1px;
right: 0;
}
}
.tags-input{
background-color: inherit;
border: $border-width-base $border-style-base $border-color-base;
color: inherit;
width: auto !important;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>
<div class="input tags-wrap">
<div class="tags" transition="tags" v-bind:style="{backgroundColor: bgc[item.bgc_no]}" :key="index" v-for="(item, index) in dis_source">
<span class="content">{{item.text}}</span>
<span class="del" @click="del(index, false)">&times;</span>
</div>
<input class="tags-input ivu-input ivu-input-default" type="text" :placeholder="placeholder" v-model="text" @keyup.enter="add(text)" @keydown.delete="del(source.length - 1, true)">
</div>
</template>

<script>
export default {
props: {
source: {
type: Array
},
placeholder: {
type: String,
default: '标签,按 enter 创建'
}
},
watch: {
'source'(val) {
if (0 == val.length) {
this.dis_source = []
}
}
},
data() {
var dis_source = []
this.source.forEach(function (item) {
var obj = {
text: item,
bgc_no: Math.ceil(Math.random() * 10) - 1
}
dis_source.push(obj)
})
return {
text: '',
bgc: ['#e961b4', '#ed664b', '#7b6ac7', '#56abd1', '#f7af4c', '#fe5467', '#52c7bd', '#a479b7', '#cb81ce', '#5eabc5'],
dis_source: dis_source
}
},
methods: {
add(text) {
if(text != ''){
if (this.judgeRepeat(text)) {
this.text = ''
return;
}
var count = this.source.length
this.$set(this.source, count, text)
this.$set(this.dis_source, count, {
text: text,
bgc_no: this.dis_source.length % this.bgc.length
})
this.text = ''
}
},
del(index, way){
if(way){
if(index >=0 && this.text == ''){
this.source.splice(index, 1)
this.dis_source.splice(index, 1)
}
}else {
this.source.splice(index, 1)
this.dis_source.splice(index, 1)
}
},
judgeRepeat(text) {
var repeatFlag = false;
this.dis_source.forEach((item) => {
if (item.text === text) {
repeatFlag = true;
return true;
}
})
return repeatFlag;
}
}
}
</script>

<style lang="scss" src="./index.scss" />
37 changes: 37 additions & 0 deletions web/packages/exts/open-source/scriptis/apiPublish/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@import "@dataspherestudio/shared/common/style/variables.scss";
.api-module-title{
font-size: $font-size-base;
color: $title-color;
}
.verificationValue {
.ivu-input {
color: red!important;
border-color: red;
}
}
.api-module-content-title{
font-size: $font-size-small;
color: $title-color;
text-align: center;
}

.workbench-body-navbar-item {
margin: 0 16px;
cursor: pointer;
color: rgba($text-color, 0.8);
&.disabled {
color: rgba($text-color, 0.5);
}
&:hover {
color: $link-active-color;
&.disabled {
color: rgba($text-color, 0.5);
}
}
.ivu-icon {
font-size: 16px;
}
.navbar-item-name {
margin-left: 1px;
}
}
Loading

0 comments on commit 8d53b7f

Please sign in to comment.