Skip to content

TagSpaces is an offline, open source, document manager with tagging support

Added random sort order for directory content.

HappyDaye6f1e05ec738
diff --git a/app/locales/ar/core.json b/app/locales/ar/core.json
index f5f465ba4..54abb8a5d 100644
--- a/app/locales/ar/core.json
+++ b/app/locales/ar/core.json
@@ -248,6 +248,7 @@
"fileTags": "Tags",
"fileSize": "Size",
"fileLDTM": "Date Modified",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Path",
"fileName": "File Name",
diff --git a/app/locales/bg/core.json b/app/locales/bg/core.json
index b1f3a056a..3486a5ec2 100644
--- a/app/locales/bg/core.json
+++ b/app/locales/bg/core.json
@@ -248,6 +248,7 @@
"fileTags": "Етикети",
"fileSize": "Размер",
"fileLDTM": "Дата на промяната",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Път",
"fileName": "Име на файла",
diff --git a/app/locales/ca/core.json b/app/locales/ca/core.json
index 441ff43fe..42b1f6666 100644
--- a/app/locales/ca/core.json
+++ b/app/locales/ca/core.json
@@ -248,6 +248,7 @@
"fileTags": "Etiquetes",
"fileSize": "Size",
"fileLDTM": "Data de modificació",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Camí",
"fileName": "Nom del fitxer",
diff --git a/app/locales/cs/core.json b/app/locales/cs/core.json
index 1b3b86737..d0181936c 100644
--- a/app/locales/cs/core.json
+++ b/app/locales/cs/core.json
@@ -248,6 +248,7 @@
"fileTags": "Štítky",
"fileSize": "Velikost",
"fileLDTM": "Datum poslední změny",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Cesta",
"fileName": "Název souboru",
diff --git a/app/locales/da_DK/core.json b/app/locales/da_DK/core.json
index 3eab5d183..3996220aa 100644
--- a/app/locales/da_DK/core.json
+++ b/app/locales/da_DK/core.json
@@ -248,6 +248,7 @@
"fileTags": "Tags",
"fileSize": "Størrelse",
"fileLDTM": "Rettet dato",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Sti",
"fileName": "Fil navn",
diff --git a/app/locales/de_DE/core.json b/app/locales/de_DE/core.json
index 09b422598..e4b0aaa19 100644
--- a/app/locales/de_DE/core.json
+++ b/app/locales/de_DE/core.json
@@ -248,6 +248,7 @@
"fileTags": "Schlagwörter",
"fileSize": "Größe",
"fileLDTM": "Änderungsdatum",
+ "random": "Zufällig",
"fileDirectory": "Verzeichnis",
"filePath": "Pfad",
"fileName": "Dateiname",
diff --git a/app/locales/el/core.json b/app/locales/el/core.json
index 0106e938b..a6bef09fe 100644
--- a/app/locales/el/core.json
+++ b/app/locales/el/core.json
@@ -248,6 +248,7 @@
"fileTags": "Ετικέτες",
"fileSize": "Μέγεθος",
"fileLDTM": "Hμερομηνία τροποποίησης",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Διαδρομή",
"fileName": "Όνομα αρχείου",
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index c407d7037..1a9ab953e 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -250,13 +250,12 @@
"fileTags": "Tags",
"fileSize": "Size",
"fileLDTM": "Date Modified",
+ "random": "Random",
"fileDirectory": "Directory",
- "fileFirstTag": "First Tag",
"filePath": "Path",
"fileName": "File Name",
"createTXTFile": "New Plain Text File",
"showAddFileDialog": "Add Existing File",
- "cameraTakePicture": "Take Picture",
"deleteConfirmationTitle": "Confirm Delete",
"deleteConfirmationContent": "The selected entries will be permanently deleted. Are you sure?",
"changeBackgroundColor": "Change Background Color",
diff --git a/app/locales/en_US/core.json b/app/locales/en_US/core.json
index ca1a8ff2b..970b7e3d8 100644
--- a/app/locales/en_US/core.json
+++ b/app/locales/en_US/core.json
@@ -248,6 +248,7 @@
"fileTags": "Tags",
"fileSize": "Size",
"fileLDTM": "Date Modified",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Path",
"fileName": "File Name",
diff --git a/app/locales/eo/core.json b/app/locales/eo/core.json
index 7e8e8b243..41d323500 100644
--- a/app/locales/eo/core.json
+++ b/app/locales/eo/core.json
@@ -248,6 +248,7 @@
"fileTags": "Etikedoj",
"fileSize": "Grando",
"fileLDTM": "Dato modifita",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Vojo",
"fileName": "Nomo de dosiero",
diff --git a/app/locales/es/core.json b/app/locales/es/core.json
index 11cc3d348..b102063a9 100644
--- a/app/locales/es/core.json
+++ b/app/locales/es/core.json
@@ -248,6 +248,7 @@
"fileTags": "Etiquetas",
"fileSize": "Tamaño",
"fileLDTM": "Modificado",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Ruta",
"fileName": "Nombre del archivo",
diff --git a/app/locales/fa/core.json b/app/locales/fa/core.json
index 271d9379c..56f27d621 100644
--- a/app/locales/fa/core.json
+++ b/app/locales/fa/core.json
@@ -248,6 +248,7 @@
"fileTags": "تگ ها",
"fileSize": "Size",
"fileLDTM": "Date Modified",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Path",
"fileName": "File Name",
diff --git a/app/locales/fr/core.json b/app/locales/fr/core.json
index 478722067..7a9c17230 100644
--- a/app/locales/fr/core.json
+++ b/app/locales/fr/core.json
@@ -248,6 +248,7 @@
"fileTags": "Étiquettes",
"fileSize": "Taille",
"fileLDTM": "Date de modification",
+ "random": "Random",
"fileDirectory": "Dossier",
"filePath": "Chemin",
"fileName": "Nom du fichier",
diff --git a/app/locales/hu/core.json b/app/locales/hu/core.json
index 9a53d1add..7c93a8009 100644
--- a/app/locales/hu/core.json
+++ b/app/locales/hu/core.json
@@ -248,6 +248,7 @@
"fileTags": "Címkék",
"fileSize": "Méret",
"fileLDTM": "Módosítás dátuma",
+ "random": "Random",
"fileDirectory": "Könyvtár",
"filePath": "Elérési út",
"fileName": "Fájlneve",
diff --git a/app/locales/hy/core.json b/app/locales/hy/core.json
index 07efc6a83..c62d3571c 100644
--- a/app/locales/hy/core.json
+++ b/app/locales/hy/core.json
@@ -248,6 +248,7 @@
"fileTags": "Պիտակներ",
"fileSize": "Չափ",
"fileLDTM": "Փոփոխության ժամանակ",
+ "random": "Random",
"fileDirectory": "Պանակ",
"filePath": "Ուղի",
"fileName": "Նիշքի անունը",
diff --git a/app/locales/id_ID/core.json b/app/locales/id_ID/core.json
index f0aa1f0bd..5bd2f6271 100644
--- a/app/locales/id_ID/core.json
+++ b/app/locales/id_ID/core.json
@@ -248,6 +248,7 @@
"fileTags": "Tag",
"fileSize": "Ukuran",
"fileLDTM": "Tanggal Modifikasi",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Lokasi",
"fileName": "Nama File",
diff --git a/app/locales/it/core.json b/app/locales/it/core.json
index e4952633e..1218c1855 100644
--- a/app/locales/it/core.json
+++ b/app/locales/it/core.json
@@ -248,6 +248,7 @@
"fileTags": "Etichette",
"fileSize": "Dimensione",
"fileLDTM": "Data modifica",
+ "random": "Random",
"fileDirectory": "Cartella",
"filePath": "Percorso",
"fileName": "Nome file",
diff --git a/app/locales/ja/core.json b/app/locales/ja/core.json
index a684c7124..817c3aca7 100644
--- a/app/locales/ja/core.json
+++ b/app/locales/ja/core.json
@@ -248,6 +248,7 @@
"fileTags": "タグ",
"fileSize": "サイズ",
"fileLDTM": "更新日",
+ "random": "Random",
"fileDirectory": "ディレクトリ",
"filePath": "パス",
"fileName": "ファイル名",
diff --git a/app/locales/kk_KZ/core.json b/app/locales/kk_KZ/core.json
index 332af05c1..1ac077a4a 100644
--- a/app/locales/kk_KZ/core.json
+++ b/app/locales/kk_KZ/core.json
@@ -249,6 +249,7 @@
"fileTags": "Tags",
"fileSize": "Size",
"fileLDTM": "Date Modified",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Path",
"fileName": "File Name",
diff --git a/app/locales/ko/core.json b/app/locales/ko/core.json
index 494e19135..bcb8b9ce4 100644
--- a/app/locales/ko/core.json
+++ b/app/locales/ko/core.json
@@ -248,6 +248,7 @@
"fileTags": "태그",
"fileSize": "크기",
"fileLDTM": "수정일",
+ "random": "Random",
"fileDirectory": "디렉토리",
"filePath": "경로",
"fileName": "파일명",
diff --git a/app/locales/mt/core.json b/app/locales/mt/core.json
index a6cdb37d1..cc5627553 100644
--- a/app/locales/mt/core.json
+++ b/app/locales/mt/core.json
@@ -248,6 +248,7 @@
"fileTags": "Tikketti",
"fileSize": "Daqs",
"fileLDTM": "Data tal-Modifika",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Triq",
"fileName": "Isem il-Fajl",
diff --git a/app/locales/nl_NL/core.json b/app/locales/nl_NL/core.json
index fa9533dd1..403c5a503 100644
--- a/app/locales/nl_NL/core.json
+++ b/app/locales/nl_NL/core.json
@@ -248,6 +248,7 @@
"fileTags": "Tags",
"fileSize": "Grootte",
"fileLDTM": "Datum gewijzigd",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Pad",
"fileName": "Bestandsnaam",
diff --git a/app/locales/pl/core.json b/app/locales/pl/core.json
index 6d63531c8..05e0d319a 100644
--- a/app/locales/pl/core.json
+++ b/app/locales/pl/core.json
@@ -248,6 +248,7 @@
"fileTags": "Tagi",
"fileSize": "Rozmiar",
"fileLDTM": "Data modyfikacji",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Ścieżka",
"fileName": "Nazwa pliku",
diff --git a/app/locales/pt_BR/core.json b/app/locales/pt_BR/core.json
index c9b3f23aa..ebe10f7d2 100644
--- a/app/locales/pt_BR/core.json
+++ b/app/locales/pt_BR/core.json
@@ -248,6 +248,7 @@
"fileTags": "Etiquetas",
"fileSize": "Tamanho",
"fileLDTM": "Data de Modificação",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Caminho",
"fileName": "Nome do Arquivo",
diff --git a/app/locales/pt_PT/core.json b/app/locales/pt_PT/core.json
index 2a318c7ec..545be6314 100644
--- a/app/locales/pt_PT/core.json
+++ b/app/locales/pt_PT/core.json
@@ -248,6 +248,7 @@
"fileTags": "Etiquetas",
"fileSize": "Tamanho",
"fileLDTM": "Data de modificação",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Caminho",
"fileName": "Nome de ficheiro",
diff --git a/app/locales/ru/core.json b/app/locales/ru/core.json
index 4fcc7cdd2..dcdafc31d 100644
--- a/app/locales/ru/core.json
+++ b/app/locales/ru/core.json
@@ -248,6 +248,7 @@
"fileTags": "Теги",
"fileSize": "Размер",
"fileLDTM": "Изменен",
+ "random": "Random",
"fileDirectory": "Каталог",
"filePath": "Путь",
"fileName": "Имя файла",
diff --git a/app/locales/sk_SK/core.json b/app/locales/sk_SK/core.json
index b6f3063c0..be79b6a14 100644
--- a/app/locales/sk_SK/core.json
+++ b/app/locales/sk_SK/core.json
@@ -248,6 +248,7 @@
"fileTags": "Značky",
"fileSize": "Veľkosť",
"fileLDTM": "Dátum úpravy",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Cesta",
"fileName": "Názov súboru",
diff --git a/app/locales/sv/core.json b/app/locales/sv/core.json
index a529d6d49..b35bdd505 100644
--- a/app/locales/sv/core.json
+++ b/app/locales/sv/core.json
@@ -248,6 +248,7 @@
"fileTags": "Taggar",
"fileSize": "Storlek",
"fileLDTM": "Ändringsdatum",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Sökväg",
"fileName": "Filnamn",
diff --git a/app/locales/tr/core.json b/app/locales/tr/core.json
index 8994580b1..1a3945f7d 100644
--- a/app/locales/tr/core.json
+++ b/app/locales/tr/core.json
@@ -248,6 +248,7 @@
"fileTags": "Etiketler",
"fileSize": "Boyut",
"fileLDTM": "Değiştirilme Tarihi",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Dizin Yolu",
"fileName": "Dosya Adı",
diff --git a/app/locales/uk/core.json b/app/locales/uk/core.json
index 5aad5614b..9bdf32b4e 100644
--- a/app/locales/uk/core.json
+++ b/app/locales/uk/core.json
@@ -248,6 +248,7 @@
"fileTags": "Мітки",
"fileSize": "Розмір",
"fileLDTM": "Дата модифікації",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Шлях",
"fileName": "Назва файла",
diff --git a/app/locales/vi/core.json b/app/locales/vi/core.json
index ac59cf364..c3de83b24 100644
--- a/app/locales/vi/core.json
+++ b/app/locales/vi/core.json
@@ -248,6 +248,7 @@
"fileTags": "Đuôi",
"fileSize": "Kích cỡ",
"fileLDTM": "Đã Hiệu Chỉnh Ngày Tháng",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Đường Dẫn",
"fileName": "Tên Tập Tin",
diff --git a/app/locales/zh_CN/core.json b/app/locales/zh_CN/core.json
index 77d62d261..916acd12a 100644
--- a/app/locales/zh_CN/core.json
+++ b/app/locales/zh_CN/core.json
@@ -248,6 +248,7 @@
"fileTags": "标签",
"fileSize": "大小",
"fileLDTM": "修改日期",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "路径",
"fileName": "文件名",
diff --git a/app/locales/zh_HK/core.json b/app/locales/zh_HK/core.json
index ca1a8ff2b..970b7e3d8 100644
--- a/app/locales/zh_HK/core.json
+++ b/app/locales/zh_HK/core.json
@@ -248,6 +248,7 @@
"fileTags": "Tags",
"fileSize": "Size",
"fileLDTM": "Date Modified",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "Path",
"fileName": "File Name",
diff --git a/app/locales/zh_TW/core.json b/app/locales/zh_TW/core.json
index 4b080debf..baaaaf3de 100644
--- a/app/locales/zh_TW/core.json
+++ b/app/locales/zh_TW/core.json
@@ -248,6 +248,7 @@
"fileTags": "標籤",
"fileSize": "大小",
"fileLDTM": "修改日期",
+ "random": "Random",
"fileDirectory": "Directory",
"filePath": "路徑",
"fileName": "文件名稱",
diff --git a/app/perspectives/grid-perspective/src/index.js b/app/perspectives/grid-perspective/src/index.js
index 9ecad3187..4b8f24515 100644
--- a/app/perspectives/grid-perspective/src/index.js
+++ b/app/perspectives/grid-perspective/src/index.js
@@ -1099,6 +1099,17 @@ class GridPerspective extends React.Component<Props, State> {
</ListItemIcon>
<ListItemText inset primary={i18n.t('core:fileExtension')} />
</MenuItem>
+ <MenuItem
+ data-tid="gridPerspectiveSortRandom"
+ onClick={() => { this.handleSortBy('random'); }}
+ >
+ <ListItemIcon style={{ minWidth: 25 }}>
+ {(this.state.sortBy === 'random') && (
+ <ArrowDownIcon />
+ )}
+ </ListItemIcon>
+ <ListItemText inset primary={i18n.t('core:random')} />
+ </MenuItem>
</Menu>
<Menu
open={this.state.optionsContextMenuOpened}
diff --git a/app/utils/misc.js b/app/utils/misc.js
index 116cfd9c3..108e79886 100644
--- a/app/utils/misc.js
+++ b/app/utils/misc.js
@@ -371,6 +371,15 @@ export function sortByFirstTag(a, b) {
return a.tags[0].title.localeCompare(b.tags[0].title);
}
+export function shuffleArray(array) {
+ // Durstenfeld shuffle
+ for (let i = array.length - 1; i > 0; i--) {
+ const j = Math.floor(Math.random() * (i + 1));
+ [array[i], array[j]] = [array[j], array[i]];
+ }
+ return array;
+}
+
export function sortByCriteria(data, criteria, order) {
switch (criteria) {
case 'byName':
@@ -398,6 +407,8 @@ export function sortByCriteria(data, criteria, order) {
return data.sort(sortByFirstTag);
}
return data.sort((a, b) => -1 * sortByFirstTag(a, b));
+ case 'random':
+ return shuffleArray(data);
default:
return data.sort(sortByName);
}