|
| 1 | +<% content_for(:title) { "School Import Job #{page.resource.job_id}" } %> |
| 2 | + |
| 3 | +<header class="main-content__header"> |
| 4 | + <h1 class="main-content__page-title"> |
| 5 | + <%= content_for(:title) %> |
| 6 | + </h1> |
| 7 | + <div> |
| 8 | + <%= link_to( |
| 9 | + "Download CSV", |
| 10 | + admin_school_import_result_path(page.resource, format: :csv), |
| 11 | + class: "button button--primary", |
| 12 | + style: "margin-right: 10px;" |
| 13 | + ) %> |
| 14 | + <%= link_to( |
| 15 | + "Back to Import History", |
| 16 | + admin_school_import_results_path, |
| 17 | + class: "button" |
| 18 | + ) %> |
| 19 | + </div> |
| 20 | +</header> |
| 21 | + |
| 22 | +<section class="main-content__body"> |
| 23 | + <dl> |
| 24 | + <dt class="attribute-label">Job ID</dt> |
| 25 | + <dd class="attribute-data"><%= page.resource.job_id %></dd> |
| 26 | + |
| 27 | + <dt class="attribute-label">User</dt> |
| 28 | + <dd class="attribute-data"> |
| 29 | + <% user_field = UserInfoField.new(:user_id, page.resource.user_id, "show") %> |
| 30 | + <%= user_field.user_display %> |
| 31 | + </dd> |
| 32 | + |
| 33 | + <dt class="attribute-label">Status</dt> |
| 34 | + <dd class="attribute-data"> |
| 35 | + <% status_field = StatusField.new(:job_id, page.resource.job_id, "show") %> |
| 36 | + <span class="status-badge <%= status_field.status_class %>"> |
| 37 | + <%= status_field.job_status.upcase %> |
| 38 | + </span> |
| 39 | + </dd> |
| 40 | + |
| 41 | + <dt class="attribute-label">Created At</dt> |
| 42 | + <dd class="attribute-data"><%= page.resource.created_at.strftime("%B %d, %Y at %I:%M %p") %></dd> |
| 43 | + |
| 44 | + <% if page.resource.updated_at != page.resource.created_at %> |
| 45 | + <dt class="attribute-label">Updated At</dt> |
| 46 | + <dd class="attribute-data"><%= page.resource.updated_at.strftime("%B %d, %Y at %I:%M %p") %></dd> |
| 47 | + <% end %> |
| 48 | + </dl> |
| 49 | + |
| 50 | + <% results = page.resource.results %> |
| 51 | + <% if results.present? %> |
| 52 | + <dl> |
| 53 | + <dt class="attribute-label">Results</dt> |
| 54 | + <dd class="attribute-data"> |
| 55 | + <% results_field = ResultsSummaryField.new(:results, page.resource.results, "show") %> |
| 56 | + <%= render "fields/results_summary_field/show", field: results_field %> |
| 57 | + </dd> |
| 58 | + </dl> |
| 59 | + |
| 60 | + <% successful = results['successful'] || [] %> |
| 61 | + <% failed = results['failed'] || [] %> |
| 62 | + |
| 63 | + <% if successful.any? %> |
| 64 | + <h2 style="margin-top: 2rem;">Successful Imports (<%= successful.count %>)</h2> |
| 65 | + <table class="collection-data"> |
| 66 | + <thead> |
| 67 | + <tr> |
| 68 | + <th>School Name</th> |
| 69 | + <th>School Code</th> |
| 70 | + <th>School ID</th> |
| 71 | + <th>Owner Email</th> |
| 72 | + <th>Actions</th> |
| 73 | + </tr> |
| 74 | + </thead> |
| 75 | + <tbody> |
| 76 | + <% successful.each do |school| %> |
| 77 | + <tr> |
| 78 | + <td><%= school['name'] %></td> |
| 79 | + <td><strong><%= school['code'] %></strong></td> |
| 80 | + <td><code><%= school['id'] %></code></td> |
| 81 | + <td><%= school['owner_email'] %></td> |
| 82 | + <td> |
| 83 | + <%= link_to "View School", admin_school_path(school['id']), class: "button button--small" if school['id'] %> |
| 84 | + </td> |
| 85 | + </tr> |
| 86 | + <% end %> |
| 87 | + </tbody> |
| 88 | + </table> |
| 89 | + <% end %> |
| 90 | + |
| 91 | + <% if failed.any? %> |
| 92 | + <h2 style="margin-top: 2rem;">Failed Imports (<%= failed.count %>)</h2> |
| 93 | + <table class="collection-data"> |
| 94 | + <thead> |
| 95 | + <tr> |
| 96 | + <th>School Name</th> |
| 97 | + <th>Owner Email</th> |
| 98 | + <th>Error Code</th> |
| 99 | + <th>Error Message</th> |
| 100 | + </tr> |
| 101 | + </thead> |
| 102 | + <tbody> |
| 103 | + <% failed.each do |school| %> |
| 104 | + <tr> |
| 105 | + <td><%= school['name'] %></td> |
| 106 | + <td><%= school['owner_email'] %></td> |
| 107 | + <td><code><%= school['error_code'] %></code></td> |
| 108 | + <td style="color: red;"><%= school['error'] %></td> |
| 109 | + </tr> |
| 110 | + <% end %> |
| 111 | + </tbody> |
| 112 | + </table> |
| 113 | + |
| 114 | + <div class="field-unit" style="margin-top: 2rem;"> |
| 115 | + <h3>Common Error Codes</h3> |
| 116 | + <dl> |
| 117 | + <dt><code>OWNER_NOT_FOUND</code></dt> |
| 118 | + <dd>The owner email doesn't correspond to an existing account. The owner needs to create a Code Editor for Education account first.</dd> |
| 119 | + |
| 120 | + <dt><code>OWNER_ALREADY_CREATOR</code></dt> |
| 121 | + <dd>This owner has already created a school. Each person can only create one school.</dd> |
| 122 | + |
| 123 | + <dt><code>SCHOOL_VALIDATION_FAILED</code></dt> |
| 124 | + <dd>The school data failed validation. Check the error message for details about which fields are invalid.</dd> |
| 125 | + </dl> |
| 126 | + </div> |
| 127 | + <% end %> |
| 128 | + <% else %> |
| 129 | + <div class="flash flash-alert"> |
| 130 | + <p>No results available yet. The job may still be running or may have failed to store results.</p> |
| 131 | + </div> |
| 132 | + <% end %> |
| 133 | +</section> |
| 134 | + |
| 135 | +<style> |
| 136 | + .status-badge { |
| 137 | + padding: 4px 8px; |
| 138 | + border-radius: 4px; |
| 139 | + font-weight: bold; |
| 140 | + font-size: 0.9em; |
| 141 | + } |
| 142 | + .status-completed { |
| 143 | + background-color: #d4edda; |
| 144 | + color: #155724; |
| 145 | + } |
| 146 | + .status-failed { |
| 147 | + background-color: #f8d7da; |
| 148 | + color: #721c24; |
| 149 | + } |
| 150 | + .status-running { |
| 151 | + background-color: #fff3cd; |
| 152 | + color: #856404; |
| 153 | + } |
| 154 | + .status-queued { |
| 155 | + background-color: #d1ecf1; |
| 156 | + color: #0c5460; |
| 157 | + } |
| 158 | + .status-unknown { |
| 159 | + background-color: #e2e3e5; |
| 160 | + color: #383d41; |
| 161 | + } |
| 162 | + .button--small { |
| 163 | + padding: 4px 8px; |
| 164 | + font-size: 0.875em; |
| 165 | + } |
| 166 | +</style> |
0 commit comments