πŸ“„ Documentation: Upload.cshtml (AccountingImaging View)

Path: IrbyImaging/Views/AccountingImaging/Upload.cshtml


πŸ“‘ Table of Contents

  1. Overview & Purpose
  2. File Structure & Location
  3. Dependencies & Technologies
  4. Key Functional Areas
    4.1 Razor Directives & ViewBag
    4.2 Styles Section
    4.3 Upload Form Markup
    4.4 Loading Overlay (Spinner)
    4.5 JavaScript & Plugins
  5. View Models & Data Models
  6. API Endpoints & Controller Actions
  7. Helper Methods & Utilities
  8. Third‑party Integrations
  9. Sequence Diagram (UML)
  10. Usage Examples
  11. Conclusion

1. Overview & Purpose

This Razor View renders a file upload interface for the AccountingImaging module.
Users can browse or drag‑and‑drop multiple documents, submit them to the server, and see a loading spinner until the upload completes.

Key goals:

  • Intuitive drag‑and‑drop or browse upload
  • Progress feedback via overlay spinner
  • Multi-file support
  • Redirect to document preview on success

2. File Structure & Location

Folder File
IrbyImaging/Views/AccountingImaging/ Upload.cshtml

This view is served by the AccountingImagingController (or similar) within the ASP.NET MVC application.


3. Dependencies & Technologies

Category Library/Tool
Front‑end Framework HTML5, CSS3, Bootstrap 4+
JavaScript Library jQuery
Upload Plugin Dropzone.js
Spinner Library spin.js
ASP.NET MVC Razor syntax, Html.BeginForm helper

4. Key Functional Areas

4.1 Razor Directives & ViewBag

@{
    ViewBag.Title     = "Form File Upload";
    ViewBag.pTitle    = "Form File Upload";
    ViewBag.pageTitle = "Forms";
    var category      = ViewBag.category;
}
  • ViewBag.Title / pTitle / pageTitle: Sets page headers & SEO
  • category: Passed from Controller to filter or group uploads

4.2 Styles Section

@section styles{
  <!-- Dropzone CSS -->
  <link href="~/assets/libs/dropzone/min/dropzone.min.css" rel="stylesheet" />
}
  • Loads Dropzone’s stylesheet for drag‑and‑drop styling.

4.3 Upload Form Markup

@using (Html.BeginForm(
    "UploadDocs",
    "AccountingImaging",
    new { category = category },
    FormMethod.Post,
    null,
    new { enctype = "multipart/form-data" }
)) {
    <div class="card">
      <div class="card-body">
        <h4 class="card-title mb-4">Upload Documents</h4>
        <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
              style="height:400%"
            />
          </div>
        </div>
        <div class="row justify-content-end">
          <button id="submitbtn" type="submit" class="btn btn-primary">
            Upload Documents
          </button>
        </div>
      </div>
    </div>
}
  • Html.BeginForm: Posts to UploadDocs action of AccountingImagingController
  • enctype="multipart/form-data": Required for file uploads
  • <input type="file" multiple>: Allows selecting or dropping multiple files

4.4 Loading Overlay (Spinner)

<div id="loading">
  <div id="loadingcontent">
    <p id="loadingspinner">
      <br/> Upload in progress. Please wait.....
    </p>
  </div>
</div>
<style>
  #loading {
    display: none;
    position: fixed; top:0; left:0;
    width:100%; height:100%;
    background: rgba(255,255,255,0.8);
    z-index:1000;
  }
  /* Center the spinner text */
  #loadingspinner {
    display: table-cell;
    vertical-align: middle;
    text-align: center;
    font-size: larger;
    padding-top:80px;
  }
</style>
  • Hidden by default (display:none)
  • Revealed on submit click to block UI

4.5 JavaScript & Plugins

  1. Core Libraries

    <script src="~/assets/libs/jquery/jquery.min.js"></script>
    <script src="~/assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
    
  2. Dropzone Configuration

    <script>
    function myParamName() { return "file"; }
    
    Dropzone.options.dropzoneForm = {
      paramName: myParamName,
      autoDiscover: false,
      autoProcessQueue: false,
      addRemoveLinks: true,
      uploadMultiple: true,
      parallelUploads: 100,
    
      init: function() {
        const dz = this;
        $("#uploadfile").click(()=> dz.processQueue());
        dz.on("queuecomplete", ()=> dz.removeAllFiles());
        dz.on("successmultiple", ()=> dz.removeAllFiles());
        dz.on("complete", file => {
          dz.removeAllFiles();
          window.location.href =
            '@Url.Action("DocPreview","Imaging")?fileName=' + file.name;
        });
      },
      accept: (file, done) => done()
    };
    </script>
    
  3. Loading Spinner (spin.js)

    <script src="~/assets/js/spin.js"></script>
    <script>
    $(function(){
      $("#submitbtn").click(function(){
        $("#loading").fadeIn();
        const opts = { lines:19, length:28, width:7, scale:0.05, color:'#11467e', animation:'spinner-line-shrink' };
        new Spinner(opts).spin(document.getElementById('loading'));
      });
    });
    </script>
    

5. View Models & Data Models

This view uses no strongly‑typed model. All data is passed via ViewBag or Form Data.
The form posts IFormFile[] file (or equivalent) to the controller action.


6. API Endpoints & Controller Actions

Action Method URL Description
AccountingImaging.UploadDocs /AccountingImaging/UploadDocs?category={category} Handles multi-file upload via form post.
Imaging.DocPreview /Imaging/DocPreview?fileName={name} Displays uploaded document preview.

7. Helper Methods & Utilities

Helper Location Purpose
myParamName() Inline JS Dynamically sets Dropzone paramName.
Spinner(opts) spin.js Renders a UI spinner on top of the page.

8. Third‑party Integrations

  • Dropzone.js: Elegant drag‑and‑drop upload UI
  • spin.js: Lightweight animated spinner
  • Bootstrap: Responsive layout & components
  • jQuery: DOM manipulation & event handling

9. Sequence Diagram (UML)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  User β”‚       β”‚ Browser β”‚       β”‚  Web App   β”‚     β”‚ File Storage β”‚
β””β”€β”€β”€β”¬β”€β”€β”€β”˜       β””β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚               β”‚                    β”‚                    β”‚
    β”‚ Selects files β”‚                    β”‚                    β”‚
    └──────────────▢│                    β”‚                    β”‚
                    β”‚ Show spinner      β”‚                    β”‚
                    └──────────────────▢│                    β”‚
                    β”‚                   β”‚ Save files & meta  β”‚
                    β”‚                   └──────────────────▢│
                    β”‚                   β”‚                    β”‚
                    β”‚                   β”‚  Return success    β”‚
                    β”‚β—€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚
    β”‚ Hide spinner  β”‚                                       β”‚
    β”‚ Redirect to   β”‚                                       β”‚
    β”‚ DocPreview    β”‚                                       β”‚
    └──────────────▢│                                       β”‚

10. Usage Examples

  1. Browse & Upload

    • Click Browse or Drop Files
    • Select multiple images/PDFs
    • Hit Upload Documents
    • See loading overlay
    • Redirect to preview on finish
  2. Drag‑and‑Drop

    • Drag files into the input area (if Dropzone config is enabled)
    • Click the custom Upload button to process the queue

11. Conclusion

This Upload.cshtml view delivers a rich UI for multi‑file uploads within the AccountingImaging context. Leveraging Dropzone.js for convenience and spin.js for progress feedback, it ensures a seamless user experience. By posting to the UploadDocs action, files are handled server‑side and then previewed via the DocPreview route.


Happy Uploading! πŸ“€βœ¨