📁 IrbyImaging/Views/HRImaging/Upload.cshtml Documentation
File Path
IrbyImaging/Views/HRImaging/Upload.cshtml
📚 Table of Contents
- Overview & Purpose
- Layout & Page Metadata
- CSS & Styles
- File Upload Form
- Loading Spinner Overlay
- JavaScript & Client‑Side Logic
- Dependencies & Technologies
- Sequence Diagram (UML)
- Usage Example
- Conclusion
🔍 Overview & Purpose
This Razor Upload.cshtml view in the HRImaging folder provides a user interface for uploading one or more documents (images, PDFs, etc.) to the server.
- Intended Use: HR personnel navigating to the “Forms” section can drop or browse files and click “Upload Documents” to send them to the
HRImagingController.UploadDocsaction. - Key Features:
- Multi-file selection (
multiple) - Progress spinner overlay during submission
- Optional Dropzone.js configuration for drag‐and‐drop
- Redirect to preview after upload
- Multi-file selection (
🏗️ Layout & Page Metadata
@{
ViewBag.Title = "Form File Upload";
ViewBag.pTitle = "Form File Upload";
ViewBag.pageTitle = "Forms";
Layout = "~/Views/Shared/_Layout.cshtml";
var category = ViewBag.category;
}
- ViewBag.Title, pTitle, pageTitle: Populate page headers & navigation breadcrumbs.
- Layout: Points to the shared master page (
_Layout.cshtml). - category: Passed via route/query, forwarded into the form action.
🎨 CSS & Styles
@section styles {
<!-- Dropzone.css for drag‑and‑drop styling -->
<link href="~/assets/libs/dropzone/min/dropzone.min.css" rel="stylesheet" type="text/css" />
}
- The view imports Dropzone CSS.
- Inlined style for the loading overlay:
#loading {
display: none;
position: fixed; left: 0; top: 0;
width: 100%; height: 100%;
background: rgba(255,255,255,0.8);
z-index: 1000;
}
#loadingcontent {
display: table; width: 100%; height: 100%;
}
#loadingspinner {
display: table-cell; vertical-align: middle;
text-align: center; font-size: larger;
}
📤 File Upload Form
@using (Html.BeginForm("UploadDocs", "HRImaging",
new { category = category },
FormMethod.Post,
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"
style="height:400%"
name="file"
type="file"
multiple />
</div>
</div>
<!-- Submit Button -->
<div class="row justify-content-end">
<button
id="submitbtn"
type="submit"
class="btn btn-primary">
Upload Documents
</button>
</div>
</div>
</div>
}
- Html.BeginForm: Targets
HRImagingController.UploadDocs(category). enctype="multipart/form-data": Enables file posting.<input name="file" type="file" multiple>: Allows multiple selection.
⏳ Loading Spinner Overlay
A full‑page overlay displays while the form is being posted:
<div id="loading">
<div id="loadingcontent">
<p id="loadingspinner">
<br/> Upload in progress. Please wait.....
</p>
</div>
</div>
- #loading is initially hidden.
- Toggled via JavaScript on submit to present a “please wait” message and spinner.
💻 JavaScript & Client‑Side Logic
Dropzone Integration
Note: Current markup does not attach the Dropzone form, but the scripts are present for future drag&drop support.
Dropzone.options.dropzoneForm = {
autoDiscover: false,
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 100,
addRemoveLinks: true,
init: function() {
var myDropzone = this;
$("#uploadfile").click(function () {
myDropzone.processQueue();
});
myDropzone.on("complete", function (file) {
window.location.href =
'@Url.Action("DocPreview","Imaging")?fileName=' + file.name;
});
}
};
- paramName: Set dynamically via
myParamName()→"file". - processQueue(): Triggered by a custom #uploadfile button.
- Callbacks:
complete: Redirects toImagingController.DocPreview.
Spin.js Integration
<script type="text/javascript" src="~/assets/js/spin.js"></script>
<script>
$(function () {
$("#submitbtn").click(function () {
$("#loading").fadeIn();
var opts = {
lines: 19, length: 28, width: 7, scale: 0.05,
corners: 1, speed: 2.0, color: '#11467e',
animation: 'spinner-line-shrink'
};
new Spinner(opts).spin(document.getElementById('loading'));
});
});
</script>
- On Submit, toggles the overlay and instantiates a Spin.js spinner.
🔗 Dependencies & Technologies
| Category | Library / File | Purpose |
|---|---|---|
| CSS Framework | Bootstrap | Grid, cards, buttons |
| JS Framework | jQuery | DOM manipulation, event binding |
| Menu & Sidebar | MetisMenu | Collapsible side menu |
| Custom Scrollbars | SimpleBar | Styled scrollbars |
| Animation Effects | node-waves | Ripple effects on buttons |
| Drag‑and‑Drop | Dropzone.js | (Optional) file drop support |
| Spinner | Spin.js | Loading spinner overlay |
| ASP.NET MVC Helpers | Html.BeginForm, Url.Action, ViewBag |
Razor view helpers |
📈 Sequence Diagram (UML)
sequenceDiagram
autonumber
participant User
participant UploadView as Upload.cshtml
participant HRCtrl as HRImagingController
participant DiskService
participant ImCtrl as ImagingController
User->>UploadView: Select files & click Submit
UploadView->>HRCtrl: POST /HRImaging/UploadDocs (files)
HRCtrl->>DiskService: Save files to storage
DiskService-->>HRCtrl: Success
HRCtrl->>UploadView: Return View or Redirect
HRCtrl->>ImCtrl: RedirectToAction("DocPreview", fileName)
ImCtrl-->>User: Displays preview page
🚀 Usage Example
- Navigate to the Upload page (e.g.
/HRImaging/Upload?category=Onboarding). - Browse or Drag & Drop one or more files.
- Click “Upload Documents”.
- Spinner overlay appears.
- Files are posted to
HRImagingController.UploadDocs.
- Upon completion, you may be redirected to a document preview.
<form method="post" enctype="multipart/form-data"
action="/HRImaging/UploadDocs?category=Onboarding">
<input name="file" type="file" multiple />
<button type="submit">Upload Documents</button>
</form>
✅ Conclusion
This Upload.cshtml view provides a rich, user‑friendly file‑upload experience for HR imaging:
- Clear UI with Bootstrap cards and icons.
- Progress feedback via spin.js overlay.
- Extensible Dropzone.js snippet for future drag‑and‑drop enhancements.
Use as the front‑end for document ingestion in the HR imaging workflow.