449 lines
21 KiB
JavaScript
449 lines
21 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('headerNavigationModule')
|
|
.factory('headerNavigationModel', ['permissionModel', 'configurationModel', 'screenConfigurationModel', 'systemAlertService', 'i18nService', 'roles', '$window', 'pwaModel', 'utilityFunctions', 'searchModel', 'studioModel', '$filter',
|
|
function (permissionModel, configurationModel, screenConfigurationModel, systemAlertService, i18nService, roles, $window, pwaModel, utilityFunctions, searchModel, studioModel, $filter) {
|
|
var pvSuffix = pwaModel.isPwaEnabledPromise() ? 'PV' : '';
|
|
var studioSuffix = "Studio";
|
|
var headerNavigationModel = {}, allNavItems = [
|
|
{
|
|
state: 'dashboard',
|
|
i18nKey: 'dashboard',
|
|
type: 'link'
|
|
},
|
|
{
|
|
i18nKey: 'console',
|
|
type: 'dropdown',
|
|
elements: [
|
|
{
|
|
name: 'ticketConsole',
|
|
state: 'ticketConsole' + studioSuffix,
|
|
i18nKey: 'ticketConsole',
|
|
icon: 'file_text_o',
|
|
roles: [roles.ITSM_AGENT_ROLE, roles.ITSM_CHANGE_USER_ROLE, roles.ITSM_PROBLEM_USER_ROLE]
|
|
},
|
|
{
|
|
name: 'knowledgeConsole',
|
|
state: 'knowledgeConsole',
|
|
i18nKey: 'knowledgeConsole',
|
|
icon: 'lightbulb_o',
|
|
app: EntityVO.TYPE_KNOWLEDGE,
|
|
role: roles.ITSM_KNOWLEDGE_USER_ROLE
|
|
},
|
|
{
|
|
name: "knowledgeConsoleHKM",
|
|
handler: handleHKMKnowledgeConsoleClick,
|
|
i18nKey: 'knowledgeConsole',
|
|
icon: 'lightbulb_o',
|
|
app: EntityVO.TYPE_KNOWLEDGE,
|
|
type: 'link',
|
|
permission: roles.ITSM_KNOWLEDGE_USER_ROLE
|
|
},
|
|
{
|
|
name: 'assetConsole',
|
|
state: 'assetConsole' + studioSuffix,
|
|
i18nKey: 'assetConsole',
|
|
icon: 'cube_o',
|
|
app: EntityVO.TYPE_ASSET,
|
|
role: roles.ITSM_ASSET_USER_ROLE
|
|
}
|
|
]
|
|
},
|
|
{
|
|
state: 'calendar' + studioSuffix,
|
|
i18nKey: 'calendar',
|
|
type: 'link',
|
|
roles: [roles.ITSM_CHANGE_USER_ROLE, roles.ITSM_RELEASE_USER_ROLE, roles.ITSM_AGENT_ROLE, roles.ITSM_PROBLEM_USER_ROLE, roles.ITSM_ASSET_USER_ROLE]
|
|
},
|
|
{
|
|
state: 'smartRecorder',
|
|
i18nKey: 'smartRecorder',
|
|
type: 'link',
|
|
role: roles.ITSM_AGENT_ROLE
|
|
},
|
|
{
|
|
i18nKey: 'create',
|
|
type: 'dropdown',
|
|
elements: [
|
|
{
|
|
name: 'createIncident' + pvSuffix,
|
|
state: 'createIncident' + pvSuffix,
|
|
i18nKey: 'incident',
|
|
icon: 'file_text_o',
|
|
permission: roles.ITSM_AGENT_ROLE
|
|
},
|
|
{
|
|
name: 'createWorkorder' + pvSuffix,
|
|
state: 'createWorkorder' + pvSuffix,
|
|
i18nKey: 'workorder',
|
|
icon: 'file_wrench_o',
|
|
app: EntityVO.TYPE_WORKORDER,
|
|
permission: roles.ITSM_AGENT_ROLE
|
|
},
|
|
{
|
|
name: 'createKnowledge',
|
|
state: 'createKnowledge',
|
|
i18nKey: 'knowledge',
|
|
icon: 'lightbulb_o',
|
|
app: EntityVO.TYPE_KNOWLEDGE,
|
|
permission: roles.ITSM_KNOWLEDGE_USER_ROLE
|
|
},
|
|
{
|
|
name: "createKnowledgeHKM",
|
|
handler: handleHKMKnowledgeClick,
|
|
i18nKey: 'knowledge',
|
|
icon: 'lightbulb_o',
|
|
app: EntityVO.TYPE_KNOWLEDGE,
|
|
type: 'link',
|
|
permission: roles.ITSM_KNOWLEDGE_USER_ROLE
|
|
},
|
|
{
|
|
name: (pvSuffix === 'PV') ? 'createChangePV' : 'createChange.selector',
|
|
state: (pvSuffix === 'PV') ? 'createChangePV' : 'createChange.selector',
|
|
i18nKey: 'change',
|
|
icon: 'files_change_o',
|
|
app: EntityVO.TYPE_CHANGE,
|
|
permission: roles.ITSM_CHANGE_USER_ROLE
|
|
},
|
|
{
|
|
name: 'createRelease.selector',
|
|
state: 'createRelease.selector',
|
|
i18nKey: 'release',
|
|
icon: 'app_box_open_o',
|
|
app: EntityVO.TYPE_RELEASE,
|
|
permission: roles.ITSM_RELEASE_USER_ROLE
|
|
},
|
|
{
|
|
name: 'createProblem' + pvSuffix,
|
|
state: 'createProblem' + pvSuffix,
|
|
i18nKey: 'problem',
|
|
icon: 'search_exclamation',
|
|
app: EntityVO.TYPE_PROBLEM,
|
|
permission: roles.ITSM_PROBLEM_USER_ROLE
|
|
},
|
|
{
|
|
name: 'createKnownerror',
|
|
state: 'createKnownerror',
|
|
i18nKey: 'knownerror',
|
|
icon: 'file_exclamation_o',
|
|
app: EntityVO.TYPE_KNOWNERROR,
|
|
permission: roles.ITSM_PROBLEM_USER_ROLE
|
|
},
|
|
{
|
|
name: 'createBroadcast',
|
|
state: 'createBroadcast',
|
|
i18nKey: 'broadcast',
|
|
icon: 'speaker',
|
|
permission: roles.ITSM_BROADCAST_USER_ROLE
|
|
},
|
|
{
|
|
name: 'createAsset' + pvSuffix,
|
|
state: 'createAsset' + pvSuffix,
|
|
i18nKey: 'asset',
|
|
icon: 'cube_o',
|
|
app: EntityVO.TYPE_ASSET,
|
|
permission: roles.ITSM_ASSET_USER_ROLE
|
|
}
|
|
]
|
|
},
|
|
{
|
|
i18nKey: 'workspaces',
|
|
type: 'dropdown',
|
|
elements: [
|
|
{
|
|
handler: handleProactiveProblemManagementClick,
|
|
i18nKey: 'proactiveProblemManagement',
|
|
icon: 'search_exclamation',
|
|
app: EntityVO.TYPE_ITSM_INSIGHTS,
|
|
roles: [roles.ITSM_AGENT_ROLE, roles.ITSM_PROBLEM_USER_ROLE]
|
|
},
|
|
{
|
|
handler: handleRealtimeIncidentCorrelationClick,
|
|
i18nKey: 'realtimeIncidentCorrelation',
|
|
icon: 'file_text_o',
|
|
app: EntityVO.TYPE_ITSM_INSIGHTS,
|
|
permission: roles.ITSM_AGENT_ROLE
|
|
}
|
|
]
|
|
},
|
|
{
|
|
state: 'liveChatAgentConsole',
|
|
i18nKey: 'liveChat',
|
|
type: 'link',
|
|
app: EntityVO.TYPE_LIVE_CHAT,
|
|
roles: [roles.ITSM_AGENT_ROLE, roles.ESCHAT_AGENT_ROLE]
|
|
},
|
|
{
|
|
state: 'liveChatDashboard',
|
|
i18nKey: 'liveChat',
|
|
type: 'link',
|
|
app: EntityVO.TYPE_LIVE_CHAT,
|
|
roles: [roles.ITSM_AGENT_ROLE, roles.ESCHAT_ADMIN_ROLE]
|
|
},
|
|
{
|
|
i18nKey: 'liveChat',
|
|
type: 'dropdown',
|
|
app: EntityVO.TYPE_LIVE_CHAT,
|
|
elements: [
|
|
{
|
|
name: 'liveChatAgentConsole',
|
|
state: 'liveChatAgentConsole',
|
|
i18nKey: 'liveChatAgentConsole',
|
|
icon: 'comments_o',
|
|
type: 'dropdownItem',
|
|
app: EntityVO.TYPE_LIVE_CHAT,
|
|
roles: [roles.ITSM_AGENT_ROLE, roles.ESCHAT_AGENT_ROLE]
|
|
},
|
|
{
|
|
name: 'liveChatDashboard',
|
|
state: 'liveChatDashboard',
|
|
i18nKey: 'liveChatDashboard',
|
|
icon: 'app_chart_bar',
|
|
type: 'dropdownItem',
|
|
app: EntityVO.TYPE_LIVE_CHAT,
|
|
roles: [roles.ITSM_AGENT_ROLE, roles.ESCHAT_ADMIN_ROLE]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
handler: handleHelixDashboardClick,
|
|
i18nKey: 'helixDashboard',
|
|
app: EntityVO.TYPE_HELIX_DASHBOARD,
|
|
type: 'link'
|
|
},
|
|
{
|
|
handler: handleSmartReporterClick,
|
|
i18nKey: 'reports',
|
|
app: EntityVO.TYPE_REPORTS,
|
|
type: 'link'
|
|
},
|
|
{
|
|
i18nKey: 'configuration',
|
|
type: 'dropdown',
|
|
elements: [
|
|
{
|
|
name: 'screenConfiguration',
|
|
state: 'screenConfiguration',
|
|
i18nKey: 'screenConfiguration',
|
|
icon: 'gear',
|
|
permission: 'admin:screenConfiguration'
|
|
},
|
|
{
|
|
name: 'knowledgeStyleConfiguration',
|
|
state: 'knowledgeStyleConfiguration',
|
|
i18nKey: 'knowledgeTemplateStyles',
|
|
icon: 'lightbulb_o',
|
|
app: EntityVO.TYPE_KNOWLEDGE,
|
|
role: roles.ITSM_ADMIN_ROLE
|
|
},
|
|
{
|
|
name: 'createAqiQuestions',
|
|
state: 'createAqiQuestions',
|
|
i18nKey: 'aqi',
|
|
icon: 'pencil',
|
|
app: EntityVO.TYPE_KNOWLEDGE,
|
|
permission: roles.ITSM_KCS_COACH_ROLE
|
|
},
|
|
{
|
|
name: 'adminConsoleConfig',
|
|
state: 'adminConsoleConfig',
|
|
i18nKey: 'adminConsoleConfig',
|
|
icon: 'gear',
|
|
permission: 'admin:screenConfiguration'
|
|
},
|
|
{
|
|
type: 'link',
|
|
i18nKey: 'studioConfig',
|
|
icon: 'gear',
|
|
handler: handleStudioConfigClick,
|
|
permission: 'admin:screenConfiguration'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
state: 'knowledgeTeam',
|
|
i18nKey: 'knowledge',
|
|
type: 'link',
|
|
app: EntityVO.TYPE_KNOWLEDGE,
|
|
role: roles.ITSM_KCS_COACH_ROLE
|
|
},
|
|
{
|
|
i18nKey: 'customActions',
|
|
type: 'dropdown',
|
|
hideHeader: true,
|
|
elements: []
|
|
}
|
|
], navItemCustom = _.find(allNavItems, { i18nKey: 'customActions' });
|
|
function handleSmartReporterClick() {
|
|
screenConfigurationModel.getSmartReporterUrl().then(function (url) {
|
|
url = decodeURI(url);
|
|
$window.open(url, '_blank');
|
|
}).catch(function (error) {
|
|
systemAlertService.error({
|
|
text: error.data.errorCode ? i18nService.getLocalizedString('error.unknown') : error.data.error
|
|
});
|
|
});
|
|
}
|
|
function handleHelixDashboardClick() {
|
|
if (configurationModel.helixDashboardUrl && utilityFunctions.isValidHttpUrl(configurationModel.helixDashboardUrl)) {
|
|
$window.open(configurationModel.helixDashboardUrl, '_blank');
|
|
}
|
|
else {
|
|
console.error("Provided Helix Dashboard Url is invalid");
|
|
}
|
|
}
|
|
function handleHKMKnowledgeClick() {
|
|
if (configurationModel.comaroundEnabled) {
|
|
searchModel.getHKMUrls().then(function (urls) {
|
|
if (urls.createUrl) {
|
|
urls.createUrl = decodeURI(urls.createUrl);
|
|
$window.open(urls.createUrl, '_blank');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
function handleHKMKnowledgeConsoleClick() {
|
|
if (configurationModel.comaroundEnabled) {
|
|
searchModel.getHKMUrls().then(function (urls) {
|
|
if (urls.consoleUrl) {
|
|
urls.consoleUrl = decodeURI(urls.consoleUrl);
|
|
$window.open(urls.consoleUrl, '_blank');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
function handleProactiveProblemManagementClick() {
|
|
openExtUrl('proactiveProblemManagementURL');
|
|
}
|
|
function handleRealtimeIncidentCorrelationClick() {
|
|
openExtUrl('realtimeIncidentCorrelationURL');
|
|
}
|
|
function handleStudioConfigClick() {
|
|
if (studioModel.baseUrlForIS && (studioModel.enableISCalendar || studioModel.enableSharedConsole)) {
|
|
var configRelativeUrl = '/com.bmc.dsm.itsm-applications/settings/AGGADGGJJ03PPAR1P4VKR1P4VKS8TP';
|
|
var extendedUrl = '/helix/index.html#';
|
|
$window.open(studioModel.baseUrlForIS + extendedUrl + configRelativeUrl, '_blank');
|
|
}
|
|
else {
|
|
console.error("Innovation Studio is not configured");
|
|
}
|
|
}
|
|
function openExtUrl(urlName) {
|
|
screenConfigurationModel.getExternalUrl(urlName).then(function (url) {
|
|
url = decodeURI(url);
|
|
$window.open(url, '_blank');
|
|
}).catch(function (error) {
|
|
systemAlertService.error({
|
|
text: error.data.errorCode ? i18nService.getLocalizedString('error.unknown') : error.data.error
|
|
});
|
|
});
|
|
}
|
|
function updateNavigationItems(navItemsArray) {
|
|
var availableNavItems = [], hasPermission;
|
|
_.forEach(navItemsArray, function (item) {
|
|
if (!item.elements) {
|
|
if (item.roles && item.roles.length) {
|
|
if (item.app === EntityVO.TYPE_LIVE_CHAT) {
|
|
if (item.type === 'link') {
|
|
if (permissionModel.checkLiveChatRoles()) {
|
|
return;
|
|
}
|
|
}
|
|
else if (item.type === 'dropdownItem') {
|
|
if (!permissionModel.checkLiveChatRoles()) {
|
|
return;
|
|
}
|
|
}
|
|
hasPermission = _.every(item.roles, function (role) {
|
|
return permissionModel.hasRole(role);
|
|
});
|
|
}
|
|
else {
|
|
hasPermission = _.some(item.roles, function (role) {
|
|
return permissionModel.hasRole(role);
|
|
});
|
|
}
|
|
if (!hasPermission) {
|
|
return;
|
|
}
|
|
}
|
|
if (item.role && !permissionModel.hasRole(item.role)) {
|
|
return;
|
|
}
|
|
if (item.app && !configurationModel.isServerApplicationEnabled(item.app)) {
|
|
return;
|
|
}
|
|
if (item.permission) {
|
|
if (item.permission === 'galileo-asset-access') {
|
|
if (!permissionModel.hasAssetCreatePermission()) {
|
|
return;
|
|
}
|
|
}
|
|
else if (!permissionModel.hasPermission(item.permission)) {
|
|
return;
|
|
}
|
|
}
|
|
availableNavItems.push(item);
|
|
}
|
|
else {
|
|
item.elements = updateNavigationItems(item.elements);
|
|
if (item.elements.length) {
|
|
availableNavItems.push(item);
|
|
}
|
|
}
|
|
});
|
|
return availableNavItems;
|
|
}
|
|
headerNavigationModel.updateNavigationItems = function () {
|
|
return updateNavigationItems(allNavItems);
|
|
};
|
|
headerNavigationModel.clearCustomActions = function () {
|
|
_.remove(navItemCustom.elements, { extended: true });
|
|
};
|
|
headerNavigationModel.getCustomActions = function (navConfig) {
|
|
_.forEach(navConfig.actionList, function (urlItem) {
|
|
if (_.includes(urlItem.supportedPlatforms, 'web')) {
|
|
var newElement = {
|
|
extended: true
|
|
};
|
|
newElement.label = urlItem.labels[i18nService.language] || urlItem.labels.default;
|
|
newElement.url = urlItem.url;
|
|
newElement.target = urlItem.target;
|
|
newElement.sequenceNo = urlItem.sequenceNo;
|
|
navItemCustom.elements.push(newElement);
|
|
}
|
|
});
|
|
function getPwaResultLaunchURL() {
|
|
var midtierUrl = localStorage.getItem('midtierUrl'), homeServer = localStorage.getItem('homeServer'), resultListFormAndView = configurationModel.get('pwaResultListFormAndView');
|
|
return midtierUrl + '/pwa/#/forms/' + homeServer + resultListFormAndView;
|
|
}
|
|
var isPwaEnabled = pwaModel.isPwaEnabled();
|
|
// Remove the flag false when goes live
|
|
if (isPwaEnabled && false) {
|
|
var mySequence = 1;
|
|
if (navItemCustom.elements.length > 0) {
|
|
mySequence = Math.max.apply(null, navItemCustom.elements.map(function (o) { return o.sequenceNo; })) + 1;
|
|
}
|
|
navItemCustom.elements.push({
|
|
extended: true,
|
|
label: $filter('i18n')('header.navigation.pvResultList'),
|
|
sequenceNo: mySequence,
|
|
target: 'new',
|
|
url: getPwaResultLaunchURL()
|
|
});
|
|
}
|
|
if (navItemCustom.elements.length) {
|
|
if (navConfig.actionOrder === 'alphabetical') {
|
|
navItemCustom.elements = _.sortBy(navItemCustom.elements, 'label');
|
|
}
|
|
else {
|
|
navItemCustom.elements = _.sortBy(navItemCustom.elements, 'sequenceNo');
|
|
}
|
|
}
|
|
};
|
|
return headerNavigationModel;
|
|
}
|
|
]);
|
|
}());
|