feat(fusion_clock): redesign dashboard — layered, role-aware, gradient cards (dark+light)
- Rework /fusion_clock/dashboard_data into a personal block (everyone) plus a team block (team lead = direct reports, manager = org-wide). A regular employee's payload never contains another employee's data. - New OWL stacked layout: gradient KPI cards (Today/Week/OT/Streak), Today's Shift, Recent Activity, Upcoming Leave, Recent Penalties; team band adds Present/Absent/Late/Pending, roster, and Needs Attention. - Dark/light via compile-time $o-webclient-color-scheme branching; drop the old runtime html.o_dark dashboard block. - Open the Dashboard menu to group_fusion_clock_user (lead/manager imply). - Add HttpCase permission/no-leak tests. Bump 3.13.2 -> 3.14.0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Fusion Clock',
|
'name': 'Fusion Clock',
|
||||||
'version': '19.0.3.13.2',
|
'version': '19.0.3.14.0',
|
||||||
'category': 'Human Resources/Attendances',
|
'category': 'Human Resources/Attendances',
|
||||||
'summary': 'Complete Employee T&A with Geofencing, Shifts, Penalties, Overtime, Kiosk, Dashboard & Payroll Export',
|
'summary': 'Complete Employee T&A with Geofencing, Shifts, Penalties, Overtime, Kiosk, Dashboard & Payroll Export',
|
||||||
'description': """
|
'description': """
|
||||||
|
|||||||
@@ -670,78 +670,216 @@ class FusionClockAPI(http.Controller):
|
|||||||
'enable_corrections': ICP.get_param('fusion_clock.enable_correction_requests', 'True') == 'True',
|
'enable_corrections': ICP.get_param('fusion_clock.enable_correction_requests', 'True') == 'True',
|
||||||
}
|
}
|
||||||
|
|
||||||
@http.route('/fusion_clock/dashboard_data', type='jsonrpc', auth='user', methods=['POST'])
|
def _dashboard_personal(self, employee):
|
||||||
def dashboard_data(self, **kw):
|
"""Build the always-present personal block. Caller's own employee
|
||||||
"""Return dashboard data for managers."""
|
only — never another employee's data."""
|
||||||
user = request.env.user
|
env = request.env
|
||||||
is_manager = user.has_group('fusion_clock.group_fusion_clock_manager')
|
local_today = get_local_today(env, employee)
|
||||||
is_team_lead = user.has_group('fusion_clock.group_fusion_clock_team_lead')
|
day_plan = employee._get_fclk_day_plan(local_today)
|
||||||
|
|
||||||
if not is_manager and not is_team_lead:
|
is_checked_in = employee.attendance_state == 'checked_in'
|
||||||
return {'error': 'Access denied.'}
|
check_in = False
|
||||||
|
location_name = ''
|
||||||
|
if is_checked_in:
|
||||||
|
att = env['hr.attendance'].sudo().search([
|
||||||
|
('employee_id', '=', employee.id),
|
||||||
|
('check_out', '=', False),
|
||||||
|
], limit=1)
|
||||||
|
if att:
|
||||||
|
check_in = fields.Datetime.to_string(att.check_in)
|
||||||
|
location_name = att.x_fclk_location_id.name or ''
|
||||||
|
|
||||||
now = fields.Datetime.now()
|
today_start_utc, today_end_utc = get_local_day_boundaries(env, local_today, employee)
|
||||||
today = get_local_today(request.env)
|
today_atts = env['hr.attendance'].sudo().search([
|
||||||
today_start, _ = get_local_day_boundaries(request.env, today)
|
('employee_id', '=', employee.id),
|
||||||
|
('check_in', '>=', fields.Datetime.to_string(today_start_utc)),
|
||||||
|
('check_in', '<', fields.Datetime.to_string(today_end_utc)),
|
||||||
|
('check_out', '!=', False),
|
||||||
|
])
|
||||||
|
today_hours = round(sum(a.x_fclk_net_hours or 0 for a in today_atts), 2)
|
||||||
|
|
||||||
Attendance = request.env['hr.attendance'].sudo()
|
week_start = local_today - timedelta(days=local_today.weekday())
|
||||||
Employee = request.env['hr.employee'].sudo()
|
week_start_utc, _ignore = get_local_day_boundaries(env, week_start, employee)
|
||||||
|
week_atts = env['hr.attendance'].sudo().search([
|
||||||
|
('employee_id', '=', employee.id),
|
||||||
|
('check_in', '>=', fields.Datetime.to_string(week_start_utc)),
|
||||||
|
('check_in', '<', fields.Datetime.to_string(today_end_utc)),
|
||||||
|
('check_out', '!=', False),
|
||||||
|
])
|
||||||
|
week_hours = round(sum(a.x_fclk_net_hours or 0 for a in week_atts), 2)
|
||||||
|
|
||||||
# Filter employees by access
|
if not employee.x_fclk_enable_clock:
|
||||||
if is_manager:
|
status_note = 'Clock disabled'
|
||||||
employees = Employee.search([('x_fclk_enable_clock', '=', True)])
|
elif day_plan.get('is_off'):
|
||||||
|
status_note = 'Day off'
|
||||||
|
elif not day_plan.get('scheduled'):
|
||||||
|
status_note = 'Not scheduled today'
|
||||||
|
elif is_checked_in:
|
||||||
|
status_note = 'Clocked in'
|
||||||
else:
|
else:
|
||||||
employee = self._get_employee()
|
status_note = 'Not clocked in'
|
||||||
if not employee:
|
|
||||||
return {'error': 'No employee record found.'}
|
|
||||||
employees = Employee.search([
|
|
||||||
('parent_id', '=', employee.id),
|
|
||||||
('x_fclk_enable_clock', '=', True),
|
|
||||||
])
|
|
||||||
|
|
||||||
emp_ids = employees.ids
|
recent = env['hr.attendance'].sudo().search([
|
||||||
|
('employee_id', '=', employee.id),
|
||||||
|
('check_out', '!=', False),
|
||||||
|
], order='check_in desc', limit=6)
|
||||||
|
recent_activity = [{
|
||||||
|
'check_in': fields.Datetime.to_string(a.check_in),
|
||||||
|
'check_out': fields.Datetime.to_string(a.check_out),
|
||||||
|
'worked_hours': round(a.worked_hours or 0, 2),
|
||||||
|
'overtime_hours': round(a.x_fclk_overtime_hours or 0, 2),
|
||||||
|
'location': a.x_fclk_location_id.name or '',
|
||||||
|
} for a in recent]
|
||||||
|
|
||||||
|
leaves = env['fusion.clock.leave.request'].sudo().search([
|
||||||
|
('employee_id', '=', employee.id),
|
||||||
|
('leave_date', '>=', local_today),
|
||||||
|
], order='leave_date asc', limit=5)
|
||||||
|
leave_sel = dict(env['fusion.clock.leave.request']._fields['state'].selection)
|
||||||
|
leave_list = [{
|
||||||
|
'label': lv._fclk_date_label(),
|
||||||
|
'state': leave_sel.get(lv.state, lv.state),
|
||||||
|
} for lv in leaves]
|
||||||
|
|
||||||
|
month_start = local_today.replace(day=1)
|
||||||
|
penalties = env['fusion.clock.penalty'].sudo().search([
|
||||||
|
('employee_id', '=', employee.id),
|
||||||
|
('date', '>=', month_start),
|
||||||
|
], order='date desc', limit=5)
|
||||||
|
pen_sel = dict(env['fusion.clock.penalty']._fields['penalty_type'].selection)
|
||||||
|
penalty_list = [{
|
||||||
|
'type': pen_sel.get(p.penalty_type, p.penalty_type),
|
||||||
|
'date': fields.Date.to_string(p.date),
|
||||||
|
'minutes': round(p.penalty_minutes or 0, 1),
|
||||||
|
} for p in penalties]
|
||||||
|
|
||||||
|
return {
|
||||||
|
'employee_name': employee.name,
|
||||||
|
'enable_clock': employee.x_fclk_enable_clock,
|
||||||
|
'is_checked_in': is_checked_in,
|
||||||
|
'check_in': check_in,
|
||||||
|
'location_name': location_name,
|
||||||
|
'pending_reason': employee.x_fclk_pending_reason,
|
||||||
|
'today_hours': today_hours,
|
||||||
|
'week_hours': week_hours,
|
||||||
|
'overtime_week': round(employee.x_fclk_overtime_this_week or 0, 2),
|
||||||
|
'ontime_streak': employee.x_fclk_ontime_streak,
|
||||||
|
'shift': {
|
||||||
|
'label': day_plan.get('label') or '',
|
||||||
|
'hours': round(day_plan.get('hours') or 0.0, 2),
|
||||||
|
'source': day_plan.get('source') or 'none',
|
||||||
|
'scheduled_off': bool(day_plan.get('is_off')),
|
||||||
|
'scheduled': bool(day_plan.get('scheduled')),
|
||||||
|
'status_note': status_note,
|
||||||
|
},
|
||||||
|
'recent_activity': recent_activity,
|
||||||
|
'leaves': leave_list,
|
||||||
|
'penalties': penalty_list,
|
||||||
|
}
|
||||||
|
|
||||||
|
def _dashboard_team(self, emp_ids, scope):
|
||||||
|
"""Build the team/org block for the given (already role-scoped)
|
||||||
|
employee ids. ``scope`` is 'team' (lead's direct reports) or 'org'."""
|
||||||
|
env = request.env
|
||||||
|
today = get_local_today(env)
|
||||||
|
today_start, _ignore = get_local_day_boundaries(env, today)
|
||||||
|
Attendance = env['hr.attendance'].sudo()
|
||||||
|
|
||||||
# Currently clocked in
|
|
||||||
open_atts = Attendance.search([
|
open_atts = Attendance.search([
|
||||||
('employee_id', 'in', emp_ids),
|
('employee_id', 'in', emp_ids),
|
||||||
('check_out', '=', False),
|
('check_out', '=', False),
|
||||||
])
|
])
|
||||||
clocked_in = [{
|
|
||||||
'employee': a.employee_id.name,
|
|
||||||
'check_in': fields.Datetime.to_string(a.check_in),
|
|
||||||
'location': a.x_fclk_location_id.name or '',
|
|
||||||
} for a in open_atts]
|
|
||||||
|
|
||||||
# Today stats
|
ActivityLog = env['fusion.clock.activity.log'].sudo()
|
||||||
today_atts = Attendance.search([
|
late_logs = ActivityLog.search([
|
||||||
('employee_id', 'in', emp_ids),
|
|
||||||
('check_in', '>=', today_start),
|
|
||||||
])
|
|
||||||
present_ids = set(a.employee_id.id for a in today_atts)
|
|
||||||
|
|
||||||
ActivityLog = request.env['fusion.clock.activity.log'].sudo()
|
|
||||||
late_count = ActivityLog.search_count([
|
|
||||||
('employee_id', 'in', emp_ids),
|
('employee_id', 'in', emp_ids),
|
||||||
('log_type', '=', 'late_clock_in'),
|
('log_type', '=', 'late_clock_in'),
|
||||||
('log_date', '>=', today_start),
|
('log_date', '>=', today_start),
|
||||||
])
|
])
|
||||||
|
late_emp_ids = set(late_logs.mapped('employee_id').ids)
|
||||||
|
|
||||||
# Pending alerts
|
clocked_in = [{
|
||||||
pending_reasons = Employee.search_count([
|
'employee': a.employee_id.name,
|
||||||
|
'check_in': fields.Datetime.to_string(a.check_in),
|
||||||
|
'location': a.x_fclk_location_id.name or '',
|
||||||
|
'late': a.employee_id.id in late_emp_ids,
|
||||||
|
} for a in open_atts]
|
||||||
|
|
||||||
|
today_atts = Attendance.search([
|
||||||
|
('employee_id', 'in', emp_ids),
|
||||||
|
('check_in', '>=', today_start),
|
||||||
|
])
|
||||||
|
present_ids = set(today_atts.mapped('employee_id').ids)
|
||||||
|
|
||||||
|
# employees on an approved leave covering today
|
||||||
|
leave_recs = env['fusion.clock.leave.request'].sudo().search([
|
||||||
|
('employee_id', 'in', emp_ids),
|
||||||
|
('leave_date', '<=', today),
|
||||||
|
])
|
||||||
|
on_leave_ids = set()
|
||||||
|
for lv in leave_recs:
|
||||||
|
end = lv.date_to or lv.leave_date
|
||||||
|
if lv.leave_date and lv.leave_date <= today <= end:
|
||||||
|
on_leave_ids.add(lv.employee_id.id)
|
||||||
|
|
||||||
|
present_count = len(present_ids)
|
||||||
|
on_leave_count = len(on_leave_ids - present_ids)
|
||||||
|
absent_count = max(len(emp_ids) - present_count - on_leave_count, 0)
|
||||||
|
|
||||||
|
pending_reasons = env['hr.employee'].sudo().search_count([
|
||||||
('id', 'in', emp_ids),
|
('id', 'in', emp_ids),
|
||||||
('x_fclk_pending_reason', '=', True),
|
('x_fclk_pending_reason', '=', True),
|
||||||
])
|
])
|
||||||
pending_corrections = request.env['fusion.clock.correction'].sudo().search_count([
|
pending_approvals = env['fusion.clock.correction'].sudo().search_count([
|
||||||
('employee_id', 'in', emp_ids),
|
('employee_id', 'in', emp_ids),
|
||||||
('state', '=', 'pending'),
|
('state', '=', 'pending'),
|
||||||
])
|
])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'clocked_in': clocked_in,
|
'scope': scope,
|
||||||
'total_employees': len(emp_ids),
|
'total_employees': len(emp_ids),
|
||||||
'present_count': len(present_ids),
|
'present_count': present_count,
|
||||||
'absent_count': len(emp_ids) - len(present_ids),
|
'on_leave_count': on_leave_count,
|
||||||
'late_count': late_count,
|
'absent_count': absent_count,
|
||||||
|
'late_count': len(late_emp_ids),
|
||||||
'pending_reasons': pending_reasons,
|
'pending_reasons': pending_reasons,
|
||||||
'pending_corrections': pending_corrections,
|
'pending_approvals': pending_approvals,
|
||||||
|
'clocked_in': clocked_in,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@http.route('/fusion_clock/dashboard_data', type='jsonrpc', auth='user', methods=['POST'])
|
||||||
|
def dashboard_data(self, **kw):
|
||||||
|
"""Layered, role-aware dashboard payload.
|
||||||
|
|
||||||
|
Everyone gets their own ``personal`` block. The ``team`` block is
|
||||||
|
added ONLY for team leads (their direct reports) and managers
|
||||||
|
(org-wide). A regular employee's payload never contains another
|
||||||
|
employee's data.
|
||||||
|
"""
|
||||||
|
user = request.env.user
|
||||||
|
employee = self._get_employee()
|
||||||
|
if not employee:
|
||||||
|
return {'error': 'No employee profile is linked to your account.'}
|
||||||
|
|
||||||
|
is_manager = user.has_group('fusion_clock.group_fusion_clock_manager')
|
||||||
|
is_team_lead = user.has_group('fusion_clock.group_fusion_clock_team_lead')
|
||||||
|
role = 'manager' if is_manager else ('team_lead' if is_team_lead else 'employee')
|
||||||
|
|
||||||
|
result = {
|
||||||
|
'role': role,
|
||||||
|
'personal': self._dashboard_personal(employee),
|
||||||
|
'team': None,
|
||||||
|
}
|
||||||
|
|
||||||
|
Employee = request.env['hr.employee'].sudo()
|
||||||
|
if is_manager:
|
||||||
|
emp_ids = Employee.search([('x_fclk_enable_clock', '=', True)]).ids
|
||||||
|
result['team'] = self._dashboard_team(emp_ids, 'org')
|
||||||
|
elif is_team_lead:
|
||||||
|
emp_ids = Employee.search([
|
||||||
|
('parent_id', '=', employee.id),
|
||||||
|
('x_fclk_enable_clock', '=', True),
|
||||||
|
]).ids
|
||||||
|
result['team'] = self._dashboard_team(emp_ids, 'team')
|
||||||
|
|
||||||
|
return result
|
||||||
|
|||||||
@@ -13,16 +13,11 @@ export class FusionClockDashboard extends Component {
|
|||||||
this.action = useService("action");
|
this.action = useService("action");
|
||||||
this.state = useState({
|
this.state = useState({
|
||||||
loading: true,
|
loading: true,
|
||||||
clocked_in: [],
|
|
||||||
total_employees: 0,
|
|
||||||
present_count: 0,
|
|
||||||
absent_count: 0,
|
|
||||||
late_count: 0,
|
|
||||||
pending_reasons: 0,
|
|
||||||
pending_corrections: 0,
|
|
||||||
error: "",
|
error: "",
|
||||||
|
role: "employee",
|
||||||
|
personal: {},
|
||||||
|
team: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
onWillStart(async () => {
|
onWillStart(async () => {
|
||||||
await this._fetchData();
|
await this._fetchData();
|
||||||
});
|
});
|
||||||
@@ -30,12 +25,15 @@ export class FusionClockDashboard extends Component {
|
|||||||
|
|
||||||
async _fetchData() {
|
async _fetchData() {
|
||||||
this.state.loading = true;
|
this.state.loading = true;
|
||||||
|
this.state.error = "";
|
||||||
try {
|
try {
|
||||||
const data = await rpc("/fusion_clock/dashboard_data", {});
|
const data = await rpc("/fusion_clock/dashboard_data", {});
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
this.state.error = data.error;
|
this.state.error = data.error;
|
||||||
} else {
|
} else {
|
||||||
Object.assign(this.state, data);
|
this.state.role = data.role;
|
||||||
|
this.state.personal = data.personal;
|
||||||
|
this.state.team = data.team;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.state.error = "Failed to load dashboard data.";
|
this.state.error = "Failed to load dashboard data.";
|
||||||
@@ -43,25 +41,47 @@ export class FusionClockDashboard extends Component {
|
|||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async onRefresh() {
|
// ---- display helpers ----
|
||||||
await this._fetchData();
|
get greeting() {
|
||||||
|
const h = new Date().getHours();
|
||||||
|
if (h < 12) return "Good morning";
|
||||||
|
if (h < 17) return "Good afternoon";
|
||||||
|
return "Good evening";
|
||||||
|
}
|
||||||
|
get todayLabel() {
|
||||||
|
return new Date().toLocaleDateString(undefined, {
|
||||||
|
weekday: "long", month: "long", day: "numeric",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
sourceLabel(source) {
|
||||||
|
return { schedule: "Posted schedule", shift: "Recurring shift", none: "—" }[source] || "—";
|
||||||
|
}
|
||||||
|
initials(name) {
|
||||||
|
return (name || "")
|
||||||
|
.split(" ").filter(Boolean).slice(0, 2)
|
||||||
|
.map((p) => p[0].toUpperCase()).join("");
|
||||||
|
}
|
||||||
|
fmtDate(s) {
|
||||||
|
if (!s) return "";
|
||||||
|
const d = new Date(s.replace(" ", "T") + "Z");
|
||||||
|
return d.toLocaleDateString(undefined, { month: "short", day: "numeric" });
|
||||||
|
}
|
||||||
|
fmtTime(s) {
|
||||||
|
if (!s) return "";
|
||||||
|
const d = new Date(s.replace(" ", "T") + "Z");
|
||||||
|
return d.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" });
|
||||||
}
|
}
|
||||||
|
|
||||||
onViewAttendances() {
|
// ---- actions ----
|
||||||
this.action.doAction("hr_attendance.hr_attendance_action");
|
onRefresh() { return this._fetchData(); }
|
||||||
}
|
onOpenClock() { this.action.doAction({ type: "ir.actions.act_url", url: "/my/clock", target: "self" }); }
|
||||||
|
onViewTimesheets() { this.action.doAction({ type: "ir.actions.act_url", url: "/my/clock/timesheets", target: "self" }); }
|
||||||
onViewCorrections() {
|
onViewAttendances() { this.action.doAction("hr_attendance.hr_attendance_action"); }
|
||||||
this.action.doAction("fusion_clock.action_fusion_clock_correction");
|
onViewCorrections() { this.action.doAction("fusion_clock.action_fusion_clock_correction"); }
|
||||||
}
|
onViewActivityLogs() { this.action.doAction("fusion_clock.action_fusion_clock_activity_log"); }
|
||||||
|
onViewPenalties() { this.action.doAction("fusion_clock.action_fusion_clock_penalty"); }
|
||||||
onViewActivityLogs() {
|
onViewShiftPlanner() { this.action.doAction("fusion_clock.action_fusion_clock_shift_planner"); }
|
||||||
this.action.doAction("fusion_clock.action_fusion_clock_activity_log");
|
onViewReports() { this.action.doAction("fusion_clock.action_fusion_clock_report"); }
|
||||||
}
|
|
||||||
|
|
||||||
onViewPenalties() {
|
|
||||||
this.action.doAction("fusion_clock.action_fusion_clock_penalty");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registry.category("actions").add("fusion_clock.Dashboard", FusionClockDashboard);
|
registry.category("actions").add("fusion_clock.Dashboard", FusionClockDashboard);
|
||||||
|
|||||||
@@ -553,116 +553,148 @@ html.o_dark {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
// Dashboard Summary Cards
|
// Dashboard — layered, role-aware (gradient KPIs + stacked layout)
|
||||||
|
// Dark/light resolved at COMPILE TIME via $o-webclient-color-scheme.
|
||||||
|
// Gradient KPI cards are identical in both modes (white on gradient);
|
||||||
|
// only page / section-card / text tokens swap.
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
.fclk-dash-card {
|
$o-webclient-color-scheme: bright !default;
|
||||||
position: relative;
|
|
||||||
border-radius: 12px;
|
|
||||||
padding: 20px;
|
|
||||||
text-align: center;
|
|
||||||
overflow: hidden;
|
|
||||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
||||||
|
|
||||||
&:hover {
|
$_fclk-dash-page-hex: #f3f4f6;
|
||||||
transform: translateY(-2px);
|
$_fclk-dash-card-hex: #ffffff;
|
||||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
|
$_fclk-dash-border-hex: #e5e7eb;
|
||||||
|
$_fclk-dash-text-hex: #1f2937;
|
||||||
|
$_fclk-dash-muted-hex: #6b7280;
|
||||||
|
$_fclk-dash-row-hex: #f0f0f2;
|
||||||
|
|
||||||
|
@if $o-webclient-color-scheme == dark {
|
||||||
|
$_fclk-dash-page-hex: #0f1117 !global;
|
||||||
|
$_fclk-dash-card-hex: #1a1d23 !global;
|
||||||
|
$_fclk-dash-border-hex: #2a2d35 !global;
|
||||||
|
$_fclk-dash-text-hex: #f1f1f4 !global;
|
||||||
|
$_fclk-dash-muted-hex: #9ca3af !global;
|
||||||
|
$_fclk-dash-row-hex: #2a2d35 !global;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fclk-dash-page: var(--fclk-dash-page, #{$_fclk-dash-page-hex});
|
||||||
|
$fclk-dash-card: var(--fclk-dash-card, #{$_fclk-dash-card-hex});
|
||||||
|
$fclk-dash-border: var(--fclk-dash-border, #{$_fclk-dash-border-hex});
|
||||||
|
$fclk-dash-text: var(--fclk-dash-text, #{$_fclk-dash-text-hex});
|
||||||
|
$fclk-dash-muted: var(--fclk-dash-muted, #{$_fclk-dash-muted-hex});
|
||||||
|
$fclk-dash-row: var(--fclk-dash-row, #{$_fclk-dash-row-hex});
|
||||||
|
|
||||||
|
$fclk-g-today: linear-gradient(135deg, #10b981 0%, #0ea5a4 100%);
|
||||||
|
$fclk-g-week: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
|
||||||
|
$fclk-g-ot: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
|
||||||
|
$fclk-g-streak: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
|
||||||
|
$fclk-g-present: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
|
||||||
|
$fclk-g-absent: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
|
||||||
|
$fclk-g-late: linear-gradient(135deg, #eab308 0%, #f59e0b 100%);
|
||||||
|
$fclk-g-pending: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
|
||||||
|
|
||||||
|
.fclk-dash {
|
||||||
|
background: $fclk-dash-page;
|
||||||
|
min-height: 100%;
|
||||||
|
|
||||||
|
.fclk-dash-wrap { max-width: 1200px; margin: 0 auto; padding: 20px; }
|
||||||
|
|
||||||
|
.fclk-dash-header {
|
||||||
|
display: flex; justify-content: space-between; align-items: flex-start;
|
||||||
|
flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
}
|
.fclk-dash-hello { font-size: 22px; font-weight: 800; color: $fclk-dash-text; }
|
||||||
|
.fclk-dash-date { font-size: 13px; color: $fclk-dash-muted; margin-top: 2px; }
|
||||||
.fclk-dash-card-icon {
|
.fclk-dash-headctl { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
|
||||||
width: 44px;
|
.fclk-dash-statusbadge {
|
||||||
height: 44px;
|
border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 700;
|
||||||
border-radius: 12px;
|
background: rgba(16, 185, 129, .15); color: #10b981;
|
||||||
display: inline-flex;
|
border: 1px solid rgba(16, 185, 129, .35);
|
||||||
align-items: center;
|
&.is-out {
|
||||||
justify-content: center;
|
background: rgba(107, 114, 128, .15); color: $fclk-dash-muted;
|
||||||
font-size: 20px;
|
border-color: rgba(107, 114, 128, .3);
|
||||||
margin-bottom: 12px;
|
}
|
||||||
}
|
}
|
||||||
|
.fclk-dash-btn-primary {
|
||||||
.fclk-dash-card-value {
|
background: $fclk-g-today; color: #fff; border: none; border-radius: 10px;
|
||||||
font-size: 32px;
|
padding: 8px 16px; font-weight: 700; font-size: 13px; cursor: pointer;
|
||||||
font-weight: 700;
|
}
|
||||||
line-height: 1;
|
.fclk-dash-btn-ghost {
|
||||||
margin-bottom: 4px;
|
background: transparent; color: $fclk-dash-muted; border: 1px solid $fclk-dash-border;
|
||||||
}
|
border-radius: 10px; padding: 8px 12px; font-size: 13px; cursor: pointer;
|
||||||
|
|
||||||
.fclk-dash-card-label {
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 500;
|
|
||||||
letter-spacing: 0.2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fclk-dash-card--total {
|
|
||||||
background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%);
|
|
||||||
border: 1px solid #bfdbfe;
|
|
||||||
|
|
||||||
.fclk-dash-card-icon { background: rgba(59, 130, 246, 0.15); color: #2563eb; }
|
|
||||||
.fclk-dash-card-value { color: #1e3a5f; }
|
|
||||||
.fclk-dash-card-label { color: #3b82f6; }
|
|
||||||
}
|
|
||||||
|
|
||||||
.fclk-dash-card--present {
|
|
||||||
background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
|
|
||||||
border: 1px solid #a7f3d0;
|
|
||||||
|
|
||||||
.fclk-dash-card-icon { background: rgba(16, 185, 129, 0.15); color: #059669; }
|
|
||||||
.fclk-dash-card-value { color: #064e3b; }
|
|
||||||
.fclk-dash-card-label { color: #10b981; }
|
|
||||||
}
|
|
||||||
|
|
||||||
.fclk-dash-card--absent {
|
|
||||||
background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
|
|
||||||
border: 1px solid #fecaca;
|
|
||||||
|
|
||||||
.fclk-dash-card-icon { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
|
|
||||||
.fclk-dash-card-value { color: #7f1d1d; }
|
|
||||||
.fclk-dash-card-label { color: #ef4444; }
|
|
||||||
}
|
|
||||||
|
|
||||||
.fclk-dash-card--late {
|
|
||||||
background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
|
|
||||||
border: 1px solid #fde68a;
|
|
||||||
|
|
||||||
.fclk-dash-card-icon { background: rgba(245, 158, 11, 0.15); color: #d97706; }
|
|
||||||
.fclk-dash-card-value { color: #78350f; }
|
|
||||||
.fclk-dash-card-label { color: #f59e0b; }
|
|
||||||
}
|
|
||||||
|
|
||||||
html.o_dark {
|
|
||||||
.fclk-dash-card--total {
|
|
||||||
background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(99, 102, 241, 0.1) 100%);
|
|
||||||
border-color: rgba(59, 130, 246, 0.25);
|
|
||||||
.fclk-dash-card-value { color: #93c5fd; }
|
|
||||||
.fclk-dash-card-label { color: #60a5fa; }
|
|
||||||
.fclk-dash-card-icon { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.fclk-dash-card--present {
|
.fclk-kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
|
||||||
background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(52, 211, 153, 0.08) 100%);
|
.fclk-kpi {
|
||||||
border-color: rgba(16, 185, 129, 0.25);
|
border-radius: 16px; padding: 16px; color: #fff;
|
||||||
.fclk-dash-card-value { color: #6ee7b7; }
|
box-shadow: 0 6px 20px rgba(0, 0, 0, .10);
|
||||||
.fclk-dash-card-label { color: #34d399; }
|
}
|
||||||
.fclk-dash-card-icon { background: rgba(16, 185, 129, 0.2); color: #34d399; }
|
.fclk-kpi-ic {
|
||||||
|
width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .22);
|
||||||
|
display: flex; align-items: center; justify-content: center; font-size: 16px; margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
.fclk-kpi-val { font-size: 26px; font-weight: 800; line-height: 1; }
|
||||||
|
.fclk-kpi-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; opacity: .85; margin-top: 6px; }
|
||||||
|
|
||||||
|
.fclk-kpi--today { background: $fclk-g-today; }
|
||||||
|
.fclk-kpi--week { background: $fclk-g-week; }
|
||||||
|
.fclk-kpi--ot { background: $fclk-g-ot; }
|
||||||
|
.fclk-kpi--streak { background: $fclk-g-streak; }
|
||||||
|
.fclk-kpi--present { background: $fclk-g-present; }
|
||||||
|
.fclk-kpi--absent { background: $fclk-g-absent; }
|
||||||
|
.fclk-kpi--late { background: $fclk-g-late; }
|
||||||
|
.fclk-kpi--pending { background: $fclk-g-pending; }
|
||||||
|
|
||||||
|
.fclk-dash-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
|
||||||
|
.fclk-dash-card {
|
||||||
|
background: $fclk-dash-card; border: 1px solid $fclk-dash-border;
|
||||||
|
border-radius: 14px; padding: 16px;
|
||||||
|
}
|
||||||
|
.fclk-dash-card h4 {
|
||||||
|
margin: 0 0 12px; font-size: 14px; color: $fclk-dash-text;
|
||||||
|
display: flex; justify-content: space-between; align-items: center;
|
||||||
|
}
|
||||||
|
.fclk-dash-line {
|
||||||
|
display: flex; justify-content: space-between; align-items: center;
|
||||||
|
font-size: 13px; padding: 7px 0; border-top: 1px solid $fclk-dash-row; color: $fclk-dash-text;
|
||||||
|
&:first-of-type { border-top: none; }
|
||||||
|
}
|
||||||
|
.fclk-dash-muted { color: $fclk-dash-muted; }
|
||||||
|
.fclk-pin { color: #10b981; font-weight: 700; }
|
||||||
|
.fclk-pyel { color: #d97706; font-weight: 700; }
|
||||||
|
.fclk-pred { color: #dc2626; font-weight: 700; }
|
||||||
|
.fclk-dash-empty { text-align: center; color: $fclk-dash-muted; padding: 18px 0; font-size: 13px; }
|
||||||
|
|
||||||
|
.fclk-dash-divider {
|
||||||
|
display: flex; align-items: center; gap: 12px; margin: 22px 0 14px;
|
||||||
|
span {
|
||||||
|
font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px;
|
||||||
|
color: $fclk-dash-muted; font-weight: 700; white-space: nowrap;
|
||||||
|
}
|
||||||
|
&::before, &::after { content: ""; flex: 1; height: 1px; background: $fclk-dash-border; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.fclk-dash-card--absent {
|
.fclk-dash-av {
|
||||||
background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(248, 113, 113, 0.08) 100%);
|
display: inline-flex; width: 26px; height: 26px; border-radius: 50%;
|
||||||
border-color: rgba(239, 68, 68, 0.25);
|
background: $fclk-dash-row; color: $fclk-dash-text; font-size: 11px; font-weight: 700;
|
||||||
.fclk-dash-card-value { color: #fca5a5; }
|
align-items: center; justify-content: center; margin-right: 8px;
|
||||||
.fclk-dash-card-label { color: #f87171; }
|
}
|
||||||
.fclk-dash-card-icon { background: rgba(239, 68, 68, 0.18); color: #f87171; }
|
.fclk-dash-late-badge {
|
||||||
|
background: rgba(217, 119, 6, .15); color: #d97706; border-radius: 999px;
|
||||||
|
padding: 2px 8px; font-size: 11px; font-weight: 700; margin-left: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fclk-dash-card--late {
|
.fclk-dash-actions { display: flex; flex-wrap: wrap; gap: 10px; }
|
||||||
background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(251, 191, 36, 0.08) 100%);
|
.fclk-dash-act {
|
||||||
border-color: rgba(245, 158, 11, 0.25);
|
background: $fclk-dash-page; border: 1px solid $fclk-dash-border; border-radius: 10px;
|
||||||
.fclk-dash-card-value { color: #fcd34d; }
|
padding: 9px 14px; font-size: 13px; color: $fclk-dash-text; cursor: pointer;
|
||||||
.fclk-dash-card-label { color: #fbbf24; }
|
&:hover { border-color: $fclk-blue; }
|
||||||
.fclk-dash-card-icon { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.fclk-dash-card:hover {
|
@media (max-width: 992px) {
|
||||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
|
.fclk-kpi-row { grid-template-columns: repeat(2, 1fr); }
|
||||||
|
.fclk-dash-2col { grid-template-columns: 1fr; }
|
||||||
|
}
|
||||||
|
@media (max-width: 576px) {
|
||||||
|
.fclk-kpi-row { grid-template-columns: 1fr; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,148 +2,198 @@
|
|||||||
<templates xml:space="preserve">
|
<templates xml:space="preserve">
|
||||||
|
|
||||||
<t t-name="fusion_clock.Dashboard">
|
<t t-name="fusion_clock.Dashboard">
|
||||||
<div class="o_action">
|
<div class="o_action fclk-dash">
|
||||||
<div class="container-fluid py-3">
|
<div class="fclk-dash-wrap">
|
||||||
|
|
||||||
<!-- Header -->
|
|
||||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
||||||
<h2 class="mb-0">Fusion Clock Dashboard</h2>
|
|
||||||
<button class="btn btn-outline-primary" t-on-click="onRefresh">
|
|
||||||
<i class="fa fa-refresh"/> Refresh
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<t t-if="state.loading">
|
<t t-if="state.loading">
|
||||||
<div class="text-center py-5">
|
<div class="fclk-dash-empty">
|
||||||
<i class="fa fa-spinner fa-spin fa-2x"/>
|
<i class="fa fa-spinner fa-spin fa-2x"/>
|
||||||
<p class="mt-2">Loading dashboard...</p>
|
<p class="mt-2">Loading dashboard…</p>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
|
|
||||||
<t t-if="state.error">
|
<t t-if="state.error">
|
||||||
<div class="alert alert-danger">
|
<div class="fclk-dash-card"><t t-esc="state.error"/></div>
|
||||||
<t t-esc="state.error"/>
|
|
||||||
</div>
|
|
||||||
</t>
|
</t>
|
||||||
|
|
||||||
<t t-if="!state.loading and !state.error">
|
<t t-if="!state.loading and !state.error">
|
||||||
<!-- Summary Cards -->
|
<!-- HEADER -->
|
||||||
<div class="row mb-4">
|
<div class="fclk-dash-header">
|
||||||
<div class="col-md-3 mb-3">
|
<div>
|
||||||
<div class="fclk-dash-card fclk-dash-card--total">
|
<div class="fclk-dash-hello"><t t-esc="greeting"/>, <t t-esc="state.personal.employee_name"/> 👋</div>
|
||||||
<div class="fclk-dash-card-icon">
|
<div class="fclk-dash-date"><t t-esc="todayLabel"/></div>
|
||||||
<i class="fa fa-users"/>
|
|
||||||
</div>
|
|
||||||
<div class="fclk-dash-card-value"><t t-esc="state.total_employees"/></div>
|
|
||||||
<div class="fclk-dash-card-label">Total Employees</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 mb-3">
|
<div class="fclk-dash-headctl">
|
||||||
<div class="fclk-dash-card fclk-dash-card--present">
|
<span class="fclk-dash-statusbadge" t-att-class="{'is-out': !state.personal.is_checked_in}">
|
||||||
<div class="fclk-dash-card-icon">
|
<t t-if="state.personal.is_checked_in">● Clocked in</t>
|
||||||
<i class="fa fa-check-circle"/>
|
<t t-else="">○ Not clocked in</t>
|
||||||
</div>
|
</span>
|
||||||
<div class="fclk-dash-card-value"><t t-esc="state.present_count"/></div>
|
<button class="fclk-dash-btn-primary" t-on-click="onOpenClock">Open My Clock</button>
|
||||||
<div class="fclk-dash-card-label">Present Today</div>
|
<button class="fclk-dash-btn-ghost" t-on-click="onRefresh"><i class="fa fa-refresh"/></button>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3 mb-3">
|
|
||||||
<div class="fclk-dash-card fclk-dash-card--absent">
|
|
||||||
<div class="fclk-dash-card-icon">
|
|
||||||
<i class="fa fa-times-circle"/>
|
|
||||||
</div>
|
|
||||||
<div class="fclk-dash-card-value"><t t-esc="state.absent_count"/></div>
|
|
||||||
<div class="fclk-dash-card-label">Absent Today</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3 mb-3">
|
|
||||||
<div class="fclk-dash-card fclk-dash-card--late">
|
|
||||||
<div class="fclk-dash-card-icon">
|
|
||||||
<i class="fa fa-clock-o"/>
|
|
||||||
</div>
|
|
||||||
<div class="fclk-dash-card-value"><t t-esc="state.late_count"/></div>
|
|
||||||
<div class="fclk-dash-card-label">Late Today</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<!-- PERSONAL KPIs -->
|
||||||
<!-- Currently Clocked In -->
|
<div class="fclk-kpi-row">
|
||||||
<div class="col-md-8 mb-4">
|
<div class="fclk-kpi fclk-kpi--today">
|
||||||
<div class="card">
|
<div class="fclk-kpi-ic">⏱</div>
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="fclk-kpi-val"><t t-esc="state.personal.today_hours"/>h</div>
|
||||||
<h5 class="mb-0">Currently Clocked In</h5>
|
<div class="fclk-kpi-lbl">Today</div>
|
||||||
<span class="badge bg-success"><t t-esc="state.clocked_in.length"/> active</span>
|
</div>
|
||||||
</div>
|
<div class="fclk-kpi fclk-kpi--week">
|
||||||
<div class="card-body p-0">
|
<div class="fclk-kpi-ic">📅</div>
|
||||||
<t t-if="state.clocked_in.length === 0">
|
<div class="fclk-kpi-val"><t t-esc="state.personal.week_hours"/>h</div>
|
||||||
<div class="text-center py-4 text-muted">
|
<div class="fclk-kpi-lbl">This Week</div>
|
||||||
No employees currently clocked in
|
</div>
|
||||||
</div>
|
<div class="fclk-kpi fclk-kpi--ot">
|
||||||
</t>
|
<div class="fclk-kpi-ic">⚡</div>
|
||||||
<t t-else="">
|
<div class="fclk-kpi-val"><t t-esc="state.personal.overtime_week"/>h</div>
|
||||||
<table class="table table-sm mb-0">
|
<div class="fclk-kpi-lbl">OT This Week</div>
|
||||||
<thead>
|
</div>
|
||||||
<tr>
|
<div class="fclk-kpi fclk-kpi--streak">
|
||||||
<th>Employee</th>
|
<div class="fclk-kpi-ic">🔥</div>
|
||||||
<th>Clock-In</th>
|
<div class="fclk-kpi-val"><t t-esc="state.personal.ontime_streak"/></div>
|
||||||
<th>Location</th>
|
<div class="fclk-kpi-lbl">On-time Streak</div>
|
||||||
</tr>
|
</div>
|
||||||
</thead>
|
</div>
|
||||||
<tbody>
|
|
||||||
<t t-foreach="state.clocked_in" t-as="emp" t-key="emp_index">
|
<!-- PERSONAL DETAIL -->
|
||||||
<tr>
|
<div class="fclk-dash-2col">
|
||||||
<td><t t-esc="emp.employee"/></td>
|
<div class="fclk-dash-card">
|
||||||
<td><t t-esc="emp.check_in"/></td>
|
<h4>Today's Shift</h4>
|
||||||
<td><t t-esc="emp.location"/></td>
|
<div class="fclk-dash-line">
|
||||||
</tr>
|
<span>Scheduled</span>
|
||||||
</t>
|
<span class="fclk-dash-muted">
|
||||||
</tbody>
|
<t t-if="state.personal.shift.label"><t t-esc="state.personal.shift.label"/> (<t t-esc="state.personal.shift.hours"/>h)</t>
|
||||||
</table>
|
<t t-else="">Not scheduled today</t>
|
||||||
</t>
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="fclk-dash-line">
|
||||||
|
<span>Status</span>
|
||||||
|
<span t-att-class="state.personal.is_checked_in ? 'fclk-pin' : 'fclk-dash-muted'"><t t-esc="state.personal.shift.status_note"/></span>
|
||||||
|
</div>
|
||||||
|
<div class="fclk-dash-line">
|
||||||
|
<span>Source</span>
|
||||||
|
<span class="fclk-dash-muted"><t t-esc="sourceLabel(state.personal.shift.source)"/></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="fclk-dash-card">
|
||||||
|
<h4>My Recent Activity</h4>
|
||||||
|
<t t-if="state.personal.recent_activity.length === 0">
|
||||||
|
<div class="fclk-dash-empty">No recent activity</div>
|
||||||
|
</t>
|
||||||
|
<t t-foreach="state.personal.recent_activity" t-as="a" t-key="a_index">
|
||||||
|
<div class="fclk-dash-line">
|
||||||
|
<span><t t-esc="fmtDate(a.check_in)"/></span>
|
||||||
|
<span class="fclk-dash-muted">
|
||||||
|
<t t-esc="a.worked_hours"/>h<t t-if="a.overtime_hours > 0"> · +<t t-esc="a.overtime_hours"/> OT</t>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="fclk-dash-2col">
|
||||||
|
<div class="fclk-dash-card">
|
||||||
|
<h4>Upcoming Leave</h4>
|
||||||
|
<t t-if="state.personal.leaves.length === 0">
|
||||||
|
<div class="fclk-dash-empty">No upcoming leave</div>
|
||||||
|
</t>
|
||||||
|
<t t-foreach="state.personal.leaves" t-as="lv" t-key="lv_index">
|
||||||
|
<div class="fclk-dash-line"><span><t t-esc="lv.label"/></span><span class="fclk-dash-muted"><t t-esc="lv.state"/></span></div>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
<div class="fclk-dash-card">
|
||||||
|
<h4>Recent Penalties</h4>
|
||||||
|
<t t-if="state.personal.penalties.length === 0">
|
||||||
|
<div class="fclk-dash-empty">None this month 🎉</div>
|
||||||
|
</t>
|
||||||
|
<t t-foreach="state.personal.penalties" t-as="p" t-key="p_index">
|
||||||
|
<div class="fclk-dash-line"><span><t t-esc="p.type"/> · <t t-esc="p.date"/></span><span class="fclk-pyel">−<t t-esc="p.minutes"/> min</span></div>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- TEAM / ORG BAND -->
|
||||||
|
<t t-if="state.team">
|
||||||
|
<div class="fclk-dash-divider"><span>Team / Org</span></div>
|
||||||
|
|
||||||
|
<div class="fclk-kpi-row">
|
||||||
|
<div class="fclk-kpi fclk-kpi--present">
|
||||||
|
<div class="fclk-kpi-ic">✅</div>
|
||||||
|
<div class="fclk-kpi-val"><t t-esc="state.team.present_count"/></div>
|
||||||
|
<div class="fclk-kpi-lbl">Present now</div>
|
||||||
|
</div>
|
||||||
|
<div class="fclk-kpi fclk-kpi--absent">
|
||||||
|
<div class="fclk-kpi-ic">🚫</div>
|
||||||
|
<div class="fclk-kpi-val"><t t-esc="state.team.absent_count"/></div>
|
||||||
|
<div class="fclk-kpi-lbl">Absent today</div>
|
||||||
|
</div>
|
||||||
|
<div class="fclk-kpi fclk-kpi--late">
|
||||||
|
<div class="fclk-kpi-ic">⏰</div>
|
||||||
|
<div class="fclk-kpi-val"><t t-esc="state.team.late_count"/></div>
|
||||||
|
<div class="fclk-kpi-lbl">Late today</div>
|
||||||
|
</div>
|
||||||
|
<div class="fclk-kpi fclk-kpi--pending">
|
||||||
|
<div class="fclk-kpi-ic">📨</div>
|
||||||
|
<div class="fclk-kpi-val"><t t-esc="state.team.pending_approvals"/></div>
|
||||||
|
<div class="fclk-kpi-lbl">Pending approvals</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Alerts Panel -->
|
<div class="fclk-dash-2col">
|
||||||
<div class="col-md-4 mb-4">
|
<div class="fclk-dash-card">
|
||||||
<div class="card">
|
<h4>Currently Clocked In <span class="fclk-dash-muted"><t t-esc="state.team.present_count"/> of <t t-esc="state.team.total_employees"/></span></h4>
|
||||||
<div class="card-header">
|
<t t-if="state.team.clocked_in.length === 0">
|
||||||
<h5 class="mb-0">Alerts</h5>
|
<div class="fclk-dash-empty">No one is clocked in right now</div>
|
||||||
|
</t>
|
||||||
|
<t t-foreach="state.team.clocked_in" t-as="emp" t-key="emp_index">
|
||||||
|
<div class="fclk-dash-line">
|
||||||
|
<span><span class="fclk-dash-av"><t t-esc="initials(emp.employee)"/></span><t t-esc="emp.employee"/>
|
||||||
|
<span t-if="emp.late" class="fclk-dash-late-badge">late</span>
|
||||||
|
</span>
|
||||||
|
<span class="fclk-dash-muted"><t t-esc="fmtTime(emp.check_in)"/> · <t t-esc="emp.location"/></span>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
<div class="fclk-dash-card">
|
||||||
|
<h4>Needs Attention</h4>
|
||||||
|
<div class="fclk-dash-line" t-on-click="onViewActivityLogs" style="cursor:pointer;">
|
||||||
|
<span class="fclk-pred"><t t-esc="state.team.absent_count"/> absent (no leave)</span>
|
||||||
|
<span class="fclk-dash-muted">review →</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="fclk-dash-line">
|
||||||
<div class="d-flex justify-content-between align-items-center mb-3 cursor-pointer"
|
<span><t t-esc="state.team.on_leave_count"/> on approved leave</span>
|
||||||
t-on-click="onViewActivityLogs">
|
<span class="fclk-dash-muted">today</span>
|
||||||
<span><i class="fa fa-exclamation-circle text-warning me-2"/>Pending Reasons</span>
|
</div>
|
||||||
<span class="badge bg-warning"><t t-esc="state.pending_reasons"/></span>
|
<div class="fclk-dash-line" t-on-click="onViewActivityLogs" style="cursor:pointer;">
|
||||||
</div>
|
<span class="fclk-pyel"><t t-esc="state.team.pending_reasons"/> auto clock-out — reason pending</span>
|
||||||
<div class="d-flex justify-content-between align-items-center mb-3 cursor-pointer"
|
<span class="fclk-dash-muted">view →</span>
|
||||||
t-on-click="onViewCorrections">
|
</div>
|
||||||
<span><i class="fa fa-edit text-info me-2"/>Pending Corrections</span>
|
<div class="fclk-dash-line" t-on-click="onViewCorrections" style="cursor:pointer;">
|
||||||
<span class="badge bg-info"><t t-esc="state.pending_corrections"/></span>
|
<span><t t-esc="state.team.pending_approvals"/> correction requests</span>
|
||||||
</div>
|
<span class="fclk-dash-muted">open →</span>
|
||||||
<div class="d-flex justify-content-between align-items-center cursor-pointer"
|
|
||||||
t-on-click="onViewPenalties">
|
|
||||||
<span><i class="fa fa-clock-o text-danger me-2"/>Late Today</span>
|
|
||||||
<span class="badge bg-danger"><t t-esc="state.late_count"/></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</t>
|
||||||
|
|
||||||
<!-- Quick Actions -->
|
<!-- QUICK ACTIONS -->
|
||||||
<div class="card mt-3">
|
<div class="fclk-dash-card">
|
||||||
<div class="card-header">
|
<h4>Quick Actions</h4>
|
||||||
<h5 class="mb-0">Quick Actions</h5>
|
<div class="fclk-dash-actions">
|
||||||
</div>
|
<span class="fclk-dash-act" t-on-click="onOpenClock">🕒 Open My Clock</span>
|
||||||
<div class="card-body">
|
<span class="fclk-dash-act" t-on-click="onViewTimesheets">📄 My Timesheets</span>
|
||||||
<button class="btn btn-outline-primary w-100 mb-2" t-on-click="onViewAttendances">
|
<t t-if="state.team">
|
||||||
<i class="fa fa-list me-1"/> View All Attendances
|
<span class="fclk-dash-act" t-on-click="onViewAttendances">📋 All Attendances</span>
|
||||||
</button>
|
<span class="fclk-dash-act" t-on-click="onViewCorrections">📨 Approvals</span>
|
||||||
<button class="btn btn-outline-secondary w-100" t-on-click="onViewActivityLogs">
|
<span class="fclk-dash-act" t-on-click="onViewPenalties">⚠ Penalties</span>
|
||||||
<i class="fa fa-history me-1"/> Activity Logs
|
<span class="fclk-dash-act" t-on-click="onViewActivityLogs">🗒 Activity Logs</span>
|
||||||
</button>
|
</t>
|
||||||
</div>
|
<t t-if="state.role === 'manager'">
|
||||||
</div>
|
<span class="fclk-dash-act" t-on-click="onViewShiftPlanner">📅 Shift Planner</span>
|
||||||
|
<span class="fclk-dash-act" t-on-click="onViewReports">📊 Reports</span>
|
||||||
|
</t>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ from . import test_clock_nfc_kiosk
|
|||||||
from . import test_shift_planner
|
from . import test_shift_planner
|
||||||
from . import test_photo_retention
|
from . import test_photo_retention
|
||||||
from . import test_schedule_driven
|
from . import test_schedule_driven
|
||||||
|
from . import test_dashboard
|
||||||
|
|||||||
142
fusion_clock/tests/test_dashboard.py
Normal file
142
fusion_clock/tests/test_dashboard.py
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import json
|
||||||
|
from odoo import fields
|
||||||
|
from odoo.tests import tagged, HttpCase
|
||||||
|
|
||||||
|
|
||||||
|
@tagged('-at_install', 'post_install', 'fusion_clock')
|
||||||
|
class TestFusionClockDashboard(HttpCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super().setUpClass()
|
||||||
|
Users = cls.env['res.users']
|
||||||
|
Emp = cls.env['hr.employee']
|
||||||
|
|
||||||
|
g_user = cls.env.ref('fusion_clock.group_fusion_clock_user')
|
||||||
|
g_lead = cls.env.ref('fusion_clock.group_fusion_clock_team_lead')
|
||||||
|
g_mgr = cls.env.ref('fusion_clock.group_fusion_clock_manager')
|
||||||
|
g_internal = cls.env.ref('base.group_user')
|
||||||
|
|
||||||
|
def mk_user(login, group):
|
||||||
|
return Users.create({
|
||||||
|
'name': login,
|
||||||
|
'login': login,
|
||||||
|
'password': login,
|
||||||
|
'group_ids': [(6, 0, (g_internal + group).ids)],
|
||||||
|
})
|
||||||
|
|
||||||
|
cls.mgr_user = mk_user('fc_mgr', g_mgr)
|
||||||
|
cls.mgr_emp = Emp.create({
|
||||||
|
'name': 'Manager Mae', 'user_id': cls.mgr_user.id,
|
||||||
|
'x_fclk_enable_clock': True,
|
||||||
|
})
|
||||||
|
cls.lead_user = mk_user('fc_lead', g_lead)
|
||||||
|
cls.lead_emp = Emp.create({
|
||||||
|
'name': 'Lead Leo', 'user_id': cls.lead_user.id,
|
||||||
|
'x_fclk_enable_clock': True,
|
||||||
|
})
|
||||||
|
cls.rep1_user = mk_user('fc_rep1', g_user)
|
||||||
|
cls.rep1_emp = Emp.create({
|
||||||
|
'name': 'Report Rita', 'user_id': cls.rep1_user.id,
|
||||||
|
'parent_id': cls.lead_emp.id, 'x_fclk_enable_clock': True,
|
||||||
|
})
|
||||||
|
cls.rep2_user = mk_user('fc_rep2', g_user)
|
||||||
|
cls.rep2_emp = Emp.create({
|
||||||
|
'name': 'Report Raj', 'user_id': cls.rep2_user.id,
|
||||||
|
'parent_id': cls.lead_emp.id, 'x_fclk_enable_clock': True,
|
||||||
|
})
|
||||||
|
cls.other_user = mk_user('fc_other', g_user)
|
||||||
|
cls.other_emp = Emp.create({
|
||||||
|
'name': 'Outsider Olga', 'user_id': cls.other_user.id,
|
||||||
|
'parent_id': cls.mgr_emp.id, 'x_fclk_enable_clock': True,
|
||||||
|
})
|
||||||
|
|
||||||
|
# Clock in both of the lead's reports so present_count / roster are
|
||||||
|
# exercised (and so the leak test proves a clocked-in *sibling* never
|
||||||
|
# appears in another employee's payload).
|
||||||
|
Att = cls.env['hr.attendance']
|
||||||
|
now = fields.Datetime.now()
|
||||||
|
Att.create({'employee_id': cls.rep1_emp.id, 'check_in': now})
|
||||||
|
Att.create({'employee_id': cls.rep2_emp.id, 'check_in': now})
|
||||||
|
|
||||||
|
def _call(self):
|
||||||
|
resp = self.url_open(
|
||||||
|
'/fusion_clock/dashboard_data',
|
||||||
|
data=json.dumps({'jsonrpc': '2.0', 'method': 'call', 'params': {}}),
|
||||||
|
headers={'Content-Type': 'application/json'},
|
||||||
|
)
|
||||||
|
self.assertEqual(resp.status_code, 200)
|
||||||
|
result = resp.json()['result']
|
||||||
|
self.assertFalse(isinstance(result, dict) and result.get('error'), msg=result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
# ---- Task 1: personal block ----
|
||||||
|
def test_employee_sees_only_personal(self):
|
||||||
|
self.authenticate('fc_rep1', 'fc_rep1')
|
||||||
|
data = self._call()
|
||||||
|
self.assertEqual(data['role'], 'employee')
|
||||||
|
self.assertIsNone(data['team'])
|
||||||
|
self.assertEqual(data['personal']['employee_name'], 'Report Rita')
|
||||||
|
for key in ('today_hours', 'week_hours', 'overtime_week', 'ontime_streak', 'shift'):
|
||||||
|
self.assertIn(key, data['personal'])
|
||||||
|
|
||||||
|
# ---- Task 2: team/org scoping ----
|
||||||
|
def test_team_lead_scoped_to_direct_reports(self):
|
||||||
|
self.authenticate('fc_lead', 'fc_lead')
|
||||||
|
data = self._call()
|
||||||
|
self.assertEqual(data['role'], 'team_lead')
|
||||||
|
self.assertIsNotNone(data['team'])
|
||||||
|
self.assertEqual(data['team']['scope'], 'team')
|
||||||
|
self.assertEqual(data['team']['total_employees'], 2)
|
||||||
|
for key in ('present_count', 'absent_count', 'on_leave_count',
|
||||||
|
'late_count', 'pending_reasons', 'pending_approvals', 'clocked_in'):
|
||||||
|
self.assertIn(key, data['team'])
|
||||||
|
# both reports are clocked in → present and on the roster
|
||||||
|
self.assertEqual(data['team']['present_count'], 2)
|
||||||
|
self.assertEqual(data['team']['absent_count'], 0)
|
||||||
|
roster_names = {row['employee'] for row in data['team']['clocked_in']}
|
||||||
|
self.assertEqual(roster_names, {'Report Rita', 'Report Raj'})
|
||||||
|
|
||||||
|
def test_manager_sees_org_wide(self):
|
||||||
|
self.authenticate('fc_mgr', 'fc_mgr')
|
||||||
|
data = self._call()
|
||||||
|
self.assertEqual(data['role'], 'manager')
|
||||||
|
self.assertIsNotNone(data['team'])
|
||||||
|
self.assertEqual(data['team']['scope'], 'org')
|
||||||
|
self.assertGreaterEqual(data['team']['total_employees'], 5)
|
||||||
|
# the two clocked-in reports are counted org-wide too
|
||||||
|
self.assertGreaterEqual(data['team']['present_count'], 2)
|
||||||
|
|
||||||
|
# ---- Task 3: no cross-employee leak + no-employee path ----
|
||||||
|
def test_no_cross_employee_leak_for_employee(self):
|
||||||
|
self.authenticate('fc_rep1', 'fc_rep1')
|
||||||
|
data = self._call()
|
||||||
|
blob = json.dumps(data)
|
||||||
|
self.assertIn('Report Rita', blob) # own name present
|
||||||
|
self.assertNotIn('Report Raj', blob) # sibling absent
|
||||||
|
self.assertNotIn('Outsider Olga', blob) # unrelated absent
|
||||||
|
self.assertNotIn('Lead Leo', blob) # lead absent
|
||||||
|
|
||||||
|
def test_team_lead_roster_excludes_outsiders(self):
|
||||||
|
self.authenticate('fc_lead', 'fc_lead')
|
||||||
|
data = self._call()
|
||||||
|
blob = json.dumps(data['team'])
|
||||||
|
self.assertNotIn('Outsider Olga', blob)
|
||||||
|
self.assertNotIn('Manager Mae', blob)
|
||||||
|
|
||||||
|
def test_user_without_employee_gets_error(self):
|
||||||
|
g_user = self.env.ref('fusion_clock.group_fusion_clock_user')
|
||||||
|
g_internal = self.env.ref('base.group_user')
|
||||||
|
self.env['res.users'].create({
|
||||||
|
'name': 'No Emp', 'login': 'fc_noemp', 'password': 'fc_noemp',
|
||||||
|
'group_ids': [(6, 0, (g_internal + g_user).ids)],
|
||||||
|
})
|
||||||
|
self.authenticate('fc_noemp', 'fc_noemp')
|
||||||
|
resp = self.url_open(
|
||||||
|
'/fusion_clock/dashboard_data',
|
||||||
|
data=json.dumps({'jsonrpc': '2.0', 'method': 'call', 'params': {}}),
|
||||||
|
headers={'Content-Type': 'application/json'},
|
||||||
|
)
|
||||||
|
self.assertEqual(resp.status_code, 200)
|
||||||
|
self.assertIn('error', resp.json()['result'])
|
||||||
@@ -24,13 +24,15 @@
|
|||||||
sequence="46"
|
sequence="46"
|
||||||
groups="group_fusion_clock_kiosk_app"/>
|
groups="group_fusion_clock_kiosk_app"/>
|
||||||
|
|
||||||
<!-- Dashboard -->
|
<!-- Dashboard — layered & role-aware: personal band for everyone,
|
||||||
|
team band for leads (direct reports), org band for managers.
|
||||||
|
Gated to the base clock-user group (lead/manager imply it). -->
|
||||||
<menuitem id="menu_fusion_clock_dashboard"
|
<menuitem id="menu_fusion_clock_dashboard"
|
||||||
name="Dashboard"
|
name="Dashboard"
|
||||||
parent="menu_fusion_clock_root"
|
parent="menu_fusion_clock_root"
|
||||||
action="action_fusion_clock_dashboard"
|
action="action_fusion_clock_dashboard"
|
||||||
sequence="5"
|
sequence="5"
|
||||||
groups="group_fusion_clock_manager,group_fusion_clock_team_lead"/>
|
groups="group_fusion_clock_user"/>
|
||||||
|
|
||||||
<!-- ============================================================
|
<!-- ============================================================
|
||||||
Attendance — day-to-day operational records
|
Attendance — day-to-day operational records
|
||||||
|
|||||||
Reference in New Issue
Block a user