|
|
@@ -443,7 +443,7 @@ else:
|
|
|
<div id="uploadFileModal" class="modal hide fade">
|
|
|
<div class="modal-header">
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="${ _('Close') }"><span aria-hidden="true">×</span></button>
|
|
|
- <h2 class="modal-title">${_('Upload to')} <span data-bind="text: currentDecodedPath"></span></h2>
|
|
|
+ <h2 class="modal-title">${_('Upload to')} <span data-bind="text: currentPath"></span></h2>
|
|
|
</div>
|
|
|
<div class="modal-body form-inline">
|
|
|
<div id="fileUploader" class="uploader">
|
|
|
@@ -801,16 +801,6 @@ else:
|
|
|
return (bytes / Math.pow(k, i)).toPrecision(dm) + ' ' + sizes[i];
|
|
|
}
|
|
|
|
|
|
- var updateHash = function (hash) {
|
|
|
- hash = encodeURI(decodeURIComponent(hash));
|
|
|
- %if not is_embeddable:
|
|
|
- window.location.hash = hash;
|
|
|
- %else:
|
|
|
- hueUtils.changeURL('#' + hash);
|
|
|
- huePubSub.publish('fb.update.hash');
|
|
|
- %endif
|
|
|
- }
|
|
|
-
|
|
|
var Page = function (page) {
|
|
|
if (page != null) {
|
|
|
return {
|
|
|
@@ -916,11 +906,10 @@ else:
|
|
|
if (this.url == null || this.url == "") {
|
|
|
// forcing root on empty breadcrumb url
|
|
|
this.url = "/";
|
|
|
- }
|
|
|
-
|
|
|
- fileBrowserViewModel.targetPageNum(1);
|
|
|
- fileBrowserViewModel.targetPath("${url('filebrowser:filebrowser.views.view', path='')}" + stripHashes(this.url));
|
|
|
- updateHash(this.url);
|
|
|
+ }
|
|
|
+ fileBrowserViewModel.targetPageNum(1);
|
|
|
+ const pathPrefix = "${url('filebrowser:filebrowser.views.view', path='')}";
|
|
|
+ huePubSub.publish('open.filebrowserlink', { pathPrefix, decodedPath: this.url, fileBrowserModel: fileBrowserViewModel});
|
|
|
}
|
|
|
else {
|
|
|
window.open($(e.target).attr('href'));
|
|
|
@@ -1055,16 +1044,8 @@ else:
|
|
|
};
|
|
|
|
|
|
self.currentPath = ko.observable(currentDirPath);
|
|
|
- self.currentDecodedPath = ko.observable(decodeURI(currentDirPath));
|
|
|
-
|
|
|
- self.currentPath.subscribe(function (path) {
|
|
|
- // currentEditablePath can be edited by the user in #hueBreadcrumbText.
|
|
|
- // It is using a decoded currentPath in order to correctly display non ASCII characters
|
|
|
- const decodedPath = decodeURI(path);
|
|
|
- if (decodedPath !== self.currentDecodedPath()) {
|
|
|
- self.currentDecodedPath(decodedPath);
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ self.currentPath.subscribe(function (path) {
|
|
|
$(document).trigger('currPathLoaded', { path: path });
|
|
|
});
|
|
|
|
|
|
@@ -1171,7 +1152,7 @@ else:
|
|
|
self.showSummary = function () {
|
|
|
self.isLoadingSummary(true);
|
|
|
$("#contentSummaryModal").modal("show");
|
|
|
- $.getJSON("${url('filebrowser:content_summary', path='')}" + self.selectedFile().path, function (data) {
|
|
|
+ $.getJSON("${url('filebrowser:content_summary', path='')}" + encodeURIComponent(self.selectedFile().path), function (data) {
|
|
|
if (data.status == 0) {
|
|
|
self.contentSummary(ko.mapping.fromJS(data.summary));
|
|
|
self.isLoadingSummary(false);
|
|
|
@@ -1191,8 +1172,8 @@ else:
|
|
|
|
|
|
self.retrieveData = function (clearAssistCache) {
|
|
|
self.isLoading(true);
|
|
|
-
|
|
|
- $.getJSON(self.targetPath() + (self.targetPath().indexOf('?') > 0 ? '&' : '?') + "pagesize=" + self.recordsPerPage() + "&pagenum=" + self.targetPageNum() + "&filter=" + self.searchQuery() + "&sortby=" + self.sortBy() + "&descending=" + self.sortDescending() + "&format=json", function (data) {
|
|
|
+ const encodedSearchFilter = encodeURIComponent(self.searchQuery());
|
|
|
+ $.getJSON(self.targetPath() + (self.targetPath().indexOf('?') > 0 ? '&' : '?') + "pagesize=" + self.recordsPerPage() + "&pagenum=" + self.targetPageNum() + "&filter=" + encodedSearchFilter + "&sortby=" + self.sortBy() + "&descending=" + self.sortDescending() + "&format=json", function (data) {
|
|
|
if (data.error){
|
|
|
$(document).trigger("error", data.error);
|
|
|
self.isLoading(false);
|
|
|
@@ -1349,7 +1330,6 @@ else:
|
|
|
e.preventDefault();
|
|
|
fileBrowserViewModel.targetPageNum(1);
|
|
|
fileBrowserViewModel.targetPath("${url('filebrowser:filebrowser.views.view', path='')}?" + folderPath);
|
|
|
- updateHash('');
|
|
|
fileBrowserViewModel.retrieveData();
|
|
|
}
|
|
|
else {
|
|
|
@@ -1367,60 +1347,24 @@ else:
|
|
|
}
|
|
|
|
|
|
self.viewFile = function (file, e) {
|
|
|
- const urlEncodedPercentage = '%25';
|
|
|
-
|
|
|
e.stopImmediatePropagation();
|
|
|
+ const decodedPath = file.path;
|
|
|
+ const pathPrefix = "${url('filebrowser:filebrowser.views.view', path='')}";
|
|
|
+
|
|
|
if (file.type == "dir") {
|
|
|
// Reset page number so that we don't hit a page that doesn't exist
|
|
|
- self.targetPageNum(1);
|
|
|
+ self.targetPageNum(1);
|
|
|
self.enableFilterAfterSearch = false;
|
|
|
self.searchQuery("");
|
|
|
- self.targetPath(file.url);
|
|
|
-
|
|
|
- const path = file.path;
|
|
|
- const percentageEncodedPath = path.includes('%') && !path.includes(urlEncodedPercentage) ?
|
|
|
- path.replaceAll('%', urlEncodedPercentage) : path;
|
|
|
-
|
|
|
- updateHash(stripHashes(percentageEncodedPath));
|
|
|
+ huePubSub.publish('open.filebrowserlink', { pathPrefix, decodedPath, fileBrowserModel: self });
|
|
|
} else {
|
|
|
-
|
|
|
- // Fix to encode potential hash characters in a file name when viewing a file
|
|
|
- let url = file.name.indexOf('#') >= 0 && file.url.indexOf('#') >= 0
|
|
|
- ? file.url.replaceAll('#', encodeURIComponent('#')) : file.url;
|
|
|
-
|
|
|
- %if is_embeddable:
|
|
|
-
|
|
|
- // Fix. The '%' character needs to be encoded twice due to a bug in the page library
|
|
|
- // that decodes the url twice
|
|
|
-
|
|
|
- if (file.path.includes('%') && !file.path.includes(urlEncodedPercentage)) {
|
|
|
- url = url.replaceAll(urlEncodedPercentage, encodeURIComponent(urlEncodedPercentage));
|
|
|
- }
|
|
|
-
|
|
|
- huePubSub.publish('open.link', url);
|
|
|
- %else:
|
|
|
- window.location.href = url;
|
|
|
- %endif
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- self.editFile = function () {
|
|
|
- huePubSub.publish('open.link', self.selectedFile().url.replace("${url('filebrowser:filebrowser.views.view', path='')}", "${url('filebrowser:filebrowser_views_edit', path='')}"));
|
|
|
+ huePubSub.publish('open.filebrowserlink', { pathPrefix, decodedPath });
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
self.downloadFile = function () {
|
|
|
- const baseUrl = "${url('filebrowser:filebrowser_views_download', path='')}";
|
|
|
- // If the hash characters aren't encoded the page library will
|
|
|
- // split the path on the first occurence and the remaining string will not
|
|
|
- // be part of the path. Question marks must also be encoded or the string after the first
|
|
|
- // question mark will be interpreted as the url querystring.
|
|
|
- // Percentage character must be double encoded due to the page library that decodes the url twice
|
|
|
- const doubleUrlEncodedPercentage = '%2525';
|
|
|
- const partiallyEncodedFilePath = self.selectedFile().path.replaceAll('%', doubleUrlEncodedPercentage).replaceAll('#', encodeURIComponent('#'))
|
|
|
- .replaceAll('?', encodeURIComponent('?'));;
|
|
|
- const fullUrl = baseUrl+partiallyEncodedFilePath;
|
|
|
-
|
|
|
- huePubSub.publish('open.link', fullUrl);
|
|
|
+ huePubSub.publish('ignore.next.unload');
|
|
|
+ huePubSub.publish('open.filebrowserlink', { pathPrefix: '/filebrowser/download=', decodedPath: self.selectedFile().path });
|
|
|
};
|
|
|
|
|
|
self.renameFile = function () {
|
|
|
@@ -1488,7 +1432,7 @@ else:
|
|
|
|
|
|
if (!isMoveOnSelf){
|
|
|
hiddenFields($("#moveForm"), "src_path", paths);
|
|
|
- $("#moveForm").attr("action", "/filebrowser/move?next=${url('filebrowser:filebrowser.views.view', path='')}" + self.currentPath());
|
|
|
+ $("#moveForm").attr("action", "/filebrowser/move?next=${url('filebrowser:filebrowser.views.view', path='')}" + encodeURIComponent(self.currentPath()));
|
|
|
$('#moveForm').ajaxForm({
|
|
|
dataType: 'json',
|
|
|
success: function() {
|
|
|
@@ -1698,7 +1642,7 @@ else:
|
|
|
|
|
|
$("#deleteForm").attr("action", "/filebrowser/rmtree" + "?" +
|
|
|
(self.skipTrash() ? "skip_trash=true&" : "") +
|
|
|
- "next=${url('filebrowser:filebrowser.views.view', path='')}" + self.currentPath());
|
|
|
+ "next=${url('filebrowser:filebrowser.views.view', path='')}" + encodeURIComponent(self.currentPath()));
|
|
|
|
|
|
$("#deleteModal").modal({
|
|
|
keyboard:true,
|
|
|
@@ -2493,39 +2437,7 @@ else:
|
|
|
|
|
|
$("*[rel='tooltip']").tooltip({ placement:"bottom" });
|
|
|
|
|
|
- var hashchange = function () {
|
|
|
- if (window.location.pathname.indexOf('/filebrowser') > -1) {
|
|
|
- var targetPath = "";
|
|
|
- var hash = decodeURI(window.location.hash.substring(1));
|
|
|
- if (hash != null && hash != "" && hash.indexOf('/') > -1) {
|
|
|
- targetPath = "${url('filebrowser:filebrowser.views.view', path='')}";
|
|
|
- if (hash.indexOf("!!") != 0) {
|
|
|
- targetPath += stripHashes(encodeURIComponent(hash));
|
|
|
- }
|
|
|
- else {
|
|
|
- targetPath = fileBrowserViewModel.targetPath() + encodeURI(hash);
|
|
|
- }
|
|
|
- fileBrowserViewModel.targetPageNum(1)
|
|
|
- }
|
|
|
- if (window.location.href.indexOf("#") == -1) {
|
|
|
- fileBrowserViewModel.targetPageNum(1);
|
|
|
- targetPath = "${current_request_path | n,unicode }";
|
|
|
- }
|
|
|
- if (targetPath != "") {
|
|
|
- fileBrowserViewModel.targetPath(targetPath);
|
|
|
- fileBrowserViewModel.retrieveData();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- huePubSub.subscribe('fb.update.hash', hashchange, 'filebrowser');
|
|
|
-
|
|
|
- if (window.location.hash != null && window.location.hash.length > 1) {
|
|
|
- hashchange();
|
|
|
- }
|
|
|
- else {
|
|
|
- fileBrowserViewModel.retrieveData();
|
|
|
- }
|
|
|
+ fileBrowserViewModel.retrieveData();
|
|
|
|
|
|
|
|
|
$("#editBreadcrumb").click(function (e) {
|
|
|
@@ -2546,17 +2458,14 @@ else:
|
|
|
$.jHueNotify.warn("${ _('Listing of buckets is not allowed. Redirecting to the home directory.') }");
|
|
|
target_path = window.USER_HOME_DIR;
|
|
|
}
|
|
|
- fileBrowserViewModel.targetPath("${url('filebrowser:filebrowser.views.view', path='')}" + target_path);
|
|
|
+ fileBrowserViewModel.targetPath("${url('filebrowser:filebrowser.views.view', path='')}" + encodeURIComponent(target_path));
|
|
|
fileBrowserViewModel.getStats(function (data) {
|
|
|
- if (data.type != null && data.type == "file") {
|
|
|
- %if is_embeddable:
|
|
|
- huePubSub.publish('open.link', data.url);
|
|
|
- %else:
|
|
|
- huePubSub.publish('open.link', data.url);
|
|
|
- %endif
|
|
|
+ const pathPrefix = "${url('filebrowser:filebrowser.views.view', path='')}";
|
|
|
+ if (data.type != null && data.type == "file") {
|
|
|
+ huePubSub.publish('open.filebrowserlink', { pathPrefix, decodedPath: target_path});
|
|
|
return false;
|
|
|
} else {
|
|
|
- updateHash(target_path);
|
|
|
+ huePubSub.publish('open.filebrowserlink', { pathPrefix, decodedPath: target_path, fileBrowserModel: fileBrowserViewModel});
|
|
|
}
|
|
|
$("#jHueHdfsAutocomplete").hide();
|
|
|
});
|
|
|
@@ -2583,7 +2492,6 @@ else:
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- $(window).bind("hashchange.fblist", hashchange);
|
|
|
|
|
|
$(".actionbar").data("originalWidth", $(".actionbar").width());
|
|
|
|