{{template "header" .}}

<div class="alert alert-dismissible" id="common-alert" role="alert" style="display: none">
    <p></p>
    <button type="button" class="btn-close" onclick="($('#common-alert').hide())"></button>
</div>

<div class="container px-5 py-5 my-5">
    <div class="container">
        <h2>Google Disk Info:</h2>
        <p>{{.GDiskInfo}}</p>
    </div>
    <div class="container">
        <h2>Template Generator:</h2>
        <h4>Template folder: {{.GDisk.TemplateFolder}} | ID: {{.GDisk.TemplateFolderID}}</h4>

        {{range .GDiskTemplateFolder}}
            <p>{{.Name}} | Size: {{.Size}} bytes | Event: {{.Event}} | <a href="{{.File}}">Download URL</a></p>
        {{end}}


        <h4>Save folder: {{.GDisk.SaveFolder}} | ID: {{.GDisk.SaveFolderID}}</h4>

        {{range .GDiskSaveFolder}}
            <p>{{.Name}} | Size: {{.Size}} bytes | Event: {{.Event}} | <a href="{{.File}}">Download URL</a></p>
        {{end}}

    </div>

</div>

<script>
    $(function () {
        var token = window.location.search
        if (token.length === 0) {
            return
        }
        var alert = $('#common-alert');
        $.ajax({
            url: "/gdisk/saveToken" + token,
            type: 'POST',
            dataType: 'json',
            success: function (result) {
                location.replace("/");
            },
            error: function (result) {
                alert.addClass('alert-danger');
                alert.show();
                alert.children('p').html(result.responseText);
            }
        })
    })
</script>

<script src="https://accounts.google.com/gsi/client" async defer></script>
{{template "footer" .}}

