sysadmin_dashboard_gitlogs.html 6.48 KB
Newer Older
Carson Gee committed
1
<%inherit file="/main.html" />
2 3 4 5 6 7 8
<%!
    from django.core.urlresolvers import reverse
    from django.utils.translation import ugettext as _
    from django.utils.timezone import utc as UTC
    from util.date_utils import get_time_display, DEFAULT_DATE_TIME_FORMAT
    from django.conf import settings
%>
Carson Gee committed
9 10 11 12 13 14
<%namespace name='static' file='/static_content.html'/>

<%block name="headextra">
  <%static:css group='style-course'/>
  <script type="text/javascript" src="${static.url('js/vendor/flot/jquery.flot.js')}"></script>
  <script type="text/javascript" src="${static.url('js/vendor/flot/jquery.flot.axislabels.js')}"></script>
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
  <script>
      $(function() {
          $(".toggle-import-log").click(function(e) {
              var self = $(this);
              var id = self.data("import-log");
              $("#import-log-" + id).toggle({
                  duration: 200
              });
              if (self.html() === "[ + ]") {
                  self.html("[ &#8722; ]");
              } else {
                  self.html("[ + ]");
              }
              e.preventDefault();
          });
      });
  </script>
Carson Gee committed
32
</%block>
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
<%def name="pagination()">
    <div class="pagination">
        %if logs.has_previous():
            <span class="previous-page">
              <a href="?page=${logs.previous_page_number()}">
                ${_("previous")}
              </a>
            </span>
        %endif
        ${_("Page {current_page} of {total_pages}".format(
            current_page=logs.number,
            total_pages=logs.paginator.num_pages
        ))}
        %if logs.has_next():
            <span class="next-page">
              <a href="?page=${logs.next_page_number()}">
                ${_("next")}
              </a>
            </span>
        %endif
      </div>
</%def>
Carson Gee committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
<style type="text/css">
a.active-section {
	color: #551A8B;
}
.sysadmin-dashboard-content h2 a {
	margin-right: 1.2em;
}
table.stat_table {
	font-family: verdana,arial,sans-serif;
	font-size:11px;
	color:#333333;
	border-width: 1px;
	border-color: #666666;
	border-collapse: collapse;
}
table.stat_table th {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #dedede;
}
table.stat_table td {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #ffffff;
}
84 85 86
.import-log {
    display: none;
}
Carson Gee committed
87

88 89 90 91 92 93 94 95 96 97 98 99 100
.pagination, .page-status {
    text-align: center;
    padding: 12px 0 12px 0;
}

.pagination .previous-page {
    padding-right: 10px;
}

.pagination .next-page {
    padding-left: 10px;
}

Carson Gee committed
101 102 103 104 105 106 107 108
a.selectedmode { background-color: yellow; }

textarea {
  height: 200px;
}
</style>

<section class="container">
109
  <div class="sysadmin-dashboard-wrapper">
Carson Gee committed
110

111 112 113 114 115 116 117 118 119 120 121
    <section class="sysadmin-dashboard-content" style="margin-left:10pt;margin-top:10pt;margin-right:10pt;margin-bottom:20pt">
      <h1>${_('Sysadmin Dashboard')}</h1>
      <hr />
      <h2 class="instructor-nav">
        <a href="${reverse('sysadmin')}">${_('Users')}</a>
        <a href="${reverse('sysadmin_courses')}">${_('Courses')}</a>
        <a href="${reverse('sysadmin_staffing')}">${_('Staffing and Enrollment')}</a>
        ## Translators: refers to http://git-scm.com/docs/git-log
        <a href="${reverse('gitlogs')}" class="active-section">${_('Git Logs')}</a>
      </h2>
      <hr />
Carson Gee committed
122

123 124 125 126
      <form name="dashform" method="POST" action="${reverse('sysadmin')}">
        <input type="hidden" name="csrfmiddlewaretoken" value="${ csrf_token }">
        <input type="hidden" name="dash_mode" value="">
      </form>
Carson Gee committed
127

128
      ## Translators: refers to http://git-scm.com/docs/git-log
129
      <h3>${_('Git Logs')}</h3>
Carson Gee committed
130

131 132
      %if course_id is not None:
          ## Translators: Git is a version-control system; see http://git-scm.com/about
133
          <h2>${_('Recent git load activity for {course_id}').format(course_id=course_id) | h}</h2>
134 135 136 137 138
          %if error_msg:
              <h3>${_('Error')}:</h3>
              <p>${error_msg}</p>
          %endif
      %endif
Carson Gee committed
139

140 141 142 143 144
      %if len(logs):
          ${pagination()}

          <table class="stat_table" width="100%">
            <thead>
145
              <tr>
146 147 148 149
                <th width="15%">${_('Date')}</th>
                <th width="15%">${_('Course ID')}</th>
                ## Translators: Git is a version-control system; see http://git-scm.com/about
                <th>${_('Git Action')}</th>
150
              </tr>
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
            </thead>
            <tbody>
              %for index, cil in enumerate(logs):
                  <%
                      # Appropriate datetime string for current locale and timezone
                      date = get_time_display(cil.created.replace(tzinfo=UTC),
                                              DEFAULT_DATE_TIME_FORMAT, coerce_tz=settings.TIME_ZONE)
                  %>
                  <tr>
                    <td>${date}</td>
                    <td>
                      <a href="${reverse('gitlogs_detail', kwargs={'course_id': unicode(cil.course_id)})}">
                        ${cil.course_id | h}
                      </a>
                    </td>
                    <td>
                      %if course_id is not None:
                          <a class="toggle-import-log" data-import-log="${index}" href="#">[ + ]</a>
                      %endif
                      ${cil.git_log}
Brandon DeRosier committed
171 172
                    </td>
                  </tr>
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200

                  ## Show the full log of the latest import if viewing logs for a specific course
                  %if course_id is not None:
                      <tr class="import-log" id="import-log-${index}">
                        <td colspan="3">
                          <pre>
                            ${cil.import_log | h}
                          </pre>
                        </td>
                      </tr>
                  %endif
              %endfor
            </tbody>
          </table>

          ${pagination()}
      %else:
          <div class="page-status">
            %if not course_id:
                # If viewing all logs there are no logs available, let the user know
                ## Translators: git is a version-control system; see http://git-scm.com/about
                ${_('No git import logs have been recorded.')}
            %else:
                # If viewing a single course and there are no logs available, let the user know
                ## Translators: git is a version-control system; see http://git-scm.com/about
                ${_('No git import logs have been recorded for this course.')}
            %endif
          </div>
Brandon DeRosier committed
201
      %endif
202

203 204
    </section>
  </div>
Carson Gee committed
205
</section>