📝 LytxTemplateUpload.cshtml Documentation


📚 Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Model
  4. Layout & Structure
  5. Styles & Loading Overlay
  6. JavaScript & Dropzone Integration
  7. API Endpoint & Form Submission
  8. Sequence Diagram (UML)
  9. Usage Examples
  10. Conclusion

🔍 Overview & Purpose

The LytxTemplateUpload.cshtml view is an ASP.NET Razor page that presents a user interface for uploading “LyTx” data files.

  • Goal: Allow users to browse or drag‑drop files and upload them to the server.
  • Key Features:
    • File input (single or multiple files)
    • Dropzone.js integration for an enhanced drag‑drop experience
    • Loading overlay UI feedback
    • Automatic redirect to a preview page upon upload completion

🛠️ Dependencies & Technologies

Layer Library/Technology Purpose
ASP.NET MVC/Razor @model, Html.BeginForm Server‑side view templating
CSS Framework Bootstrap (bootstrap.bundle.min.js/css) Layout, buttons, responsive grid
UI Plugins Dropzone.js (dropzone.js) Drag‑drop file uploads
DOM Manipulation jQuery (jquery.min.js) Event binding, DOM updates
MetisMenu metisMenu.min.js Sidebar menu controls (site‑wide)
SimpleBar simplebar.min.js Custom scrollbar styling
Node Waves waves.min.js Click ripple effects

👤 View Model

@model UploadViewModel
  • UploadViewModel – A view model that may contain metadata about the file(s) (e.g., description, allowed types).
  • Note: This view only uses the model to set up the page; file data is posted via multipart/form-data.

📐 Layout & Structure

@{
    ViewData["Title"] = "Upload";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section styles{ ... }
<h2>Lytx Template</h2>
<hr />
@using (Html.BeginForm("LytxTemplateUpload", "Imaging", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title mb-4">Upload LyTx Data</h4>
                    <div class="row mb-8">
                        <label class="col-form-label col-lg-1">Browse or Drop Files…</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>
        </div>
    </div>
}
  • Form Tag Helpers
    • Html.BeginForm("LytxTemplateUpload", "Imaging", FormMethod.Post, new { enctype = "multipart/form-data" })
  • Bootstrap Grid used to center and style the card and input.

🎨 Styles & Loading Overlay

<style>
  #loading { /* full-screen overlay */ }
  #loadingcontent { /* centering wrapper */ }
  #loadingspinner { /* spinner text alignment */ }
</style>
  • #loading: Semi‑transparent overlay shown during file upload.
  • #loadingcontent / #loadingspinner: Vertically and horizontally centers a loading message or spinner.

📜 JavaScript & Dropzone Integration

<script src="~/assets/libs/jquery/jquery.min.js"></script>
<script src="~/assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- ... other libs ... -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/5.5.1/dropzone.js"></script>
<script src="~/assets/js/app.js"></script>
<script>
  function myParamName() { return "file"; }

  Dropzone.options.dropzoneForm = {
    paramName: myParamName,
    autoDiscover: false,
    autoProcessQueue: false,
    uploadMultiple: true,
    parallelUploads: 100,
    init: function () {
      var dz = this;
      $("#uploadfile").click(function () {
        dz.processQueue();
      });
      dz.on("queuecomplete", () => dz.removeAllFiles());
      dz.on("complete", file => {
        dz.removeAllFiles();
        window.location.href = '@Url.Action("DocPreview","Imaging")?fileName=' + file.name;
      });
    },
    accept: (file, done) => done()
  };
</script>
  • autoDiscover: Disabled to manually initialize Dropzone.
  • autoProcessQueue: Disabled to trigger upload on button click.
  • Events:
    • queuecomplete: Clears the dropzone when all files finish.
    • complete: Redirects to a preview page with file.name as query string.

🔗 API Endpoint & Form Submission

HTTP Method URL Action Method Description
POST /Imaging/LytxTemplateUpload ImagingController.Upload* Receives multipart/form-data

* Controller method name inferred: public IActionResult LytxTemplateUpload(UploadViewModel model, IFormFile file)


🔄 Sequence Diagram (UML)

sequenceDiagram
  participant U as User
  participant V as LytxTemplateUpload.cshtml
  participant C as ImagingController
  participant S as StorageService

  U->>V: GET /Imaging/LytxTemplateUpload
  V-->>U: Render upload form
  U->>V: Selects/drops file & clicks Upload
  V->>C: POST /Imaging/LytxTemplateUpload (file)
  C->>S: Save file to disk/database
  S-->>C: Success + filename
  C-->>V: Redirect to /Imaging/DocPreview?fileName=xxx
  V-->>U: Redirect and show preview

📂 Usage Examples

  1. Navigate to Upload Page
    https://yourdomain.com/Imaging/LytxTemplateUpload
    
  2. Select or Drop a File
    • Click the big area or drag‑drop into the input.
  3. Click “Upload”
    • Loading overlay appears.
  4. Automatic Redirect
    • On completion, you’re taken to DocPreview with the file name.

🏁 Conclusion

The LytxTemplateUpload.cshtml view offers a clean, user‑friendly interface for uploading “LyTx” data via both standard file input and drag‑drop (Dropzone.js). Its modular structure (Razor view + Dropzone integration + loading overlay) ensures:

  • Easy customization
  • Seamless user feedback
  • Straightforward server-side handling

Feel free to extend this template by:

  • Adding client‑side validations
  • Displaying upload progress bars
  • Handling errors (e.g., file type/size restrictions)

Happy coding! 🚀