📁 IrbyImaging/Views/LegalImaging/Upload.cshtml

Description
This Razor view provides a user interface for uploading one or more files within the Legal Imaging area of the IrbyImaging application. It leverages native HTML file inputs, optional Dropzone.js integration, a loading overlay with a spinner, and posts the files to the UploadDocs action on the LegalImaging controller.


📖 Table of Contents

  1. Overview & Purpose
  2. Key Functional Areas
  3. Dependencies & Technologies
  4. View Model & Routing Context
  5. UI Structure & Markup
  6. JavaScript Behavior & Helpers
  7. Loading Overlay & Spinner
  8. Sample Usage Flow
  9. Conclusion & Next Steps

🧐 Overview & Purpose

This view, Upload.cshtml, is designed to let legal staff upload supporting documents (e.g., PDFs, images) in bulk. Key objectives:

  • Browse or drag‑and‑drop multiple files simultaneously.
  • Show a progress spinner during upload.
  • Post data to the back‑end endpoint LegalImaging/UploadDocs with an optional category parameter.
  • Optionally integrate with Dropzone.js for an improved drag‑and‑drop experience.

🧩 Key Functional Areas

Area Description
Page Metadata Sets page title, layout, and breadcrumb via ViewBag.
File Upload Form Native <input type="file" multiple> wrapped in Html.BeginForm.
Dropzone.js Integration (Commented out) configuration to enable advanced drag‑and‑drop.
Loading Overlay & Spinner Displays progress feedback during upload using [spin.js].
Scripts & Styles References to jQuery, Bootstrap, Dropzone, spin.js, and custom app scripts.

🔧 Dependencies & Technologies

  • ASP.NET MVC Razor
  • jQuery (~/assets/libs/jquery/jquery.min.js)
  • Bootstrap 4 (~/assets/libs/bootstrap/js/bootstrap.bundle.min.js)
  • MetisMenu, SimpleBar, Waves (page utilities)
  • Dropzone.js (CDN) — optional, commented out
  • spin.js (~/assets/js/spin.js)
  • Custom CSS (~/assets/libs/dropzone/min/dropzone.min.css)

📐 View Model & Routing Context

This view does not expose a strongly‑typed model. Instead, it uses:

@{
    var category = ViewBag.category;    // Category passed via query string or controller
}

The form posts to:

@using (Html.BeginForm(
    actionName: "UploadDocs",
    controllerName: "LegalImaging",
    routeValues: new { category = category },
    method: FormMethod.Post,
    htmlAttributes: new { enctype = "multipart/form-data" }))
{ 
    <!-- file inputs & submit button -->
}

👀 UI Structure & Markup

  1. Header & Layout

    ViewBag.Title = "Form File Upload";
    Layout       = "~/Views/Shared/_LegalLayout.cshtml";
    
  2. Styles Section

    @section styles{
      <link href="~/assets/libs/dropzone/min/dropzone.min.css" rel="stylesheet" />
    }
    
  3. File Picker

    <div class="row mb-4">
      <i class="display-5 text-muted bx bxs-cloud-upload"></i>
      <label class="col-form-label col-lg-3">Browse or Drop Files to Upload...</label>
      <div class="col-lg-12">
        <input class="form-control" name="file" type="file" multiple />
      </div>
    </div>
    
  4. Submit Button

    <button id="submitbtn" type="submit" class="btn btn-primary">
      Upload Documents
    </button>
    
  5. Loading Overlay

    <div id="loading">
      <div id="loadingcontent">
        <p id="loadingspinner">
          Upload in progress. Please wait.....
        </p>
      </div>
    </div>
    

🛠️ JavaScript Behavior & Helpers

1. Dropzone Configuration (Optional)

Currently commented out. Enable by uncommenting and matching the form to .dropzone.

Dropzone.options.dropzoneForm = {
  autoProcessQueue: false,
  uploadMultiple: true,
  parallelUploads: 100,
  init: function () {
    var dz = this;
    $("#uploadfile").click(() => dz.processQueue());
    dz.on("complete", file => {
        window.location.href = 
          '@Url.Action("DocPreview","Imaging")?fileName=' + file.name;
    });
  }
};

2. Loading Spinner via spin.js

$(function () {
  $("#submitbtn").click(function () {
    $("#loading").fadeIn();
    var opts = {
      lines: 19, length: 28, width: 7, speed: 2.0,
      color: '#11467e', animation: 'spinner-line-shrink'
    };
    new Spinner(opts).spin(document.getElementById('loading'));
  });
});

🔄 Sample Usage Flow

  1. User navigates to /LegalImaging/Upload?category=Contracts.
  2. View renders the file picker UI.
  3. User clicks Browse, selects multiple files.
  4. User clicks Upload Documents (#submitbtn).
  5. Loading overlay appears with spinner.
  6. Form posts multipart data to POST /LegalImaging/UploadDocs?category=Contracts.
  7. Controller handles files, saves to disk/database, then returns a redirect or JSON.
  8. View hides spinner or redirects to a preview page.

✅ Conclusion & Next Steps

  • Extend this view by re‑enabling Dropzone.js for richer UX.
  • Implement server‑side validation or size/type checks in UploadDocs.
  • Enhance error handling: display validation messages on the page.
  • Integrate with a progress bar or percentage indicator via AJAX.

🚀 Result: A flexible, multi‑file upload form tailor‑made for the Legal Imaging workflow in IrbyImaging!