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
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(function () {
'use strict';
angular.module('imtecho')
.controller('AdminChatbotDashboardController', AdminChatbotDashboardController);

AdminChatbotDashboardController.$inject = ['$scope', 'ChatbotService'];

function AdminChatbotDashboardController($scope, ChatbotService) {
var vm = this;

vm.stats = {
totalTickets: 154,
resolvedTickets: 120,
avgResolutionTime: '4.2 hrs',
userSatisfaction: '4.8/5'
};

vm.trends = [
{ category: 'Technical', count: 45 },
{ category: 'Clinical', count: 82 },
{ category: 'Administrative', count: 12 },
{ category: 'Other', count: 15 }
];
}
})();
71 changes: 71 additions & 0 deletions medplat-ui/app/chatbot/controllers/chatbot.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
(function () {
'use strict';
angular.module('imtecho')
.controller('ChatbotController', ChatbotController);

ChatbotController.$inject = ['$scope', 'ChatbotService', '$state'];

function ChatbotController($scope, ChatbotService, $state) {
var vm = this;

vm.messages = [
{ sender: 'AI ANM', text: 'Hello! I am your AI assistant. How can I help you today?', time: new Date() }
];
vm.newMessage = '';
vm.isTyping = false;
vm.selectedLanguage = 'en';
vm.languages = [
{ code: 'en', name: 'English' },
{ code: 'hi', name: 'Hindi' },
{ code: 'gu', name: 'Gujarati' }
];

vm.sendMessage = function () {
if (!vm.newMessage.trim()) return;

var userMsg = { sender: 'You', text: vm.newMessage, time: new Date() };
vm.messages.push(userMsg);
var textToSend = vm.newMessage;
vm.newMessage = '';
vm.isTyping = true;

ChatbotService.sendMessage(textToSend).then(function (response) {
$scope.$apply(function () {
vm.messages.push({
sender: 'AI ANM',
text: response.data.response,
time: new Date()
});
vm.isTyping = false;
});
});
};

vm.changeLanguage = function () {
// Toggle language logic here
console.log('Language changed to: ' + vm.selectedLanguage);
};

vm.reportIssue = function () {
vm.messages.push({
sender: 'AI ANM',
text: 'Sure, I can help you report an issue. What type of issue is it?',
isFlow: true,
options: ['Technical', 'Clinical', 'Administrative', 'Other']
});
};

vm.selectOption = function (option) {
vm.messages.push({ sender: 'You', text: option, time: new Date() });
vm.messages.push({
sender: 'AI ANM',
text: 'I\'ve started a report for a ' + option + ' issue. Please describe the issue in detail.',
time: new Date()
});
};

vm.closeChat = function () {
$state.go('techo.dashboard.webtasks');
};
}
})();
39 changes: 39 additions & 0 deletions medplat-ui/app/chatbot/controllers/ticket-dashboard.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
(function () {
'use strict';
angular.module('imtecho')
.controller('TicketDashboardController', TicketDashboardController);

TicketDashboardController.$inject = ['$scope', 'ChatbotService', 'PagingService'];

function TicketDashboardController($scope, ChatbotService, PagingService) {
var vm = this;

vm.tickets = [];
vm.loading = false;
vm.filter = {
status: 'ALL',
priority: 'ALL'
};

vm.loadTickets = function () {
vm.loading = true;
ChatbotService.getTickets(vm.filter).then(function (response) {
$scope.$apply(function () {
vm.tickets = response.data.content;
vm.loading = false;
});
});
};

vm.getStatusClass = function (status) {
switch (status) {
case 'OPEN': return 'badge-info';
case 'IN_PROGRESS': return 'badge-warning';
case 'CLOSED': return 'badge-success';
default: return 'badge-secondary';
}
};

vm.loadTickets();
}
})();
56 changes: 56 additions & 0 deletions medplat-ui/app/chatbot/services/chatbot.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(function () {
'use strict';
angular.module('imtecho')
.service('ChatbotService', ChatbotService);

ChatbotService.$inject = ['$http', 'AUTHENTICATION_URL', 'GENERAL_CONFIG'];

function ChatbotService($http, AUTHENTICATION_URL, GENERAL_CONFIG) {
var service = this;

service.sendMessage = function (message) {
// Mocking AI response for now
// In real scenario: return $http.post(GENERAL_CONFIG.apiUrl + '/chatbot/message', { text: message });
return new Promise(function (resolve) {
setTimeout(function () {
var responses = [
"I understand. Let me help you with that.",
"I've noted the issue. Would you like to create a ticket?",
"Hello! I am AI ANM, your assistant. How can I help you today?",
"Please provide more details so I can assist you better.",
"That's interesting! I'll look into it."
];
var randomResponse = responses[Math.floor(Math.random() * responses.length)];
resolve({ data: { response: randomResponse } });
}, 1000);
});
};

service.getTickets = function (params) {
// Mocking ticket retrieval
return new Promise(function (resolve) {
setTimeout(function () {
resolve({
data: {
content: [
{ id: 'TKT-001', title: 'Login Issue', status: 'OPEN', priority: 'HIGH', createdAt: new Date() },
{ id: 'TKT-002', title: 'Data Not Syncing', status: 'IN_PROGRESS', priority: 'MEDIUM', createdAt: new Date() },
{ id: 'TKT-003', title: 'New Feature Request', status: 'CLOSED', priority: 'LOW', createdAt: new Date() }
],
totalElements: 3
}
});
}, 500);
});
};

service.reportIssue = function (issueData) {
// Mocking issue reporting
return new Promise(function (resolve) {
setTimeout(function () {
resolve({ data: { ticketId: 'TKT-' + Math.floor(1000 + Math.random() * 9000) } });
}, 1000);
});
};
}
})();
59 changes: 59 additions & 0 deletions medplat-ui/app/chatbot/views/admin-dashboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<div class="admin-dashboard container-fluid p-4">
<h2 class="mb-4">Chatbot Performance Dashboard</h2>

<div class="row mb-4">
<div class="col-md-3">
<div class="card text-center p-3 shadow-sm">
<div class="text-muted small">Total Tickets</div>
<div class="h3 mb-0">{{adminDash.stats.totalTickets}}</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-center p-3 shadow-sm text-success">
<div class="text-muted small">Resolved</div>
<div class="h3 mb-0">{{adminDash.stats.resolvedTickets}}</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-center p-3 shadow-sm text-primary">
<div class="text-muted small">Avg. Resolution</div>
<div class="h3 mb-0">{{adminDash.stats.avgResolutionTime}}</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-center p-3 shadow-sm text-warning">
<div class="text-muted small">User Rating</div>
<div class="h3 mb-0">{{adminDash.stats.userSatisfaction}}</div>
</div>
</div>
</div>

<div class="row">
<div class="col-md-6">
<div class="card shadow-sm">
<div class="card-header bg-white"><strong>Issue Trends by Category</strong></div>
<div class="card-body">
<div ng-repeat="trend in adminDash.trends" class="mb-3">
<div class="d-flex justify-content-between mb-1">
<span>{{trend.category}}</span>
<span>{{trend.count}}</span>
</div>
<div class="progress" style="height: 10px;">
<div class="progress-bar" role="progressbar"
style="width: {{ (trend.count / 154) * 100 }}%"></div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card shadow-sm">
<div class="card-header bg-white"><strong>Chatbot Accuracy Rate</strong></div>
<div class="card-body text-center">
<div style="font-size: 48px; color: #28a745;">92%</div>
<p class="text-muted">Based on 1,200+ automated interactions this month.</p>
</div>
</div>
</div>
</div>
</div>
Loading