From 9efac0f0678890cc0a67a8c603ec4bb1d540d89f Mon Sep 17 00:00:00 2001 From: tomasz1986 Date: Tue, 25 Jan 2022 23:08:27 +0100 Subject: [PATCH] gui: Tweak the Restore Versions modal for better usability (#7972) --- gui/black/assets/css/theme.css | 9 +- gui/dark/assets/css/theme.css | 9 +- gui/default/assets/css/overrides.css | 74 +- gui/default/assets/css/tree.css | 58 + gui/default/index.html | 2 +- .../syncthing/core/syncthingController.js | 26 +- .../folder/restoreVersionsMassActions.html | 2 +- .../folder/restoreVersionsModalView.html | 24 +- .../restoreVersionsVersionSelector.html | 2 +- gui/default/vendor/daterangepicker/LICENSE | 4 +- .../daterangepicker/daterangepicker.css | 164 +- .../vendor/daterangepicker/daterangepicker.js | 213 +- gui/default/vendor/fancytree/LICENSE.txt | 4 +- .../vendor/fancytree/css/ui.fancytree.css | 706 - .../fancytree/jquery.fancytree-all-deps.js | 22271 ++++++++-------- .../vendor/fancytree/skin-lion/icons.gif | Bin 5937 -> 0 bytes .../vendor/fancytree/skin-lion/loading.gif | Bin 1849 -> 0 bytes .../vendor/fancytree/skin-lion/vline.gif | Bin 852 -> 0 bytes gui/light/assets/css/theme.css | 11 +- 19 files changed, 12099 insertions(+), 11480 deletions(-) create mode 100644 gui/default/assets/css/tree.css delete mode 100644 gui/default/vendor/fancytree/css/ui.fancytree.css delete mode 100644 gui/default/vendor/fancytree/skin-lion/icons.gif delete mode 100644 gui/default/vendor/fancytree/skin-lion/loading.gif delete mode 100644 gui/default/vendor/fancytree/skin-lion/vline.gif diff --git a/gui/black/assets/css/theme.css b/gui/black/assets/css/theme.css index f6cdb51f7..622a22a58 100644 --- a/gui/black/assets/css/theme.css +++ b/gui/black/assets/css/theme.css @@ -265,6 +265,11 @@ code.ng-binding{ color: #222; } -.fancytree-title { - color: #aaa !important; +/* + * Fancytree tweaks + */ + +.fancytree-container tr:hover, +.fancytree-focused { + background-color: #222; } diff --git a/gui/dark/assets/css/theme.css b/gui/dark/assets/css/theme.css index d2aafed96..f554bb8a8 100644 --- a/gui/dark/assets/css/theme.css +++ b/gui/dark/assets/css/theme.css @@ -277,6 +277,11 @@ code.ng-binding{ color: #3fa9f0; } -.fancytree-title { - color: #aaa !important; +/* + * Fancytree tweaks + */ + +.fancytree-container tr:hover, +.fancytree-focused { + background-color: #424242; } diff --git a/gui/default/assets/css/overrides.css b/gui/default/assets/css/overrides.css index aa4a1e7b1..410e59733 100644 --- a/gui/default/assets/css/overrides.css +++ b/gui/default/assets/css/overrides.css @@ -301,6 +301,62 @@ ul.three-columns li, ul.two-columns li { z-index: 980; } +/* + * Restore Versions tweaks + */ + +#restoreTree-container { + overflow-y: scroll; + resize: vertical; + /* Limit height to prevent vertical screen overflow. */ + max-height: calc(100vh - 390px); + /* Always fit at least one folder with dropdown open. */ + min-height: 136px; +} +@media (min-width: 768px) { + #restoreTree-container { + max-height: calc(100vh - 401px); + } +} +@media (min-width: 992px) { + #restoreTree-container { + max-height: calc(100vh - 333px); + } +} + +/* Ignore fixed height when manually resized. */ +#restoreTree-container[style*="height"] { + max-height: none; +} + +/* Remove table outline as rows have own focus style already. */ +#restoreTree:focus { + outline: 0; +} + +/* Align dropdown with title first line. */ +#restoreTree td + td { + padding-top: 4px; + vertical-align: top; +} + +/* Reduce space between toggle and menu on mobile. */ +#restoreTree .dropdown-toggle { + margin-bottom: 0; +} + +/* Change direction to remain on screen on mobile. */ +#restoreTree .dropdown-menu { + left: auto; + right: 0; +} + +/* Ensure maximum space for filtering and date range. */ +#restoreVersions .form-group, +#restoreVersions .form-control { + width: 100%; +} + /** Footer nav on small devices **/ @media (max-width: 1199px) { /* Stay at the end of the page, with space reserved for the footer @@ -396,10 +452,6 @@ ul.three-columns li, ul.two-columns li { padding-top: 10px; } -.fancytree-ext-table { - width: 100% !important; -} - @media (max-width: 419px) { /* the selectors are build to target only the content of folder and device panels as it would "destroy" e.g. out of sync or recent changes listings */ @@ -420,12 +472,18 @@ ul.three-columns li, ul.two-columns li { width: 100%; } - /* all buttons, except panel headings, get bottom margin, as they won't fit - beside each other anymore */ + /* All buttons, except panel headings, get bottom margin, as they + won't fit beside each other anymore. Reduce footer padding to + compensate for the margin. */ .btn:not(.panel-heading), - /* this "+"-selector is needed to override some bootstrap defaults */ .btn:not(.panel-heading) + .btn:not(.panel-heading) { - margin-bottom: 1rem; + margin-bottom: 10px; + } + .panel-footer { + padding-bottom: 0; + } + .modal-footer { + padding-bottom: 5px; } } diff --git a/gui/default/assets/css/tree.css b/gui/default/assets/css/tree.css new file mode 100644 index 000000000..b55488f41 --- /dev/null +++ b/gui/default/assets/css/tree.css @@ -0,0 +1,58 @@ +/* +// Copyright (C) 2021 The Syncthing Authors. +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this file, +// You can obtain one at https://mozilla.org/MPL/2.0/. + +*/ + +.fancytree-container { + cursor: pointer; + width: 100%; +} + +.fancytree-hide { + visibility: collapse; +} + +/* Node needs to be block, and expander, icon and title + inline-block to properly wrap unbreakable text. */ +.fancytree-node { + display: block; + white-space: nowrap; + /* expander 16px + icon 16px + title padding 8px */ + padding-right: 40px; +} +.fancytree-expander, +.fancytree-icon, +.fancytree-title { + display: inline-block; +} + +.fancytree-expander, +.fancytree-icon { + margin-top: 4px; + vertical-align: top; + width: 16px; +} + +.fancytree-childcounter { + background: #777; + border-radius: 10px; + border: 1px solid gray; + color: #fff; + font-size: 13px; + opacity: .75; + padding: 2px 3px; + position: relative; + right: 8px; + top: -9px; + user-select: none; +} + +.fancytree-title { + padding-left: 8px; + white-space: normal; + word-break: break-all; +} diff --git a/gui/default/index.html b/gui/default/index.html index 85868c8ba..0f9af35d3 100644 --- a/gui/default/index.html +++ b/gui/default/index.html @@ -23,9 +23,9 @@ + - diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index d786da04c..ff4143fca 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -2509,23 +2509,22 @@ angular.module('syncthing.core') } $scope.restoreVersions.tree = $("#restoreTree").fancytree({ - extensions: ["table", "filter"], + extensions: ["table", "filter", "glyph"], quicksearch: true, filter: { - autoApply: true, - counter: true, - hideExpandedCounter: true, hideExpanders: true, - highlight: true, - leavesOnly: false, - nodata: true, mode: "hide" }, - table: { - indentation: 20, - nodeColumnIdx: 0, + glyph: { + preset: "awesome5", }, - debugLevel: 2, + table: { + indentation: 24, + }, + // Set to '1' to silence errors after pressing arrow keys on file nodes. + // Happens on the official option cofiguration from the developer's site + // too, so probably a bug? + debugLevel: 1, source: buildTree($scope.restoreVersions.versions), renderColumns: function (event, data) { // Case insensitive sort with folders on top. @@ -2540,9 +2539,9 @@ angular.module('syncthing.core') $tdList = $(node.tr).find(">td"), template; if (node.folder) { - template = '
'; + template = '
'; } else { - template = '
'; + template = '
'; } var scope = $rootScope.$new(true); @@ -2601,7 +2600,6 @@ angular.module('syncthing.core') timePicker: true, timePicker24Hour: true, timePickerSeconds: true, - autoUpdateInput: true, opens: "left", drops: "up", startDate: minDate, diff --git a/gui/default/syncthing/folder/restoreVersionsMassActions.html b/gui/default/syncthing/folder/restoreVersionsMassActions.html index 4dfba00f9..eecc313da 100644 --- a/gui/default/syncthing/folder/restoreVersionsMassActions.html +++ b/gui/default/syncthing/folder/restoreVersionsMassActions.html @@ -1,4 +1,4 @@ -