mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
gui: Defer jsTree initialisation until next digest cycle (fixes #4738)
This commit is contained in:
parent
603da2dce2
commit
9212303906
@ -1996,114 +1996,116 @@ angular.module('syncthing.core')
|
|||||||
});
|
});
|
||||||
|
|
||||||
$q.all([dataReceived, modalShown.promise]).then(function() {
|
$q.all([dataReceived, modalShown.promise]).then(function() {
|
||||||
if (closed) {
|
$timeout(function(){
|
||||||
resetRestoreVersions();
|
if (closed) {
|
||||||
return;
|
resetRestoreVersions();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.restoreVersions.tree = $("#restoreTree").fancytree({
|
$scope.restoreVersions.tree = $("#restoreTree").fancytree({
|
||||||
extensions: ["table", "filter"],
|
extensions: ["table", "filter"],
|
||||||
quicksearch: true,
|
quicksearch: true,
|
||||||
filter: {
|
filter: {
|
||||||
autoApply: true,
|
autoApply: true,
|
||||||
counter: true,
|
counter: true,
|
||||||
hideExpandedCounter: true,
|
hideExpandedCounter: true,
|
||||||
hideExpanders: true,
|
hideExpanders: true,
|
||||||
highlight: true,
|
highlight: true,
|
||||||
leavesOnly: false,
|
leavesOnly: false,
|
||||||
nodata: true,
|
nodata: true,
|
||||||
mode: "hide"
|
mode: "hide"
|
||||||
},
|
},
|
||||||
table: {
|
table: {
|
||||||
indentation: 20,
|
indentation: 20,
|
||||||
nodeColumnIdx: 0,
|
nodeColumnIdx: 0,
|
||||||
},
|
},
|
||||||
debugLevel: 2,
|
debugLevel: 2,
|
||||||
source: buildTree($scope.restoreVersions.versions),
|
source: buildTree($scope.restoreVersions.versions),
|
||||||
renderColumns: function(event, data) {
|
renderColumns: function(event, data) {
|
||||||
var node = data.node,
|
var node = data.node,
|
||||||
$tdList = $(node.tr).find(">td"),
|
$tdList = $(node.tr).find(">td"),
|
||||||
template;
|
template;
|
||||||
if (node.folder) {
|
if (node.folder) {
|
||||||
template = '<div ng-include="\'syncthing/folder/restoreVersionsMassActions.html\'" class="pull-right"/>';
|
template = '<div ng-include="\'syncthing/folder/restoreVersionsMassActions.html\'" class="pull-right"/>';
|
||||||
} else {
|
} else {
|
||||||
template = '<div ng-include="\'syncthing/folder/restoreVersionsVersionSelector.html\'" class="pull-right"/>';
|
template = '<div ng-include="\'syncthing/folder/restoreVersionsVersionSelector.html\'" class="pull-right"/>';
|
||||||
|
}
|
||||||
|
|
||||||
|
var scope = $rootScope.$new(true);
|
||||||
|
scope.key = node.key;
|
||||||
|
scope.restoreVersions = $scope.restoreVersions;
|
||||||
|
|
||||||
|
$tdList.eq(1).html(
|
||||||
|
$compile(template)(scope)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Force angular to redraw.
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$apply();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}).fancytree("getTree");
|
||||||
|
|
||||||
var scope = $rootScope.$new(true);
|
var minDate = moment(),
|
||||||
scope.key = node.key;
|
maxDate = moment(0, 'X'),
|
||||||
scope.restoreVersions = $scope.restoreVersions;
|
date;
|
||||||
|
|
||||||
$tdList.eq(1).html(
|
// Find version window.
|
||||||
$compile(template)(scope)
|
$.each($scope.restoreVersions.versions, function(key) {
|
||||||
);
|
$.each($scope.restoreVersions.versions[key], function(idx, version) {
|
||||||
|
date = moment(version.versionTime);
|
||||||
|
if (date.isBefore(minDate)) {
|
||||||
|
minDate = date;
|
||||||
|
}
|
||||||
|
if (date.isAfter(maxDate)) {
|
||||||
|
maxDate = date;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Force angular to redraw.
|
$scope.restoreVersions.filters['start'] = minDate;
|
||||||
|
$scope.restoreVersions.filters['end'] = maxDate;
|
||||||
|
|
||||||
|
var ranges = {
|
||||||
|
'All time': [minDate, maxDate],
|
||||||
|
'Today': [moment(), moment()],
|
||||||
|
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||||
|
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
||||||
|
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
||||||
|
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
||||||
|
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||||
|
};
|
||||||
|
|
||||||
|
// Filter out invalid ranges.
|
||||||
|
$.each(ranges, function(key, range) {
|
||||||
|
if (!range[0].isBetween(minDate, maxDate, null, '[]') && !range[1].isBetween(minDate, maxDate, null, '[]')) {
|
||||||
|
delete ranges[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#restoreVersionDateRange").daterangepicker({
|
||||||
|
timePicker: true,
|
||||||
|
timePicker24Hour: true,
|
||||||
|
timePickerSeconds: true,
|
||||||
|
autoUpdateInput: true,
|
||||||
|
opens: "left",
|
||||||
|
drops: "up",
|
||||||
|
startDate: minDate,
|
||||||
|
endDate: maxDate,
|
||||||
|
minDate: minDate,
|
||||||
|
maxDate: maxDate,
|
||||||
|
ranges: ranges,
|
||||||
|
locale: {
|
||||||
|
format: 'YYYY/MM/DD HH:mm:ss',
|
||||||
|
}
|
||||||
|
}).on('apply.daterangepicker', function(ev, picker) {
|
||||||
|
$scope.restoreVersions.filters['start'] = picker.startDate;
|
||||||
|
$scope.restoreVersions.filters['end'] = picker.endDate;
|
||||||
|
// Events for this UI element are not managed by angular.
|
||||||
|
// Force angular to wake up.
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}).fancytree("getTree");
|
|
||||||
|
|
||||||
var minDate = moment(),
|
|
||||||
maxDate = moment(0, 'X'),
|
|
||||||
date;
|
|
||||||
|
|
||||||
// Find version window.
|
|
||||||
$.each($scope.restoreVersions.versions, function(key) {
|
|
||||||
$.each($scope.restoreVersions.versions[key], function(idx, version) {
|
|
||||||
date = moment(version.versionTime);
|
|
||||||
if (date.isBefore(minDate)) {
|
|
||||||
minDate = date;
|
|
||||||
}
|
|
||||||
if (date.isAfter(maxDate)) {
|
|
||||||
maxDate = date;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.restoreVersions.filters['start'] = minDate;
|
|
||||||
$scope.restoreVersions.filters['end'] = maxDate;
|
|
||||||
|
|
||||||
var ranges = {
|
|
||||||
'All time': [minDate, maxDate],
|
|
||||||
'Today': [moment(), moment()],
|
|
||||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
|
||||||
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
|
|
||||||
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
|
|
||||||
'This Month': [moment().startOf('month'), moment().endOf('month')],
|
|
||||||
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
|
||||||
};
|
|
||||||
|
|
||||||
// Filter out invalid ranges.
|
|
||||||
$.each(ranges, function(key, range) {
|
|
||||||
if (!range[0].isBetween(minDate, maxDate, null, '[]') && !range[1].isBetween(minDate, maxDate, null, '[]')) {
|
|
||||||
delete ranges[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#restoreVersionDateRange").daterangepicker({
|
|
||||||
timePicker: true,
|
|
||||||
timePicker24Hour: true,
|
|
||||||
timePickerSeconds: true,
|
|
||||||
autoUpdateInput: true,
|
|
||||||
opens: "left",
|
|
||||||
drops: "up",
|
|
||||||
startDate: minDate,
|
|
||||||
endDate: maxDate,
|
|
||||||
minDate: minDate,
|
|
||||||
maxDate: maxDate,
|
|
||||||
ranges: ranges,
|
|
||||||
locale: {
|
|
||||||
format: 'YYYY/MM/DD HH:mm:ss',
|
|
||||||
}
|
|
||||||
}).on('apply.daterangepicker', function(ev, picker) {
|
|
||||||
$scope.restoreVersions.filters['start'] = picker.startDate;
|
|
||||||
$scope.restoreVersions.filters['end'] = picker.endDate;
|
|
||||||
// Events for this UI element are not managed by angular.
|
|
||||||
// Force angular to wake up.
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.$apply();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user