forked from github/dataease
Merge branch 'dev' of github.com:dataease/dataease into dev
This commit is contained in:
commit
ffbd32febf
@ -45,6 +45,8 @@ public class ShiroServiceImpl implements ShiroService {
|
||||
//验证链接
|
||||
filterChainDefinitionMap.put("/api/link/validate**", ANON);
|
||||
filterChainDefinitionMap.put("/api/map/areaEntitys/**", ANON);
|
||||
//未读消息数量
|
||||
filterChainDefinitionMap.put("/api/sys_msg/unReadCount", ANON);
|
||||
|
||||
filterChainDefinitionMap.put("/**/*.json", ANON);
|
||||
filterChainDefinitionMap.put("/system/ui/**", ANON);
|
||||
|
@ -1,4 +0,0 @@
|
||||
package io.dataease.base.mapper.ext;
|
||||
|
||||
public interface ExtBaseMapper {
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="io.dataease.base.mapper.ext.ExtBaseMapper">
|
||||
|
||||
|
||||
<sql id="orders">
|
||||
<if test="request.orders != null and request.orders.size() > 0">
|
||||
order by
|
||||
<foreach collection="request.orders" separator="," item="order">
|
||||
${order.name} ${order.type}
|
||||
</foreach>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<sql id="condition">
|
||||
<choose>
|
||||
<when test='${object}.operator == "like"'>
|
||||
like CONCAT('%', #{${object}.value},'%')
|
||||
</when>
|
||||
<when test='${object}.operator == "not like"'>
|
||||
not like CONCAT('%', #{${object}.value},'%')
|
||||
</when>
|
||||
<when test='${object}.operator == "in"'>
|
||||
in
|
||||
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test='${object}.operator == "not in"'>
|
||||
not in
|
||||
<foreach collection="${object}.value" item="v" separator="," open="(" close=")">
|
||||
#{v}
|
||||
</foreach>
|
||||
</when>
|
||||
<when test='${object}.operator == "between"'>
|
||||
between #{${object}.value[0]} and #{${object}.value[1]}
|
||||
</when>
|
||||
<when test='${object}.operator == "gt"'>
|
||||
> #{${object}.value}
|
||||
</when>
|
||||
<when test='${object}.operator == "lt"'>
|
||||
< #{${object}.value}
|
||||
</when>
|
||||
<when test='${object}.operator == "ge"'>
|
||||
>= #{${object}.value}
|
||||
</when>
|
||||
<when test='${object}.operator == "le"'>
|
||||
<= #{${object}.value}
|
||||
</when>
|
||||
<when test='${object}.operator == "current user"'>
|
||||
= '${@io.metersphere.commons.utils.SessionUtils@getUserId()}'
|
||||
</when>
|
||||
<otherwise>
|
||||
= #{${object}.value}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</sql>
|
||||
|
||||
</mapper>
|
@ -1,34 +0,0 @@
|
||||
package io.dataease.commons.utils;
|
||||
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.aspectj.util.FileUtil;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
public class FileUtils {
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
public static void createBodyFiles(List<String> bodyUploadIds, List<MultipartFile> bodyFiles) {
|
||||
if (CollectionUtils.isNotEmpty(bodyUploadIds) && CollectionUtils.isNotEmpty(bodyFiles)) {
|
||||
File testDir = new File(BODY_FILE_DIR);
|
||||
if (!testDir.exists()) {
|
||||
testDir.mkdirs();
|
||||
}
|
||||
for (int i = 0; i < bodyUploadIds.size(); i++) {
|
||||
MultipartFile item = bodyFiles.get(i);
|
||||
File file = new File(BODY_FILE_DIR + "/" + bodyUploadIds.get(i) + "_" + item.getOriginalFilename());
|
||||
try (InputStream in = item.getInputStream(); OutputStream out = new FileOutputStream(file)) {
|
||||
file.createNewFile();
|
||||
FileUtil.copyStream(in, out);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e);
|
||||
DEException.throwException(Translator.get("upload_fail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.base.domain.SysMsgChannel;
|
||||
import io.dataease.base.domain.SysMsgSetting;
|
||||
import io.dataease.base.domain.SysMsgType;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
@ -21,6 +22,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "系统:消息管理")
|
||||
@ -46,6 +48,16 @@ public class MsgController {
|
||||
return listPager;
|
||||
}
|
||||
|
||||
@ApiOperation("查询未读数量")
|
||||
@PostMapping("/unReadCount")
|
||||
public Long unReadCount(@RequestBody Map<String, Long> request) {
|
||||
if(null == request || null == request.get("userId")) {
|
||||
throw new RuntimeException("缺少用户ID");
|
||||
}
|
||||
Long userId = request.get("userId");
|
||||
return sysMsgService.queryCount(userId);
|
||||
}
|
||||
|
||||
@ApiOperation("设置已读")
|
||||
@PostMapping("/setReaded/{msgId}")
|
||||
public void setReaded(@PathVariable Long msgId) {
|
||||
|
@ -105,6 +105,13 @@ public class SysMsgService {
|
||||
return msgGridDtos;
|
||||
}
|
||||
|
||||
public Long queryCount(Long userId) {
|
||||
SysMsgExample example = new SysMsgExample();
|
||||
SysMsgExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andUserIdEqualTo(userId).andStatusEqualTo(false);
|
||||
return sysMsgMapper.countByExample(example);
|
||||
}
|
||||
|
||||
public void setReaded(Long msgId) {
|
||||
SysMsg sysMsg = new SysMsg();
|
||||
sysMsg.setMsgId(msgId);
|
||||
|
@ -9,6 +9,15 @@ export function query(pageIndex, pageSize, data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function unReadCount(data) {
|
||||
return request({
|
||||
url: '/api/sys_msg/unReadCount',
|
||||
method: 'post',
|
||||
loading: false,
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function updateStatus(msgId) {
|
||||
return request({
|
||||
url: '/api/sys_msg/setReaded/' + msgId,
|
||||
|
@ -53,14 +53,14 @@
|
||||
class-name="notification"
|
||||
icon-class="notification"
|
||||
/>
|
||||
<span v-if="paginationConfig.total" class="msg-number">{{ paginationConfig.total }}</span>
|
||||
<span v-if="count || paginationConfig.total" class="msg-number">{{ count || paginationConfig.total }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</el-popover>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { query, updateStatus } from '@/api/system/msg'
|
||||
import { query, updateStatus, unReadCount } from '@/api/system/msg'
|
||||
import { getTypeName, loadMsgTypes } from '@/utils/webMsg'
|
||||
import { mapGetters } from 'vuex'
|
||||
import bus from '@/utils/bus'
|
||||
@ -76,21 +76,30 @@ export default {
|
||||
pageSize: 5,
|
||||
total: 0
|
||||
},
|
||||
timer: null
|
||||
timer: null,
|
||||
count: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters([
|
||||
'permission_routes'
|
||||
'permission_routes',
|
||||
'user'
|
||||
])
|
||||
},
|
||||
watch: {
|
||||
'visible': function(newV, oldV) {
|
||||
if (newV && !oldV) {
|
||||
this.search()
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 先加载消息类型
|
||||
loadMsgTypes()
|
||||
this.search()
|
||||
this.queryCount()
|
||||
// 每30s定时刷新拉取消息
|
||||
this.timer = setInterval(() => {
|
||||
this.search()
|
||||
this.queryCount()
|
||||
}, 30000)
|
||||
},
|
||||
mounted() {
|
||||
@ -105,19 +114,11 @@ export default {
|
||||
this.timer && clearInterval(this.timer)
|
||||
},
|
||||
methods: {
|
||||
// handClick(lang) {
|
||||
// console.log(lang)
|
||||
// },
|
||||
|
||||
showDetail(row) {
|
||||
const param = { ...{ msgNotification: true, msgType: row.typeId, sourceParam: row.param }}
|
||||
this.visible = false
|
||||
// if (this.$route && this.$route.name && this.$route.name.includes('panel') && row.type === 0) {
|
||||
// bus.$emit('to-msg-share', param)
|
||||
// } else if (this.$route && this.$route.name && this.$route.name.includes('dataset') && row.type === 1) {
|
||||
// bus.$emit('to-msg-dataset', param)
|
||||
// } else {
|
||||
// this.$router.push({ name: row.router, params: param })
|
||||
// }
|
||||
|
||||
if (this.$route && this.$route.name && this.$route.name === row.router) {
|
||||
// 如果当前路由就是目标路由 那么使用router.push页面不会刷新 这时候要使用事件方式
|
||||
row.callback && bus.$emit(row.callback, param)
|
||||
@ -164,6 +165,31 @@ export default {
|
||||
this.$store.commit('permission/SET_CURRENT_ROUTES', route)
|
||||
// this.setSidebarHide(route)
|
||||
},
|
||||
queryCount() {
|
||||
const token = getToken()
|
||||
|
||||
if (!token || token === 'null' || token === 'undefined' || !this.user || !this.user.userId) {
|
||||
this.timer && clearInterval(this.timer)
|
||||
const message = this.$t('login.tokenError')
|
||||
this.$alert(message, {
|
||||
confirmButtonText: this.$t('login.re_login'),
|
||||
showClose: false,
|
||||
callback: function(action, instance) {
|
||||
if (action === 'confirm') {
|
||||
this.$store.dispatch('user/logout').then(() => {
|
||||
location.reload()
|
||||
})
|
||||
}
|
||||
}.bind(this)
|
||||
})
|
||||
}
|
||||
const param = {
|
||||
userId: this.user.userId
|
||||
}
|
||||
unReadCount(param).then(res => {
|
||||
this.count = res.data
|
||||
})
|
||||
},
|
||||
search() {
|
||||
const param = {
|
||||
status: false,
|
||||
|
@ -309,6 +309,12 @@ export default {
|
||||
this.chart.type === 'map' && this.sendToChildren(param)
|
||||
this.drillClickDimensionList.push({ dimensionList: param.data.dimensionList })
|
||||
this.getData(this.element.propValue.viewId)
|
||||
} else if (this.chart.drillFields.length > 0) {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: this.$t('chart.last_layer'),
|
||||
showClose: true
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -696,6 +696,10 @@ export default {
|
||||
filter: 'Filter',
|
||||
none: 'None',
|
||||
background: 'Background',
|
||||
|
||||
border: 'Corner',
|
||||
border_width: 'Border width',
|
||||
border_radius: 'Border radius',
|
||||
alpha: 'Transparency',
|
||||
add_filter: 'Add Filter',
|
||||
no_limit: 'No limit',
|
||||
@ -842,7 +846,8 @@ export default {
|
||||
width: 'Width',
|
||||
height: 'Height',
|
||||
system_case: 'System',
|
||||
custom_case: 'Custom'
|
||||
custom_case: 'Custom',
|
||||
last_layer: 'This Is The Last Layer'
|
||||
},
|
||||
dataset: {
|
||||
sheet_warn: 'There are multiple sheet pages, and the first one is extracted by default',
|
||||
@ -1013,7 +1018,8 @@ export default {
|
||||
merge: 'Merge',
|
||||
no_merge: 'Dont Merge',
|
||||
merge_msg: 'If the fields in the data table are consistent, merge them into one data set?',
|
||||
merge_title: 'Merge data'
|
||||
merge_title: 'Merge data',
|
||||
field_name_less_50: 'Field name can not more 50 chars.'
|
||||
},
|
||||
datasource: {
|
||||
datasource: 'Data Source',
|
||||
|
@ -696,6 +696,9 @@ export default {
|
||||
filter: '過濾',
|
||||
none: '無',
|
||||
background: '背景',
|
||||
border: '邊角',
|
||||
border_width: '邊框寬度',
|
||||
border_radius: '邊框半徑',
|
||||
alpha: '透明度',
|
||||
add_filter: '添加過濾',
|
||||
no_limit: '無顯示',
|
||||
@ -842,7 +845,8 @@ export default {
|
||||
width: '寬度',
|
||||
height: '高度',
|
||||
system_case: '系統方案',
|
||||
custom_case: '自定義'
|
||||
custom_case: '自定義',
|
||||
last_layer: '当前已经是最后一级'
|
||||
},
|
||||
dataset: {
|
||||
sheet_warn: '有多個sheet頁面,默認抽取第一個',
|
||||
@ -1013,7 +1017,8 @@ export default {
|
||||
merge: '合併',
|
||||
no_merge: '不合併',
|
||||
merge_msg: '數據表中存在自斷一直的情況,是否合併到一個數據集中?',
|
||||
merge_title: '合併數據'
|
||||
merge_title: '合併數據',
|
||||
field_name_less_50: '字段名不能超過50個字符'
|
||||
},
|
||||
datasource: {
|
||||
datasource: '數據源',
|
||||
|
@ -696,6 +696,9 @@ export default {
|
||||
filter: '过滤',
|
||||
none: '无',
|
||||
background: '背景',
|
||||
border: '边角',
|
||||
border_width: '边框宽度',
|
||||
border_radius: '边框半径',
|
||||
alpha: '透明度',
|
||||
add_filter: '添加过滤',
|
||||
no_limit: '无限制',
|
||||
@ -842,7 +845,8 @@ export default {
|
||||
width: '宽度',
|
||||
height: '高度',
|
||||
system_case: '系统方案',
|
||||
custom_case: '自定义'
|
||||
custom_case: '自定义',
|
||||
last_layer: '当前已经是最后一级'
|
||||
},
|
||||
dataset: {
|
||||
sheet_warn: '有多个 Sheet 页,默认抽取第一个',
|
||||
@ -1013,7 +1017,8 @@ export default {
|
||||
merge: '合并',
|
||||
no_merge: '不合并',
|
||||
merge_msg: '数据表中存在字段一致的情况,是否合并到一个数据集中?',
|
||||
merge_title: '合并数据'
|
||||
merge_title: '合并数据',
|
||||
field_name_less_50: '字段名不能超过50个字符'
|
||||
},
|
||||
datasource: {
|
||||
datasource: '数据源',
|
||||
|
@ -10,7 +10,6 @@
|
||||
@import '~umy-ui/lib/theme-chalk/index.css';
|
||||
// 引入样式
|
||||
@import './deicon/iconfont.css';
|
||||
// @import '../metersphere/common/css/index.css';
|
||||
|
||||
|
||||
body {
|
||||
|
@ -8,7 +8,7 @@ import i18n from '@/lang'
|
||||
import { tryShowLoading, tryHideLoading } from './loading'
|
||||
import { getLinkToken, setLinkToken } from '@/utils/auth'
|
||||
// import router from '@/router'
|
||||
const interruptTokenContineUrls = Config.interruptTokenContineUrls
|
||||
// const interruptTokenContineUrls = Config.interruptTokenContineUrls
|
||||
const TokenKey = Config.TokenKey
|
||||
const RefreshTokenKey = Config.RefreshTokenKey
|
||||
const LinkTokenKey = Config.LinkTokenKey
|
||||
@ -88,7 +88,8 @@ const checkAuth = response => {
|
||||
})
|
||||
}
|
||||
// token到期后自动续命 刷新token
|
||||
if (response.headers[RefreshTokenKey] && !interruptTokenContineUrls.some(item => response.config.url.indexOf(item) >= 0)) {
|
||||
// if (response.headers[RefreshTokenKey] && !interruptTokenContineUrls.some(item => response.config.url.indexOf(item) >= 0)) {
|
||||
if (response.headers[RefreshTokenKey]) {
|
||||
const refreshToken = response.headers[RefreshTokenKey]
|
||||
store.dispatch('user/refreshToken', refreshToken)
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ export function componentStyle(chart_option, chart) {
|
||||
chart_option.legend.icon = customStyle.legend.icon
|
||||
chart_option.legend.textStyle = customStyle.legend.textStyle
|
||||
}
|
||||
if (customStyle.xAxis && (chart.type.includes('bar') || chart.type.includes('line'))) {
|
||||
if (customStyle.xAxis && (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter'))) {
|
||||
chart_option.xAxis.show = customStyle.xAxis.show
|
||||
chart_option.xAxis.position = customStyle.xAxis.position
|
||||
chart_option.xAxis.name = customStyle.xAxis.name
|
||||
@ -59,7 +59,7 @@ export function componentStyle(chart_option, chart) {
|
||||
chart_option.xAxis.splitLine = customStyle.xAxis.splitLine
|
||||
chart_option.xAxis.nameTextStyle = customStyle.xAxis.nameTextStyle
|
||||
}
|
||||
if (customStyle.yAxis && (chart.type.includes('bar') || chart.type.includes('line'))) {
|
||||
if (customStyle.yAxis && (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter'))) {
|
||||
chart_option.yAxis.show = customStyle.yAxis.show
|
||||
chart_option.yAxis.position = customStyle.yAxis.position
|
||||
chart_option.yAxis.name = customStyle.yAxis.name
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div style="display: flex;">
|
||||
<view-track-bar ref="viewTrack" :track-menu="trackMenu" class="track-bar" :style="trackBarStyleTime" @trackClick="trackClick" />
|
||||
<div :id="chartId" style="width: 100%;height: 100%;" />
|
||||
<div :id="chartId" style="width: 100%;height: 100%;overflow: hidden;" :style="{ borderRadius: borderRadius}" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -56,7 +56,8 @@ export default {
|
||||
},
|
||||
pointParam: null,
|
||||
|
||||
dynamicAreaCode: null
|
||||
dynamicAreaCode: null,
|
||||
borderRadius: '0px'
|
||||
}
|
||||
},
|
||||
|
||||
@ -195,11 +196,20 @@ export default {
|
||||
myEcharts(option) {
|
||||
// 指定图表的配置项和数据
|
||||
const chart = this.myChart
|
||||
this.setBackGroundBorder()
|
||||
setTimeout(chart.setOption(option, true), 500)
|
||||
window.onresize = function() {
|
||||
chart.resize()
|
||||
}
|
||||
},
|
||||
setBackGroundBorder() {
|
||||
if (this.chart.customStyle) {
|
||||
const customStyle = JSON.parse(this.chart.customStyle)
|
||||
if (customStyle.background) {
|
||||
this.borderRadius = (customStyle.background.borderRadius || 0) + 'px'
|
||||
}
|
||||
}
|
||||
},
|
||||
chartResize() {
|
||||
// 指定图表的配置项和数据
|
||||
const chart = this.myChart
|
||||
|
@ -8,6 +8,10 @@
|
||||
<el-form-item :label="$t('chart.not_alpha')" class="form-item form-item-slider">
|
||||
<el-slider v-model="colorForm.alpha" show-input :show-input-controls="false" input-size="mini" @change="changeBackgroundStyle" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('chart.border_radius')" class="form-item form-item-slider">
|
||||
<el-slider v-model="colorForm.borderRadius" show-input :show-input-controls="false" input-size="mini" @change="changeBackgroundStyle" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
</div>
|
||||
|
@ -447,10 +447,10 @@
|
||||
<el-row>
|
||||
<span class="padding-lr">{{ $t('chart.module_style') }}</span>
|
||||
<el-collapse v-model="styleActiveNames" class="style-collapse">
|
||||
<el-collapse-item v-show="view.type && (view.type.includes('bar') || view.type.includes('line'))" name="xAxis" :title="$t('chart.xAxis')">
|
||||
<el-collapse-item v-show="view.type && (view.type.includes('bar') || view.type.includes('line') || view.type.includes('scatter'))" name="xAxis" :title="$t('chart.xAxis')">
|
||||
<x-axis-selector :param="param" class="attr-selector" :chart="chart" @onChangeXAxisForm="onChangeXAxisForm" />
|
||||
</el-collapse-item>
|
||||
<el-collapse-item v-show="view.type && (view.type.includes('bar') || view.type.includes('line'))" name="yAxis" :title="$t('chart.yAxis')">
|
||||
<el-collapse-item v-show="view.type && (view.type.includes('bar') || view.type.includes('line') || view.type.includes('scatter'))" name="yAxis" :title="$t('chart.yAxis')">
|
||||
<y-axis-selector :param="param" class="attr-selector" :chart="chart" @onChangeYAxisForm="onChangeYAxisForm" />
|
||||
</el-collapse-item>
|
||||
<el-collapse-item v-show="view.type && view.type.includes('radar')" name="split" :title="$t('chart.split')">
|
||||
@ -1416,6 +1416,12 @@ export default {
|
||||
this.drillClickDimensionList.push({ dimensionList: param.data.dimensionList })
|
||||
this.getData(this.param.id)
|
||||
}
|
||||
} else if (this.view.drillFields.length > 0) {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: this.$t('chart.last_layer'),
|
||||
showClose: true
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -312,6 +312,10 @@ export default {
|
||||
},
|
||||
|
||||
saveCalcField() {
|
||||
if (this.fieldForm.name && this.fieldForm.name.length > 50) {
|
||||
this.$message.error(this.$t('dataset.field_name_less_50'))
|
||||
return
|
||||
}
|
||||
if (!this.fieldForm.id) {
|
||||
this.fieldForm.type = this.fieldForm.deType
|
||||
this.fieldForm.deExtractType = this.fieldForm.deType
|
||||
|
@ -327,6 +327,10 @@ export default {
|
||||
// // this.closeEdit()
|
||||
// this.initField()
|
||||
// })
|
||||
if (item.name && item.name.length > 50) {
|
||||
this.$message.error(this.$t('dataset.field_name_less_50'))
|
||||
return
|
||||
}
|
||||
|
||||
post('/dataset/field/save', item).then(response => {
|
||||
this.initField()
|
||||
|
@ -1,234 +0,0 @@
|
||||
<template>
|
||||
<div v-loading="result.loading">
|
||||
<el-form ref="form" :model="form" size="small" :rules="rules" :disabled="show">
|
||||
<el-form-item :label="$t('ldap.url')" prop="url">
|
||||
<el-input v-model="form.url" :placeholder="$t('ldap.input_url_placeholder')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('ldap.dn')" prop="dn">
|
||||
<el-input v-model="form.dn" :placeholder="$t('ldap.input_dn')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('ldap.password')" prop="password">
|
||||
<el-input
|
||||
v-model="form.password"
|
||||
:placeholder="$t('ldap.input_password')"
|
||||
show-password
|
||||
auto-complete="new-password"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('ldap.ou')" prop="ou">
|
||||
<el-input v-model="form.ou" :placeholder="$t('ldap.input_ou_placeholder')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('ldap.filter')" prop="filter">
|
||||
<el-input v-model="form.filter" :placeholder="$t('ldap.input_filter_placeholder')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('ldap.mapping')" prop="mapping">
|
||||
<el-input v-model="form.mapping" :placeholder="$t('ldap.input_mapping_placeholder')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('ldap.open')" prop="open">
|
||||
<el-checkbox v-model="form.open" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div>
|
||||
<el-button type="primary" size="small" :disabled="!show" @click="testConnection">{{ $t('ldap.test_connect') }}
|
||||
</el-button>
|
||||
<el-button type="primary" size="small" :disabled="!showLogin || !show" @click="testLogin">
|
||||
{{ $t('ldap.test_login') }}
|
||||
</el-button>
|
||||
<el-button v-if="showEdit" size="small" @click="edit">{{ $t('ldap.edit') }}</el-button>
|
||||
<el-button v-if="showSave" type="success" size="small" @click="save('form')">{{ $t('commons.save') }}
|
||||
</el-button>
|
||||
<el-button v-if="showCancel" type="info" size="small" @click="cancel">{{ $t('commons.cancel') }}</el-button>
|
||||
</div>
|
||||
|
||||
<el-dialog
|
||||
v-loading="result.loading"
|
||||
:title="$t('ldap.test_login')"
|
||||
:visible.sync="loginVisible"
|
||||
width="30%"
|
||||
destroy-on-close
|
||||
@close="close"
|
||||
>
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginFormRules" label-width="90px">
|
||||
<el-form-item :label="$t('commons.username')" prop="username">
|
||||
<el-input v-model="loginForm.username" autocomplete="off" :placeholder="$t('ldap.input_username')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.password')" prop="password">
|
||||
<el-input
|
||||
v-model="loginForm.password"
|
||||
autocomplete="new-password"
|
||||
:placeholder="$t('ldap.input_password')"
|
||||
show-password
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="text" @click="loginVisible = false">{{ $t('commons.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="login('loginForm')">确认</el-button>
|
||||
</div>
|
||||
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import MsDialogFooter from '@/metersphere/common/components/MsDialogFooter'
|
||||
// import { listenGoBack, removeGoBackListener } from '@/metersphere/common/js/utils'
|
||||
|
||||
export default {
|
||||
name: 'LdapSetting',
|
||||
components: {
|
||||
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: { open: false },
|
||||
loginForm: {},
|
||||
result: {},
|
||||
show: true,
|
||||
showEdit: true,
|
||||
showSave: false,
|
||||
showCancel: false,
|
||||
showLogin: false,
|
||||
loginVisible: false,
|
||||
rules: {
|
||||
url: { required: true, message: this.$t('ldap.input_url'), trigger: ['change', 'blur'] },
|
||||
dn: { required: true, message: this.$t('ldap.input_dn'), trigger: ['change', 'blur'] },
|
||||
password: { required: true, message: this.$t('ldap.input_password'), trigger: ['change', 'blur'] },
|
||||
ou: { required: true, message: this.$t('ldap.input_ou'), trigger: ['change', 'blur'] },
|
||||
filter: { required: true, message: this.$t('ldap.input_filter'), trigger: ['change', 'blur'] },
|
||||
mapping: { required: true, message: this.$t('ldap.input_mapping'), trigger: ['change', 'blur'] }
|
||||
},
|
||||
loginFormRules: {
|
||||
username: { required: true, message: this.$t('ldap.input_username'), trigger: 'blur' },
|
||||
password: { required: true, message: this.$t('ldap.input_password'), trigger: 'blur' }
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.result = this.$get('/system/ldap/info', response => {
|
||||
this.form = response.data
|
||||
this.form.open = this.form.open === 'true'
|
||||
this.$nextTick(() => {
|
||||
this.$refs.form.clearValidate()
|
||||
})
|
||||
})
|
||||
},
|
||||
edit() {
|
||||
this.show = false
|
||||
this.showEdit = false
|
||||
this.showSave = true
|
||||
this.showCancel = true
|
||||
},
|
||||
cancel() {
|
||||
this.showEdit = true
|
||||
this.showCancel = false
|
||||
this.showSave = false
|
||||
this.show = true
|
||||
this.init()
|
||||
},
|
||||
close() {
|
||||
this.loginVisible = false
|
||||
},
|
||||
testConnection() {
|
||||
if (!this.checkParam()) {
|
||||
return false
|
||||
}
|
||||
this.result = this.$post('/ldap/test/connect', this.form, () => {
|
||||
this.$success(this.$t('commons.connection_successful'))
|
||||
this.showLogin = true
|
||||
}, () => {
|
||||
this.showLogin = false
|
||||
})
|
||||
},
|
||||
testLogin() {
|
||||
if (!this.checkParam()) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.form.ou) {
|
||||
this.$warning(this.$t('ldap.ou_cannot_be_empty'))
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.form.filter) {
|
||||
this.$warning(this.$t('ldap.filter_cannot_be_empty'))
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.form.mapping) {
|
||||
this.$warning(this.$t('ldap.mapping_cannot_be_empty'))
|
||||
return false
|
||||
}
|
||||
|
||||
this.loginForm = {}
|
||||
this.loginVisible = true
|
||||
},
|
||||
checkParam() {
|
||||
if (!this.form.url) {
|
||||
this.$warning(this.$t('ldap.url_cannot_be_empty'))
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.form.dn) {
|
||||
this.$warning(this.$t('ldap.dn_cannot_be_empty'))
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.form.password) {
|
||||
this.$warning(this.$t('ldap.password_cannot_be_empty'))
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
save(form) {
|
||||
const param = [
|
||||
{ paramKey: 'ldap.url', paramValue: this.form.url, type: 'text', sort: 1 },
|
||||
{ paramKey: 'ldap.dn', paramValue: this.form.dn, type: 'text', sort: 2 },
|
||||
{ paramKey: 'ldap.password', paramValue: this.form.password, type: 'password', sort: 3 },
|
||||
{ paramKey: 'ldap.ou', paramValue: this.form.ou, type: 'text', sort: 4 },
|
||||
{ paramKey: 'ldap.filter', paramValue: this.form.filter, type: 'text', sort: 5 },
|
||||
{ paramKey: 'ldap.mapping', paramValue: this.form.mapping, type: 'text', sort: 6 },
|
||||
{ paramKey: 'ldap.open', paramValue: this.form.open, type: 'text', sort: 7 }
|
||||
]
|
||||
|
||||
this.$refs[form].validate(valid => {
|
||||
if (valid) {
|
||||
this.result = this.$post('/system/save/ldap', param, () => {
|
||||
this.show = true
|
||||
this.showEdit = true
|
||||
this.showSave = false
|
||||
this.showCancel = false
|
||||
this.showLogin = false
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.init()
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
login(form) {
|
||||
this.$refs[form].validate(valid => {
|
||||
if (valid) {
|
||||
this.result = this.$post('/ldap/test/login', this.loginForm, () => {
|
||||
this.$success(this.$t('ldap.login_success'))
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
Loading…
Reference in New Issue
Block a user