{{ define "kas/database_backup.htm" }}
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <title>数据库备份 - 后台管理 - 看丽人</title>
    <script type="text/javascript">
        const ISGOKEEP = true;
    </script>
    {{ template "_common.htm" .}}
    <script type="text/javascript">
        LoadMemberInfo();
    </script>
</head>

<body>
    {{ template "kas/_header.htm" .}}
    <main role="main">
        <div class="album py-3 bg-light">
            <div class="container">
                {{ template "kas/_nav.htm" .}}
                <div class="alert alert-dark border-bottom"><a href="/kas/settings">系统设置</a> > 数据库备份</div>
                <form class="form-signin" id="frmSettings">
                    <div class="form-group">
                        <label for="iptBackuptime">备份时间</label>
                        <input name="backup_time" type="text" id="iptBackuptime" class="form-control" disabled
                            value="每天凌晨3点">
                    </div>
                    <div class="form-group">
                        <label for="iptBackuptime">备份目录</label>
                        <input name="backup_dir" type="text" id="iptBackupdir" class="form-control" disabled
                            value="./data/backup">
                    </div>
                    <div class="py-2">
                        <button class="btn btn-danger btn-block" type="button" id="btnBackup">手动备份</button>
                    </div>
                </form>
            </div>
        </div>

    </main>
    {{ template "kas/_footer.htm" .}}
    <script type="text/javascript">
        var gokeep_token = GetCookie(TokenName())
        if (gokeep_token == null) {
            DirectTo("/kas");
        }

        $("#btnBackup").click(function (event) {
            $('#btnBackup').addClass('disabled');
            $.ajax({
                url: '/api/v1/auth/database_backup',
                type: 'GET',
                dataType: 'json',
                beforeSend: function (xhr) {
                    xhr.setRequestHeader('Authorization', 'Bearer ' + gokeep_token);
                },
            }).done(function (data) {
                $('#btnBackup').removeClass('disabled');
                if (data.code === 0) {
                    ShowMsg("成功备份内容到./data/backup中");
                    return;
                } else {
                    ShowMsg("备份失败");
                    return;
                }
            });
        })

    </script>
</body>

</html>
{{ end }}