diff --git a/src/filemanager.html b/src/filemanager.html
index 89b9e56a4..079c1e5e8 100644
--- a/src/filemanager.html
+++ b/src/filemanager.html
@@ -48,12 +48,16 @@
-
-
+
+
+
+
+
+
@@ -81,6 +85,16 @@
+
+
diff --git a/src/js/client.js b/src/js/client.js
index 0d3574eed..5d2bdf812 100644
--- a/src/js/client.js
+++ b/src/js/client.js
@@ -2414,9 +2414,16 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
// FileManager API
- Client.prototype.filesGet = function (appId, path, download, callback) {
- if (download) {
+ // mode can be 'download', 'open', 'link' or 'data'
+ Client.prototype.filesGet = function (appId, path, mode, callback) {
+ if (mode === 'download') {
window.open(client.apiOrigin + '/api/v1/apps/' + appId + '/files/' + path + '?download=true&access_token=' + token);
+ callback(null);
+ } else if (mode === 'open') {
+ window.open(client.apiOrigin + '/api/v1/apps/' + appId + '/files/' + path + '?download=false&access_token=' + token);
+ callback(null);
+ } else if (mode === 'link') {
+ callback(null, client.apiOrigin + '/api/v1/apps/' + appId + '/files/' + path + '?download=false&access_token=' + token);
} else {
function responseHandler(data, headers, status) {
if (headers()['content-type'] && headers()['content-type'].indexOf('application/json') !== -1) return JSON.parse(data);
diff --git a/src/js/filemanager.js b/src/js/filemanager.js
index 01d6680ca..964ce01ca 100644
--- a/src/js/filemanager.js
+++ b/src/js/filemanager.js
@@ -1,6 +1,6 @@
'use strict';
-/* global angular, $, async, monaco */
+/* global angular, $, async, monaco, Mimer */
require.config({ paths: { 'vs': '3rdparty/vs' }});
@@ -23,6 +23,12 @@ app.config(function ($sceProvider) {
$sceProvider.enabled(false);
});
+app.filter("trustUrl", ['$sce', function ($sce) {
+ return function (recordingUrl) {
+ return $sce.trustAsResourceUrl(recordingUrl);
+ };
+}]);
+
// https://stackoverflow.com/questions/25621321/angularjs-ng-drag
var ngDragEventDirectives = {};
angular.forEach(
@@ -118,7 +124,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
if (entry.isDirectory) return;
- Client.filesGet($scope.appId, filePath, true, function (error) {
+ Client.filesGet($scope.appId, filePath, 'download', function (error) {
if (error) return Client.error(error);
});
};
@@ -200,7 +206,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
$scope.refresh = function () {
$scope.busy = true;
- Client.filesGet($scope.appId, $scope.cwd, false, function (error, result) {
+ Client.filesGet($scope.appId, $scope.cwd, 'data', function (error, result) {
$scope.busy = false;
if (error) return Client.error(error);
@@ -216,10 +222,19 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
if (entry.isDirectory) {
$scope.changeDirectory(filePath);
} else if (entry.isFile) {
- $scope.textEditor.show(entry);
- } else {
+ var mimeType = Mimer().get(entry.fileName);
+ var mimeGroup = mimeType.split('/')[0];
- }
+ if (mimeGroup === 'video' || mimeGroup === 'image') {
+ $scope.mediaViewer.show(entry);
+ } else if (mimeType === 'application/pdf') {
+ Client.filesGet($scope.appId, filePath, 'open', function (error) { if (error) return Client.error(error); });
+ } else if (mimeGroup === 'text' || mimeGroup === 'application') {
+ $scope.textEditor.show(entry);
+ } else {
+ Client.filesGet($scope.appId, filePath, 'open', function (error) { if (error) return Client.error(error); });
+ }
+ } else {}
};
$scope.goDirectoryUp = function () {
@@ -376,6 +391,26 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
}
};
+ $scope.mediaViewer = {
+ type: '',
+ src: '',
+ entry: null,
+
+ show: function (entry) {
+ var filePath = sanitize($scope.cwd + '/' + entry.fileName);
+
+ Client.filesGet($scope.appId, filePath, 'link', function (error, result) {
+ if (error) return Client.error(error);
+
+ $scope.mediaViewer.entry = entry;
+ $scope.mediaViewer.type = Mimer().get(entry.fileName).split('/')[0];
+ $scope.mediaViewer.src = result;
+
+ $('#mediaViewerModal').modal('show');
+ });
+ }
+ };
+
$scope.textEditor = {
busy: false,
entry: null,
@@ -393,7 +428,7 @@ app.controller('FileManagerController', ['$scope', '$timeout', 'Client', functio
var filePath = sanitize($scope.cwd + '/' + entry.fileName);
var language = getLanguage(entry.fileName);
- Client.filesGet($scope.appId, filePath, false, function (error, result) {
+ Client.filesGet($scope.appId, filePath, 'data', function (error, result) {
if (error) return Client.error(error);
if (!$scope.textEditor.editor) {