UNPKG

unserver-unify

Version:

49 lines 1.86 kB
angular.module('bamboo').controller('AttachmentPreviewDlgCtrl', function($scope, $uibModalInstance, CommonService, config, $sce) { var self = this; self.type = config.type; self.fileURL = config.absURL; // console.log(config); var msoffice = ['doc', 'docx', 'docm', 'dotm', 'dotx', 'xlsx', 'xlsb', 'xlsm', 'pptx', 'ppsx', 'ppt', 'pps', 'pptm', 'potm', 'ppam', 'potx', 'ppsm']; var imgType = ['gif', 'jpeg', 'jpg', 'jpeg', 'png']; var videoType = ['ogg', 'mp4']; if (msoffice.includes(self.type)) { var _protocol = window.location.protocol; var fullurl = _protocol + self.fileURL; // console.log(fullurl); self.fileURL = "https://view.officeapps.live.com/op/embed.aspx?src=" + fullurl; self.type = 'msoffice'; // console.log(self.type); } else if (imgType.includes(self.type)) { self.type = 'img'; } else if (videoType.includes(self.type)) { self.type = 'video'; } else if (self.type == 'pdf') { self.type = 'pdf'; } else if (self.type == 'txt') { self.type = 'txt'; } else if (self.type == 'youtube'||self.type == 'vimeo') { // console.log("youtube"); } else { self.type = undefined; } if (self.type == 'youtube') { self.title = "Youtube"; self.fileURL = CommonService.getYoutubeLinkfromUrl(self.fileURL); } else if (self.type == 'vimeo') { self.title = "Vimeo"; console.log(self.fileURL); self.fileURL = CommonService.getVimeoLinkfromUrl(self.fileURL); console.log(self.fileURL); } else { self.title = decodeURI(self.fileURL.split('/').pop()); self.fileURL = $sce.trustAsResourceUrl(self.fileURL); } $scope.ok = function() { $uibModalInstance.close("ok"); }; self.cancel = function() { // console.log("---"); //$uibModalInstance.dismiss(); $uibModalInstance.close(); }; });