Open different mimetypes differently in filemanager
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user