sis_import.mustache 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <%
  2. # Copyright (C) 2011 - present Instructure, Inc.
  3. #
  4. # This file is part of Canvas.
  5. #
  6. # Canvas is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU Affero General Public License as published by the Free
  8. # Software Foundation, version 3 of the License.
  9. #
  10. # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License along
  16. # with this program. If not, see <http://www.gnu.org/licenses/>.
  17. %>
  18. <% add_crumb t(:sis_import_crumb, "SIS Import") %>
  19. <% @active_tab = "sis_import" %>
  20. <% content_for :page_title do %>{{#t}}SIS Import{{/t}}
  21. <% end %>
  22. <div>
  23. <h1>{{#t}}SIS Import{{/t}}</h1>
  24. <% if can_do(@account, @current_user, :import_sis) %>
  25. <div class="sis_messages" style="<%= hidden %>">
  26. <div class="ui-state-error sis_error_message" style="padding: 0.5em 1em"></div>
  27. <%= link_to t(:try_import_again_link, "Try import again"), account_sis_import_path %>
  28. </div>
  29. <div class="form" style="<%= hidden if @current_batch && @current_batch.importing? %>">
  30. <%= form_tag account_sis_imports_path(@account.id), :multipart => true, :id => "sis_importer" do %>
  31. <p class="instruction"><%= mt(:select_file_instructions,
  32. "Select the zip file that you want imported. \n" +
  33. "For a description of how to generate these zip files, [please see this documentation](%{url}).",
  34. :url => "/doc/api/file.sis_csv.html") %></p>
  35. <div>
  36. <input type="file" name="attachment" style="font-size: 1.2em;"/>
  37. <p/>
  38. <label for="import_type"><%= before_label(t(:import_type_label, "Import type")) %></label>
  39. <select id="import_type" name="import_type">
  40. <% SisBatch.valid_import_types.each do |type, data| %>
  41. <option value="<%= type %>"
  42. <% if data[:default] %> selected
  43. <% end %>><%= data[:name].respond_to?(:call) ? data[:name].call : data[:name] %></option>
  44. <% end %>
  45. </select>
  46. <p/>
  47. <div id="batch_check">
  48. <input type="checkbox" name="batch_mode" value="1" id="batch_mode"/>
  49. <label for="batch_mode">{{#t}}This is a full batch update{{/t}}</label>
  50. <br>
  51. <p class='instruction'>
  52. <%= mt(:batch_import_instructions,
  53. "If selected, this will delete everything for this term, which includes all courses and enrollments that are not in the selected import file above. \nSee the documentation for details.") %>
  54. </p>
  55. <label id="batch_mode_term_id_label" for="batch_mode_term_id">
  56. {{#t}}Term:{{/t}}
  57. </label>
  58. <select id="batch_mode_term_id" name="batch_mode_term_id">
  59. <%= options_from_collection_for_select(@terms, :id, :name, @terms.first.try(:id)) %>
  60. </select>
  61. </div>
  62. <div id="stickiness_options">
  63. <div id="override_sis_stickiness_container">
  64. <input type="checkbox" name="override_sis_stickiness" value="1" id="override_sis_stickiness"/>
  65. <label for="override_sis_stickiness">{{#t}}Override UI changes{{/t}}</label>
  66. <p class='instruction'>
  67. <%= mt(:override_sis_stickiness_instructions,
  68. "By default, UI changes have priority over SIS import changes; for a number of fields, the SIS import will not change that field's data if an admin has changed that field through the UI. If you select this option, this SIS import will override UI changes. \nSee the documentation for details.") %>
  69. </p>
  70. <div id="add_sis_stickiness_container" style="padding-left: 20px;">
  71. <input type="checkbox" name="add_sis_stickiness" value="1" id="add_sis_stickiness"/>
  72. <label for="add_sis_stickiness">{{#t}}Process as UI changes{{/t}}</label>
  73. <p class='instruction'>
  74. <%= mt(:add_sis_stickiness_instructions,
  75. "With this option selected, changes made through this SIS import will be processed as if they are UI changes, preventing subsequent non-overriding SIS imports from changing the fields changed here.") %>
  76. </p>
  77. </div>
  78. <div id="clear_sis_stickiness_container" style="padding-left: 20px;">
  79. <input type="checkbox" name="clear_sis_stickiness" value="1" id="clear_sis_stickiness"/>
  80. <label for="clear_sis_stickiness">{{#t}}Clear UI-changed state{{/t}}</label>
  81. <p class='instruction'>
  82. <%= mt(:clear_sis_stickiness_instructions,
  83. "With this option selected, all fields in all records touched by this SIS import will be able to be changed in future non-overriding SIS imports.") %>
  84. </p>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <div>
  90. <button type="submit" class="submit_button btn btn-primary">{{#t}}Process Data{{/t}}</button>
  91. </div>
  92. <div class="clear"></div>
  93. <% end %>
  94. </div>
  95. <% end %>
  96. <div class="progress_bar_holder" style="<%= hidden unless @current_batch && @current_batch.importing? %> margin-top: 10px;">
  97. <div class="copy_progress"></div>
  98. <div class="progress_message">{{#t}}The import process has started! This can take awhile if there is a lot to import. You can leave the page and come back.{{/t}}</div>
  99. </div>
  100. <div id="import_log_holder" style="<%= hidden %>">
  101. <h2>{{#t}}Import Progress Log{{/t}}</h2>
  102. <div id="import_log"></div>
  103. </div>
  104. <% pending_batch_count = @account.sis_batches.needs_processing.count %>
  105. <% pending_batch_count -= 1 if @current_batch && @current_batch.created? %>
  106. <% if pending_batch_count > 0 %>
  107. <div class="pending_batches" style="margin-top: 20px">
  108. <h2>{{#t}}Pending Batches{{/t}}</h2>
  109. <p><%= t(:pending_batches_count, {:one => "%{count} batch waiting to be processed.", :other => "%{count} batches waiting to be processed."}, :count => pending_batch_count) %></p>
  110. </div>
  111. <% end %>
  112. <% if show_last_batch %>
  113. <div class="last_batch" style="margin-top: 20px;">
  114. <h2>{{#t}}Last Batch{{/t}}</h2>
  115. <p><%= t(:started_at_message, "Started: %{started_at}", :started_at => datetime_string(@last_batch.created_at)) %>
  116. <br/>
  117. <% if @last_batch.diffing_data_set_identifier %>
  118. <p><%= t("Data Set Identifier: %{data_set_id}", data_set_id: @last_batch.diffing_data_set_identifier) %></p>
  119. <% if @last_batch.data[:diffed_against_sis_batch_id] %>
  120. <p>{{#t}}Incremental update successfully generated against a previous SIS Import.{{/t}}</p>
  121. <% end %>
  122. <% end %>
  123. <% if @last_batch.workflow_state == 'imported' %>
  124. {{#t}}All SIS data was successfully imported.{{/t}}
  125. <%= print_counts @last_batch %>
  126. <% elsif @last_batch.workflow_state == 'imported_with_messages' %>
  127. {{#t}}The SIS data was imported but with these messages:{{/t}}
  128. <% if @last_batch.errors_attachment_id %>
  129. <p>{{#t}}Download the complete list of errors and warnings here.{{/t}}
  130. <%= link_to "<i class='icon-download'></i>".html_safe,
  131. file_download_url(@last_batch.errors_attachment,
  132. verifier: @last_batch.errors_attachment.uuid,
  133. download: '1',
  134. download_frd: '1'),
  135. 'aria-label' => t('Download errors_attchment'),
  136. 'title' => t('Download errors_attchment') %></p>
  137. <% end %>
  138. <%= print_messages(@last_batch) %>
  139. <%= print_counts @last_batch %>
  140. <% elsif @last_batch.workflow_state == 'failed' %>
  141. {{#t}}There was an error importing your SIS data. No records were imported.{{/t}}
  142. <% elsif @last_batch.workflow_state == 'failed_with_messages' %>
  143. {{#t}}The SIS data was imported but with these messages:{{/t}}
  144. <% if @last_batch.errors_attachment_id %>
  145. <p>{{#t}}Download the complete list of errors and warnings here.{{/t}}
  146. <%= link_to "<i class='icon-download'></i>".html_safe,
  147. file_download_url(@last_batch.errors_attachment,
  148. verifier: @last_batch.errors_attachment.uuid,
  149. download: '1',
  150. download_frd: '1'),
  151. 'aria-label' => t('Download errors_attchment'),
  152. 'title' => t('Download errors_attchment') %></p>
  153. <% end %>
  154. {{#t}}No SIS records were imported. The import failed with these messages:{{/t}}
  155. <%= print_messages(@last_batch) %>
  156. <% elsif @last_batch.workflow_state == 'aborted' %>
  157. {{#t}}The previous SIS batch was aborted{{/t}}
  158. <%= print_messages(@last_batch) %>
  159. <% end %>
  160. </p>
  161. </div>
  162. <% end %>
  163. </div>
  164. <% js_bundle :sis_import %>