ATSHome/Index.cshtml Documentation 📄✨

File Path: IrbyImaging/Views/ATSHome/Index.cshtml


Table of Contents 📑

  1. Overview & Purpose
  2. Layout & ViewData Configuration
  3. User Profile Card 👤
  4. Employee Lookup 🔍
  5. Total Assets Analytics 🍩
  6. Recent Activity Timeline 📅
  7. Pie Charts Section 📈
  8. Autocomplete Quick Search 📝
  9. AJAX & Chart Rendering Scripts ⚙️
  10. Dependencies & Technologies 🛠️
  11. ViewBag / ViewData Models
  12. API Endpoints Overview 🌐
  13. Sequence / Component Diagram UML
  14. Usage Examples & Code Snippets
  15. Conclusion

1. Overview & Purpose 🔍

This Razor View serves as the ATS (Asset Tracking System) Home Dashboard for Irby Imaging employees. It provides:

  • A welcome/profile card showing the logged‑in user.
  • Employee lookup forms (by number, phone, or name).
  • Interactive charts (donut + pie) summarizing asset distribution.
  • A recent activity timeline of asset check‑in/out.
  • AJAX calls to fetch live data for charts.
  • Autocomplete search for employees.

2. Layout & ViewData Configuration 📝

@{
    ViewData["Title"] = "Home Page";
    Layout = "~/Views/Shared/_ATSLayout.cshtml";
}
@{
    var fname = User.Claims.ToList();   // Get claims
    var fullname = fname[1].Value;     // Extract display name
    ViewData["Title"] = "Home Page";   // Page title
}
  • Layout: References the shared master page (_ATSLayout.cshtml).
  • ViewData["Title"]: Sets the browser/tab title.
  • User.Claims: Extracts the authenticated user’s full name for display.

3. User Profile Card 👤

A Bootstrap card displaying:

  • Welcome message.
  • Profile avatar.
  • DisplayName & User.Identity.Name or fallback text.
<div class="card overflow-hidden">
  <div class="bg-primary bg-soft">…</div>
  <div class="card-body pt-0">
    <div class="avatar-md profile-user-wid mb-4">
      <img src="~/images/users/avatar-1.jpg" class="img-thumbnail rounded-circle">
    </div>
    @if (User.Identity.IsAuthenticated) {
      <h5>@ViewBag.DisplayName</h5>
      <p>@User.Identity.Name</p>
    } else {
      <h5>Irby User</h5>
      <p>Admin</p>
    }
  </div>
</div>

4. Employee Lookup 🔍

Forms

Search Type Form Action Input Field Validation Error Display
Employee Number asp-controller="ATSHome"asp-action="SearchByEmployeeNumber" name="number" @ViewBag.EmployeeNumberError
Mobile Phone Number asp-action="SearchByMobilePhoneNumber" name="phoneNumber" @ViewBag.PhoneNumberError
Quick Name Search (Auto) asp-controller="Employees"asp-action="Details" id="quickSearchField"<input hidden id="employeeId"> n/a
  • Bootstrap input group + button styling.
  • Server-side validation messages via ViewBag.

5. Total Assets Analytics 🍩

A donut chart summarizing:

  • Computers
  • Mobile Devices
  • Network Equipment
  • Office Printers
<div id="donut-chart" class="apex-charts"></div>
<div class="row text-center text-muted">
  <div class="col-4">
    <p><i class="mdi mdi-circle text-primary"></i> COMPUTERS</p>
    <h5>@ViewBag.TotalComputerCount</h5>
  </div>
  <!-- …other categories… -->
</div>
  • Data loaded via AJAX: /ATSHome/GetChartData/
  • Chart rendered by ApexCharts.

6. Recent Activity Timeline 📅

A vertical timeline of up to 8 recent asset events:

<ul class="verti-timeline list-unstyled">
  <li class="event-list">
    <div class="event-timeline-dot"><i class="bx bx-right-arrow-circle"></i></div>
    <div class="d-flex">
      <div class="flex-shrink-0 me-3">
        <h5>@ViewBag.Date1 <i class="bx bx-right-arrow-alt"></i></h5>
      </div>
      <div class="flex-grow-1">
        <div>@ViewBag.Asset1 : @ViewBag.Notes1</div>
      </div>
    </div>
  </li>
  <!-- … up to Date8 … -->
</ul>
  • Displays Date, Asset Name and Notes.
  • Controlled via ViewBag.DateN, ViewBag.AssetN, ViewBag.NotesN.

7. Pie Charts Section 📈

