Trim history option in settings (UI only)

pull/1/head
yflory 5 years ago
parent 214d4e8e42
commit 19c329f6e7

@ -85,6 +85,7 @@
white-space: normal;
font-weight: bold;
}
&.danger, &.btn-danger {
background-color: @colortheme_alertify-red;
border-color: @colortheme_alertify-red-border;
@ -94,6 +95,14 @@
}
}
&.danger-alt, &.btn-danger-alt {
border-color: @colortheme_alertify-red;
color: @colortheme_alertify-red;
&:hover, &:active {
background-color: lighten(@colortheme_alertify-red, 35%);
}
}
&.safe, &.btn-safe {
background-color: @colortheme_alertify-green;
border-color: @colortheme_alertify-green-border;

@ -30,6 +30,13 @@ define([
});
}
UIElements.prettySize = function (bytes) {
var kB = Util.bytesToKilobytes(bytes);
if (kB < 1024) { return kB + Messages.KB; }
var mB = Util.bytesToMegabytes(bytes);
return mB + Messages.MB;
};
UIElements.updateTags = function (common, href) {
var existing, tags;
NThen(function(waitFor) {

@ -224,6 +224,7 @@
else if (bytes >= oneMegabyte) { return 'MB'; }
};
// given a path, asynchronously return an arraybuffer
Util.fetch = function (src, cb, progress) {
var CB = Util.once(cb);

@ -182,13 +182,6 @@ define([
}
};
var prettySize = function (bytes) {
var kB = Util.bytesToKilobytes(bytes);
if (kB < 1024) { return kB + Messages.KB; }
var mB = Util.bytesToMegabytes(bytes);
return mB + Messages.MB;
};
queue.next = function () {
if (queue.queue.length === 0) {
clearTimeout(queue.to);
@ -251,7 +244,7 @@ define([
// name
$('<td>').append($link).appendTo($tr);
// size
$('<td>').text(prettySize(estimate)).appendTo($tr);
$('<td>').text(UIElements.prettySize(estimate)).appendTo($tr);
// progress
$('<td>', {'class': 'cp-fileupload-table-progress'}).append($progressContainer).appendTo($tr);
// cancel

@ -73,6 +73,7 @@ define([
'cp-settings-thumbnails',
'cp-settings-drive-backup',
'cp-settings-drive-import-local',
'cp-settings-trim-history'
//'cp-settings-drive-reset'
],
'cursor': [
@ -1197,6 +1198,40 @@ define([
return $div;
};
makeBlock('trim-history', function (cb) {
// XXX settings_trimHistoryTitle, settings_trimHistoryHint, settings_trimHistoryButton
// XXX trimHistory_confirm
var spinner = UI.makeSpinner();
var button = h('button.btn.btn-danger-alt', {
disabled: 'disabled'
}, Messages.trimHistoryButton || 'test'); // XXX
var currentSize = h('p', $(spinner.spinner).clone()[0]);
var content = h('div', [
currentSize,
button,
spinner.ok,
spinner.spinner
]);
Messages.trimHistory_currentSize = 'Abcd: <b>{0}</b>'; // XXX
var size;
nThen(function (waitFor) {
size = UIElements.prettySize(1024*12); // XXX get size
}).nThen(function () {
$(currentSize).html(Messages._getKey('trimHistory_currentSize', [size]));
$(button).click(function () {
UI.confirm(Messages.trimHistory_confirm, function (yes) {
if (!yes) { return; }
spinner.spin();
});
}).prop('disabled', '');
});
cb(content);
}, true);
/*
create['drive-reset'] = function () {
var $div = $('<div>', {'class': 'cp-settings-drive-reset cp-sidebarlayout-element'});

Loading…
Cancel
Save