<commit_before><% @page_title = 'Upload Your Files - Publish and Preserve your Data' %>
<%= render partial: 'stash_engine/shared/dataset_steps_nav' %>

<h1 class="o-heading__level1">Upload Your Files <span class="t-upload__heading-optional">(optional)</span></h1>

<p>
  Size limits: <%= filesize(current_tenant.max_file_size) %> per file,
  <%= filesize(current_tenant.max_total_version_size) %> in total. To upload larger datasets,
  <%= link_to "contact us", contact_us_url, class: 'o-link__primary' %>.
</p>

<h2 class="t-upload__choose-heading--active">Step 1: Choose your files</h2>
<div>
  <%= form_for @file, html: {multipart: true, id: 'fileupload'} do |f| %>
    <div class="c-choose">
      <%= f.hidden_field :resource_id %>
      <div id="upload_bg" class="c-choose__drop o-drop">
        Drag and drop files here
      </div>
      <div class="c-choose__or">or</div>
      <div class="c-choose__label">
        <%= label_tag(:upload_upload, "Choose Files", class: 'c-input__file-label') %>
        <%= file_field_tag 'upload[upload]', multiple: true, class: 'c-input__file' %>
      </div>
    </div>
  <% end %>
</div>
<div class="t-upload__container">
  <h2 class="t-upload__choose-heading" id="upload_tweaker_head">Step 2: Upload your files</h2>
  <%= button_to 'undo all changes', revert_file_upload_path(resource_id: @resource.id), method: :patch, remote: true,
                class: "o-button__undo", form_class: 'o-button__inline-form', id: 'revert_all' %>
</div>
<div class="c-upload">
  <div id="upload_list">
    <% if @resource.file_uploads.count < 1 %>
      <span id="no_chosen">No files chosen</span>
    <% else %>
      <%= render partial: "stash_engine/file_uploads/uploaded_file", collection: @uploads %>
    <% end %>
  </div>

  <div id="upload_total">
    <span id="upload_total_all">Total:</span><br/><br/>
    <span id="upload_in_version">In this version:</span>
  </div>

  <div class="c-upload__upload-complete-text" id="upload_complete" style="display: none;">Upload complete.</div>

  <div class="bad_upload" id="over_single_size"></div>

  <div class="bad_upload" id="over_upload_size" style="display: none;">
    <p>
      The files you've added are larger than <%= filesize(current_tenant.max_submission_size) %> which is the upload
      limit for a single submission.  Please remove some files to bring your upload size under this limit.
    </p>
  </div>
  <div class="bad_upload" id="over_files_size" style="display: none;">
    <p>
      Your file size is over <%= filesize(current_tenant.max_total_version_size) %>. You must remove some files to bring your
      total under this limit before you can upload these files.
    </p>
  </div>

  <div>
    <p id="confirm_text_upload" style="display: none;"><span><%= check_box_tag 'confirm_to_upload', 'yes', false, id: 'confirm_to_upload' %></span> I confirm that no Personal Health Information or Sensitive Data are being uploaded with this submission.</p>
    <button id="upload_all" type="button" disabled class="o-button__plain-text2 confirm_upload" style="display: none;">Upload</button>
    <button id="cancel_all" type="button" class="o-button__plain-text2" style="display: none;" >Cancel all</button>
  </div>

  <div id="revert_all">
    <%# button_to 'undo all changes', revert_file_upload_path(resource_id: @resource.id), method: :patch, remote: true,
                  class: "o-button__plain-text2", form_class: 'o-button__inline-form' %>
    <!-- <button id="revert_all" type="button" class="o-button__plain-text2">Revert all files</button> -->
  </div>
</div>

<%= render partial: 'stash_engine/file_uploads/dropped_file' %>

<div class="o-dataset-nav">
  <%= link_to 'Back to Describe Dataset', metadata_entry_pages_find_or_create_path(resource_id: params[:id]), class: 'o-button__icon-left', role: 'button', id: 'describe_back' %>
  <%= link_to 'Proceed to Review', review_resource_path(params[:id]), class: 'o-button__icon-right', role: 'button', id: 'proceed_review' %>
</div>

<script type="text/javascript" charset="utf-8">
  var uploadInProgress = false;<commit_msg>add ui class for disabled upload button<commit_after><% @page_title = 'Upload Your Files - Publish and Preserve your Data' %>
<%= render partial: 'stash_engine/shared/dataset_steps_nav' %>

