Skip to content

Commit ff11c0a

Browse files
Merge pull request #1 from SimplyTheBecks/64010.fm_changes
added search by directory, copy path functions and added validation o…
2 parents dd087f5 + e116b02 commit ff11c0a

File tree

17 files changed

+193
-10
lines changed

17 files changed

+193
-10
lines changed

src/components/blocks/Navbar.vue

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@
7979
</button>
8080
</div>
8181
</div>
82+
<div class="col-auto">
83+
<form v-on:submit.prevent="search">
84+
<div class="input-group">
85+
<input type="text" class="form-control" v-model="searchTerm" :placeholder="lang.placeholders.search">
86+
<div class="input-group-append">
87+
<button class="btn btn-outline-secondary" type="submit"><i class="fa fa-search"/></button>
88+
</div>
89+
<div class="input-group-append">
90+
<button class="btn btn-outline-secondary" @click="clearSearch()" type="button">{{lang.btn.clear}}</button>
91+
</div>
92+
</div>
93+
</form>
94+
</div>
8295
<div class="col-auto text-right">
8396
<div class="btn-group" role="group">
8497
<button type="button" class="btn btn-secondary"
@@ -194,6 +207,15 @@ export default {
194207
hiddenFiles() {
195208
return this.$store.state.fm.settings.hiddenFiles;
196209
},
210+
211+
searchTerm: {
212+
get() {
213+
return this.$store.state.fm.searchTerm;
214+
},
215+
set(value) {
216+
this.$store.dispatch('fm/searchTermUpdate', value);
217+
}
218+
},
197219
},
198220
methods: {
199221
/**
@@ -203,6 +225,18 @@ export default {
203225
this.$store.dispatch('fm/refreshAll');
204226
},
205227
228+
/**
229+
* Search
230+
*/
231+
search() {
232+
this.$store.dispatch('fm/search');
233+
},
234+
235+
clearSearch() {
236+
this.searchTerm = '';
237+
this.$store.dispatch('fm/refreshAll');
238+
},
239+
206240
/**
207241
* History back
208242
*/

src/components/blocks/mixins/contextMenuActions.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,13 @@ export default {
178178
show: true,
179179
});
180180
},
181+
182+
/**
183+
* Copy Path of the item
184+
* work only with https
185+
*/
186+
pathAction() {
187+
navigator.clipboard.writeText(this.selectedItems[0].path)
188+
},
181189
},
182190
};

src/components/blocks/mixins/contextMenuRules.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,13 @@ export default {
132132
propertiesRule() {
133133
return !this.multiSelect;
134134
},
135+
136+
/**
137+
* Path - menu item path - show or hide
138+
* @returns {boolean}
139+
*/
140+
pathRule() {
141+
return !this.multiSelect;
142+
},
135143
},
136144
};

src/components/manager/GridView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="fm-grid">
3-
<div class="d-flex align-content-start flex-wrap">
3+
<div class="d-flex align-content-start flex-wrap" v-on:mouseleave="unHold()">
44
<div v-if="!isRootPath" v-on:click="levelUp" class="fm-grid-item text-center" >
55
<div class="fm-item-icon">
66
<i class="fas fa-level-up-alt fa-5x pb-2"/>

