既定のアップロード先フォルダを設定できるように

This commit is contained in:
syuilo 2019-07-08 04:17:53 +09:00
parent 5c2ed9e5d3
commit 841c8d619f
7 changed files with 74 additions and 7 deletions

View file

@ -958,7 +958,7 @@ desktop/views/components/drive.file.vue:
unmark-as-sensitive: "閲覧注意を解除" unmark-as-sensitive: "閲覧注意を解除"
copy-url: "URLをコピー" copy-url: "URLをコピー"
download: "ダウンロード" download: "ダウンロード"
else-files: "その他..." else-files: "その他"
set-as-avatar: "アイコンに設定" set-as-avatar: "アイコンに設定"
set-as-banner: "バナーに設定" set-as-banner: "バナーに設定"
open-in-app: "アプリで開く" open-in-app: "アプリで開く"
@ -969,6 +969,7 @@ desktop/views/components/drive.file.vue:
copied-url-to-clipboard: "URLをクリップボードにコピーしました" copied-url-to-clipboard: "URLをクリップボードにコピーしました"
desktop/views/components/drive.folder.vue: desktop/views/components/drive.folder.vue:
upload-folder: "既定アップロード先"
unable-to-process: "操作を完了できません" unable-to-process: "操作を完了できません"
circular-reference-detected: "移動先のフォルダーは、移動するフォルダーのサブフォルダーです。" circular-reference-detected: "移動先のフォルダーは、移動するフォルダーのサブフォルダーです。"
unhandled-error: "不明なエラー" unhandled-error: "不明なエラー"
@ -980,6 +981,8 @@ desktop/views/components/drive.folder.vue:
rename: "名前を変更" rename: "名前を変更"
rename-folder: "フォルダ名の変更" rename-folder: "フォルダ名の変更"
input-new-folder-name: "新しいフォルダ名を入力してください" input-new-folder-name: "新しいフォルダ名を入力してください"
else-folders: "その他"
set-as-upload-folder: "既定アップロード先に設定"
desktop/views/components/drive.vue: desktop/views/components/drive.vue:
search: "検索" search: "検索"
@ -1143,6 +1146,9 @@ common/views/components/drive-settings.vue:
max: "容量" max: "容量"
in-use: "使用中" in-use: "使用中"
stats: "統計" stats: "統計"
default-upload-folder: "既定のアップロード先フォルダ"
default-upload-folder-name: "フォルダ"
change-default-upload-folder: "フォルダを変更"
common/views/components/mute-and-block.vue: common/views/components/mute-and-block.vue:
mute-and-block: "ミュートとブロック" mute-and-block: "ミュートとブロック"

View file

@ -245,7 +245,7 @@ export default (opts) => ({
}, },
upload(file) { upload(file) {
(this.$refs.uploader as any).upload(file); (this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder);
}, },
onChangeUploadings(uploads) { onChangeUploadings(uploads) {

View file

@ -158,7 +158,7 @@ export default Vue.extend({
}, },
upload(file) { upload(file) {
(this.$refs.uploader as any).upload(file); (this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder);
}, },
onUploaded(file) { onUploaded(file) {

View file

@ -11,6 +11,12 @@
<header>{{ $t('stats') }}</header> <header>{{ $t('stats') }}</header>
<div ref="chart" style="margin-bottom: -16px; margin-left: -8px; color: #000;"></div> <div ref="chart" style="margin-bottom: -16px; margin-left: -8px; color: #000;"></div>
</section> </section>
<section>
<header>{{ $t('default-upload-folder') }}</header>
<ui-input v-model="uploadFolderName" readonly>{{ $t('default-upload-folder-name') }}</ui-input>
<ui-button @click="chooseUploadFolder()">{{ $t('change-default-upload-folder') }}</ui-button>
</section>
</ui-card> </ui-card>
</template> </template>
@ -26,7 +32,8 @@ export default Vue.extend({
return { return {
fetching: true, fetching: true,
usage: null, usage: null,
capacity: null capacity: null,
uploadFolderName: null
}; };
}, },
@ -40,10 +47,25 @@ export default Vue.extend({
l: 0.5 l: 0.5
}) })
}; };
} },
uploadFolder: {
get() { return this.$store.state.settings.uploadFolder; },
set(value) { this.$store.dispatch('settings/set', { key: 'uploadFolder', value }); }
},
}, },
mounted() { mounted() {
if (this.uploadFolder == null) {
this.uploadFolderName = this.$t('@._settings.root');
} else {
this.$root.api('drive/folders/show', {
folderId: this.uploadFolder
}).then(folder => {
this.uploadFolderName = folder.name;
});
}
this.$root.api('drive').then(info => { this.$root.api('drive').then(info => {
this.capacity = info.capacity; this.capacity = info.capacity;
this.usage = info.usage; this.usage = info.usage;
@ -152,6 +174,13 @@ export default Vue.extend({
chart.render(); chart.render();
}); });
},
chooseUploadFolder() {
this.$chooseDriveFolder().then(folder => {
this.uploadFolder = folder ? folder.id : null;
this.uploadFolderName = folder ? folder.name : this.$t('@._settings.root');
})
} }
} }
}); });

