<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Push service</title>
</head>
<body>
        <h1>Push service</h1>
    % if enable_channel_creation:
    <section>
        <h2>Create a New Channel</h2>
        <form method="post" action="create">
            <button type="submit">Create Channel</button>
        </form>
    </section>
    % endif
    % if not is_admin:
    <section>
        <h2>Access to channels</h2>
        <p>Use a channel name you known to access it.</p>
        <p>E.g.: <a href="${base_url}channel_name">${base_url}<i>channel_name</i></a></p>
    </section>
    % endif
    % if enable_admin:
    % if is_admin:
    <section>
        <h2>Channels</h2>
        <ul>
      % for channel in channels:
          <li><a href="${channel}">${channel}</a> - <button onclick="confirmDelete('${channel}');">delete</button></li>
      % endfor
        </ul>
        <script>
        function confirmDelete(channel) {
            if (confirm("Are you sure you want to delete this channel?")) {
                fetch(channel+'/delete')
                .then(()=>{window.location.reload();});
            }
            return false;
        }
        </script>
    </section>
    % endif
    <section>
    % if is_admin:
        <a href="logout">Admin logout</a>
    % else:
        <a href="login">Admin login</a>
    % endif
    % endif
    </section>
</body>
</html>
