159 lines
12 KiB
JavaScript
159 lines
12 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('myitsmApp')
|
|
.factory('configurationModel', ['appConfiguration', '$rootScope', 'metadataModel', 'AUTH_EVENTS', 'utilityFunctions',
|
|
function (appConfiguration, $rootScope, metadataModel, AUTH_EVENTS, utilityFunctions) {
|
|
var configurationModel = {}, enabledServerApplications, config = appConfiguration;
|
|
configurationModel.get = function (segment) {
|
|
return $rootScope.$eval('config.' + segment, { config: config }) || {};
|
|
};
|
|
configurationModel.set = function (segment, data) {
|
|
//creating shotcurt
|
|
if (segment === 'enabledServerApplications') {
|
|
enabledServerApplications = data;
|
|
}
|
|
appConfiguration[segment] = data;
|
|
};
|
|
configurationModel.getWeekStartingDay = function () {
|
|
return (!window.isRtl) ? 1 : 0;
|
|
};
|
|
configurationModel.isServerApplicationEnabled = function (appName) {
|
|
return _.includes(enabledServerApplications, appName);
|
|
};
|
|
configurationModel.isFileExtensionAllowed = function (fileExt) {
|
|
var asc = configurationModel.get('attachmentSecurityConfiguration');
|
|
if (asc) {
|
|
var fileExtensions = _(asc.fileExtensions).map(function (val) { return val.toLowerCase(); }).value();
|
|
if (asc.ruleType === 'whiteListExtensions' && _.includes(fileExtensions, fileExt.toLowerCase())) {
|
|
return true;
|
|
}
|
|
if (asc.ruleType === 'blackListExtensions' && !_.includes(fileExtensions, fileExt.toLowerCase())) {
|
|
return true;
|
|
}
|
|
if (asc.ruleType === 'allowAll') {
|
|
return true;
|
|
}
|
|
if (asc.ruleType === 'allowNone') {
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
function loadGlobalMetadata() {
|
|
metadataModel.getMetadataByType(EntityVO.TYPE_GLOBAL).then(function (metadata) {
|
|
if (metadata.configurationParameters) {
|
|
var cp = metadata.configurationParameters;
|
|
configurationModel.companyChunkSize = cp.assignmentCompanyChunkSize ? parseInt(cp.assignmentCompanyChunkSize) : 80;
|
|
configurationModel.organizationChunkSize = cp.assignmentSupportOrganizationChunkSize ? parseInt(cp.assignmentSupportOrganizationChunkSize) : 80;
|
|
configurationModel.supportGroupChunkSize = cp.assignmentSupportGroupChunkSize ? parseInt(cp.assignmentSupportGroupChunkSize) : 80;
|
|
configurationModel.supportPersonChunkSize = cp.assignmentSupportPersonChunkSize ? parseInt(cp.assignmentSupportPersonChunkSize) : 80;
|
|
configurationModel.locationSiteChunkSize = cp.locationSiteChunkSize ? parseInt(cp.locationSiteChunkSize) : 80;
|
|
configurationModel.personChunkSize = cp.personChunkSize ? parseInt(cp.personChunkSize) : 20;
|
|
configurationModel.restrictConsoleResultForNoOfDays = parseInt(cp.restrictConsoleResultForNoOfDays) <= 0 ? 0 : parseInt(cp.restrictConsoleResultForNoOfDays);
|
|
configurationModel.restrictPersonProfileResultForNoOfDays = (cp.restrictPersonProfileResultForNoOfDays && parseInt(cp.restrictPersonProfileResultForNoOfDays) > 0) ? parseInt(cp.restrictPersonProfileResultForNoOfDays) : 0;
|
|
configurationModel.skipAssetSearchInSmartRecorder = typeof cp.skipAssetSearchInSmartRecorder === 'string' ? cp.skipAssetSearchInSmartRecorder === 'true' : false;
|
|
if (cp.explicitStatsRefresh) {
|
|
var explicitStatsRefresh = cp.explicitStatsRefresh;
|
|
configurationModel.explicitStatsRefresh = typeof explicitStatsRefresh === 'string' ? explicitStatsRefresh === 'true' : explicitStatsRefresh;
|
|
}
|
|
if (cp.disableCollisionManagement) {
|
|
var disableCollisionManagement = cp.disableCollisionManagement;
|
|
configurationModel.disableCollisionManagement = typeof disableCollisionManagement === 'string' ? disableCollisionManagement === 'true' : disableCollisionManagement;
|
|
}
|
|
configurationModel.autoTriggerChangeCollisionForCIsUpto = cp.autoTriggerChangeCollisionForCIsUpto === 0 ? cp.autoTriggerChangeCollisionForCIsUpto :
|
|
(cp.autoTriggerChangeCollisionForCIsUpto > -1 ? Math.abs(cp.autoTriggerChangeCollisionForCIsUpto) : undefined);
|
|
if (cp.disableImpactAnalysis) {
|
|
var disableImpactAnalysis = cp.disableImpactAnalysis;
|
|
configurationModel.disableImpactAnalysis = typeof disableImpactAnalysis === 'string' ? disableImpactAnalysis === 'true' : disableImpactAnalysis;
|
|
}
|
|
if (cp.showNameInSmartRecorderCreateTicket) {
|
|
var showNameInSmartRecorderCreateTicket = cp.showNameInSmartRecorderCreateTicket;
|
|
configurationModel.showNameInSmartRecorderCreateTicket = typeof showNameInSmartRecorderCreateTicket === 'string' ? showNameInSmartRecorderCreateTicket === 'true' : showNameInSmartRecorderCreateTicket;
|
|
}
|
|
if (cp.dateTimeStyleProperty) {
|
|
configurationModel.dateTimeStyleProperty = cp.dateTimeStyleProperty;
|
|
}
|
|
if (cp.socialWorklogAccessSetting) {
|
|
var socialWorklogAccessSetting = cp.socialWorklogAccessSetting;
|
|
configurationModel.socialWorklogAccessSetting = typeof socialWorklogAccessSetting === 'string' ? socialWorklogAccessSetting === 'true' : (typeof socialWorklogAccessSetting === 'boolean') ? socialWorklogAccessSetting : false;
|
|
}
|
|
if (cp.showFilterForRecommendedKnowledge) {
|
|
var showFilterForRecommendedKnowledge = cp.showFilterForRecommendedKnowledge;
|
|
configurationModel.showFilterForRecommendedKnowledge = typeof showFilterForRecommendedKnowledge === 'string' ? showFilterForRecommendedKnowledge === 'true' : false;
|
|
}
|
|
if (cp.quickTicketCreateEnabled) {
|
|
var quickTicketCreateEnabled = cp.quickTicketCreateEnabled;
|
|
configurationModel.quickTicketCreateEnabled = typeof quickTicketCreateEnabled === 'string' ? quickTicketCreateEnabled === 'true' : false;
|
|
}
|
|
if (cp.enableESChatIntegration) {
|
|
var enableESChatIntegration = cp.enableESChatIntegration;
|
|
configurationModel.enableESChatIntegration = typeof enableESChatIntegration === 'string' ? enableESChatIntegration === 'true' : false;
|
|
}
|
|
if (cp.productAliasBasedSearch) {
|
|
var productAliasBasedSearch = cp.productAliasBasedSearch;
|
|
configurationModel.productAliasBasedSearch = typeof productAliasBasedSearch === 'string' ? productAliasBasedSearch === 'true' : false;
|
|
}
|
|
if (cp.midTierURL) {
|
|
configurationModel.midTierURL = cp.midTierURL;
|
|
}
|
|
if (cp.enableAdvanceSearchInConsole) {
|
|
var enableAdvanceSearchInConsole = cp.enableAdvanceSearchInConsole;
|
|
configurationModel.enableAdvanceSearchInConsole = typeof enableAdvanceSearchInConsole === 'string' ? enableAdvanceSearchInConsole === 'true' : false;
|
|
}
|
|
if (cp.showNeedsAttentionFlag) {
|
|
var showNeedsAttentionFlag = cp.showNeedsAttentionFlag;
|
|
configurationModel.showNeedsAttentionFlag = typeof showNeedsAttentionFlag === 'string' ? showNeedsAttentionFlag === 'true' : ((typeof showNeedsAttentionFlag === 'boolean') ? showNeedsAttentionFlag : false);
|
|
}
|
|
if (!cp.showSecurityTickets) {
|
|
configurationModel.showSecurityTickets = false;
|
|
}
|
|
else {
|
|
configurationModel.showSecurityTickets = typeof cp.showSecurityTickets === 'string' ? cp.showSecurityTickets === 'true' : false;
|
|
}
|
|
if (cp.showMailstopOnPersoncard) {
|
|
configurationModel.showMailstopOnPersoncard = typeof cp.showMailstopOnPersoncard === 'string' ? cp.showMailstopOnPersoncard === 'true' : false;
|
|
}
|
|
if (cp.showPhoneNumOnPersonCard) {
|
|
configurationModel.showPhoneNumOnPersonCard = typeof cp.showPhoneNumOnPersonCard === 'string' ? cp.showPhoneNumOnPersonCard === 'true' : false;
|
|
}
|
|
if (cp.enableDWPWidgetIntegration) {
|
|
configurationModel.enableDWPWidgetIntegration = typeof cp.enableDWPWidgetIntegration === 'string' ? cp.enableDWPWidgetIntegration === 'true' : false;
|
|
}
|
|
if (!cp.copyPrimaryCategoriesOnResolve) {
|
|
configurationModel.copyPrimaryCategoriesOnResolve = false;
|
|
}
|
|
else {
|
|
configurationModel.copyPrimaryCategoriesOnResolve = typeof cp.copyPrimaryCategoriesOnResolve === 'string' ? cp.copyPrimaryCategoriesOnResolve === 'true' : false;
|
|
}
|
|
configurationModel.isPWAEnabled = cp['Enable-Progressive-Views'] && (cp['Enable-Progressive-Views'] === 'T' || cp['Enable-Progressive-Views'] === 'true') ? true : false;
|
|
configurationModel.helixDashboardUrl = cp.helixDashboardUrl && cp.helixDashboardUrl.length ? cp.helixDashboardUrl : false;
|
|
var searchByCompanyFlag = cp.smartRecorderSearchByCompany;
|
|
configurationModel.smartRecorderSearchByCompany = typeof searchByCompanyFlag === 'string' ? searchByCompanyFlag === 'true' : searchByCompanyFlag;
|
|
if (cp.showARMessageOnGetEntry) {
|
|
configurationModel.showARMessageOnGetEntry = typeof cp.showARMessageOnGetEntry === 'string' ? cp.showARMessageOnGetEntry === 'true' : ((typeof showARMessageOnGetEntry === 'boolean') ? showARMessageOnGetEntry : false);
|
|
;
|
|
}
|
|
}
|
|
var isPwaEnabled = localStorage.getItem('overridePV') === 'T' ? false : configurationModel.isPWAEnabled;
|
|
configurationModel.comaroundEnabled = !!(metadata.comaroundEnabled === true && isPwaEnabled && localStorage.getItem('midtierUrl'));
|
|
if (configurationModel.comaroundEnabled) {
|
|
if (utilityFunctions.isValidHttpUrl(metadata.comaroundHostUrl)) {
|
|
configurationModel.comaroundHostUrl = metadata.comaroundHostUrl;
|
|
}
|
|
else {
|
|
console.error("Provided Comaround URL is invalid");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
$rootScope.$on(AUTH_EVENTS.LOGIN_SUCCESS, function () {
|
|
loadGlobalMetadata();
|
|
});
|
|
$rootScope.$on(AUTH_EVENTS.SESSION_ACTIVE, function () {
|
|
loadGlobalMetadata();
|
|
});
|
|
return configurationModel;
|
|
}]);
|
|
}());
|