View file

@ -122,7 +122,7 @@ export default define({
}, },
upload(file) { upload(file) {
(this.$refs.uploader as any).upload(file); (this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder);
}, },
onDragover(e) { onDragover(e) {

View file

@ -20,6 +20,9 @@
<template v-if="!hover"><fa :icon="['far', 'folder']" fixed-width/></template> <template v-if="!hover"><fa :icon="['far', 'folder']" fixed-width/></template>
{{ folder.name }} {{ folder.name }}
</p> </p>
<p class="upload" v-if="$store.state.settings.uploadFolder == folder.id">
{{ $t('upload-folder') }}
</p>
</div> </div>
</template> </template>
@ -73,6 +76,14 @@ export default Vue.extend({
text: this.$t('@.delete'), text: this.$t('@.delete'),
icon: ['far', 'trash-alt'], icon: ['far', 'trash-alt'],
action: this.deleteFolder action: this.deleteFolder
}, null, {
type: 'nest',
text: this.$t('contextmenu.else-folders'),
menu: [{
type: 'item',
text: this.$t('contextmenu.set-as-upload-folder'),
action: this.setAsUploadFolder
}]
}], { }], {
closed: () => { closed: () => {
this.isContextmenuShowing = false; this.isContextmenuShowing = false;
@ -213,6 +224,13 @@ export default Vue.extend({
deleteFolder() { deleteFolder() {
this.$root.api('drive/folders/delete', { this.$root.api('drive/folders/delete', {
folderId: this.folder.id folderId: this.folder.id
}).then(() => {
if (this.$store.state.settings.uploadFolder === this.folder.id) {
this.$store.dispatch('settings/set', {
key: 'uploadFolder',
value: null
});
}
}).catch(err => { }).catch(err => {
switch(err.id) { switch(err.id) {
case 'b0fc8a17-963c-405d-bfbc-859a487295e1': case 'b0fc8a17-963c-405d-bfbc-859a487295e1':
@ -229,7 +247,14 @@ export default Vue.extend({
}); });
} }
}); });
} },
setAsUploadFolder() {
this.$store.dispatch('settings/set', {
key: 'uploadFolder',
value: this.folder.id
});
},
} }
}); });
</script> </script>
@ -279,4 +304,10 @@ export default Vue.extend({
margin-left 2px margin-left 2px
text-align left text-align left
> .upload
margin 4px 4px
font-size 0.8em
text-align right
color var(--desktopDriveFolderFg)
</style> </style>

View file

@ -38,6 +38,7 @@ const defaultSettings = {
homeProfiles: {}, homeProfiles: {},
mobileHomeProfiles: {}, mobileHomeProfiles: {},
deckProfiles: {}, deckProfiles: {},
uploadFolder: null,
}; };
const defaultDeviceSettings = { const defaultDeviceSettings = {