1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-13 13:50:07 +00:00

[shared file view] added modification for 'preview only' (#3867)

This commit is contained in:
llj
2019-07-17 17:34:22 +08:00
committed by Daniel Pan
parent accb814d22
commit 694900e82b
2 changed files with 30 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ const propTypes = {
};
let loginUser = window.app.pageOptions.name;
const { repoID, sharedToken, trafficOverLimit, fileName, fileSize, sharedBy, siteName, enableWatermark, download, zipped, filePath } = window.shared.pageOptions;
const { repoID, sharedToken, trafficOverLimit, fileName, fileSize, sharedBy, siteName, enableWatermark, canDownload, zipped, filePath } = window.shared.pageOptions;
class SharedFileView extends React.Component {
@@ -50,6 +50,21 @@ class SharedFileView extends React.Component {
duration: 3
});
}
if (!canDownload) {
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
return false;
});
document.addEventListener('keydown', function(e) {
// prevent ctrl + s/p/a/c, i.e, 'save', 'print', 'select all', 'copy'
// metaKey: for mac
if ((e.ctrlKey || e.metaKey) && (e.which == 83 || e.which == 80 || e.which == 65 || e.which == 67)) {
e.preventDefault();
e.stopPropagation();
return false;
}
});
}
}
renderPath = () => {
@@ -91,7 +106,7 @@ class SharedFileView extends React.Component {
<p className="share-by ellipsis">{gettext('Shared by:')}{' '}{sharedBy}</p>
}
</div>
{download &&
{canDownload &&
<div className="float-right">
{(loginUser && loginUser !== sharedBy) &&
<Button color="secondary" id="save"

View File

@@ -35,6 +35,18 @@
{% elif filetype == 'Unknown' %}
{% render_bundle 'sharedFileViewUnknown' 'css' %}
{% endif %}
{% if not permissions.can_download %}
<style type="text/css">
body {
user-select:none;
}
@media print {
html {
display:none;
}
}
</style>
{% endif %}
{% endblock %}
{% block extra_script %}
@@ -51,7 +63,7 @@
sharedBy: '{{ shared_by|email2nickname }}',
siteName: '{{ site_name }}',
enableWatermark: {% if enable_watermark %}true{% else %}false{% endif %},
download: '{{ permissions.can_download }}' == 'True',
canDownload: {% if permissions.can_download %}true{% else %}false{% endif %},
fileContent: '{{ file_content|escapejs }}',
err: {% if err %}'{{ err }}'{% else %}''{% endif %},
fileType: '{{ filetype }}',