1*169d7bccSPatrick Williams{% extends "base.html" %} 2*169d7bccSPatrick Williams{% load projecttags %} 3*169d7bccSPatrick Williams{% load humanize %} 4*169d7bccSPatrick Williams{% load static %} 5*169d7bccSPatrick Williams 6*169d7bccSPatrick Williams{% block title %} Import Builds from eventlogs - Toaster {% endblock %} 7*169d7bccSPatrick Williams 8*169d7bccSPatrick Williams{% block pagecontent %} 9*169d7bccSPatrick Williams 10*169d7bccSPatrick Williams<div class="container-fluid"> 11*169d7bccSPatrick Williams <div id="overlay" class="hide"> 12*169d7bccSPatrick Williams <div class="spinner"> 13*169d7bccSPatrick Williams <div class="fa-spin"> 14*169d7bccSPatrick Williams </div> 15*169d7bccSPatrick Williams </div> 16*169d7bccSPatrick Williams </div> 17*169d7bccSPatrick Williams <div class="row"> 18*169d7bccSPatrick Williams <div class="col-md-12"> 19*169d7bccSPatrick Williams <div class="page-header"> 20*169d7bccSPatrick Williams <div class="row"> 21*169d7bccSPatrick Williams <div class="col-md-6"> 22*169d7bccSPatrick Williams <h1>Import command line builds</h1> 23*169d7bccSPatrick Williams </div> 24*169d7bccSPatrick Williams {% if import_all %} 25*169d7bccSPatrick Williams <div class="col-md-6"> 26*169d7bccSPatrick Williams <button id="import_all" type="button" class="btn btn-primary navbar-btn navbar-right"> 27*169d7bccSPatrick Williams <span class="glyphicon glyphicon-upload" style="vertical-align: top;"></span> Import All 28*169d7bccSPatrick Williams </button> 29*169d7bccSPatrick Williams </div> 30*169d7bccSPatrick Williams {% endif %} 31*169d7bccSPatrick Williams </div> 32*169d7bccSPatrick Williams </div> 33*169d7bccSPatrick Williams {% if messages %} 34*169d7bccSPatrick Williams <div class="row-fluid" id="empty-state-{{table_name}}"> 35*169d7bccSPatrick Williams {% for message in messages %} 36*169d7bccSPatrick Williams <div class="alert alert-danger">{{message}}</div> 37*169d7bccSPatrick Williams {%endfor%} 38*169d7bccSPatrick Williams </div> 39*169d7bccSPatrick Williams {% endif %} 40*169d7bccSPatrick Williams <div class="row"> 41*169d7bccSPatrick Williams <h4 style="margin-left: 15px;"><strong>Import eventlog file</strong></h4> 42*169d7bccSPatrick Williams <form method="POST" enctype="multipart/form-data" action="{% url 'cmdlines' %}" id="form_file"> 43*169d7bccSPatrick Williams {% csrf_token %} 44*169d7bccSPatrick Williams <div class="col-md-6" style="padding-left: 20px;"> 45*169d7bccSPatrick Williams <div class="row"> 46*169d7bccSPatrick Williams <input type="hidden" value="{{dir}}" name="dir"> 47*169d7bccSPatrick Williams <div class="col-md-3"> {{ form.eventlog_file}} </div> 48*169d7bccSPatrick Williams </div> 49*169d7bccSPatrick Williams <div class="row" style="padding-top: 10px;"> 50*169d7bccSPatrick Williams <div class="col-md-6"> 51*169d7bccSPatrick Williams <button id="file_import" type="submit" disabled="disabled" class="btn btn-default navbar-btn" > 52*169d7bccSPatrick Williams <span class="glyphicon glyphicon-upload" style="vertical-align: top;"></span> Import 53*169d7bccSPatrick Williams </button> 54*169d7bccSPatrick Williams </div> 55*169d7bccSPatrick Williams </div> 56*169d7bccSPatrick Williams </div> 57*169d7bccSPatrick Williams </form> 58*169d7bccSPatrick Williams </div> 59*169d7bccSPatrick Williams 60*169d7bccSPatrick Williams <div class="row" style="padding-top: 20px;"> 61*169d7bccSPatrick Williams <div class="col-md-8 "> 62*169d7bccSPatrick Williams <h4><strong>Eventlogs from existing build directory: </strong> 63*169d7bccSPatrick Williams <a href="#" data-toggle="tooltip" title="{{dir}}"> 64*169d7bccSPatrick Williams <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-info-circle" viewBox="0 0 16 16" data-toggle="tooltip"> 65*169d7bccSPatrick Williams <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/> 66*169d7bccSPatrick Williams <path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0"/> 67*169d7bccSPatrick Williams </svg> 68*169d7bccSPatrick Williams </a> 69*169d7bccSPatrick Williams </h4> 70*169d7bccSPatrick Williams {% if files %} 71*169d7bccSPatrick Williams <div class="table-responsive"> 72*169d7bccSPatrick Williams <table class="table col-md-6 table-bordered table-hover" id="eventlog-table" style="border-collapse: collapse;"> 73*169d7bccSPatrick Williams <thead> 74*169d7bccSPatrick Williams <tr class="row"> 75*169d7bccSPatrick Williams <th scope="col">Name</th> 76*169d7bccSPatrick Williams <th scope="col">Size</th> 77*169d7bccSPatrick Williams <th scope="col">Action</th> 78*169d7bccSPatrick Williams </tr> 79*169d7bccSPatrick Williams </thead> 80*169d7bccSPatrick Williams <tbody> 81*169d7bccSPatrick Williams {% for file in files %} 82*169d7bccSPatrick Williams <tr class="row" style="height: 48px;"> 83*169d7bccSPatrick Williams <th scope="row" class="col-md-4" style="vertical-align: middle;"> 84*169d7bccSPatrick Williams <input type="hidden" value="{{file.name}}" name="{{file.name}}">{{file.name}} 85*169d7bccSPatrick Williams </th> 86*169d7bccSPatrick Williams <td class="col-md-4 align-middle" style="vertical-align: middle;">{{file.size|filesizeformat}}</td> 87*169d7bccSPatrick Williams <td class="col-md-4 align-middle" style="vertical-align: middle;"> 88*169d7bccSPatrick Williams {% if file.imported == True and file.build_id is not None %} 89*169d7bccSPatrick Williams <a href="{% url 'builddashboard' file.build_id %}">Build Details</a> 90*169d7bccSPatrick Williams {% elif request.session.file == file.name or request.session.all_builds %} 91*169d7bccSPatrick Williams <a data-toggle="tooltip" title="Build in progress"> 92*169d7bccSPatrick Williams <span class="glyphicon glyphicon-upload" style="font-size: 18px; color:grey"></span> 93*169d7bccSPatrick Williams </a> 94*169d7bccSPatrick Williams {%else%} 95*169d7bccSPatrick Williams <a onclick="_ajax_update('{{file.name}}', false, '{{dir}}')" data-toggle="tooltip" title="Import File"> 96*169d7bccSPatrick Williams <span class="glyphicon glyphicon-upload" style="font-size: 18px;"></span> 97*169d7bccSPatrick Williams </a> 98*169d7bccSPatrick Williams {%endif%} 99*169d7bccSPatrick Williams </td> 100*169d7bccSPatrick Williams </tr> 101*169d7bccSPatrick Williams {% endfor%} 102*169d7bccSPatrick Williams </tbody> 103*169d7bccSPatrick Williams </table> 104*169d7bccSPatrick Williams </div> 105*169d7bccSPatrick Williams {% else %} 106*169d7bccSPatrick Williams <div class="row-fluid" id="empty-state-{{table_name}}"> 107*169d7bccSPatrick Williams <div class="alert alert-info">Sorry - no files found</div> 108*169d7bccSPatrick Williams </div> 109*169d7bccSPatrick Williams {%endif%} 110*169d7bccSPatrick Williams </div> 111*169d7bccSPatrick Williams </div> 112*169d7bccSPatrick Williams </div> 113*169d7bccSPatrick Williams </div> 114*169d7bccSPatrick Williams</div> 115*169d7bccSPatrick Williams 116*169d7bccSPatrick Williams<link rel="stylesheet" href="{% static 'css/jquery.dataTables-1.13.8.min.css' %}" type='text/css'/> 117*169d7bccSPatrick Williams<script src="{% static 'js/jquery.dataTables-1.13.8.min.js' %}"> </script> 118*169d7bccSPatrick Williams<script> 119*169d7bccSPatrick Williams 120*169d7bccSPatrick Williamsfunction _ajax_update(file, all, dir){ 121*169d7bccSPatrick Williams function getCookie(name) { 122*169d7bccSPatrick Williams var cookieValue = null; 123*169d7bccSPatrick Williams if (document.cookie && document.cookie !== '') { 124*169d7bccSPatrick Williams var cookies = document.cookie.split(';'); 125*169d7bccSPatrick Williams for (var i = 0; i < cookies.length; i++) { 126*169d7bccSPatrick Williams var cookie = jQuery.trim(cookies[i]); 127*169d7bccSPatrick Williams // Does this cookie string begin with the name we want? 128*169d7bccSPatrick Williams if (cookie.substring(0, name.length + 1) === (name + '=')) { 129*169d7bccSPatrick Williams cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); 130*169d7bccSPatrick Williams break; 131*169d7bccSPatrick Williams } 132*169d7bccSPatrick Williams } 133*169d7bccSPatrick Williams } 134*169d7bccSPatrick Williams return cookieValue; 135*169d7bccSPatrick Williams } 136*169d7bccSPatrick Williams var csrftoken = getCookie('csrftoken'); 137*169d7bccSPatrick Williams 138*169d7bccSPatrick Williams function csrfSafeMethod(method) { 139*169d7bccSPatrick Williams // these HTTP methods do not require CSRF protection 140*169d7bccSPatrick Williams return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method)); 141*169d7bccSPatrick Williams } 142*169d7bccSPatrick Williams $.ajaxSetup({ 143*169d7bccSPatrick Williams beforeSend: function (xhr, settings) { 144*169d7bccSPatrick Williams if (!csrfSafeMethod(settings.type) && !this.crossDomain) { 145*169d7bccSPatrick Williams xhr.setRequestHeader("X-CSRFToken", csrftoken); 146*169d7bccSPatrick Williams } 147*169d7bccSPatrick Williams } 148*169d7bccSPatrick Williams }); 149*169d7bccSPatrick Williams 150*169d7bccSPatrick Williams $.ajax({ 151*169d7bccSPatrick Williams url:'/toastergui/cmdline/', 152*169d7bccSPatrick Williams type: "POST", 153*169d7bccSPatrick Williams data: {file: file, all: all, dir: dir}, 154*169d7bccSPatrick Williams success:function(data){ 155*169d7bccSPatrick Williams if (data['response']=='building'){ 156*169d7bccSPatrick Williams location.reload() 157*169d7bccSPatrick Williams } else { 158*169d7bccSPatrick Williams window.location = '/toastergui/builds/' 159*169d7bccSPatrick Williams } 160*169d7bccSPatrick Williams }, 161*169d7bccSPatrick Williams complete:function(data){ 162*169d7bccSPatrick Williams }, 163*169d7bccSPatrick Williams error:function (xhr, textStatus, thrownError){ 164*169d7bccSPatrick Williams console.log('fail'); 165*169d7bccSPatrick Williams } 166*169d7bccSPatrick Williams }); 167*169d7bccSPatrick Williams} 168*169d7bccSPatrick Williams 169*169d7bccSPatrick Williams$('#import_all').on('click', function(){ 170*169d7bccSPatrick Williams _ajax_update("{{files | safe}}", true, "{{dir | safe}}"); 171*169d7bccSPatrick Williams}); 172*169d7bccSPatrick Williams 173*169d7bccSPatrick Williams 174*169d7bccSPatrick Williams$('#import_page').hide(); 175*169d7bccSPatrick Williams 176*169d7bccSPatrick Williams$(function () { 177*169d7bccSPatrick Williams $('[data-toggle="tooltip"]').tooltip() 178*169d7bccSPatrick Williams}) 179*169d7bccSPatrick Williams 180*169d7bccSPatrick Williams 181*169d7bccSPatrick Williams$("#id_eventlog_file").change(function(){ 182*169d7bccSPatrick Williams $('#file_import').prop("disabled", false); 183*169d7bccSPatrick Williams $('#file_import').addClass('btn-primary') 184*169d7bccSPatrick Williams $('#file_import').removeClass('btn-default') 185*169d7bccSPatrick Williams}) 186*169d7bccSPatrick Williams 187*169d7bccSPatrick Williams$(document).ajaxStart(function(){ 188*169d7bccSPatrick Williams $('#overlay').removeClass('hide'); 189*169d7bccSPatrick Williams window.setTimeout( 190*169d7bccSPatrick Williams function() { 191*169d7bccSPatrick Williams window.location = '/toastergui/builds/' 192*169d7bccSPatrick Williams }, 10000) 193*169d7bccSPatrick Williams}); 194*169d7bccSPatrick Williams 195*169d7bccSPatrick Williams$( "#form_file").on( "submit", function( event ) { 196*169d7bccSPatrick Williams $('#overlay').removeClass('hide'); 197*169d7bccSPatrick Williams window.setTimeout( 198*169d7bccSPatrick Williams function() { 199*169d7bccSPatrick Williams window.location = '/toastergui/builds/' 200*169d7bccSPatrick Williams }, 10000) 201*169d7bccSPatrick Williams}); 202*169d7bccSPatrick Williams 203*169d7bccSPatrick Williams$(document).ready( function () { 204*169d7bccSPatrick Williams $('#eventlog-table').DataTable({order: [[0, 'desc']], "pageLength": 50}); 205*169d7bccSPatrick Williams}); 206*169d7bccSPatrick Williams 207*169d7bccSPatrick Williams</script> 208*169d7bccSPatrick Williams 209*169d7bccSPatrick Williams{% endblock %} 210