Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rudern
物联大师
提交
887a9d7d
物
物联大师
项目概览
rudern
/
物联大师
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
物
物联大师
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
887a9d7d
编写于
8月 31, 2020
作者:
J
Jason
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
可以创建TCP服务了,并且正常监听
上级
1303306f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
121 addition
and
13 deletion
+121
-13
dtu/channel.go
dtu/channel.go
+1
-1
dtu/misc.go
dtu/misc.go
+3
-9
portal/src/app/main/channel-edit/channel-edit.component.html
portal/src/app/main/channel-edit/channel-edit.component.html
+55
-1
portal/src/app/main/channel-edit/channel-edit.component.ts
portal/src/app/main/channel-edit/channel-edit.component.ts
+62
-2
未找到文件。
dtu/channel.go
浏览文件 @
887a9d7d
...
...
@@ -42,7 +42,7 @@ func (c *Channel) Open() error {
func
(
c
*
Channel
)
Dial
()
error
{
conn
,
err
:=
net
.
Dial
(
c
.
Net
,
c
.
Addr
)
if
err
!=
nil
{
log
.
Println
(
err
)
return
err
}
go
c
.
receive
(
conn
)
...
...
dtu/misc.go
浏览文件 @
887a9d7d
...
...
@@ -11,16 +11,10 @@ import (
var
channels
sync
.
Map
var
connections
sync
.
Map
//
//func init() {
// channels = new(sync.Map)
// connections = new(sync.Map)
//}
func
Channels
()
[]
*
types
.
Channel
{
cs
:=
make
([]
*
types
.
Channel
,
0
)
func
Channels
()
[]
*
Channel
{
cs
:=
make
([]
*
Channel
,
0
)
channels
.
Range
(
func
(
key
,
value
interface
{})
bool
{
cs
=
append
(
cs
,
value
.
(
*
types
.
Channel
))
cs
=
append
(
cs
,
value
.
(
*
Channel
))
return
true
})
return
cs
...
...
portal/src/app/main/channel-edit/channel-edit.component.html
浏览文件 @
887a9d7d
<p>
channel-edit works!
</p>
<form
nz-form
nzLayout=
"horizontal"
[formGroup]=
"validateForm"
(ngSubmit)=
"submit()"
>
<nz-form-item>
<nz-form-label>
名称
</nz-form-label>
<nz-form-control
nzErrorTip=
"请输入名称"
>
<input
nz-input
formControlName=
"name"
placeholder=
"名称"
/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label>
序列号
</nz-form-label>
<nz-form-control
nzErrorTip=
"请输入序列号"
>
<input
nz-input
formControlName=
"serial"
placeholder=
"序列号"
/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label>
网络类型
</nz-form-label>
<nz-form-control
nzErrorTip=
"请输入类型"
>
<input
nz-input
formControlName=
"net"
placeholder=
"下拉"
/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label>
地址
</nz-form-label>
<nz-form-control
nzErrorTip=
"请输入地址"
>
<input
nz-input
formControlName=
"addr"
placeholder=
":1843"
/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label>
服务端
</nz-form-label>
<nz-form-control
nzErrorTip=
"请勾选"
>
<label
nz-checkbox
formControlName=
"is_server"
>
<span>
启用
</span>
</label>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label>
心跳
</nz-form-label>
<nz-form-control
nzErrorTip=
"请勾选"
>
<label
nz-checkbox
formControlName=
"heart_beat.enable"
>
<span>
启用
</span>
</label>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label>
注册包
</nz-form-label>
<nz-form-control
nzErrorTip=
"请勾选"
>
<label
nz-checkbox
formControlName=
"register.enable"
>
<span>
启用
</span>
</label>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-control>
<button
nz-button
nzType=
"primary"
>
保存
</button>
</nz-form-control>
</nz-form-item>
</form>
portal/src/app/main/channel-edit/channel-edit.component.ts
浏览文件 @
887a9d7d
import
{
Component
,
Input
,
OnInit
}
from
'
@angular/core
'
;
import
{
ApiService
}
from
'
../../api.service
'
;
import
{
FormBuilder
,
FormGroup
,
Validators
}
from
'
@angular/forms
'
;
import
{
NzDrawerRef
}
from
'
ng-zorro-antd
'
;
@
Component
({
selector
:
'
app-channel-edit
'
,
...
...
@@ -7,11 +10,68 @@ import {Component, Input, OnInit} from '@angular/core';
})
export
class
ChannelEditComponent
implements
OnInit
{
@
Input
()
channel
=
{};
@
Input
()
channel
:
any
=
{};
constructor
()
{
}
validateForm
!
:
FormGroup
;
constructor
(
private
as
:
ApiService
,
private
fb
:
FormBuilder
,
private
drawerRef
:
NzDrawerRef
<
string
>
)
{
}
ngOnInit
():
void
{
this
.
initForm
({});
if
(
this
.
channel
.
id
)
{
this
.
as
.
get
(
'
channel/
'
+
this
.
channel
.
id
).
subscribe
(
res
=>
{
this
.
channel
=
res
.
data
;
this
.
initForm
(
this
.
channel
);
});
}
}
submit
():
void
{
for
(
const
i
in
this
.
validateForm
.
controls
)
{
this
.
validateForm
.
controls
[
i
].
markAsDirty
();
this
.
validateForm
.
controls
[
i
].
updateValueAndValidity
();
}
if
(
!
this
.
validateForm
.
valid
)
{
return
;
}
if
(
this
.
channel
.
id
)
{
this
.
as
.
put
(
'
channel/
'
+
this
.
channel
.
id
,
this
.
validateForm
.
value
).
subscribe
(
res
=>
{
console
.
log
(
res
);
// TODO 修改成功
this
.
drawerRef
.
close
(
res
.
data
);
});
}
else
{
this
.
as
.
post
(
'
channel
'
,
this
.
validateForm
.
value
).
subscribe
(
res
=>
{
console
.
log
(
res
);
// TODO 保存成功
this
.
drawerRef
.
close
(
res
.
data
);
});
}
}
initForm
(
item
):
void
{
if
(
!
item
.
register
)
item
.
register
=
{};
if
(
!
item
.
heart_beat
)
item
.
heart_beat
=
{};
this
.
validateForm
=
this
.
fb
.
group
({
name
:
[
item
.
name
,
[
Validators
.
required
]],
// tags: [item.tags],
serial
:
[
item
.
serial
],
net
:
[
item
.
net
,
[
Validators
.
required
]],
addr
:
[
item
.
addr
,
[
Validators
.
required
]],
is_server
:
[
item
.
is_server
],
disabled
:
[
item
.
disabled
],
'
register.enable
'
:
[
item
.
register
.
enable
],
'
register.regex
'
:
[
item
.
register
.
regex
],
'
heart_beat.enable
'
:
[
item
.
heart_beat
.
enable
],
'
heart_beat.interval
'
:
[
item
.
heart_beat
.
interval
],
'
heart_beat.content
'
:
[
item
.
heart_beat
.
content
],
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录