Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

EPIC-893: Remove previewer logic #84

Merged
merged 2 commits into from
Apr 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 2 additions & 54 deletions modules/documents/client/directives/documents.manager.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,60 +208,8 @@ angular.module('documents')
};

self.dblClick = function(doc){
/*
If user can not read the document (BG: I'm not sure this is possible) then show an alert to say
"You can not read this document" (BG: someone needs to review the text)
Else (user can read file)
If the doc is a pdf then open it with the pdf viewer
Else show a confirmation dialog to offer the user can download the file.
If user selects yes then download the file.
Else no op
*/
if(!doc.userCan.read) {
AlertService.success('You can not have access to read this document.');
return;
}
if(doc.internalMime === 'application/pdf') {
openPDF(doc);
return;
}
// $filter bytes is filterBytes in documents.client.controllers.js
var size = $filter('bytes')(doc.internalSize, 2);
var msg = 'Confirm download of: ' + doc.displayName + ' (' + size + ')';

var scope = {
titleText: doc.displayName,
confirmText: msg,
confirmItems: undefined,
okText: 'OK',
cancelText: 'Cancel',
onOk: downLoadFile,
onCancel: cancelDownload,
okArgs: doc
};
ConfirmService.confirmDialog(scope);
return;

function downLoadFile(doc) {
var pdfURL = window.location.protocol + "//" + window.location.host + "/api/document/" + doc._id + "/fetch";
window.open(pdfURL, "_self");
return Promise.resolve(true);
}
function cancelDownload() {
return Promise.resolve();
}
function openPDF(doc){
var modalDocView = $modal.open({
resolve: {
pdfobject: { _id: doc._id }
},
templateUrl: 'modules/documents/client/views/partials/pdf-viewer.html',
controller: 'controllerModalPdfViewer',
controllerAs: 'pdfViewer',
windowClass: 'document-viewer-modal'
});
modalDocView.result.then(function () {}, function () {});
}
var pdfURL = window.location.protocol + "//" + window.location.host + "/api/document/" + doc._id + "/fetch";
window.open(pdfURL, "_blank");
};

self.checkDir = function(doc) {
Expand Down
4 changes: 2 additions & 2 deletions modules/documents/client/views/document-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
</button>
<ul class="dropdown-menu pull-right">
<li ng-if="doc.userCan.read">
<a class="btn icon-btn" href="/api/document/{{ doc._id }}/fetch" target="_self" title="Download File">
<a class="btn icon-btn" href="/api/document/{{ doc._id }}/fetch" target="_blank" title="Download File">
<span class="glyphicon glyphicon-download-alt"></span></a>
</li>
<li ng-if="doc.userCan.write">
Expand Down Expand Up @@ -370,7 +370,7 @@ <h2 title="{{documentMgr.infoPanel.data.displayName | removeExtension}}">{{docum
<a ng-if="documentMgr.infoPanel.data.userCan.read"
class="btn btn-sm btn-default"
href="/api/document/{{ documentMgr.infoPanel.data._id }}/fetch"
target="_self"
target="_blank"
title="Download File"><span class="glyphicon glyphicon-download-alt"></span></a>
<button ng-if="documentMgr.infoPanel.data.userCan.read && documentMgr.infoPanel.data.internalMime === 'application/pdf'"
x-modal-pdf-viewer
Expand Down