IrbyImaging.Views.Home.Index.cshtml Documentation 🏠
Table of Contents
- Overview & Purpose
- File Structure & Layout
- Dependencies & Technologies
- Key Functional Areas
- View Models & Data Models
- API Endpoints & Navigation
- Helper Methods / Utilities
- Error Handling & Input Validation
- Third-party Integrations
- UML Component Diagram 📐
- Sample Usage & Code Snippets
- Conclusion
Overview & Purpose
Index.cshtml is the Home Page view of the IrbyImaging web application, built with ASP.NET Core MVC. It greets an authenticated user, displays dynamic widgets (clock & to‑do list), and, based on the user’s department (especially IT), shows quick‑access menu cards to related modules:
- ATS (Asset Tracking)
- HelpDesk
- BLACKBIRD (Analytics & PM)
- TIME ENTRY
- FIELD DATA CAPTURE
- DOCUMENT MANAGEMENT
- CERTIFIED PAYROLL
- IRBY FORMS
This page serves as a dashboard, centralizing navigation and lightweight productivity tools.
File Structure & Layout
IrbyImaging/
└── Views/
└── Home/
└── Index.cshtml ← This file
- @using System.Security.Principal – Imports identity-related types.
- Razor Block – Retrieves user claims, sets
ViewData["Title"]. - HTML Markup – Defines cards, clock, to‑do list & menu.
- CSS Styles – Inline
<style>blocks for layout & animations. - JavaScript – Inline
<script>for clock, to‑do logic; external scripts loaded at bottom.
Dependencies & Technologies
| Category | Tools / Libraries |
|---|---|
| Backend | ASP.NET Core MVC, C#, Razor Views |
| Frontend Frameworks | Bootstrap, jQuery, jQuery UI |
| UI Plugins | metisMenu, simplebar, node‑waves |
| Charting | ApexCharts |
| Storage / State | LocalStorage (for To‑Do list) |
| Markup & Styles | HTML5, CSS3 |
| Scripting | Vanilla JS, Razor Syntax |
Key Functional Areas
1. Razor & Data Binding
@using System.Security.Principal
@{
var fname = User.Claims.ToList();
var fullname = fname[1].Value; // Claim: Full Name
ViewData["Title"] = "Home Page";
// Layout = "~/Views/Shared/_LayoutNew.cshtml";
}
- User.Claims → list of JWT/identity claims.
- ViewData["Title"] → sets browser tab title.
- ViewBag properties (DisplayName, Role, Department) are provided by the controller action.
2. User Greeting Card 👤
<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" … />
</div>
@if (User.Identity.IsAuthenticated) {
<h5 class="font-size-15">@ViewBag.DisplayName</h5>
<p>@ViewBag.Role</p>
<p>@ViewBag.Department</p>
} else {
<h5>Irby User</h5><p>Admin</p>
}
</div>
</div>
- Authenticated vs Anonymous logic
- Displays DisplayName, Role, Department from
ViewBag. - Fallback to Irby User/Admin for unauthenticated sessions.
3. Clock Widget ⏰
Markup:
<div class="clock">
<div class="outer-clock-face">
… <div id="A1" class="hand hour-hand"></div>
… <div id="A2" class="hand min-hand"></div>
… <div id="A3" class="hand second-hand"></div>
</div>
<div class="date-display">
<span id="current-date"></span>
</div>
</div>
Script:
function setDate() {
const now = new Date();
const seconds = now.getSeconds();
const mins = now.getMinutes();
const hour = now.getHours();
// Calculate degrees and rotate hands
secondHand.style.transform = `rotate(${((seconds/60)*360)+90}deg)`;
minsHand.style.transform = `rotate(${((mins/60)*360)+((seconds/60)*6)+90}deg)`;
hourHand.style.transform = `rotate(${((hour/12)*360)+((mins/60)*30)+90}deg)`;
// Update human-friendly date
document.getElementById("current-date").textContent =
now.toLocaleDateString(undefined, {
weekday: "long", year: "numeric", month: "long", day: "numeric"
});
}
setInterval(setDate, 1000);
setDate();
- Hands: rotate via CSS
transform. - Date: uses
toLocaleDateStringfor i18n. - Tick:
setIntervalevery second.
4. To-Do List Component ✅
HTML:
<div class="todo-container">
<div class="todo-header">To-Do List</div>
<div class="todo-form">
<input id="todo-input" placeholder="Enter a task…" />
<button onclick="addTodo()">Add</button>
</div>
<ul id="todo-list"></ul>
<button class="remove-completed" onclick="removeCompleted()">Remove Completed</button>
</div>
Behavior (JS):
- Persistence: uses
localStorageunder key"todos". - Functions:
addTodo()– create & render new item.renderTodo(text, completed)– builds<li>.editTodo(),saveEdit()– in‑place edit on Enter or Save.markCompleted()– moves to completed state.deleteTodo()– removes one item.removeCompleted()– wipes all completed tasks.saveTodos()– writes array of{text, completed}tolocalStorage.
5. Conditional IT Menu Grid 🛠️
@if (ViewBag.Department == "IT") {
<div class="menu-container">
<form asp-controller="ATSHome" asp-action="Index" method="post">
<button class="menu-item">
<img src="/images/ATS1.png" />
<div class="menu-text"><h2>IRBY ATS</h2><p>Tracks …</p></div>
</button>
</form>
</div>
<!-- Repeat: HelpDeskHome, IView, TimeEntry, IrbyForms … -->
}
- Role‑based: only users in IT see this grid.
- Each menu card is a
<form>-wrapped<button>posting to a controller action. - Flexibility: can add more cards by duplicating the pattern.
6. Styles & Animations ✨
- .menu-item: flex layout, hover transitions (
transform,box-shadow,background-color). - .clock, .outer-clock-face, .hand: styled circular clock with subtle 3D box‑shadows.
- .todo-container: white card, red shadows for incomplete tasks, green for completed, hover states on buttons.
7. JavaScript Utilities & Helpers 🔧
- Clock:
setDate(),setInterval(). - To‑Do List:
- Initialization:
window.onload→ loads persisted items. - CRUD:
addTodo,editTodo,markCompleted,deleteTodo,removeCompleted. - Persistence:
saveTodos↔localStorage.
- Initialization:
- External scripts: jQuery, Bootstrap Bundle, metisMenu, simplebar, node-waves, ApexCharts, custom
app.js.
View Models & Data Models
This view relies on:
| Property | Source | Usage |
|---|---|---|
ViewBag.DisplayName |
HomeController | User’s full name in greeting. |
ViewBag.Role |
HomeController | User’s role (e.g. “Admin”). |
ViewBag.Department |
HomeController | Department filter for menu grid. |
ViewData["Title"] |
This view | Browser tab title. |
User.Claims |
ASP.NET Identity | Additional user info (fullname). |
No strongly‑typed ViewModel is used; data flows through ViewBag and ViewData.
API Endpoints & Navigation
| Menu Item | Controller | Action | Method |
|---|---|---|---|
| IRBY ATS | ATSHome | Index | POST |
| IRBY HELPDESK | HelpDeskHome | Index | POST |
| BLACKBIRD | IView | Index | POST |
| TIME ENTRY | (unnamed) | Index? (N/A) | POST |
| FIELD DATA CAPTURE | TimeEntry | PayrollDraft | POST |
| DOCUMENT MANAGEMENT | (unnamed) | Index? (N/A) | POST |
| CERTIFIED PAYROLL | TimeEntry | FringeBenefitSheet | POST |
| IRBY FORMS | IrbyForms | Index | POST |
Note: For forms without explicit
asp-controller/asp-action, the target may default to current controller or require further routing.
Helper Methods / Utilities
setDate()– updates clock every second.addTodo()– validate non-empty input, render & save.renderTodo()– DOM creation for list items.editTodo() / saveEdit()– swap between<span>and<input>.markCompleted(),deleteTodo(),removeCompleted()– manage item states & persistence.saveTodos()– serializes<li>states tolocalStorage.
Error Handling & Input Validation
- Empty Tasks:
addTodo()andsaveEdit()ignore blank entries (trim() === ""). - LocalStorage: fallback to
[]if no saved data. - No explicit try/catch in view; exceptions bubble to global error handlers.
Third-party Integrations
| Library / Plugin | Purpose |
|---|---|
| jQuery | DOM manipulation (legacy). |
| Bootstrap 5 | Responsive grid & utility classes. |
| metisMenu | Sidebar / menu behaviors. |
| simplebar | Custom scrollbars. |
| node-waves | Ripple effect on button clicks. |
| apexcharts | Charting (though not used in this view). |
| jQuery UI | CSS for date‑picker (optional). |
UML Component Diagram 📐
classDiagram
HomeController --> IndexView : returns
IndexView -- ATSHomeController : POST /ATSHome/Index
IndexView -- HelpDeskHomeController : POST /HelpDeskHome/Index
IndexView -- IViewController : POST /IView/Index
IndexView -- TimeEntryController : POST /TimeEntry/PayrollDraft
IndexView -- IrbyFormsController : POST /IrbyForms/Index
class IndexView {
+setDate()
+addTodo()
+editTodo()
+saveEdit()
+markCompleted()
+deleteTodo()
+removeCompleted()
+saveTodos()
}
Sample Usage & Code Snippets
1. Changing the Layout
By default the view uses _Layout.cshtml. To switch:
@{
Layout = "~/Views/Shared/_LayoutNew.cshtml";
}
2. Pre‑populating To‑Do List
In a controller:
public IActionResult Index()
{
ViewBag.InitialTodos = JsonSerializer.Serialize(new[]{
new { text="Setup VM", completed=false },
new { text="Deploy App", completed=true }
});
return View();
}
Then in JS:
window.onload = function(){
const initial = JSON.parse('@Html.Raw(ViewBag.InitialTodos)');
initial.forEach(item => renderTodo(item.text, item.completed));
saveTodos();
};
3. Adding a New Menu Card
@if (ViewBag.Department == "IT")
{
<div class="menu-container">
<form asp-controller="NewModule" asp-action="Index" method="post">
<button class="menu-item">
<img src="/images/NewModule.png" />
<div class="menu-text">
<h2>NEW MODULE</h2>
<p>Description of new module</p>
</div>
</button>
</form>
</div>
}
Conclusion
The Home/Index.cshtml view is a centralized dashboard designed for IrbyImaging users. It demonstrates:
- Dynamic Razor rendering of user info
- Interactive widgets: real‑time clock & persistent to‑do list
- Role‑based navigation for IT staff
- Rich styling & UX through custom CSS and 3rd‑party libraries
- JavaScript-driven state management with localStorage
With modular markup and clear helper functions, you can easily extend clock faces, task operations, or menu cards to fit evolving requirements. Happy coding! 🎉