[反向代理]源站可以设置名称、描述、是否启用

This commit is contained in:
刘祥超
2020-11-30 20:00:32 +08:00
parent d308219a82
commit f6f08af2a0
7 changed files with 90 additions and 15 deletions

View File

@@ -58,6 +58,8 @@ func (this *IndexAction) RunGet(params struct {
"id": originConfig.Id,
"weight": originConfig.Weight,
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
"name": originConfig.Name,
"isOn": originConfig.IsOn,
}
primaryOriginMaps = append(primaryOriginMaps, m)
}
@@ -66,6 +68,8 @@ func (this *IndexAction) RunGet(params struct {
"id": originConfig.Id,
"weight": originConfig.Weight,
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
"name": originConfig.Name,
"isOn": originConfig.IsOn,
}
backupOriginMaps = append(backupOriginMaps, m)
}

View File

@@ -43,6 +43,9 @@ func (this *AddPopupAction) RunPost(params struct {
Weight int32
Protocol string
Addr string
Name string
Description string
IsOn bool
Must *actions.Must
}) {
@@ -59,14 +62,15 @@ func (this *AddPopupAction) RunPost(params struct {
port := addr[portIndex+1:]
createResp, err := this.RPC().OriginRPC().CreateOrigin(this.AdminContext(), &pb.CreateOriginRequest{
Name: "",
Name: params.Name,
Addr: &pb.NetworkAddress{
Protocol: params.Protocol,
Host: host,
PortRange: port,
},
Description: "",
Description: params.Description,
Weight: params.Weight,
IsOn: params.IsOn,
})
if err != nil {
this.ErrorPage(err)

View File

@@ -59,6 +59,9 @@ func (this *UpdatePopupAction) RunGet(params struct {
"protocol": config.Addr.Protocol,
"addr": config.Addr.Host + ":" + config.Addr.PortRange,
"weight": config.Weight,
"name": config.Name,
"description": config.Description,
"isOn": config.IsOn,
}
this.Show()
@@ -72,6 +75,9 @@ func (this *UpdatePopupAction) RunPost(params struct {
Protocol string
Addr string
Weight int32
Name string
Description string
IsOn bool
Must *actions.Must
}) {
@@ -89,14 +95,15 @@ func (this *UpdatePopupAction) RunPost(params struct {
_, err := this.RPC().OriginRPC().UpdateOrigin(this.AdminContext(), &pb.UpdateOriginRequest{
OriginId: params.OriginId,
Name: "",
Name: params.Name,
Addr: &pb.NetworkAddress{
Protocol: params.Protocol,
Host: host,
PortRange: port,
},
Description: "",
Description: params.Description,
Weight: params.Weight,
IsOn: params.IsOn,
})
if err != nil {
this.ErrorPage(err)

View File

@@ -57,6 +57,8 @@ func (this *IndexAction) RunGet(params struct {
"id": originConfig.Id,
"weight": originConfig.Weight,
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
"name": originConfig.Name,
"isOn": originConfig.IsOn,
}
primaryOriginMaps = append(primaryOriginMaps, m)
}
@@ -65,6 +67,8 @@ func (this *IndexAction) RunGet(params struct {
"id": originConfig.Id,
"weight": originConfig.Weight,
"addr": originConfig.Addr.Protocol.String() + "://" + originConfig.Addr.Host + ":" + originConfig.Addr.PortRange,
"name": originConfig.Name,
"isOn": originConfig.IsOn,
}
backupOriginMaps = append(backupOriginMaps, m)
}

View File

@@ -9,7 +9,7 @@ Vue.component("origin-list-box", {
methods: {
createPrimaryOrigin: function () {
teaweb.popup("/servers/server/settings/origins/addPopup?originType=primary&" + this.vParams, {
height: "22em",
height: "24em",
callback: function (resp) {
window.location.reload()
}
@@ -17,7 +17,7 @@ Vue.component("origin-list-box", {
},
createBackupOrigin: function () {
teaweb.popup("/servers/server/settings/origins/addPopup?originType=backup&" + this.vParams, {
height: "22em",
height: "24em",
callback: function (resp) {
window.location.reload()
}
@@ -25,7 +25,7 @@ Vue.component("origin-list-box", {
},
updateOrigin: function (originId, originType) {
teaweb.popup("/servers/server/settings/origins/updatePopup?originType=" + originType + "&" + this.vParams + "&originId=" + originId, {
height: "22em",
height: "24em",
callback: function (resp) {
window.location.reload()
}
@@ -72,12 +72,20 @@ Vue.component("origin-list-table", {
<tr>
<th>源站地址</th>
<th>权重</th>
<th class="width10">状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="origin in vOrigins">
<td>{{origin.addr}}</td>
<td>{{origin.addr}}
<div v-if="origin.name.length > 0" style="margin-top: 0.5em">
<tiny-basic-label>{{origin.name}}</tiny-basic-label>
</div>
</td>
<td>{{origin.weight}}</td>
<td>
<label-on :v-is-on="origin.isOn"></label-on>
</td>
<td>
<a href="" @click.prevent="updateOrigin(origin.id)">修改</a> &nbsp;
<a href="" @click.prevent="deleteOrigin(origin.id)">删除</a>

View File

@@ -1,6 +1,6 @@
{$layout "layout_popup"}
<h3>添加源站地址</h3>
<h3>添加源站</h3>
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="reverseProxyId" :value="reverseProxyId"/>
@@ -23,7 +23,7 @@
</td>
</tr>
<tr>
<td class="title">源站地址</td>
<td class="title">源站地址 *</td>
<td>
<input type="text" name="addr" ref="focus"/>
<p class="comment">源站服务器地址通常是一个IP或域名加端口<span v-if="serverType == 'httpProxy'">,不需要加 http:// 或 https://</span></p>
@@ -36,6 +36,30 @@
<p class="comment">数字越大,代表分配的请求比例越多。</p>
</td>
</tr>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>名称</td>
<td>
<input type="text" name="name" maxlength="100"/>
<p class="comment">给当前源站起一个容易识别的名称。</p>
</td>
</tr>
<tr>
<td>备注</td>
<td>
<textarea name="description" rows="3" maxlength="100"></textarea>
</td>
</tr>
<tr>
<td>是否启用</td>
<td>
<checkbox name="isOn" :value="true"></checkbox>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -1,6 +1,6 @@
{$layout "layout_popup"}
<h3>添加源站地址</h3>
<h3>修改源站</h3>
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="reverseProxyId" :value="reverseProxyId"/>
@@ -38,6 +38,30 @@
<p class="comment">数字越大,代表分配的请求比例越多。</p>
</td>
</tr>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>名称</td>
<td>
<input type="text" name="name" maxlength="100" v-model="origin.name"/>
<p class="comment">给当前源站起一个容易识别的名称。</p>
</td>
</tr>
<tr>
<td>备注</td>
<td>
<textarea name="description" rows="3" maxlength="100" v-model="origin.description"></textarea>
</td>
</tr>
<tr>
<td>是否启用</td>
<td>
<checkbox name="isOn" :value="origin.isOn"></checkbox>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>
</form>