<h1 class="o-heading__level1">Upload Your Files <span class="t-upload__heading-optional">(optional)</span></h1>

<p>
  Size limits: <%= filesize(current_tenant.max_file_size) %> per file,
  <%= filesize(current_tenant.max_total_version_size) %> in total. To upload larger datasets,
  <%= link_to "contact us", contact_us_url, class: 'o-link__primary' %>.
</p>

<h2 class="t-upload__choose-heading--active">Step 1: Choose your files</h2>
<div>
  <%= form_for @file, html: {multipart: true, id: 'fileupload'} do |f| %>
    <div class="c-choose">
      <%= f.hidden_field :resource_id %>
      <div id="upload_bg" class="c-choose__drop o-drop">
        Drag and drop files here
      </div>
      <div class="c-choose__or">or</div>
      <div class="c-choose__label">
        <%= label_tag(:upload_upload, "Choose Files", class: 'c-input__file-label') %>
        <%= file_field_tag 'upload[upload]', multiple: true, class: 'c-input__file' %>
      </div>
    </div>
  <% end %>
</div>
<div class="t-upload__container">
  <h2 class="t-upload__choose-heading" id="upload_tweaker_head">Step 2: Upload your files</h2>
  <%= button_to 'undo all changes', revert_file_upload_path(resource_id: @resource.id), method: :patch, remote: true,
                class: "o-button__undo", form_class: 'o-button__inline-form', id: 'revert_all' %>
</div>
<div class="c-upload">
  <div id="upload_list">
    <% if @resource.file_uploads.count < 1 %>
      <span id="no_chosen">No files chosen</span>
    <% else %>
      <%= render partial: "stash_engine/file_uploads/uploaded_file", collection: @uploads %>
    <% end %>
  </div>

  <div id="upload_total">
    <span id="upload_total_all">Total:</span><br/><br/>
    <span id="upload_in_version">In this version:</span>
  </div>

  <div class="c-upload__upload-complete-text" id="upload_complete" style="display: none;">Upload complete.</div>

  <div class="bad_upload" id="over_single_size"></div>

  <div class="bad_upload" id="over_upload_size" style="display: none;">
    <p>
      The files you've added are larger than <%= filesize(current_tenant.max_submission_size) %> which is the upload
      limit for a single submission.  Please remove some files to bring your upload size under this limit.
    </p>
  </div>
  <div class="bad_upload" id="over_files_size" style="display: none;">
    <p>
      Your file size is over <%= filesize(current_tenant.max_total_version_size) %>. You must remove some files to bring your
      total under this limit before you can upload these files.
    </p>
  </div>

  <div>
    <p id="confirm_text_upload" style="display: none;"><span><%= check_box_tag 'confirm_to_upload', 'yes', false, id: 'confirm_to_upload' %></span> I confirm that no Personal Health Information or Sensitive Data are being uploaded with this submission.</p>
    <button id="upload_all" type="button" disabled class="o-button__submit confirm_upload" style="display: none;">Upload</button>
    <button id="cancel_all" type="button" class="o-button__submit" style="display: none;" >Cancel all</button>
  </div>

  <div id="revert_all">
    <%# button_to 'undo all changes', revert_file_upload_path(resource_id: @resource.id), method: :patch, remote: true,
                  class: "o-button__plain-text2", form_class: 'o-button__inline-form' %>
    <!-- <button id="revert_all" type="button" class="o-button__plain-text2">Revert all files</button> -->
  </div>
</div>

<%= render partial: 'stash_engine/file_uploads/dropped_file' %>

<div class="o-dataset-nav">
  <%= link_to 'Back to Describe Dataset', metadata_entry_pages_find_or_create_path(resource_id: params[:id]), class: 'o-button__icon-left', role: 'button', id: 'describe_back' %>
  <%= link_to 'Proceed to Review', review_resource_path(params[:id]), class: 'o-button__icon-right', role: 'button', id: 'proceed_review' %>
</div>

<script type="text/javascript" charset="utf-8">
  var uploadInProgress = false;
{'fraction_non_alphanumeric': 0.16243282852955546, 'fraction_numerical': 0.003419638495359062, 'mean_word_length': 4.582140422631221, 'pattern_counts': {'":': 0, '<': 181, '<?xml version=': 0, '>': 179, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6613236', 'n_tokens_mistral': 2839, 'n_tokens_neox': 2697, 'n_words': 655}