Archive: Show number of archived pictures and improve "delete all" #272

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2023-09-03 15:44:00 +02:00
parent a59885cede
commit 386bf823d7
6 changed files with 52 additions and 18 deletions

View file

@ -327,6 +327,12 @@ export default class Config {
case "files":
this.values.count.files += data.count;
break;
case "hidden":
this.values.count.hidden += data.count;
break;
case "archived":
this.values.count.archived += data.count;
break;
case "favorites":
this.values.count.favorites += data.count;
break;

View file

@ -165,6 +165,8 @@
<v-list-tile-content>
<v-list-tile-title :class="`p-flex-menuitem menu-item ${rtl ? '--rtl' : ''}`">
<translate>Archive</translate>
<span v-show="config.count.archived > 0"
:class="`nav-count ${rtl ? '--rtl' : ''}`">{{ config.count.archived | abbreviateCount }}</span>
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
@ -539,7 +541,7 @@
</v-list-tile-content>
</v-list-tile>
<v-list-tile v-show="auth && !isPublic && $config.feature('account')" class="p-profile" @click.stop="onAccount">
<v-list-tile v-show="auth && !isPublic" class="p-profile" @click.stop="onAccountSettings">
<v-list-tile-avatar size="36">
<img :src="userAvatarURL" :alt="accountInfo" :title="accountInfo">
</v-list-tile-avatar>
@ -835,8 +837,12 @@ export default {
this.isMini = !this.isMini;
localStorage.setItem('last_navigation_mode', `${this.isMini}`);
},
onAccount: function () {
this.$router.push({name: "settings_account"});
onAccountSettings: function () {
if (this.$config.feature('account')) {
this.$router.push({name: "settings_account"});
} else {
this.$router.push({name: "settings"});
}
},
onInfo() {
if (this.isSponsor && this.config.legalUrl) {

View file

@ -33,9 +33,9 @@
<v-icon>view_column</v-icon>
</v-btn>
<v-btn v-if="canDelete && context === 'archive'" icon class="hidden-sm-and-down action-delete"
:title="$gettext('Delete')" @click.stop="deletePhotos()">
<v-icon>delete</v-icon>
<v-btn v-if="canDelete && context === 'archive' && config.count.archived > 0" icon class="hidden-sm-and-down action-sweep"
:title="$gettext('Delete')" @click.stop="sweepArchive()">
<v-icon>delete_sweep</v-icon>
</v-btn>
<v-btn v-else-if="canUpload" icon class="hidden-sm-and-down action-upload"
:title="$gettext('Upload')" @click.stop="showUpload()">
@ -175,8 +175,11 @@
</v-layout>
</v-card-text>
</v-card>
<p-photo-delete-dialog :show="dialog.delete" @cancel="dialog.delete = false"
@confirm="batchDelete"></p-photo-delete-dialog>
<p-photo-delete-dialog
:show="dialog.delete"
:text="$gettext('Are you sure you want to delete all archived pictures?')"
@cancel="dialog.delete = false" @confirm="batchDelete">
</p-photo-delete-dialog>
</v-form>
</template>
<script>
@ -296,7 +299,7 @@ export default {
showUpload() {
Event.publish("dialog.upload");
},
deletePhotos() {
sweepArchive() {
if (!this.canDelete) {
return;
}

View file

@ -1,5 +1,5 @@
<template>
<v-dialog :value="show" lazy persistent max-width="350" class="p-photo-delete-dialog" @keydown.esc="cancel">
<v-dialog :value="show" lazy persistent max-width="360" class="p-photo-delete-dialog" @keydown.esc="cancel">
<v-card raised elevation="24">
<v-container fluid class="pb-2 pr-2 pl-2">
<v-layout row wrap>
@ -7,9 +7,12 @@
<v-icon size="54" color="secondary-dark lighten-1">delete_outline</v-icon>
</v-flex>
<v-flex xs9 text-xs-left align-self-center>
<div class="subheading pr-1">
<div v-if="text === ''" class="subheading pr-1">
<translate>Are you sure you want to permanently delete these pictures?</translate>
</div>
<div v-else class="subheading pr-1">
{{ text }}
</div>
</v-flex>
<v-flex xs12 text-xs-right class="pt-3">
<v-btn depressed color="secondary-light" class="action-cancel" @click.stop="cancel">
@ -30,6 +33,10 @@ export default {
name: 'PPhotoDeleteDialog',
props: {
show: Boolean,
text: {
type: String,
default: "",
},
},
data() {
return {};

View file

@ -637,14 +637,16 @@ export default {
this.dirty = true;
this.complete = false;
if (this.context === "archive") break;
if (this.context !== "archive") {
for (let i = 0; i < data.entities.length; i++) {
const uid = data.entities[i];
for (let i = 0; i < data.entities.length; i++) {
const uid = data.entities[i];
this.removeResult(this.results, uid);
this.removeResult(this.viewer.results, uid);
this.$clipboard.removeId(uid);
this.removeResult(this.results, uid);
this.removeResult(this.viewer.results, uid);
this.$clipboard.removeId(uid);
}
} else if (!this.results.length) {
this.refresh();
}
break;

View file

@ -139,6 +139,7 @@ type ClientCounts struct {
Lenses int `json:"lenses"`
Countries int `json:"countries"`
Hidden int `json:"hidden"`
Archived int `json:"archived"`
Favorites int `json:"favorites"`
Review int `json:"review"`
Stories int `json:"stories"`
@ -542,6 +543,15 @@ func (c *Config) ClientUser(withSettings bool) ClientConfig {
Take(&cfg.Count)
}
// Get number of archived pictures.
if c.Settings().Features.Archive {
c.Db().
Table("photos").
Select("SUM(photo_quality > -1) AS archived").
Where("deleted_at IS NOT NULL").
Take(&cfg.Count)
}
// Calculate total count.
cfg.Count.All = cfg.Count.Photos + cfg.Count.Live + cfg.Count.Videos