2022-06-02 21:45:11 -04:00
{{define "dashboard-default/server"}}
2019-12-08 10:18:29 -05:00
{{template "common/header" .}}
{{template "common/menu" .}}
< div class = "nb-container" >
< div class = "ui container" >
2020-03-22 08:55:27 -04:00
< div class = "ui grid" >
< div class = "right floated right aligned twelve wide column" >
2022-09-16 12:08:27 -04:00
< button class = "ui right labeled nezha-primary-btn icon button" onclick = "batchEditServerGroup()" > < i
class="edit icon">< / i > {{tr "BatchEditServerGroup"}}
< / button >
2023-06-13 12:23:47 -04:00
< button class = "ui right labeled nezha-primary-btn icon button" onclick = "batchDeleteServer()" > < i
class="trash icon">< / i > {{tr "BatchDeleteServer"}}
< / button >
2021-08-05 23:48:34 -04:00
< button class = "ui right labeled nezha-primary-btn icon button" onclick = "addOrEditServer()" > < i
2022-04-28 22:52:26 -04:00
class="add icon">< / i > {{tr "AddServer"}}
2020-03-22 08:55:27 -04:00
< / button >
2021-11-04 00:06:20 -04:00
< button class = "ui right labeled nezha-primary-btn icon button" onclick = "forceUpdate()" > < i
2022-04-28 22:52:26 -04:00
class="arrow alternate circle up outline icon">< / i > {{tr "ForceUpdate"}}
2021-11-04 00:06:20 -04:00
< / button >
2020-03-22 08:55:27 -04:00
< / div >
< / div >
2024-08-13 11:50:55 -04:00
< table class = "ui basic table" >
2019-12-08 10:18:29 -05:00
< thead >
< tr >
2022-04-28 22:52:26 -04:00
< th > < button onclick = "checkAllServer()" class = "ui mini nezha-primary-btn button" > {{tr "SelectAll"}}< / button > < / th >
< th > ID({{tr "DisplayIndex"}})< / th >
< th > {{tr "Name"}}< / th >
2022-04-30 11:01:57 -04:00
< th > {{tr "ServerGroup"}}< / th >
2021-01-08 08:04:50 -05:00
< th > IP< / th >
2022-04-28 22:52:26 -04:00
< th > {{tr "VersionNumber"}}< / th >
2024-02-24 08:10:27 -05:00
< th > {{tr "EnableDDNS"}}< / th >
2024-10-17 09:03:03 -04:00
< th > {{tr "HideForGuest"}}< / th >
2022-04-28 22:52:26 -04:00
< th > {{tr "Secret"}}< / th >
< th > {{tr "OneKeyInstall"}}< / th >
< th > {{tr "Note"}}< / th >
2024-09-27 12:16:54 -04:00
< th > {{tr "PublicNote"}}< / th >
2022-04-28 22:52:26 -04:00
< th > {{tr "Administration"}}< / th >
2019-12-08 10:18:29 -05:00
< / tr >
< / thead >
< tbody >
{{range $server := .Servers}}
< tr >
2021-11-04 00:06:20 -04:00
< td > < input type = "checkbox" class = "nezha-servers" value = "{{$server.ID}}" / > < / td >
2021-01-30 04:10:51 -05:00
< td > {{$server.ID}}({{$server.DisplayIndex}})< / td >
2019-12-08 10:18:29 -05:00
< td > {{$server.Name}}< / td >
2022-04-30 13:56:03 -04:00
< td > {{$server.Tag}}< / td >
2021-01-08 08:04:50 -05:00
< td > {{$server.Host.IP}}< / td >
2021-06-21 09:30:42 -04:00
< td > {{$server.Host.Version}}< / td >
2024-02-24 08:10:27 -05:00
< td > {{$server.EnableDDNS}}< / td >
2024-10-17 09:03:03 -04:00
< td > {{$server.HideForGuest}}< / td >
2022-09-30 10:40:56 -04:00
< td >
2022-10-16 11:30:06 -04:00
< button class = "ui icon green mini button" data-clipboard-text = "{{$server.Secret}}" data-tooltip = "{{tr " ClickToCopy " } } " >
2022-09-30 10:40:56 -04:00
< i class = "copy icon" > < / i >
< / button >
< / td >
2021-08-10 08:04:58 -04:00
< td >
< button class = "ui icon green mini button"
2024-07-19 18:48:53 -04:00
data-clipboard-text="{{if $.Conf.GRPCHost}}{{if eq $.Conf.Language "zh-CN"}}curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh{{else}}curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install_en.sh{{end}} -o nezha.sh & & chmod +x nezha.sh & & ./nezha.sh install_agent {{$.Conf.GRPCHost}} {{if $.Conf.ProxyGRPCPort}}{{$.Conf.ProxyGRPCPort}}{{else}}{{$.Conf.GRPCPort}}{{end}} {{$server.Secret}}{{if $.Conf.TLS}} --tls{{end}}{{else}}{{tr "NoDomainAlert"}}{{end}}"
2022-10-16 11:30:06 -04:00
data-tooltip="{{tr "ClickToCopy"}}">
2021-08-10 08:04:58 -04:00
< i class = "linux icon" > < / i >
< / button >
2022-04-28 15:24:52 -04:00
< button class = "ui icon green mini button"
2022-06-22 00:16:04 -04:00
data-clipboard-text="{{if $.Conf.GRPCHost}}[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Ssl3 -bor [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12;set-ExecutionPolicy RemoteSigned;Invoke-WebRequest https://raw.githubusercontent.com/naiba/nezha/master/script/install.ps1 -OutFile C:\install.ps1;powershell.exe C:\install.ps1 {{$.Conf.GRPCHost}}:{{if $.Conf.ProxyGRPCPort}}{{$.Conf.ProxyGRPCPort}}{{else}}{{$.Conf.GRPCPort}}{{end}} {{$server.Secret}}{{if $.Conf.TLS}} --tls{{end}}{{else}}{{tr "NoDomainAlert"}}{{end}}"
2022-10-16 11:30:06 -04:00
data-tooltip="{{tr "ClickToCopy"}}">
2021-08-10 08:04:58 -04:00
< i class = "windows icon" > < / i >
< / button >
2024-05-21 11:11:43 -04:00
< button class = "ui icon green mini button"
data-clipboard-text="{{if $.Conf.GRPCHost}}curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.command -o nezha.command & & chmod +x nezha.command & & sudo ./nezha.command install_agent {{$.Conf.GRPCHost}} {{if $.Conf.ProxyGRPCPort}}{{$.Conf.ProxyGRPCPort}}{{else}}{{$.Conf.GRPCPort}}{{end}} {{$server.Secret}}{{if $.Conf.TLS}} --tls{{end}}{{else}}{{tr "NoDomainAlert"}}{{end}}"
data-tooltip="{{tr "ClickToCopy"}}">
< i class = "apple icon" > < / i >
< / button >
2021-08-10 08:04:58 -04:00
< / td >
2024-10-01 22:05:53 -04:00
< td >
{{if $server.Note}}
< button class = "ui icon green mini button" title = "{{ $server.Note }}" onclick = "addOrEditServer({{$server.MarshalForDashboard}})" > < i class = "sticky note icon" > < / i > < / button >
{{end}}
< / td >
< td >
{{if $server.PublicNote}}
< button class = "ui icon green mini button" title = "{{$server.PublicNote}}" onclick = "addOrEditServer({{$server.MarshalForDashboard}})" > < i class = "sticky clipboard icon" > < / i > < / button >
{{end}}
< / td >
2019-12-20 10:58:09 -05:00
< td >
< div class = "ui mini icon buttons" >
2021-08-17 23:56:54 -04:00
< button class = "ui button" onclick = "connectToServer({{$server.ID}})" >
< i class = "terminal icon" > < / i >
< / button >
2024-09-27 12:16:54 -04:00
< button class = "ui button" onclick = "addOrEditServer({{$server.MarshalForDashboard}})" >
2019-12-20 10:58:09 -05:00
< i class = "edit icon" > < / i >
< / button >
2020-03-22 08:55:27 -04:00
< button class = "ui button"
2023-06-13 12:23:47 -04:00
onclick="showConfirm('{{tr "DeleteServer"}}','{{tr "ConfirmToDeleteServer"}}',deleteRequest,'/api/server/'+{{$server.ID}})">
2021-01-20 06:24:59 -05:00
< i class = "trash alternate outline icon" > < / i >
2019-12-20 10:58:09 -05:00
< / button >
< / div >
< / td >
2019-12-08 10:18:29 -05:00
< / tr >
{{end}}
< / tbody >
< / table >
< / div >
< / div >
2021-08-10 08:04:58 -04:00
{{template "component/server" .}}
2019-12-08 10:18:29 -05:00
{{template "common/footer" .}}
2024-07-12 10:29:11 -04:00
< script src = "https://unpkg.com/clipboard@2.0.11/dist/clipboard.min.js" > < / script >
2021-08-10 08:04:58 -04:00
< script >
var clipboard = new ClipboardJS('.ui.icon.green.mini.button');
2021-11-04 00:06:20 -04:00
const checkBoxList = document.querySelectorAll('tbody > tr > td > input.nezha-servers[type=checkbox]')
function checkAllServer() {
checkBoxList.forEach(cb => {
cb.checked = true
})
}
function forceUpdate() {
const servers = []
checkBoxList.forEach(cb => {
if (cb.checked) {
servers.push(parseInt(cb.value))
}
})
if (servers.length == 0) {
$.suiAlert({
2022-04-28 22:52:26 -04:00
title: '{{tr "NoServerSelected"}}',
2021-11-04 00:06:20 -04:00
description: '',
type: 'warning',
time: '2',
position: 'top-center',
});
return
}
$.post('/api/force-update', JSON.stringify(servers))
.then((resp) => {
if (resp.code == 200) {
$.suiAlert({
2022-04-28 22:52:26 -04:00
title: '{{tr "ExecutionResults"}}',
2021-11-04 00:06:20 -04:00
description: resp.message,
type: 'success',
time: '3',
position: 'top-center',
});
} else {
$.suiAlert({
title: '',
description: resp.message,
type: 'error',
time: '3',
position: 'top-center',
});
}
}).catch(err => {
$.suiAlert({
title: '',
description: err,
type: 'error',
time: '3',
position: 'top-center',
});
})
}
2022-09-16 12:08:27 -04:00
function batchEditServerGroup() {
let groupName = prompt('{{tr "InputServerGroupName"}}')
2024-10-04 11:33:40 -04:00
if (groupName === null) {
return
2022-09-16 12:08:27 -04:00
}
const servers = []
checkBoxList.forEach(cb => {
if (cb.checked) {
servers.push(parseInt(cb.value))
}
})
if (servers.length == 0) {
$.suiAlert({
title: '{{tr "NoServerSelected"}}',
description: '',
type: 'warning',
time: '2',
position: 'top-center',
});
return
}
$.post('/api/batch-update-server-group', JSON.stringify({ servers: servers, group: groupName }))
.then((resp) => {
if (resp.code == 200) {
$.suiAlert({
title: '{{tr "ExecutionResults"}}',
description: resp.message,
type: 'success',
time: '3',
position: 'top-center',
});
window.location.reload()
} else {
$.suiAlert({
title: '',
description: resp.message,
type: 'error',
time: '3',
position: 'top-center',
});
}
}).catch(err => {
$.suiAlert({
title: '',
description: err,
type: 'error',
time: '3',
position: 'top-center',
});
})
}
2023-06-13 12:23:47 -04:00
function batchDeleteServer() {
const servers = []
checkBoxList.forEach(cb => {
if (cb.checked) {
servers.push(parseInt(cb.value))
}
})
if (servers.length == 0) {
$.suiAlert({
title: '{{tr "NoServerSelected"}}',
description: '',
type: 'warning',
time: '2',
position: 'top-center',
});
return
}
showConfirm('{{tr "DeleteServer"}}', '{{tr "ConfirmToDeleteServer"}}', () => postJson('/api/batch-delete-server', servers), '')
}
2021-08-10 08:04:58 -04:00
< / script >
2022-04-28 15:24:52 -04:00
{{end}}