Photos: Refactor link from the Files tab to the file folder #2926

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2023-06-13 15:57:02 +02:00
parent 9e316a2ec0
commit 53aeaffe0e
7 changed files with 37 additions and 14 deletions

View File

@@ -39,3 +39,13 @@
margin-left: -6px; margin-left: -6px;
margin-right: 6px; margin-right: 6px;
} }
#photoprism .v-btn.v-btn--depressed.v-btn--small .v-icon--right {
font-size: 16px;
margin-left: 8px;
}
#photoprism .v-btn.v-btn--depressed.v-btn--small .v-icon--left {
font-size: 16px;
margin-right: 8px;
}

View File

@@ -86,7 +86,7 @@
> >
</v-checkbox> </v-checkbox>
</v-flex> </v-flex>
<v-flex v-if="featExperimental && featPrivate" sm3 pa-2> <v-flex v-if="experimental && featPrivate" sm3 pa-2>
<v-checkbox <v-checkbox
v-model="model.Private" v-model="model.Private"
:disabled="disabled" :disabled="disabled"
@@ -134,8 +134,8 @@ export default {
}, },
data() { data() {
return { return {
featExperimental: this.$config.get("experimental") && !this.$config.ce(),
featPrivate: this.$config.feature("private"), featPrivate: this.$config.feature("private"),
experimental: this.$config.get("experimental") && !this.$config.ce(),
disabled: !this.$config.allow("albums", "manage"), disabled: !this.$config.allow("albums", "manage"),
model: new Album(), model: new Album(),
growDesc: false, growDesc: false,

View File

@@ -66,10 +66,11 @@
@click.stop.prevent="showDeleteDialog(file)"> @click.stop.prevent="showDeleteDialog(file)">
<translate>Delete</translate> <translate>Delete</translate>
</v-btn> </v-btn>
<v-btn v-if="file.Primary" small depressed dark color="primary-button" <v-btn v-if="experimental && file.Primary" small depressed dark color="primary-button"
class="btn-action action-open-folder" class="btn-action action-open-folder"
:href="getFolderUri(file)"> :href="folderUrl(file)" target="_blank">
<translate>Open folder</translate> <translate>Folder</translate>
<v-icon :right="!rtl" :left="rtl" dark size="20">open_in_new</v-icon>
</v-btn> </v-btn>
</td> </td>
</tr> </tr>
@@ -306,8 +307,10 @@ export default {
features: this.$config.settings().features, features: this.$config.settings().features,
config: this.$config.values, config: this.$config.values,
readonly: this.$config.get("readonly"), readonly: this.$config.get("readonly"),
experimental: this.$config.get("experimental"),
options: options, options: options,
busy: false, busy: false,
rtl: this.$rtl,
listColumns: [ listColumns: [
{ {
text: this.$gettext('Primary'), text: this.$gettext('Primary'),
@@ -356,11 +359,15 @@ export default {
openFile(file) { openFile(file) {
this.$viewer.show([Thumb.fromFile(this.model, file)], 0); this.$viewer.show([Thumb.fromFile(this.model, file)], 0);
}, },
getFolderUri(file) { folderUrl(m) {
const fileName = file.Name; if (!m) {
const folder = fileName.substring(0, fileName.lastIndexOf('/')); return '#';
}
return(this.config.baseUri + '/library/index/files/' + folder); const name = m.Name;
const path = name.substring(0, name.lastIndexOf('/'));
return this.$router.resolve({ path: '/index/files/' + path }).href;
}, },
downloadFile(file) { downloadFile(file) {
Notify.success(this.$gettext("Downloading…")); Notify.success(this.$gettext("Downloading…"));

View File

@@ -132,6 +132,7 @@ export class Folder extends RestModel {
if (!path || path[0] !== "/") { if (!path || path[0] !== "/") {
path = "/" + path; path = "/" + path;
} }
return this.search(RootOriginals + path, params); return this.search(RootOriginals + path, params);
} }
@@ -143,8 +144,12 @@ export class Folder extends RestModel {
if (!path || path[0] !== "/") { if (!path || path[0] !== "/") {
path = "/" + path; path = "/" + path;
} }
// Escape ":" in URL path.
path = path.replaceAll(":", "%3A");
return Api.get(this.getCollectionResource() + path, options).then((response) => { return Api.get(this.getCollectionResource() + path, options).then((response) => {
let folders = response.data.folders; let folders = response.data.folders ? response.data.folders : [];
let files = response.data.files ? response.data.files : []; let files = response.data.files ? response.data.files : [];
let count = folders.length + files.length; let count = folders.length + files.length;

View File

@@ -172,7 +172,7 @@
<v-icon color="white" class="select-off">star_border</v-icon> <v-icon color="white" class="select-off">star_border</v-icon>
</v-btn> </v-btn>
<v-btn v-if="canManage && featExperimental && featPrivate && album.Private" <v-btn v-if="canManage && experimental && featPrivate && album.Private"
:ripple="false" :ripple="false"
icon flat absolute icon flat absolute
class="input-private" class="input-private"
@@ -301,12 +301,12 @@ export default {
return { return {
searchExpanded: false, searchExpanded: false,
experimental: this.$config.get("experimental") && !this.$config.ce(),
canUpload: this.$config.allow("files", "upload") && features.upload, canUpload: this.$config.allow("files", "upload") && features.upload,
canShare: this.$config.allow("albums", "share") && features.share, canShare: this.$config.allow("albums", "share") && features.share,
canManage: this.$config.allow("albums", "manage"), canManage: this.$config.allow("albums", "manage"),
canEdit: this.$config.allow("albums", "update"), canEdit: this.$config.allow("albums", "update"),
config: this.$config.values, config: this.$config.values,
featExperimental: this.$config.get("experimental") && !this.$config.ce(),
featShare: features.share, featShare: features.share,
featPrivate: features.private, featPrivate: features.private,
categories: categories, categories: categories,

View File

@@ -172,6 +172,7 @@ export default {
this.lastFilter = {}; this.lastFilter = {};
this.routeName = this.$route.name; this.routeName = this.$route.name;
this.path = this.$route.params.pathMatch; this.path = this.$route.params.pathMatch;
this.search(); this.search();
} }
}, },

View File

@@ -22,7 +22,7 @@ func Path(s string) string {
} }
switch r { switch r {
case '~', '\\', ':', '|', '"', '?', '*', '<', '>', '{', '}': case '~', '\\', '|', '"', '?', '*', '<', '>', '{', '}':
return -1 return -1
default: default:
return r return r
@@ -38,7 +38,7 @@ func UserPath(dir string) string {
return dir return dir
} }
dir = strings.Trim(path.Clean(Path(strings.ReplaceAll(dir, "\\", "/"))), "./ \\*%#~?|<>:") dir = strings.Trim(path.Clean(Path(strings.ReplaceAll(dir, "\\", "/"))), "./ \\*%#~?|<>")
if strings.Contains(dir, "/.") || strings.Contains(dir, "..") || strings.Contains(dir, "//") { if strings.Contains(dir, "/.") || strings.Contains(dir, "..") || strings.Contains(dir, "//") {
return "" return ""