SmartIT_Extensions/BMC/smart-it-full-helix/scripts/app/knowledge-team/knowledge-team-controller.js

85 lines
4.1 KiB
JavaScript

"use strict";
(function () {
'use strict';
angular.module('knowledgeTeamModule')
.controller('KnowledgeTeamController', ['$scope', '$q', '$modal', '$state', '$window', 'knowledgeTeamModel', 'knowledgeTeamService', 'knowledgeConsoleModel', 'chatModel', 'openMailClientService', 'configurationModel',
function ($scope, $q, $modal, $state, $window, knowledgeTeamModel, knowledgeTeamService, knowledgeConsoleModel, chatModel, openMailClientService, configurationModel) {
$scope.reportsEnabled = configurationModel.isServerApplicationEnabled(EntityVO.TYPE_REPORTS);
$scope.openManageTeamModal = function () {
var modalInstance = $modal.open({
templateUrl: 'views/knowledge-team/knowledge-manage-team.html',
windowClass: 'action-blade',
controller: 'KnowledgeManageTeamController',
resolve: {}
});
modalInstance.result.then(function (data) {
$scope.coacheeList = data;
knowledgeTeamModel.coachTeamList = data;
});
};
$scope.viewTeamArticles = function () {
knowledgeConsoleModel.areFiltersPopulated = true;
knowledgeConsoleModel.kcsFilters.coachFilter = true;
knowledgeConsoleModel.kcsFilters.teamMemberFilter = false;
$state.go('knowledgeConsole');
};
$scope.showAQIAssessment = function () {
$state.go('createAqiQuestions');
};
$scope.getJobRole = function (supportGroups) {
var supportGroupName = _.result(_.find(supportGroups, { isDefault: true }), name);
return supportGroupName || supportGroups.length ? supportGroups[0].name : '';
};
$scope.showPersonArticles = function (person) {
knowledgeConsoleModel.areFiltersPopulated = true;
knowledgeConsoleModel.kcsFilters.coachFilter = false;
knowledgeConsoleModel.kcsFilters.teamMemberFilter = true;
knowledgeConsoleModel.kcsFilters.authorName = person.fullName;
var filterOption = {
name: person.fullName,
active: true,
type: 'dynamic',
filterLabel: 'author',
filterName: 'authors',
criteria: {
name: 'authors',
value: [{
loginId: person.loginId
}]
}
};
knowledgeConsoleModel.kcsFilters.authorFilter = filterOption;
knowledgeConsoleModel.filterDict[filterOption.filterName].options.push(filterOption);
$state.go('knowledgeConsole');
};
$scope.inviteForChat = function (person) {
if (person.available === 'offline') {
return;
}
return chatModel.createChatRoom(person.loginId).then(function (result) {
chatModel.inviteUserToChat(person, result);
});
};
$scope.openEmail = function (person) {
openMailClientService.openMailClient(person.email, 'KCS Team Communication', '');
};
$scope.launchReport = function (id, newWindow) {
return knowledgeTeamService.getReportURL(id).then(function (data) {
$window.open(data.url, newWindow ? '_blank' : '_self');
});
};
function init() {
$scope.dataLoading = true;
knowledgeTeamModel.getReportsList().then(function (result) {
$scope.reportingItemlist = result;
});
knowledgeTeamModel.getKnowledgeTeamList().then(function (result) {
$scope.coacheeList = result;
}).finally(function () {
$scope.dataLoading = false;
});
}
init();
}]);
})();