📄 Documentation: IrbyImaging/Views/HelpDeskHome/Index.cshtml


Table of Contents

  1. Overview & Purpose
  2. Layout & Metadata
  3. ViewData & User Details
  4. UI Structure & Key Functional Areas
  5. Dependencies & Technologies
  6. Scripts, AJAX Endpoints & Helper Methods
  7. Data Models & ViewBag Properties
  8. Error Handling & Return Types
  9. Third-Party Integrations
  10. UML Diagram: Data Flow
  11. Usage Examples
  12. Conclusion

1. Overview & Purpose 📝

This Razor View (Index.cshtml) renders the Help Desk Home Page dashboard for the IrbyImaging application. It provides:

  • A Tickets Timeline chart (line chart) showing the count of all tickets over time.
  • Mini-stat cards summarizing:
    • All Tickets
    • Requests
    • Incidents
  • A Stacked Column Chart displaying trends for Requests vs. Incidents.

All dynamic data (counts, deltas, chart series) is supplied via ViewBag properties and AJAX calls to two JSON endpoints on HelpDeskHomeController.


2. Layout & Metadata 🛠️

@{
    ViewData["Title"] = "Home Page";
    Layout = "~/Views/Shared/_HDLayout.cshtml";
}
  • ViewData["Title"]: Sets the <title> of the page to Home Page.
  • Layout: Points to a shared layout _HDLayout.cshtml that includes common header, footer, and navigation.

3. ViewData & User Details 👤

@{
    var fname = User.Claims.ToList();
    var fullname = fname[1].Value;
    ViewData["Title"] = "Home Page";
}
  • Extracts the authenticated user's full name from claims (the second claim in the list).
  • Later in the commented-out profile card, it displays @fullname and @User.Identity.Name if the user is authenticated.

4. UI Structure & Key Functional Areas 🖥️

The page is built with Bootstrap grid and cards.

<div class="row">
    <!-- Tickets Timeline Card -->
    <div class="col-xl-5">…</div>
    <!-- Mini-Stats Cards -->
    <div class="col-xl-7">…</div>
</div>

4.1 Tickets Timeline

  • Purpose: Show monthly ticket totals and differences vs. previous periods, paired with a line chart.
  • Key ViewBag:
    • @ViewBag.TotalThisCount
    • @ViewBag.TotalLastCount
    • @ViewBag.TotalDiffCount
  • Chart Container:
    <div id="line-chart" class="apex-charts" dir="ltr"></div>
    

4.2 Mini Stats Cards

Three cards with counts and sub-statuses:

Card Type Icon Link Key Counts in ViewBag
All Tickets @Url.Action("Index","Tickets") TotalCount, TotalOpenCount, TotalInProgressCount, TotalClosedCount, TotalDiffCount
Requests @Url.Action("Index","Tickets") RequestCount, RequestOpenCount, RequestInProgressCount, RequestClosedCount, TotalDiffReqCount
Incidents @Url.Action("ViewIncidents","Tickets") IncidentCount, IncidentOpenCount, IncidentInProgressCount, IncidentClosedCount, TotalDiffIncCount

Snippet for one card:

<div class="card mini-stats-wid">
  <div class="card-body">
    <div class="d-flex">
      <div class="flex-grow-1">
        <p class="text-black fw-bolder font-size-20">
          All Tickets
          <span class="badge irby-red">@ViewBag.TotalCount</span>
          <div class="d-flex">
            <span class="badge badge-soft-success font-size-12">@ViewBag.TotalDiffCount</span>
            <span class="ms-2 text-truncate">From previous month</span>
          </div>
        </p>
        <p class="text-black fw-bold font-size-15">Open - @ViewBag.TotalOpenCount</p>
        …
      </div>
      <div class="flex-shrink-0 align-self-center">
        <div class="mini-stat-icon avatar-sm rounded-circle bg-primary">
          <span class="avatar-title">
            <a href="@Url.Action("Index","Tickets")">
              <i class="bx bx-copy-alt font-size-24" style="color:white"></i>
            </a>
          </span>
        </div>
      </div>
    </div>
  </div>
</div>

4.3 Tickets Trend Chart

  • Purpose: Compare Requests vs. Incidents over time using a stacked column chart.
  • Container:
    <div id="stacked-column-chart" class="apex-charts" dir="ltr"></div>
    

5. Dependencies & Technologies 📦

Library / Framework Purpose
ASP.NET Razor (CSHTML) Server-side view templating
Bootstrap 4/5 Responsive grid & styling
jQuery 1.10.2 / 3.x DOM manipulation, AJAX
jQuery UI 1.10.2 UI enhancements (loaded but lightly used)
ApexCharts Interactive charts (line & bar)
MetisMenu / Simplebar / Waves Sidebar menus, custom scrollbars, effects
Google Charts Loader (Loaded but not utilized in this view)
~/Views/Shared/_HDLayout Shared layout for helpdesk pages

6. Scripts, AJAX Endpoints & Helper Methods 🧩

All chart data is fetched asynchronously via jQuery AJAX from two controller endpoints.

6.1 GetTicketsData() & LoadChart()

function GetData() {
  $.ajax({
    url: '/HelpDeskHome/GetTicketsData/',
    type: "POST",
    cache: false,
    success: function(data) {
      if (data.success && data.all.length > 0) {
        LoadChart(data.all, data.requests, data.incidents, data.labels);
      } else {
        alert(data.message || "No data available.");
      }
    },
    error: function(response) {
      console.error(response);
      alert("Error fetching ticket data.");
    }
  });
}

