55 lines
2.6 KiB
JavaScript
55 lines
2.6 KiB
JavaScript
'use strict';
|
|
(function () {
|
|
'use strict';
|
|
angular.module('pwa')
|
|
.factory('pwaModel', ['authModel', 'session', '$window', '$q', '$rootScope', 'AUTH_EVENTS', 'systemAlertService', '$filter', 'metadataModel',
|
|
function (authModel, session, $window, $q, $rootScope, AUTH_EVENTS, systemAlertService, $filter, metadataModel) {
|
|
var pwaModel = {};
|
|
pwaModel.taskFrom = '';
|
|
pwaModel.pwaConfigurationFlag = false;
|
|
pwaModel.createIncFromSmartRecorder = false;
|
|
pwaModel.createRelatedFromAsset = false;
|
|
pwaModel.draftCallMade = false;
|
|
pwaModel.init = function () {
|
|
metadataModel.getMetadataByType(EntityVO.TYPE_GLOBAL).then(function (metadata) {
|
|
pwaModel.pwaConfigurationFlag = (metadata.configurationParameters['Enable-Progressive-Views'] === 'T' || metadata.configurationParameters['Enable-Progressive-Views'] === 'true');
|
|
pwaModel.pwaConfigurationFlag = localStorage.getItem('overridePV') === 'T' ? false : pwaModel.pwaConfigurationFlag;
|
|
});
|
|
};
|
|
pwaModel.isPwaEnabledPromise = function () {
|
|
if (!pwaModel.pwaConfigurationFlag) {
|
|
return metadataModel.getMetadataByType(EntityVO.TYPE_GLOBAL).then(function (metadata) {
|
|
pwaModel.pwaConfigurationFlag = (metadata.configurationParameters['Enable-Progressive-Views'] === 'T' || metadata.configurationParameters['Enable-Progressive-Views'] === 'true');
|
|
pwaModel.pwaConfigurationFlag = localStorage.getItem('overridePV') === 'T' ? false : pwaModel.pwaConfigurationFlag;
|
|
return checkPwaEnabled();
|
|
});
|
|
}
|
|
else {
|
|
return $q.when(checkPwaEnabled());
|
|
}
|
|
};
|
|
pwaModel.isPwaEnabled = function () {
|
|
return checkPwaEnabled();
|
|
};
|
|
pwaModel.isDraftCallMade = function () {
|
|
return pwaModel.draftCallMade;
|
|
};
|
|
function checkPwaEnabled() {
|
|
var midtierUrl = localStorage.getItem('midtierUrl'), homeServer = localStorage.getItem('homeServer');
|
|
if (pwaModel.pwaConfigurationFlag && midtierUrl) {
|
|
if (authModel.isSSOEnabled()) {
|
|
return true;
|
|
}
|
|
else {
|
|
return homeServer || false;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
;
|
|
pwaModel.init();
|
|
return pwaModel;
|
|
}
|
|
]);
|
|
}());
|