133 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			133 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
{{define "dashboard/server"}}
 | 
						|
{{template "common/header" .}}
 | 
						|
{{template "common/menu" .}}
 | 
						|
<div class="nb-container">
 | 
						|
    <div class="ui container">
 | 
						|
        <div class="ui grid">
 | 
						|
            <div class="right floated right aligned twelve wide column">
 | 
						|
                <button class="ui right labeled nezha-primary-btn icon button" onclick="addOrEditServer()"><i
 | 
						|
                        class="add icon"></i> {{tr "AddServer"}}
 | 
						|
                </button>
 | 
						|
                <button class="ui right labeled nezha-primary-btn icon button" onclick="forceUpdate()"><i
 | 
						|
                        class="arrow alternate circle up outline icon"></i> {{tr "ForceUpdate"}}
 | 
						|
                </button>
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
        <table class="ui very basic table">
 | 
						|
            <thead>
 | 
						|
                <tr>
 | 
						|
                    <th><button onclick="checkAllServer()" class="ui mini nezha-primary-btn button">{{tr "SelectAll"}}</button></th>
 | 
						|
                    <th>ID({{tr "DisplayIndex"}})</th>
 | 
						|
                    <th>{{tr "Name"}}</th>
 | 
						|
                    <th>{{tr "ServerGroup"}}</th>
 | 
						|
                    <th>IP</th>
 | 
						|
                    <th>{{tr "VersionNumber"}}</th>
 | 
						|
                    <th>{{tr "Secret"}}</th>
 | 
						|
                    <th>{{tr "OneKeyInstall"}}</th>
 | 
						|
                    <th>{{tr "Note"}}</th>
 | 
						|
                    <th>{{tr "Administration"}}</th>
 | 
						|
                </tr>
 | 
						|
            </thead>
 | 
						|
            <tbody>
 | 
						|
                {{range $server := .Servers}}
 | 
						|
                <tr>
 | 
						|
                    <td><input type="checkbox" class="nezha-servers" value="{{$server.ID}}" /></td>
 | 
						|
                    <td>{{$server.ID}}({{$server.DisplayIndex}})</td>
 | 
						|
                    <td>{{$server.Name}}</td>
 | 
						|
                    <td>{{$server.ServerGroup}}</td>
 | 
						|
                    <td>{{$server.Host.IP}}</td>
 | 
						|
                    <td>{{$server.Host.Version}}</td>
 | 
						|
                    <td>{{$server.Secret}}</td>
 | 
						|
                    <td>
 | 
						|
                        <button class="ui icon green mini button"
 | 
						|
                            data-clipboard-text="{{if $.Conf.GRPCHost}}curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./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}}"
 | 
						|
                            data-tooltip="{{tr "ClickToCopyTheInstallationCommand"}}">
 | 
						|
                            <i class="linux icon"></i>
 | 
						|
                        </button>
 | 
						|
                        <button class="ui icon green mini button"
 | 
						|
                            data-clipboard-text="{{if $.Conf.GRPCHost}}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}}"
 | 
						|
                            data-tooltip="{{tr "ClickToCopyTheInstallationCommand"}}">
 | 
						|
                            <i class="windows icon"></i>
 | 
						|
                        </button>
 | 
						|
                    </td>
 | 
						|
                    <td style="word-break: break-word;">{{$server.Note}}</td>
 | 
						|
                    <td>
 | 
						|
                        <div class="ui mini icon buttons">
 | 
						|
                            <button class="ui button" onclick="connectToServer({{$server.ID}})">
 | 
						|
                                <i class="terminal icon"></i>
 | 
						|
                            </button>
 | 
						|
                            <button class="ui button" onclick="addOrEditServer({{$server.Marshal}})">
 | 
						|
                                <i class="edit icon"></i>
 | 
						|
                            </button>
 | 
						|
                            <button class="ui button"
 | 
						|
                                onclick="showConfirm('{{tr "DeleteServer"}}}','{{tr "ConfirmToDeleteThisServer"}}',deleteRequest,'/api/server/'+{{$server.ID}})">
 | 
						|
                                <i class="trash alternate outline icon"></i>
 | 
						|
                            </button>
 | 
						|
                        </div>
 | 
						|
                    </td>
 | 
						|
                </tr>
 | 
						|
                {{end}}
 | 
						|
            </tbody>
 | 
						|
        </table>
 | 
						|
    </div>
 | 
						|
</div>
 | 
						|
{{template "component/server" .}}
 | 
						|
{{template "common/footer" .}}
 | 
						|
<script src="https://fastly.jsdelivr.net/npm/clipboard@2.0.8/dist/clipboard.min.js"></script>
 | 
						|
<script>
 | 
						|
    var clipboard = new ClipboardJS('.ui.icon.green.mini.button');
 | 
						|
    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({
 | 
						|
                title: '{{tr "NoServerSelected"}}',
 | 
						|
                description: '',
 | 
						|
                type: 'warning',
 | 
						|
                time: '2',
 | 
						|
                position: 'top-center',
 | 
						|
            });
 | 
						|
            return
 | 
						|
        }
 | 
						|
        $.post('/api/force-update', JSON.stringify(servers))
 | 
						|
            .then((resp) => {
 | 
						|
                if (resp.code == 200) {
 | 
						|
                    $.suiAlert({
 | 
						|
                        title: '{{tr "ExecutionResults"}}',
 | 
						|
                        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',
 | 
						|
                });
 | 
						|
            })
 | 
						|
    }
 | 
						|
</script>
 | 
						|
{{end}}
 |