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

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
{$layout "layout_popup"} {$layout "layout_popup"}
<h3>添加源站地址</h3> <h3>添加源站</h3>
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success"> <form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="reverseProxyId" :value="reverseProxyId"/> <input type="hidden" name="reverseProxyId" :value="reverseProxyId"/>
@@ -23,7 +23,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="title">源站地址</td> <td class="title">源站地址 *</td>
<td> <td>
<input type="text" name="addr" ref="focus"/> <input type="text" name="addr" ref="focus"/>
<p class="comment">源站服务器地址通常是一个IP或域名加端口<span v-if="serverType == 'httpProxy'">,不需要加 http:// 或 https://</span></p> <p class="comment">源站服务器地址通常是一个IP或域名加端口<span v-if="serverType == 'httpProxy'">,不需要加 http:// 或 https://</span></p>
@@ -36,6 +36,30 @@
<p class="comment">数字越大,代表分配的请求比例越多。</p> <p class="comment">数字越大,代表分配的请求比例越多。</p>
</td> </td>
</tr> </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> </table>
<submit-btn></submit-btn> <submit-btn></submit-btn>
</form> </form>

View File

@@ -1,6 +1,6 @@
{$layout "layout_popup"} {$layout "layout_popup"}
<h3>添加源站地址</h3> <h3>修改源站</h3>
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success"> <form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
<input type="hidden" name="reverseProxyId" :value="reverseProxyId"/> <input type="hidden" name="reverseProxyId" :value="reverseProxyId"/>
@@ -38,6 +38,30 @@
<p class="comment">数字越大,代表分配的请求比例越多。</p> <p class="comment">数字越大,代表分配的请求比例越多。</p>
</td> </td>
</tr> </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> </table>
<submit-btn></submit-btn> <submit-btn></submit-btn>
</form> </form>