Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
shiguanghuxian committed Feb 14, 2019
2 parents db009bf + e510a25 commit 29a8e1a
Show file tree
Hide file tree
Showing 11 changed files with 566 additions and 72 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ func main() {
signal.Notify(c, os.Interrupt, os.Kill) // , syscall.SIGUSR1, syscall.SIGUSR2
<-c
p.Stop()
log.Println("程序退出")
log.Println("Exit")
}
10 changes: 5 additions & 5 deletions program/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ func (p *Program) startAPI() {
WriteTimeout: 10 * time.Second,
}

log.Println("启动HTTP服务:", addr)
log.Println("Start HTTP the service:", addr)
var err error
if p.cfg.HTTP.TLSEnable == true {
if p.cfg.HTTP.TLSConfig == nil || p.cfg.HTTP.TLSConfig.CertFile == "" || p.cfg.HTTP.TLSConfig.KeyFile == "" {
log.Fatalln("启用tls必须配置证书文件路径")
log.Fatalln("Enable tls must configure certificate file path")
}
err = s.ListenAndServeTLS(p.cfg.HTTP.TLSConfig.CertFile, p.cfg.HTTP.TLSConfig.KeyFile)
} else if p.cfg.HTTP.TLSEncryptEnable == true {
if len(p.cfg.HTTP.TLSEncryptDomainNames) == 0 {
log.Fatalln("域名列表不能为空")
log.Fatalln("The domain name list cannot be empty")
}
err = autotls.Run(router, p.cfg.HTTP.TLSEncryptDomainNames...)
} else {
Expand Down Expand Up @@ -129,7 +129,7 @@ func (p *Program) middlewareEtcd() gin.HandlerFunc {
func getEtcdCli(name, role string) (ctl *etcdv3.Etcd3Client, s *config.EtcdServer, err error) {
s = config.GetEtcdServer(name)
if s == nil {
return nil, nil, errors.New("etcd服务不存在")
return nil, nil, errors.New("The etcd service does not exist")
}
if len(s.Roles) > 0 {
isRole := false
Expand All @@ -140,7 +140,7 @@ func getEtcdCli(name, role string) (ctl *etcdv3.Etcd3Client, s *config.EtcdServe
}
}
if isRole == false {
return nil, nil, errors.New("无权限访问")
return nil, nil, errors.New("No access")
}
}
ctl, err = etcdv3.GetEtcdCli(s)
Expand Down
2 changes: 1 addition & 1 deletion program/http_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (p *Program) handlerStatic(c *gin.Context) {
// 读取模版内容
body, err := tpls.Asset(uri)
if err != nil {
logger.Log.Errorw("UI静态文件读取错误", "err", err)
logger.Log.Errorw("UI static file reading error", "err", err)
c.Status(http.StatusNotFound)
return
}
Expand Down
2 changes: 1 addition & 1 deletion program/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ func openURL(urlAddr string) {
}
err := cmd.Start()
if err != nil {
logger.Log.Errorw("打开浏览器错误", "err", err)
logger.Log.Errorw("Error opening browser", "err", err)
}
}
57 changes: 29 additions & 28 deletions program/v1/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ func V1(v1 *gin.RouterGroup) {

// 获取etcd key列表
func getEtcdKeyList(c *gin.Context) {
go saveLog(c, "获取列表")
go saveLog(c, "Get the key list")

key := c.Query("key")

var err error
defer func() {
if err != nil {
logger.Log.Errorw("获取key列表错误", "err", err)
logger.Log.Errorw("Get key list error", "err", err)
c.JSON(http.StatusBadRequest, gin.H{
"msg": err.Error(),
})
Expand Down Expand Up @@ -82,13 +82,13 @@ func getEtcdKeyList(c *gin.Context) {

// 获取key的值
func getEtcdKeyValue(c *gin.Context) {
go saveLog(c, "获取key的值")
go saveLog(c, "Get the value of the key")

key := c.Query("key")
var err error
defer func() {
if err != nil {
logger.Log.Errorw("获取key值的值错误", "err", err)
logger.Log.Errorw("Get the value of the key value incorrectly", "err", err)
c.JSON(http.StatusBadRequest, gin.H{
"msg": err.Error(),
})
Expand All @@ -114,12 +114,12 @@ func getEtcdKeyValue(c *gin.Context) {

// 获取服务节点
func getEtcdMembers(c *gin.Context) {
go saveLog(c, "获取etcd集群信息")
go saveLog(c, "Get etcd cluster information")

var err error
defer func() {
if err != nil {
logger.Log.Errorw("获取服务节点错误", "err", err)
logger.Log.Errorw("Get service node error", "err", err)
c.JSON(http.StatusBadRequest, gin.H{
"msg": err.Error(),
})
Expand Down Expand Up @@ -161,14 +161,14 @@ func putEtcdKey(c *gin.Context) {

// 删除key
func delEtcdKey(c *gin.Context) {
go saveLog(c, "删除key")
go saveLog(c, "Delete key")

key := c.Query("key")

var err error
defer func() {
if err != nil {
logger.Log.Errorw("删除key错误", "err", err)
logger.Log.Errorw("Delete key error", "err", err)
c.JSON(http.StatusBadRequest, gin.H{
"msg": err.Error(),
})
Expand All @@ -194,12 +194,12 @@ func delEtcdKey(c *gin.Context) {

// 保存key
func saveEtcdKey(c *gin.Context, isPut bool) {
go saveLog(c, "保存key")
go saveLog(c, "Save key")

var err error
defer func() {
if err != nil {
logger.Log.Errorw("保存key错误", "err", err)
logger.Log.Errorw("Save key error", "err", err)
c.JSON(http.StatusBadRequest, gin.H{
"msg": err.Error(),
})
Expand All @@ -212,7 +212,7 @@ func saveEtcdKey(c *gin.Context, isPut bool) {
return
}
if req.FullDir == "" {
err = errors.New("参数错误")
err = errors.New("Parameter error")
return
}

Expand Down Expand Up @@ -274,7 +274,7 @@ func saveEtcdKey(c *gin.Context, isPut bool) {
// 保存key
if req.IsDir == true {
if isPut == true {
err = errors.New("目录不能修改")
err = errors.New("Directory cannot be modified")
} else {
err = cli.Put(req.FullDir, etcdv3.DEFAULT_DIR_VALUE, !isPut)
}
Expand All @@ -291,15 +291,15 @@ func saveEtcdKey(c *gin.Context, isPut bool) {

// 获取key前缀,下的值为指定格式 josn toml
func getValueToFormat(c *gin.Context) {
go saveLog(c, "格式化显示key")
go saveLog(c, "Format display key")

format := c.Query("format")
key := c.Query("key")

var err error
defer func() {
if err != nil {
logger.Log.Errorw("保存key错误", "err", err)
logger.Log.Errorw("Save key error", "err", err)
c.JSON(http.StatusBadRequest, gin.H{
"msg": err.Error(),
})
Expand Down Expand Up @@ -333,18 +333,18 @@ func getValueToFormat(c *gin.Context) {
case "toml":

default:
err = errors.New("不支持的格式")
err = errors.New("Unsupported format")
}
}

// 获取etcd服务列表
func getEtcdServerList(c *gin.Context) {
go saveLog(c, "获取etcd服务列表")
go saveLog(c, "Get the etcd service column table")

cfg := config.GetCfg()
if cfg == nil {
c.JSON(http.StatusBadRequest, gin.H{
"msg": "配置为nil",
"msg": "Configured as nil",
})
return
}
Expand Down Expand Up @@ -400,12 +400,13 @@ func getUserList(c *gin.Context) {
// 获取操作类型列表
func getLogTypeList(c *gin.Context) {
c.JSON(http.StatusOK, []string{
"获取列表",
"获取key的值",
"获取etcd集群信息",
"删除key",
"保存key",
"获取etcd服务列表",
"Get the key list",
"Format display key",
"Get the value of the key",
"Get etcd cluster information",
"Delete key",
"Save key",
"Get the etcd service column table",
})
}

Expand All @@ -429,7 +430,7 @@ func getLogsList(c *gin.Context) {
var err error
defer func() {
if err != nil {
logger.Log.Errorw("查看日志错误", "err", err)
logger.Log.Errorw("View log errors", "err", err)
c.JSON(http.StatusBadRequest, gin.H{
"msg": err.Error(),
})
Expand All @@ -453,15 +454,15 @@ func getLogsList(c *gin.Context) {
// 判断文件是否存在
if exists, err := common.PathExists(fileName); exists == false || err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"msg": fmt.Sprintf("[%s]没有日志", dateStr),
"msg": fmt.Sprintf("No logs for [%s]", dateStr),
})
return
}
// 读取指定行
file, err := os.Open(fileName)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"msg": "读取日志文件错误",
"msg": "Read log file error",
})
return
}
Expand All @@ -478,7 +479,7 @@ func getLogsList(c *gin.Context) {
oneLog := new(LogLine)
err = json.Unmarshal([]byte(logTxt), oneLog)
if err != nil {
logger.Log.Errorw("解析日志文件错误", "err", err)
logger.Log.Errorw("Parse log file error", "err", err)
continue
}
// 只看info类型日志
Expand Down Expand Up @@ -526,7 +527,7 @@ func restoreDirKey(c *gin.Context) {
var err error
defer func() {
if err != nil {
logger.Log.Errorw("修复数据错误", "err", err)
logger.Log.Errorw("Fix data error", "err", err)
c.JSON(http.StatusBadRequest, gin.H{
"msg": err.Error(),
})
Expand Down
19 changes: 18 additions & 1 deletion static/src/i18n/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const lang = {
public:{
add:'Add',
edit:"Edit",
confirmDelete:'Confirm delete',
delete:"Delete",
multiDelete:'Multi Delete',
hide:'Hide',
Expand All @@ -16,8 +17,24 @@ const lang = {
editKey:'Editor Key',
addKey:'Add Key',
open:'Open',
show:'Show'
show:'Show',
keyNotEmpty:'Key can not be empty',
addSuccessfully:'Added successfully!',
saveSuccessfully:'Saved successfully!',
},
logs:{
date:'Date',
user:'User',
typeof:'Type',
filter:'Filter',
selectDate:'Please select a date',
selectDateShowLog:'Select date to view the log',
},
etcdServer:{
repairDirectory:'Repair directory',
determineRepairDirectory:'Determine the directory problem for repairing the etcd key',
}

}

export default lang;
18 changes: 17 additions & 1 deletion static/src/i18n/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const lang = {
public:{
add:'添加',
edit:"编辑",
confirmDelete:'确定删除',
delete:"删除",
multiDelete:'批删除',
hide:'隐藏',
Expand All @@ -16,7 +17,22 @@ const lang = {
addKey:'添加key',
editKey:'编辑key',
open:'打开',
show:'查看'
show:'查看',
keyNotEmpty:'key不能为空',
addSuccessfully:'添加成功!',
saveSuccessfully:'保存成功!'
},
logs:{
date:'日期',
user:'用户',
typeof:'类型',
filter:'筛选',
selectDate:'请选择日期',
selectDateShowLog:'选择日期查看日志',
},
etcdServer:{
repairDirectory:'修复目录',
determineRepairDirectory:'确定修复etcd key的目录问题',
}
}

Expand Down
4 changes: 2 additions & 2 deletions static/src/views/EtcdServer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default {
h('Poptip', {
props: {
confirm: true,
title:'确定修复etcd key的目录问题?'
title:this.$t('etcdServer.determineRepairDirectory')
},
on: {
"on-ok": () => {
Expand All @@ -67,7 +67,7 @@ export default {
style: {
marginRight: '5px'
}
}, '修复目录'),
}, this.$t('etcdServer.repairDirectory')),
])
]);
}
Expand Down
8 changes: 4 additions & 4 deletions static/src/views/Keys.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export default {
{
props: {
confirm: true,
title: "确定删除"
title: this.$t('public.confirmDelete')
},
on: {
"on-ok": () => {
Expand Down Expand Up @@ -392,7 +392,7 @@ export default {
// 添加key
addKey() {
if (this.addKeyInfo.key == "" || typeof this.addKeyInfo.key == "undefined") {
this.$Message.warning("key不能为空");
this.$Message.warning(this.$t('key.keyNotEmpty'));
return;
}
// console.log(this.currentPath.trim('/'))
Expand All @@ -415,7 +415,7 @@ export default {
}).then(response => {
console.log(response);
if(response.status == 200){
this.$Message.success("添加成功!");
this.$Message.success(this.$t('key.addSuccessfully'));
this.getKeyList();
this.addKeyInfo = {};
this.addKeyInfoModel = false;
Expand All @@ -439,7 +439,7 @@ export default {
.then(response => {
console.log(response);
if(response.status == 200){
this.$Message.success("保存成功!");
this.$Message.success(this.$t('key.saveSuccessfully'));
this.getKeyList();
this.showKeyInfoModel = false;
}
Expand Down
Loading

0 comments on commit 29a8e1a

Please sign in to comment.