From db410a3cdc919eda8023598becfe036f7b3ffd61 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Sun, 17 Nov 2024 12:52:39 +1300 Subject: [PATCH] More prints info --- Dotnet/AppApi/AppApi.cs | 5 +-- html/src/app.js | 57 +++++++++++++++++++------ html/src/localization/en/en.json | 2 + html/src/mixins/dialogs/currentUser.pug | 14 ++++-- html/src/mixins/dialogs/userDialog.pug | 2 + html/src/mixins/tabs/settings.pug | 2 + 6 files changed, 61 insertions(+), 21 deletions(-) diff --git a/Dotnet/AppApi/AppApi.cs b/Dotnet/AppApi/AppApi.cs index 06e21df5..b0d603dd 100644 --- a/Dotnet/AppApi/AppApi.cs +++ b/Dotnet/AppApi/AppApi.cs @@ -577,9 +577,8 @@ public string GetFileBase64(string path) public async Task SavePrintToFile(string url, string fileName) { - var directory = Path.Combine(GetVRChatPhotosLocation(), "Prints"); - Directory.CreateDirectory(directory); - var path = Path.Combine(directory, fileName); + var path = Path.Combine(GetVRChatPhotosLocation(), fileName); + Directory.CreateDirectory(Path.GetDirectoryName(path)); if (File.Exists(path)) return false; diff --git a/html/src/app.js b/html/src/app.js index c85f3c85..4a7401e0 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -17450,31 +17450,52 @@ speechSynthesis.getVoices(); $app.methods.refreshPrintTable = function () { this.galleryDialogPrintsLoading = true; var params = { - n: 100, - tag: 'print' + n: 100 }; - API.getFileList(params); + API.getPrints(params); }; - API.$on('FILES:LIST', function (args) { - if (args.params.tag === 'print') { - $app.printTable = args.json.reverse(); - $app.galleryDialogPrintsLoading = false; - } - }); + API.getPrints = function (params) { + return this.call(`prints/user/${API.currentUser.id}`, { + method: 'GET', + params + }).then((json) => { + var args = { + json, + params + }; + this.$emit('PRINT:LIST', args); + return args; + }); + }; - $app.methods.deletePrint = function (fileId) { - API.deleteFile(fileId).then((args) => { - API.$emit('PRINT:DELETE', args); + API.deletePrint = function (printId) { + return this.call(`prints/${printId}`, { + method: 'DELETE' + }).then((json) => { + var args = { + json, + printId + }; + this.$emit('PRINT:DELETE', args); return args; }); }; + API.$on('PRINT:LIST', function (args) { + $app.printTable = args.json.reverse(); + $app.galleryDialogPrintsLoading = false; + }); + + $app.methods.deletePrint = function (printId) { + API.deletePrint(printId); + }; + API.$on('PRINT:DELETE', function (args) { var array = $app.printTable; var { length } = array; for (var i = 0; i < length; ++i) { - if (args.fileId === array[i].id) { + if (args.printId === array[i].id) { array.splice(i, 1); break; } @@ -17594,7 +17615,15 @@ speechSynthesis.getVoices(); console.error('Print image URL is missing', print); return; } - var fileName = `${printId}.png`; + var createdAt = new Date(print.json.createdAt); + var authorName = print.json.authorName; + // fileDate format: 2024-11-03_16-14-25.757 + var fileNameDate = createdAt + .toISOString() + .replace(/:/g, '-') + .replace(/T/g, '_') + .replace(/Z/g, ''); + var fileName = `Prints\\${createdAt.toISOString().slice(0, 7)}\\${authorName}_${fileNameDate}_${printId}.png`; var status = await AppApi.SavePrintToFile(imageUrl, fileName); if (status) { console.log(`Print saved to file: ${fileName}`); diff --git a/html/src/localization/en/en.json b/html/src/localization/en/en.json index 9ede2594..02d133bb 100644 --- a/html/src/localization/en/en.json +++ b/html/src/localization/en/en.json @@ -435,6 +435,7 @@ }, "save_instance_prints_to_file": { "header": "Save Instance Prints To File", + "header_tooltip": "Requires \"--enable-sdk-log-levels\" VRC launch option", "description": "Save spawned prints to your VRChat Pictures folder" }, "remote_database": { @@ -652,6 +653,7 @@ "sort_by": "Sort by:", "edit_mode": "Edit Mode", "exit_edit_mode": "Exit Edit Mode", + "hold_shift": "Hold shift to leave without confirmation", "own_groups": "Own Groups", "mutual_groups": "Mutual Groups", "groups": "Groups", diff --git a/html/src/mixins/dialogs/currentUser.pug b/html/src/mixins/dialogs/currentUser.pug index 02265d4d..e800ddb5 100644 --- a/html/src/mixins/dialogs/currentUser.pug +++ b/html/src/mixins/dialogs/currentUser.pug @@ -158,9 +158,15 @@ mixin currentUser() el-button(type="default" size="small" @click="refreshPrintTable" icon="el-icon-refresh") {{ $t('dialog.gallery_icons.refresh') }} //- el-button(type="default" size="small" @click="displayPrintUpload" icon="el-icon-upload2" :disabled="!API.currentUser.$isVRCPlus") {{ $t('dialog.gallery_icons.upload') }} br - .x-friend-item(v-if="image.versions && image.versions.length > 0" v-for="image in printTable" :key="image.id" style="display:inline-block;margin-top:10px;width:unset;cursor:default") - .vrcplus-icon(v-if="image.versions[image.versions.length - 1].file.url" style="overflow:hidden" @click="showFullscreenImageDialog(image.versions[image.versions.length - 1].file.url)") - img.avatar(v-lazy="image.versions[image.versions.length - 1].file.url") + .x-friend-item(v-for="image in printTable" :key="image.id" style="display:inline-block;margin-top:10px;width:unset;cursor:default") + .vrcplus-icon(style="overflow:hidden" @click="showFullscreenImageDialog(image.files.image)") + img.avatar(v-lazy="image.files.image") + div(style="margin-top:5px") + span(v-text="image.note") + br + location(v-if="image.worldId" :location="image.worldId" :hint="image.worldName") + br + display-name(v-if="image.authorId" :userid="image.authorId" :hint="image.authorName" style="color:#909399;font-family:monospace") div(style="float:right;margin-top:5px") - el-button(type="default" @click="showFullscreenImageDialog(image.versions[image.versions.length - 1].file.url)" size="mini" icon="el-icon-picture-outline" circle) + el-button(type="default" @click="showFullscreenImageDialog(image.files.image)" size="mini" icon="el-icon-picture-outline" circle) el-button(type="default" @click="deletePrint(image.id)" size="mini" icon="el-icon-delete" circle style="margin-left:5px") diff --git a/html/src/mixins/dialogs/userDialog.pug b/html/src/mixins/dialogs/userDialog.pug index a2a20ace..b4339398 100644 --- a/html/src/mixins/dialogs/userDialog.pug +++ b/html/src/mixins/dialogs/userDialog.pug @@ -298,6 +298,8 @@ mixin userDialog() el-tab-pane(:label="$t('dialog.user.groups.header')") el-button(type="default" :loading="userDialog.isGroupsLoading" @click="getUserGroups(userDialog.id)" size="mini" icon="el-icon-refresh" circle) span(style="margin-left:5px") {{ $t('dialog.user.groups.total_count', { count: userGroups.groups.length }) }} + template(v-if="userDialogGroupEditMode") + span(style="margin-left:10px;color:#909399;font-size:10px") {{ $t('dialog.user.groups.hold_shift') }} div(style="float:right") template(v-if="!userDialogGroupEditMode") span(style="margin-right:5px") {{ $t('dialog.user.groups.sort_by') }} diff --git a/html/src/mixins/tabs/settings.pug b/html/src/mixins/tabs/settings.pug index 4fcc907b..36c654ad 100644 --- a/html/src/mixins/tabs/settings.pug +++ b/html/src/mixins/tabs/settings.pug @@ -476,6 +476,8 @@ mixin settingsTab() span.name(style="min-width:300px") {{ $t('view.settings.advanced.advanced.local_world_persistence.description') }} el-switch(v-model="disableWorldDatabase" :active-value="false" :inactive-value="true" @change="saveVRCXWindowOption") span.sub-header {{ $t('view.settings.advanced.advanced.save_instance_prints_to_file.header') }} + el-tooltip(placement="top" style="margin-left:5px" :content="$t('view.settings.advanced.advanced.save_instance_prints_to_file.header_tooltip')") + i.el-icon-info div.options-container-item span.name(style="min-width:300px") {{ $t('view.settings.advanced.advanced.save_instance_prints_to_file.description') }} el-switch(v-model="saveInstancePrints" @change="saveVRCXWindowOption")