Shows pie charts for:

  • Computers (#pie-chart1)
  • Mobile Devices (#pie-chart2)
  • Network Equipment (#pie-chart7)
  • Office Printers (#pie-chart8)

Each card includes:

  • Chart container.
  • Legend items with counts from ViewBag.

Pie Chart Sample


Uses jQuery UI Autocomplete:

$('#quickSearchField').autocomplete({
  source: '@Url.Action("GetNames","ATSHome")',
  select: function (e, ui) {
    e.preventDefault();
    $('#quickSearchField').val(ui.item.label);
    $('#employeeId').val(ui.item.value);
  }
});
  • GetNames action returns JSON [ { label: "Jane Doe", value: 123 }, … ].
  • Fills hidden employeeId for the detail lookup.

9. AJAX & Chart Rendering Scripts ⚙️

Common Pattern

$.ajax({
  url: '/ATSHome/GetChartData/',
  type: "POST",
  success: function (data) {
    if (data.success && data.series.length) {
      LoadDonut(data.series, data.labels);
    } else {
      alert(data.message);
    }
  },
  error: function (response) {
    console.error(response);
    alert("Error loading data");
  }
});

Chart Configuration

function LoadDonut(series, labels) {
  var options = {
    chart: { type: 'donut', height: 250 },
    series: series,
    labels: labels,
    responsive: [{ breakpoint: 480, options: { legend: { position: 'bottom' } } }]
  };
  new ApexCharts(document.querySelector("#donut-chart"), options).render();
}
  • Similar functions for pie-chart1, pie-chart2, pie-chart7, pie-chart8.

10. Dependencies & Technologies 🛠️

Library / Framework Purpose
ASP.NET Core MVC (Razor Pages) Server-side view & routing
Bootstrap 4 / 5 Responsive layout & components
jQuery & jQuery UI DOM manipulation & autocomplete
ApexCharts Interactive charts
MetisMenu, SimpleBar, Waves Sidebar & UI enhancements
Font Awesome / Boxicons / MDI Icons

11. ViewBag / ViewData Models 📦

Key Type Description
ViewBag.DisplayName string User’s full name
ViewBag.TotalComputerCount int Total computers count
ViewBag.TotalMobileDeviceCount int Total mobile devices count
ViewBag.Date1…Date8 string Recent activity dates
ViewBag.Asset1…Asset8 string Asset names
ViewBag.Notes1…Notes8 string Activity notes
… more counts for pie charts … int E.g., ActiveComputersCount, etc.

12. API Endpoints Overview 🌐

Endpoint Method Description Returns
/ATSHome/GetChartData POST Data for Total Assets donut chart JSON { success, series[], labels[], message }
/ATSHome/GetComputersData POST Pie data for Computers JSON…
/ATSHome/GetMobileDevicesData POST Pie data for Mobile Devices JSON…
/ATSHome/GetNetworkEquipmentData POST Pie data for Network Equipment JSON…
/ATSHome/GetOfficePrintersData POST Pie data for Office Printers JSON…
/ATSHome/GetNames GET Autocomplete Employee Names JSON [ { label, value }, … ]

13. Sequence / Component Diagram UML 📊

sequenceDiagram
    participant U as User
    participant B as Browser (Index.cshtml)
    participant S as ATSHomeController
    participant D as DataService

    U->>B: Load Dashboard
    B->>S: GET /ATSHome/Index
    S->>D: Fetch ViewBag data
    D-->>S: Return counts & activity
    S-->>B: Render HTML + ViewBag

    Note over B,S: On Document Ready
    B->>S: POST /ATSHome/GetChartData
    S->>D: Query assets summary
    D-->>S: Returns JSON
    S-->>B: JSON data
    B->>B: Render ApexCharts donut

14. Usage Examples & Code Snippets 🖥️

1) Searching an Employee by Number

<form asp-controller="ATSHome" asp-action="SearchByEmployeeNumber">
  <div class="input-group">
    <input type="text" name="number" class="form-control" placeholder="Enter Employee #"/>
    <button class="btn btn-primary">Search</button>
  </div>
</form>

2) Adding a New Pie Chart

  1. Add a <div id="pie-chart9"> container.
  2. Implement GetNewData() AJAX call in scripts.
  3. Write LoadPieChart9(series, labels) with ApexCharts config.

15. Conclusion 🎉

The Index.cshtml view is the central dashboard for the ATSHome module. It elegantly combines:

  • Server-driven data (via ViewBag / ViewData).
  • Client-driven interactivity (via AJAX + ApexCharts).
  • User-friendly search (autocomplete + lookup forms).
  • Responsive design (Bootstrap + MetisMenu + SimpleBar).

This page provides real‑time visualization of assets and empowers employees to quickly locate personnel and track device usage.


Happy Coding! 🚀
— Irby Imaging Development Team