src/components/manager/Manager.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default {
4141

4242
<style lang="scss">
4343
.fm-content {
44-
height: 100%;
44+
height: 80vh;
4545
padding-left: 1rem;
4646
4747
.fm-content-body {

src/components/manager/TableView.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
v-show="sortSettings.direction === 'up'"/>
1313
</template>
1414
</th>
15+
<th class="w-65" v-on:click="sortBy('dirname')">
16+
{{ lang.manager.table.dirname }}
17+
<template v-if="sortSettings.field === 'dirname'">
18+
<i class="fas fa-sort-amount-down"
19+
v-show="sortSettings.direction === 'down'"/>
20+
<i class="fas fa-sort-amount-up"
21+
v-show="sortSettings.direction === 'up'"/>
22+
</template>
23+
</th>
1524
<th class="w-10" v-on:click="sortBy('size')">
1625
{{ lang.manager.table.size }}
1726
<template v-if="sortSettings.field === 'size'">
@@ -41,39 +50,46 @@
4150
</th>
4251
</tr>
4352
</thead>
44-
<tbody>
53+
<tbody v-on:mouseleave="unHold()">
4554
<tr v-if="!isRootPath">
4655
<td colspan="4" class="fm-content-item" v-on:click="levelUp">
4756
<i class="fas fa-level-up-alt"/>
4857
</td>
4958
</tr>
5059
<tr v-for="(directory, index) in directories"
60+
v-on:mousedown="hold('directories', directory.path, $event)"
61+
v-on:mouseover="selectItemOnOver('directories', directory.path, $event)"
62+
v-on:mouseup="unHold()"
5163
v-bind:key="`d-${index}`"
5264
v-bind:class="{'table-info': checkSelect('directories', directory.path)}"
53-
v-on:click="selectItem('directories', directory.path, $event)"
5465
v-on:contextmenu.prevent="contextMenu(directory, $event)">
66+
5567
<td class="fm-content-item unselectable"
5668
v-bind:class="(acl && directory.acl === 0) ? 'text-hidden' : ''"
5769
v-on:dblclick="selectDirectory(directory.path)">
5870
<i class="far fa-folder"/> {{ directory.basename }}
5971
</td>
72+
<td>{{ directory.dirname }}</td>
6073
<td/>
6174
<td>{{ lang.manager.table.folder }}</td>
6275
<td>
6376
{{ timestampToDate(directory.timestamp) }}
6477
</td>
6578
</tr>
6679
<tr v-for="(file, index) in files"
80+
v-on:mousedown="hold('files', file.path, $event)"
81+
v-on:mouseover="selectItemOnOver('files', file.path, $event)"
82+
v-on:mouseup="unHold()"
6783
v-bind:key="`f-${index}`"
6884
v-bind:class="{'table-info': checkSelect('files', file.path)}"
69-
v-on:click="selectItem('files', file.path, $event)"
7085
v-on:dblclick="selectAction(file.path, file.extension)"
7186
v-on:contextmenu.prevent="contextMenu(file, $event)">
7287
<td class="fm-content-item unselectable"
7388
v-bind:class="(acl && file.acl === 0) ? 'text-hidden' : ''">
7489
<i class="far" v-bind:class="extensionToIcon(file.extension)"/>
7590
{{ file.filename ? file.filename : file.basename }}
7691
</td>
92+
<td>{{ file.dirname }}</td>
7793
<td>{{ bytesToHuman(file.size) }}</td>
7894
<td>
7995
{{ file.extension }}

src/components/manager/mixins/manager.js

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
import EventBus from '../../../eventBus';
33

44
export default {
5+
data(){
6+
return {
7+
isHold : false
8+
}
9+
},
510
computed: {
611
/**
712
* Selected disk for this manager
@@ -90,6 +95,38 @@ export default {
9095
return this.selected[type].includes(path);
9196
},
9297

98+
/**
99+
* Select or hold items in list
100+
* @param type
101+
* @param path
102+
* @param event
103+
*/
104+
hold(type, path, event) {
105+
if(event.button != 2 ){
106+
this.selectItem(type, path, event);
107+
this.isHold = true;
108+
}
109+
},
110+
111+
/**
112+
* unhold left button
113+
*/
114+
unHold() {
115+
this.isHold = false;
116+
},
117+
118+
/**
119+
* Select items in list (files + folders)
120+
* @param type
121+
* @param path
122+
* @param event
123+
*/
124+
selectItemOnOver(type, path, event) {
125+
if(this.isHold){
126+
this.selectItem(type, path, event);
127+
}
128+
},
129+
93130
/**
94131
* Select items in list (files + folders)
95132
* @param type
@@ -101,7 +138,7 @@ export default {
101138
const alreadySelected = this.selected[type].includes(path);
102139

103140
// if pressed Ctrl -> multi select
104-
if (event.ctrlKey || event.metaKey) {
141+
if ((event.ctrlKey || event.metaKey) || this.isHold) {
105142
if (!alreadySelected) {
106143
// add new selected item
107144
this.$store.commit(`fm/${this.manager}/setSelected`, { type, path });
@@ -112,7 +149,7 @@ export default {
112149
}
113150

114151
// single select
115-
if (!event.ctrlKey && !alreadySelected && !event.metaKey) {
152+
if (!event.ctrlKey && !event.metaKey && !this.isHold) {
116153
this.$store.commit(`fm/${this.manager}/changeSelected`, { type, path });
117154
}
118155
},

src/components/tree/FolderTree.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default {
3030
<style lang="scss">
3131
.fm-tree {
3232
overflow: auto;
33+
max-height: 80vh;
3334
border-right: 1px solid #6d757d;
3435
3536
& > .fm-folders-tree {

src/http/get.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ export default {
3838
return HTTP.get('content', { params: { disk, path } });
3939
},
4040

41+
/**
42+
* Search content (files and folders)
43+
* @param disk
44+
* @param term
45+
* @returns {*}
46+
*/
47+
search(disk, term) {
48+
return HTTP.get('search', { params: { disk, term } });
49+
},
50+
4151
/**
4252
* Item properties
4353
*/

src/lang/en.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const en = {
2626
hidden: ' Hidden files',
2727
deleteFile: 'Delete file',
2828
},
29+
placeholders:{
30+
search: 'Search'
31+
},
2932
clipboard: {
3033
actionType: 'Type',
3134
copy: 'Copy',
@@ -35,6 +38,7 @@ const en = {
3538
},
3639
contextMenu: {
3740
copy: 'Copy',
41+
path: 'Path',
3842
cut: 'Cut',
3943
delete: 'Delete',
4044
download: 'Download',
@@ -65,6 +69,7 @@ const en = {
6569
name: 'Name',
6670
size: 'Size',
6771
type: 'Type',
72+
dirname: 'Directory',
6873
},
6974
},
7075
modal: {

src/lang/ru.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ const ru = {
2626
hidden: 'Скрытые файлы',
2727
deleteFile: 'Удалить файл',
2828
},
29+
placeholders:{
30+
search: 'Поиск'
31+
},
2932
clipboard: {
3033
actionType: 'Тип операции',
3134
copy: 'Копировать',
@@ -35,6 +38,7 @@ const ru = {
3538
},
3639
contextMenu: {
3740
copy: 'Копировать',
41+
path: 'Путь',
3842
cut: 'Вырезать',
3943
delete: 'Удалить',
4044
download: 'Скачать',
@@ -65,6 +69,7 @@ const ru = {
6569
name: 'Имя',
6670
size: 'Размер',
6771
type: 'Тип',
72+
dirname: 'Директория',
6873
},
6974
},
7075
modal: {

src/store/actions.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,28 @@ export default {
485485
return dispatch('refreshManagers');
486486
},
487487

488+
/**
489+
* @param state
490+
* @param commit
491+
* @param dispatch
492+
* @returns {*}
493+
*/
494+
search({ state, commit, dispatch }) {
495+
commit('left/setSelectedDirectory', null);
496+
// only left manager
497+
return dispatch('left/refreshDirectory', state.searchTerm);
498+
},
499+
500+
/**
501+
* Update search term
502+
* @param commit
503+
* @param term
504+
* @returns {*}
505+
*/
506+
searchTermUpdate({ commit }, term) {
507+
return commit('setSearchTerm', term);
508+
},
509+
488510
/**
489511
* Repeat sorting
490512
* @param state

src/store/manager/actions.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ export default {
3939
},
4040

4141
/**
42-
* Refresh content in the selected directory
42+
* Refresh content in the selected directory or search by term
4343
* @param state
4444
* @param commit
4545
* @param dispatch
46+
* @param term - search ter,
4647
*/
47-
refreshDirectory({ state, commit, dispatch }) {
48-
GET.content(state.selectedDisk, state.selectedDirectory).then((response) => {
48+
refreshDirectory({ state, commit, dispatch }, term = null) {
49+
let method = term == null ? 'content' : 'search'
50+
GET[method](state.selectedDisk, term ? term : state.selectedDirectory).then((response) => {
4951
commit('resetSelected');
5052
commit('resetSortSettings');
5153
commit('resetHistory');
@@ -112,6 +114,9 @@ export default {
112114
case 'name':
113115
commit('sortByName');
114116
break;
117+
case 'dirname':
118+
commit('sortByDirname');
119+
break;
115120
case 'size':
116121
commit('sortBySize');
117122
break;

src/store/manager/mutations.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,20 @@ export default {
188188
}
189189
},
190190

191+
/**
192+
* Sort table by directory
193+
* @param state
194+
*/
195+
sortByDirname(state) {
196+
if (state.sort.direction === 'up') {
197+
state.directories.sort((a, b) => a.dirname.localeCompare(b.dirname));
198+
state.files.sort((a, b) => a.dirname.localeCompare(b.dirname));
199+
} else {
200+
state.directories.sort((a, b) => b.dirname.localeCompare(a.dirname));
201+
state.files.sort((a, b) => b.dirname.localeCompare(a.dirname));
202+
}
203+
},
204+
191205
/**
192206
* Sort by file size
193207
* @param state

0 commit comments

Comments
 (0)