43 lines
2.3 KiB
JavaScript
43 lines
2.3 KiB
JavaScript
"use strict";
|
|
(function () {
|
|
'use strict';
|
|
angular.module('assetModule')
|
|
.directive('previewAsset', ['googleMapService', 'pwaModel', '$sce', function (googleMapService, pwaModel, $sce) {
|
|
return {
|
|
restrict: 'A',
|
|
templateUrl: 'views/asset/asset-details.html',
|
|
scope: {
|
|
displayMenu: '=',
|
|
hidePersonInfoCard: '=',
|
|
hideRelationships: '=',
|
|
isFullVersion: '='
|
|
},
|
|
controller: 'AssetController',
|
|
link: function (scope, element, attr) {
|
|
scope.googleMapAvailable = googleMapService.isAvailable;
|
|
scope.pvFlag = pwaModel.isPwaEnabled();
|
|
scope.isPwaEnabled = scope.pvFlag && element && element.length && !element[0].classList.contains('smart-recorder-confirmedItem_content');
|
|
if (scope.isPwaEnabled) {
|
|
function setPwaFrameUrl() {
|
|
var midtierUrl = localStorage.getItem('midtierUrl'), homeServer = localStorage.getItem('homeServer'), assetData = angular.fromJson(attr.previewAsset), context = 'Configuration Item', formView = 'SV_View', origin = window.location.origin, guid = assetData.assetId + '|' + assetData.assetClassId;
|
|
var formSrc = '';
|
|
if (midtierUrl) {
|
|
var path = 'goto';
|
|
if (homeServer) {
|
|
path = 'forms/' + homeServer;
|
|
}
|
|
formSrc = midtierUrl + '/pwa/#/' + path + '/SHR:SV_TicketDisplay/SV_TicketDisplay?origin=' + origin + '&targetForm=' + context + '&targetView=' + formView + '&targetId=' + guid + '&mode=GET&context=PREVIEW';
|
|
}
|
|
scope.url = $sce.trustAsResourceUrl(formSrc);
|
|
}
|
|
setPwaFrameUrl();
|
|
}
|
|
attr.$observe('previewAsset', function (previewAssetIds) {
|
|
var asset = angular.fromJson(previewAssetIds);
|
|
scope.init(asset.assetId, asset.assetClassId);
|
|
});
|
|
}
|
|
};
|
|
}]);
|
|
}());
|