📄 UploadVehicles.cshtml Documentation
Welcome to the comprehensive documentation for the UploadVehicles.cshtml Razor view, part of the IrbyImaging project. This view provides a user-friendly interface to upload vehicle data files and seamlessly integrates client‑side widgets, loading spinners, and a Dropzone-based file upload pipeline.
📑 Table of Contents
- Overview & Purpose
- File Structure & Location
- Dependencies & Technologies
- ViewBag Properties
- Styles Section
- Upload Form Markup
- Dropzone Integration
- Loading Spinner & Custom CSS
- JavaScript & Helper Methods
- API Endpoints Overview
- Sequence Diagram
- Usage Examples
- Conclusion
🌐 1. Overview & Purpose
This Razor view renders a Vehicle File Upload page:
- Presents a Bootstrap card UI for selecting or dragging-and-dropping files.
- Uses Dropzone.js (optional) for enhanced drag‑drop UX.
- Shows a spinner overlay (via Spin.js) during upload.
- Posts file(s) to the
UploadVehiclesaction of theImagingcontroller. - Redirects to a document preview on success.
Intended Use:
Administrators or automated processes upload CSV, Excel or other vehicle data files for processing in the imaging workflow.
📂 2. File Structure & Location
IrbyImaging/
└─ Views/
└─ Imaging/
└─ UploadVehicles.cshtml ← This file
- Location:
~/Views/Imaging/UploadVehicles.cshtml - Layout: Inherits from
~/Views/Shared/_Layout.cshtml
🧩 3. Dependencies & Technologies
| Technology | Purpose |
|---|---|
| Razor (CSHTML) | MVC view engine |
| Bootstrap | Responsive UI & components |
| jQuery | DOM manipulation & event handling |
| Dropzone.js | Drag‑drop file uploads |
| Spin.js | Loading spinner overlay |
| MetisMenu, SimpleBar, Waves | Sidebar/menu & UI effects |
🏷️ 4. ViewBag Properties
| Key | Value | Usage |
|---|---|---|
ViewBag.Title |
"Vehicle File Upload" |
Browser page title |
ViewBag.pTitle |
"Vehicle File Upload" |
Parent/UI heading |
ViewBag.pageTitle |
"Vehicle" |
Secondary heading/context |
🎨 5. Styles Section
@section styles{
<!-- Dropzone plugin CSS -->
<link href="~/assets/libs/dropzone/min/dropzone.min.css" rel="stylesheet" />
}
- @section styles: Injects Dropzone CSS into the shared layout.
📑 6. Upload Form Markup
@using (Html.BeginForm("UploadVehicles", "Imaging", FormMethod.Post,
new { enctype = "multipart/form-data" }))
{
<div class="card">
<div class="card-body">
<h4 class="card-title mb-4">Upload Vehicle Data</h4>
<div class="row mb-8">
<label class="col-form-label col-lg-1">
Browse or Drop Files to Upload...
</label>
<div class="col-lg-6">
<input class="form-control" style="height:100px"
name="file" type="file" />
</div>
</div>
<div class="row justify-content-end">
<div class="col-lg-12">
<button id="submitbtn" type="submit"
class="btn btn-primary">
Upload
</button>
</div>
</div>
</div>
</div>
}
- File Input: Single/multiple file selection.
- Submit Button: Triggers postback and shows loader.
🛠️ 7. Dropzone Integration
The view includes a Dropzone config, though the <form> does not reference dropzoneForm by default. To enable:
- Uncomment the Dropzone script in the view or include manually.
- Add
class="dropzone"andid="dropzoneForm"to<form>. - Configure
Dropzone.options.dropzoneForm:
Dropzone.options.dropzoneForm = {
paramName: myParamName, // → "file"
autoProcessQueue: false,
uploadMultiple: true,
parallelUploads: 100,
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;
});
}
};
- Helper:
myParamName()returns the field name"file".
⏳ 8. Loading Spinner & Custom CSS
CSS
#loading {
display: none;
position: fixed; top: 0; left: 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;
padding-top: 80px;
}
HTML Overlay
<div id="loading">
<div id="loadingcontent">
<p id="loadingspinner">
<br/> Upload in progress. Please wait...
</p>
</div>
</div>
- Purpose: Blocks UI and shows message/spinner while uploading.
🖥️ 9. JavaScript & Helper Methods
Script Includes
<script src="~/assets/libs/jquery/jquery.min.js"></script>
<script src="~/assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="~/assets/js/app.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/dropzone.js"></script>
<script src="~/assets/js/spin.js"></script>
Spinner Initialization
$(function(){
$("#submitbtn").click(function(){
$("#loading").fadeIn();
var opts = {
lines:19, length:28, width:7, scale:0.05,
speed:2.0, color:'#11467e', animation:'spinner-line-shrink'
};
var target = document.getElementById('loading');
var spinner = new Spinner(opts).spin(target);
});
});
- Trigger: On “Upload” button click.
- Action: Fades in overlay + starts Spin.js spinner.
🔗 10. API Endpoints Overview
| HTTP Method | URL | Purpose |
|---|---|---|
| POST | /Imaging/UploadVehicles |
Accepts multipart file upload(s) for vehicles |
| GET | /Imaging/DocPreview |
Renders preview of uploaded document |
📊 11. Sequence Diagram
sequenceDiagram
participant U as User
participant B as Browser
participant S as Server
U->>B: Navigate to UploadVehicles view
B->>U: Render upload form & scripts
U->>B: Select file(s) & click Upload
B->>B: Show #loading overlay + start spinner
B->>S: POST /Imaging/UploadVehicles (multipart)
S->>S: Process file, store, validate
S-->>B: Redirect to /Imaging/DocPreview?fileName=...
B->>U: Display document preview page
📋 12. Usage Examples
Basic Upload
- Navigate to Vehicle File Upload page.
- Click Browse and select one or more files.
- Click Upload.
- Observe loader, then automatic redirection to DocPreview.
Enabling Dropzone Drop
@using (Html.BeginForm("UploadVehicles","Imaging",FormMethod.Post,
new { enctype="multipart/form-data", @class="dropzone", id="dropzoneForm" }))
{
<!-- Dropzone will auto-handle file selection -->
}
// In Dropzone.options.dropzoneForm.init, call processQueue() on custom button
🏁 13. Conclusion
This view brings together Razor, Bootstrap, Dropzone.js, and Spin.js to offer an intuitive, responsive UI for uploading vehicle data files. Its modular structure—separating CSS, HTML, and JS—facilitates future enhancements (e.g., client-side validation, progress bars or multi-step wizards).
Feel free to extend:
- Validation: Check file size/type before upload.
- Progress feedback: Use Dropzone progress events.
- Accessibility: Add ARIA attributes to the overlay and controls.
Happy coding! 🚀