ID |
名称 |
标签 |
- 序号 |
网络 |
- 地址 |
+ 状态 |
创建时间 |
|
@@ -28,13 +29,13 @@
{{ data.id }} |
{{ data.name }} |
{{ data.tags }} |
- {{ data.serial }} |
- {{ data.net }} |
- {{ data.addr }} |
- {{ data.created }} |
+ {{ data.net.is_server ? '服务端':'客户端' }} {{data.net.type}} {{data.net.addr}} |
+ {{data.disabled ? '禁用' : ''}}
启动/停止
-
+ |
+ {{ data.created | amDateFormat:'YYYY-MM-DD HH:mm:ss' }} |
+
diff --git a/portal/src/app/main/channel/channel.component.ts b/portal/src/app/main/channel/channel.component.ts
index b108c09eb6e3a0048a3a2ddcbfe2b03ba503281f..45b2dfed0d934584d33c60954b4a08571f83a0f7 100644
--- a/portal/src/app/main/channel/channel.component.ts
+++ b/portal/src/app/main/channel/channel.component.ts
@@ -32,7 +32,7 @@ export class ChannelComponent implements OnInit {
this.drawer.create({
nzTitle: c ? '编辑' : '创建',
nzMaskClosable: false,
- nzWidth: 400,
+ nzWidth: 500,
nzContent: ChannelEditComponent,
nzContentParams: {
channel: c || {}
diff --git a/portal/src/app/main/main.module.ts b/portal/src/app/main/main.module.ts
index c49dee20e3b7929030b2c09c9d28ff79e6cf5e0a..0c37017c1e6614a75bf6f8e17c40839a3cc8e735 100644
--- a/portal/src/app/main/main.module.ts
+++ b/portal/src/app/main/main.module.ts
@@ -14,8 +14,8 @@ import {
NzCheckboxModule, NzDividerModule, NzDrawerModule,
NzFormModule,
NzIconModule,
- NzInputModule,
- NzModalModule, NzPopconfirmModule, NzSwitchModule,
+ NzInputModule, NzInputNumberModule,
+ NzModalModule, NzPopconfirmModule, NzSelectModule, NzSwitchModule,
NzTableModule,
NzToolTipModule
} from 'ng-zorro-antd';
@@ -31,6 +31,7 @@ import {ChannelDetailComponent} from './channel-detail/channel-detail.component'
import {LinkDetailComponent} from './link-detail/link-detail.component';
import {UserEditComponent} from './user-edit/user-edit.component';
import {LinkMonitorComponent} from './link-monitor/link-monitor.component';
+import {NzSpaceModule} from "ng-zorro-antd/space";
@NgModule({
@@ -64,6 +65,9 @@ import {LinkMonitorComponent} from './link-monitor/link-monitor.component';
IconsProviderModule,
NzDividerModule,
NzDrawerModule,
+ NzSelectModule,
+ NzSpaceModule,
+ NzInputNumberModule,
],
bootstrap: [MainComponent]
})
diff --git a/types/channel.go b/types/channel.go
index 92f292bcb936ec0e78345637df26435a4fd986fe..3be02a943a1b71d961950220eb8c3ffffa8c8807 100644
--- a/types/channel.go
+++ b/types/channel.go
@@ -2,15 +2,23 @@ package types
import "time"
+type NetConf struct {
+ Type string `json:"type"`
+ Addr string `json:"addr"`
+ IsServer bool `json:"is_server"`
+ Timeout int `json:"timeout"` //TODO 改为秒
+}
+
type RegisterConf struct {
- Enable bool
- Length int
- Regex string
+ Enable bool `json:"enable"`
+ Length int `json:"length"`
+ Regex string `json:"regex"`
}
type HeartBeatConf struct {
- Enable bool
- Content []byte
+ Enable bool `json:"enable"`
+ Interval int `json:"interval"` //TODO 改为秒
+ Content []byte `json:"content"`
}
type Channel struct {
@@ -18,24 +26,9 @@ type Channel struct {
Name string `json:"name"`
Tags []string `json:"tags"`
- Serial string `storm:"index" json:"serial"`
-
- Net string `json:"net"`
- Addr string `json:"addr"`
- IsServer bool `json:"is_server"`
- Timeout int `json:"timeout"` //TODO 改为秒
-
- Register struct {
- Enable bool `json:"enable"`
- Length int `json:"length"`
- Regex string `json:"regex"`
- } `json:"register"`
-
- HeartBeat struct {
- Enable bool `json:"enable"`
- Interval int `json:"interval"` //TODO 改为秒
- Content []byte `json:"content"`
- } `json:"heart_beat"`
+ Net NetConf `json:"net"`
+ Register RegisterConf `json:"register"`
+ HeartBeat HeartBeatConf `json:"heart_beat"`
Disabled bool `json:"disabled"`
Created time.Time `json:"created"`
diff --git a/web/api/channel.go b/web/api/channel.go
index 0d387d9f59b405db732241351395d9571dd54d98..7efd76740fe494b23fbedadac32f5063e9b4b9b5 100644
--- a/web/api/channel.go
+++ b/web/api/channel.go
@@ -7,7 +7,8 @@ import (
"github.com/zgwit/dtu-admin/types"
)
-func channelAll(ctx *gin.Context) {
+
+func channels(ctx *gin.Context) {
var cs []types.Channel
err := storage.DB("channel").All(&cs)
if err != nil {
@@ -17,11 +18,6 @@ func channelAll(ctx *gin.Context) {
replyOk(ctx, cs)
}
-func channels(ctx *gin.Context) {
- cs := dtu.Channels()
- replyOk(ctx, cs)
-}
-
func channelCreate(ctx *gin.Context) {
var channel types.Channel
if err := ctx.ShouldBindJSON(&channel); err != nil {
@@ -29,14 +25,15 @@ func channelCreate(ctx *gin.Context) {
return
}
- //创建并启动
- c, err := dtu.CreateChannel(&channel)
+ err := storage.DB("channel").Save(&channel)
if err != nil {
replyError(ctx, err)
return
}
- replyOk(ctx, c)
+ //TODO 启动服务
+
+ replyOk(ctx, channel)
}
func channelDelete(ctx *gin.Context) {
@@ -45,17 +42,36 @@ func channelDelete(ctx *gin.Context) {
replyError(ctx, err)
return
}
- err := dtu.DeleteChannel(pid.Id)
+
+ err := storage.DB("channel").DeleteStruct(&types.Channel{ID: pid.Id})
if err != nil {
replyError(ctx, err)
return
}
+ //TODO 删除服务
+
replyOk(ctx, nil)
}
+
func channelModify(ctx *gin.Context) {
+ var channel types.Channel
+ if err := ctx.ShouldBindJSON(&channel); err != nil {
+ replyError(ctx, err)
+ return
+ }
+
+ //TODO 不能全部字段更新,应该先取值,修改,再存入
+ err := storage.DB("channel").Update(&channel)
+ if err != nil {
+ replyError(ctx, err)
+ return
+ }
+
+ //TODO 重新启动服务
+ replyOk(ctx, channel)
}
func channelGet(ctx *gin.Context) {
@@ -64,13 +80,15 @@ func channelGet(ctx *gin.Context) {
replyError(ctx, err)
return
}
- c, err := dtu.GetChannel(pid.Id)
+
+ var channel types.Channel
+ err := storage.DB("channel").One("ID", pid.Id, &channel)
if err != nil {
replyError(ctx, err)
return
}
- replyOk(ctx, c)
+ replyOk(ctx, channel)
}
func channelStart(ctx *gin.Context) {
diff --git a/web/api/router.go b/web/api/router.go
index 2a0725893dac615d17059db56f0d3066fa8d0910..0a046f12dced5013cbd5fb5f5d0f7b92beb2c860 100644
--- a/web/api/router.go
+++ b/web/api/router.go
@@ -17,12 +17,12 @@ type paramSearch struct {
}
type paramId struct {
- Id int64 `uri:"id"`
+ Id int `uri:"id"`
}
type paramId2 struct {
- Id int64 `uri:"id"`
- Id2 int64 `uri:"id2"`
+ Id int `uri:"id"`
+ Id2 int `uri:"id2"`
}
func RegisterRoutes(app *gin.RouterGroup) {
|