Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions medplat-ui/app/config.lazyload.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@
'sidetabs.directive': ['app/common/directives/sidetabs/sidetabs.directive.js'],
'confirmation.modal': ['app/common/controllers/confirmation.modal.controller.js'],
'customjs': ['styles/js/custom.js'],
'fhs-dashboard.controller': ['app/fhs/dashboard/controllers/fhs-dashboard.controller.js'],
'fhs-dashboard.service': ['app/fhs/dashboard/services/fhs-dashboard.service.js'],
'fhs-dashboard.controller': ['app/training/mytrainingdashboard/controllers/dashboard.controller.js'],
'main-dashboard.controller': ['app/dashboard/controllers/dashboard.controller.js'],
'dashboard.service': ['app/training/mytrainingdashboard/services/dashboard.service.js'],
'main-dashboard.service': ['app/dashboard/services/dashboard.service.js'],
'alasql': ['node_modules/alasql/dist/alasql.js'],
'printthis': ['third_party/printthis.js'],
'firePath': ['third_party/fhirpath.min.js'],
Expand Down
10 changes: 10 additions & 0 deletions medplat-ui/app/config.router.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@
abstract: true,
template: '<ui-view></ui-view>'
})
.state('techo.dashboard.home', {
url: '',
title: 'Dashboard',
templateUrl: 'app/dashboard/views/dashboard.html',
controller: 'DashboardController as dashboard',
resolve: load([
'main-dashboard.controller',
'main-dashboard.service'
])
})
.state('techo.admin', {
url: "/admin",
abstract: true,
Expand Down
66 changes: 66 additions & 0 deletions medplat-ui/app/dashboard/controllers/dashboard.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
(function () {
'use strict';

angular.module('imtecho').controller('DashboardController', DashboardController);

function DashboardController($scope, $state, DashboardService, GeneralUtil) {
var vm = this;

vm.$onInit = function () {
vm.loading = true;
vm.dashboardData = {};
vm.error = null;
loadDashboardData();
};

function loadDashboardData() {
DashboardService.getDashboardData()
.then(function (response) {
vm.dashboardData = response.data;
vm.loading = false;
})
.catch(function (error) {
vm.error = 'Failed to load dashboard data';
vm.loading = false;
GeneralUtil.showMessageOnApiFailure(error);
});
}

vm.navigateToModule = function (module) {
switch (module) {
case 'admin':
$state.go('admin');
break;
case 'manage':
$state.go('manage');
break;
case 'ncd':
$state.go('ncd');
break;
case 'training':
$state.go('training');
break;
default:
console.warn('Unknown module:', module);
}
};

vm.refreshDashboard = function () {
vm.loading = true;
loadDashboardData();
};

vm.getActivityIconClass = function (activityType) {
switch (activityType) {
case 'user_login':
return 'text-success';
case 'record_created':
return 'text-info';
case 'data_sync':
return 'text-warning';
default:
return 'text-muted';
}
};
}
})();
132 changes: 132 additions & 0 deletions medplat-ui/app/dashboard/services/dashboard.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
(function () {
'use strict';

angular.module('imtecho').service('DashboardService', DashboardService);

function DashboardService($q, $http, GeneralUtil) {
this.getDashboardData = function () {
var deferred = $q.defer();

// Mock data for demonstration - replace with actual API call
var mockData = {
summary: {
totalUsers: 1250,
activeUsers: 890,
totalRecords: 15678,
todayRecords: 234,
lastUpdate: new Date()
},
recentActivities: [
{
id: 1,
type: 'user_login',
description: 'User John Doe logged in',
timestamp: new Date(Date.now() - 3600000).toISOString()
},
{
id: 2,
type: 'record_created',
description: 'New patient record created',
timestamp: new Date(Date.now() - 7200000).toISOString()
},
{
id: 3,
type: 'data_sync',
description: 'Data synchronization completed',
timestamp: new Date(Date.now() - 10800000).toISOString()
}
],
quickStats: [
{
title: 'Total Patients',
value: 3456,
icon: 'fa-users',
color: 'blue',
trend: '+12%'
},
{
title: 'Appointments Today',
value: 89,
icon: 'fa-calendar',
color: 'green',
trend: '+5%'
},
{
title: 'Pending Tasks',
value: 23,
icon: 'fa-tasks',
color: 'orange',
trend: '-8%'
},
{
title: 'System Health',
value: '98%',
icon: 'fa-heartbeat',
color: 'green',
trend: 'Stable'
}
],
modules: [
{
name: 'Administration',
key: 'admin',
description: 'System administration and configuration',
icon: 'fa-cog',
users: 45
},
{
name: 'Manage',
key: 'manage',
description: 'Data management and records',
icon: 'fa-database',
users: 234
},
{
name: 'NCD',
key: 'ncd',
description: 'Non-communicable diseases management',
icon: 'fa-heart',
users: 156
},
{
name: 'Training',
key: 'training',
description: 'Training and education modules',
icon: 'fa-graduation-cap',
users: 78
}
]
};

// Simulate API delay
setTimeout(function () {
deferred.resolve({
data: mockData
});
}, 500);

return deferred.promise;
};

this.getSystemHealth = function () {
var deferred = $q.defer();

// Mock system health data
var healthData = {
status: 'healthy',
uptime: '99.9%',
lastBackup: new Date().toISOString(),
databaseStatus: 'connected',
apiStatus: 'operational'
};

setTimeout(function () {
deferred.resolve({
data: healthData
});
}, 300);

return deferred.promise;
};
}
})();
Loading