<!-- views/action_status.ejs -->
<% include partials/header %>

<h2>Cluster</h2>
<h2><%- cluster %>
    <h3> :: <%- region %> </h3>
    <h3> :: <%- deployment %> </h3>
    <h3> :: <%- action %> </h3>
    <h3> :: <%- id %> </h3>
    <h3 id="status"> :: <%- status %> </h3>
    <h3> :: <%- error %></h3>
</h2>
<script>

    window.setInterval(function () {
        // alert('REFRESH');
        // $("#output").html($("#output").html() +<br> test</br> );
        jQuery.get("/api/<%- region %>/<%- deployment %>/<%- cluster %>/action/<%- action %>/<%- id %>/logs", function (data) {
            console.log("ACTIONEJS LOOP");

            console.log(data);

            data.forEach(function (log, index) {
                console.log(log);
                console.log(index);
                var id = 'line' + index;
                if(!$("#" + id).length)
                {

                    $("#output").append(
                        '<span id="'+ id + '" class="' + log.kind +  '">' +
                                '<span>'+ (index+1) + '</span>' +
                                '<span>'+ ' ' + log.date + '</span>' +
                                '<span>'+ ' ' + log.msg + '</span>' +
                         '</span><br />');
                }   

            });


          
            // alert( "Load was performed." );
        });

        jQuery.get("/api/<%- region %>/<%- deployment %>/<%- cluster %>/action/<%- action %>/<%- id %>/status", function (data) {
            console.log(data);
            $("#status").html(data.status);
            // alert( "Load was performed." );
        });

    }, 3000);
</script>

<pre class="language-bash">
<code id="output" class="language-bash">

</code>
</pre>


<!-- <span class="error">Bulidinbg ...</span> -->
<!-- <span class="info">Bulidinbg ...</span> -->
<!--  -->
    <!-- <%= message.msg %> -->

<% include partials/footer %>