function LoadChart(all, requests, incidents, labels) {
  var options = {
    chart: { type: "bar", stacked: true, height:360 },
    series: [
      { name: "Requests", data: requests },
      { name: "Incidents", data: incidents }
    ],
    xaxis: { categories: labels },
    colors: ["#556ee6","#f1b44c"]
  };
  new ApexCharts(document.querySelector("#stacked-column-chart"), options).render();
}
  • Endpoint: POST /HelpDeskHome/GetTicketsData/
  • Expected JSON:
    {
      "success": true,
      "all": [/*all tickets counts*/],
      "requests": [/*requests counts*/],
      "incidents": [/*incidents counts*/],
      "labels": [/*month labels*/]
    }
    

6.2 GetAllTicketsData() & LoadLineChart()

function GetLineData() {
  $.ajax({
    url: '/HelpDeskHome/GetAllTicketsData/',
    type: "POST",
    cache: false,
    success: function(data) {
      if (data.success && data.all.length > 0) {
        LoadLineChart(data.all, data.labels);
      } else {
        alert(data.message || "No line chart data.");
      }
    },
    error: function(response) {
      console.error(response);
      alert("Error fetching line chart data.");
    }
  });
}

function LoadLineChart(seriesData, labels) {
  var opts = {
    chart: { type:"line", height:320 },
    series: [{ name:"All Tickets", data: seriesData }],
    xaxis: { categories: labels },
    stroke: { curve:"smooth", width:3 },
    colors: ["#556ee6"]
  };
  new ApexCharts(document.querySelector("#line-chart"), opts).render();
}
  • Endpoint: POST /HelpDeskHome/GetAllTicketsData/
  • Expected JSON:
    {
      "success": true,
      "all": [/*all tickets counts per period*/],
      "labels": [/*labels for X-axis*/]
    }
    

7. Data Models & ViewBag Properties 📊

Property Description
ViewBag.TotalThisCount # of tickets this month
ViewBag.TotalLastCount # of tickets last month
ViewBag.TotalDiffCount Δ (difference) between this & last month
ViewBag.TotalCount Total tickets overall
ViewBag.TotalOpenCount Currently Open tickets
ViewBag.TotalInProgressCount In Progress tickets
ViewBag.TotalClosedCount Closed tickets
ViewBag.RequestCount Total Requests
ViewBag.RequestOpenCount Open requests
ViewBag.RequestInProgressCount Requests in progress
ViewBag.RequestClosedCount Closed requests
ViewBag.TotalDiffReqCount Δ for requests
ViewBag.IncidentCount Total Incidents
ViewBag.IncidentOpenCount Open incidents
ViewBag.IncidentInProgressCount Incidents in progress
ViewBag.IncidentClosedCount Closed incidents
ViewBag.TotalDiffIncCount Δ for incidents

8. Error Handling & Return Types ⚠️

  • AJAX Success:
    • Checks data.success === true.
    • Alerts data.message if success flag is false or arrays are empty.
  • AJAX Error:
    • Logs full response to console.
    • Alerts generic error message.
error: function(response) {
  console.error(response);
  alert("Error fetching …");
}

9. Third-Party Integrations 🔌

  • ApexCharts: Rendering line & bar charts.
  • jQuery / jQuery UI: Event handling & potential UI widgets.
  • Bootstrap: Responsive layout & styling.
  • Google Charts Loader: Loaded but not used in this view—could be removed or reserved for future enhancements.

10. UML Diagram: Data Flow 📈

sequenceDiagram
    participant Browser
    participant View as Index.cshtml
    participant Controller as HelpDeskHomeController

    Browser->>View: GET /HelpDeskHome/Index
    View-->>Browser: HTML + JS + Chart containers
    Browser->>View: $(document).ready()
    View->>Controller: POST /GetTicketsData
    Controller-->>View: JSON(all, requests, incidents, labels)
    View->>ApexCharts: render stacked-column-chart
    Browser->>View: $(document).ready() (line)
    View->>Controller: POST /GetAllTicketsData
    Controller-->>View: JSON(all, labels)
    View->>ApexCharts: render line-chart

11. Usage Examples 🚀

  1. Navigate to /HelpDeskHome/Index.
  2. Observe summary cards updated via server-side ViewBag.
  3. Watch dynamic charts load via AJAX:
    • Stacked Chart: Requests vs. Incidents
    • Line Chart: All Tickets over time

Tip: You can inspect network calls in your browser’s DevTools to view the JSON returned by /GetTicketsData/ and /GetAllTicketsData/.


12. Conclusion 🎯

This Razor view delivers a responsive, interactive dashboard for help desk metrics. By combining server-rendered summaries with client-side ApexCharts, it provides real‐time visualization of ticket volumes, trends, and status breakdowns. The modular AJAX helper methods (GetData / GetLineData) enable reuse and easy extension—e.g., adding new chart types or additional filters.

Next Steps:

  • Implement caching or throttling on chart endpoints for high-traffic scenarios.
  • Refine error messaging and loading spinners for better UX.
  • Review unused scripts (e.g., Google Charts loader) and clean up if not needed.

Happy Debugging & Visualization! 🚀