diff --git a/medplat-ui/app/chatbot/controllers/admin-chatbot-dashboard.controller.js b/medplat-ui/app/chatbot/controllers/admin-chatbot-dashboard.controller.js new file mode 100644 index 000000000..670ed4863 --- /dev/null +++ b/medplat-ui/app/chatbot/controllers/admin-chatbot-dashboard.controller.js @@ -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 } + ]; + } +})(); diff --git a/medplat-ui/app/chatbot/controllers/chatbot.controller.js b/medplat-ui/app/chatbot/controllers/chatbot.controller.js new file mode 100644 index 000000000..dcabdc4db --- /dev/null +++ b/medplat-ui/app/chatbot/controllers/chatbot.controller.js @@ -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'); + }; + } +})(); diff --git a/medplat-ui/app/chatbot/controllers/ticket-dashboard.controller.js b/medplat-ui/app/chatbot/controllers/ticket-dashboard.controller.js new file mode 100644 index 000000000..5b02c17bf --- /dev/null +++ b/medplat-ui/app/chatbot/controllers/ticket-dashboard.controller.js @@ -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(); + } +})(); diff --git a/medplat-ui/app/chatbot/services/chatbot.service.js b/medplat-ui/app/chatbot/services/chatbot.service.js new file mode 100644 index 000000000..07224f326 --- /dev/null +++ b/medplat-ui/app/chatbot/services/chatbot.service.js @@ -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); + }); + }; + } +})(); diff --git a/medplat-ui/app/chatbot/views/admin-dashboard.html b/medplat-ui/app/chatbot/views/admin-dashboard.html new file mode 100644 index 000000000..f65243421 --- /dev/null +++ b/medplat-ui/app/chatbot/views/admin-dashboard.html @@ -0,0 +1,59 @@ +
+

Chatbot Performance Dashboard

+ +
+
+
+
Total Tickets
+
{{adminDash.stats.totalTickets}}
+
+
+
+
+
Resolved
+
{{adminDash.stats.resolvedTickets}}
+
+
+
+
+
Avg. Resolution
+
{{adminDash.stats.avgResolutionTime}}
+
+
+
+
+
User Rating
+
{{adminDash.stats.userSatisfaction}}
+
+
+
+ +
+
+
+
Issue Trends by Category
+
+
+
+ {{trend.category}} + {{trend.count}} +
+
+
+
+
+
+
+
+
+
+
Chatbot Accuracy Rate
+
+
92%
+

Based on 1,200+ automated interactions this month.

+
+
+
+
+
\ No newline at end of file diff --git a/medplat-ui/app/chatbot/views/chatbot.html b/medplat-ui/app/chatbot/views/chatbot.html new file mode 100644 index 000000000..65e1bacad --- /dev/null +++ b/medplat-ui/app/chatbot/views/chatbot.html @@ -0,0 +1,164 @@ +
+
+
+ AI + AI ANM Assistant +
+
+ + +
+
+ +
+
+
+
{{msg.sender}}
+
{{msg.text}}
+
+ +
+
{{msg.time | date:'h:mm a'}}
+
+
+
+
AI ANM is typing...
+
+
+ +
+
+ + +
+
+ +
+ +
+
+
+ + +
+
+
+ + \ No newline at end of file diff --git a/medplat-ui/app/chatbot/views/ticket-dashboard.html b/medplat-ui/app/chatbot/views/ticket-dashboard.html new file mode 100644 index 000000000..452ca5900 --- /dev/null +++ b/medplat-ui/app/chatbot/views/ticket-dashboard.html @@ -0,0 +1,66 @@ +
+
+

Support Tickets

+ +
+ +
+
+
+
+ + +
+
+ + +
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
IDTitleStatusPriorityCreated AtActions
{{ticket.id}}{{ticket.title}}{{ticket.status}}{{ticket.priority}}{{ticket.createdAt | date:'dd/MM/yyyy'}} + +
No tickets found.
Loading tickets...
+
+
\ No newline at end of file diff --git a/medplat-ui/app/common/views/layout.html b/medplat-ui/app/common/views/layout.html index 9bd806d24..0f293607f 100644 --- a/medplat-ui/app/common/views/layout.html +++ b/medplat-ui/app/common/views/layout.html @@ -228,6 +228,41 @@ role="main"> + + +
+ Chat + {{layout.unreadNotifications}} +
+ +