Skip to content

Commit

Permalink
Improve settings page #288
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
  • Loading branch information
lastzero committed Apr 24, 2020
1 parent 6af6129 commit a57ca79
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 79 deletions.
61 changes: 37 additions & 24 deletions frontend/src/common/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ class Config {
title: "PhotoPrism",
};

this.$vuetify = null;

Event.subscribe("config.updated", (ev, data) => this.setValues(data));
Event.subscribe("count", (ev, data) => this.onCount(ev, data));

if(this.hasValue("settings")) {
if (this.hasValue("settings")) {
this.setTheme(this.getValue("settings").theme);
} else {
this.setTheme("default");
Expand All @@ -41,46 +43,57 @@ class Config {
}
}

if (values.settings) {
this.setTheme(values.settings.theme);
}

return this;
}

onCount(ev, data) {
const type = ev.split(".")[1];

switch (type) {
case "favorites":
this.values.count.favorites += data.count;
break;
case "albums":
this.values.count.albums += data.count;
break;
case "photos":
this.values.count.photos += data.count;
break;
case "countries":
this.values.count.countries += data.count;
break;
case "places":
this.values.count.places += data.count;
break;
case "labels":
this.values.count.labels += data.count;
break;
default:
console.warn("unknown count type", ev, data);
case "favorites":
this.values.count.favorites += data.count;
break;
case "albums":
this.values.count.albums += data.count;
break;
case "photos":
this.values.count.photos += data.count;
break;
case "countries":
this.values.count.countries += data.count;
break;
case "places":
this.values.count.places += data.count;
break;
case "labels":
this.values.count.labels += data.count;
break;
default:
console.warn("unknown count type", ev, data);
}

this.values.count;
}

updateSettings(settings, $vuetify) {
this.setValue("settings", settings);
this.setTheme(settings.theme);
$vuetify.theme = this.theme;

}

setVuetify(instance) {
this.$vuetify = instance;
}

setTheme(name) {
this.theme = themes[name] ? themes[name] : themes["default"];

if (this.$vuetify) {
this.$vuetify.theme = this.theme;
}

return this;
}

Expand Down
12 changes: 11 additions & 1 deletion frontend/src/component/p-navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,24 @@
</v-list-tile-content>
</v-list-tile>

<v-list-tile :to="{name: 'photos', query: { q: 'review:true' }}" :exact="true" @click="">
<v-list-tile :to="{name: 'photos', query: { q: 'review:true' }}" :exact="true" @click=""
v-if="config.settings.library.review">
<v-list-tile-content>
<v-list-tile-title>
<translate>Review</translate>
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>

<v-list-tile :to="{name: 'photos', query: { q: 'private:true' }}" :exact="true" @click=""
v-if="config.settings.library.private">
<v-list-tile-content>
<v-list-tile-title>
<translate>Private</translate>
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>

<v-list-tile to="/archive" @click="" class="p-navigation-archive" v-if="$config.feature('archive')">
<v-list-tile-content>
<v-list-tile-title>
Expand Down
23 changes: 12 additions & 11 deletions frontend/src/pages/library/originals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
<v-layout wrap align-top class="pb-3">
<v-flex xs12 sm6 lg4 class="px-2 pb-2 pt-2">
<v-checkbox
@change="onChange"
:disabled="busy"
class="ma-0 pa-0"
v-model="options.raw"
v-model="settings.library.raw"
color="secondary-dark"
:label="labels.raw"
hint="RAWs need to be converted to JPEG so that they can be displayed in a browser. You can also do this manually."
Expand All @@ -31,9 +32,10 @@

<v-flex xs12 sm6 lg4 class="px-2 pb-2 pt-2">
<v-checkbox
@change="onChange"
:disabled="busy"
class="ma-0 pa-0"
v-model="options.thumbs"
v-model="settings.library.thumbs"
color="secondary-dark"
:label="labels.thumbs"
hint="Pre-render thumbnails if not done already. On-demand rendering saves storage but requires a powerful CPU."
Expand All @@ -45,9 +47,10 @@

<v-flex xs12 sm6 lg4 class="px-2 pb-2 pt-2">
<v-checkbox
@change="onChange"
:disabled="busy"
class="ma-0 pa-0"
v-model="options.rescan"
v-model="settings.library.rescan"
color="secondary-dark"
:label="labels.rescan"
hint="Re-index all originals, including already indexed and unchanged files."
Expand Down Expand Up @@ -88,13 +91,13 @@
import Axios from "axios";
import Notify from "common/notify";
import Event from "pubsub-js";
import Settings from "../../model/settings";
export default {
name: 'p-tab-index',
data() {
let settings = this.$config.settings();
return {
settings: new Settings(this.$config.settings()),
readonly: this.$config.getValue("readonly"),
started: false,
busy: false,
Expand All @@ -103,11 +106,6 @@
action: "",
fileName: "",
source: null,
options: {
rescan: settings.library.rescan,
thumbs: settings.library.thumbs,
raw: settings.library.raw,
},
labels: {
rescan: this.$gettext("Complete rescan"),
thumbs: this.$gettext("Create thumbnails"),
Expand All @@ -116,6 +114,9 @@
}
},
methods: {
onChange() {
this.settings.save();
},
submit() {
// DO NOTHING
},
Expand All @@ -132,7 +133,7 @@
const ctx = this;
Notify.blockUI();
Api.post('index', this.options, {cancelToken: this.source.token}).then(function () {
Api.post('index', this.settings.library, {cancelToken: this.source.token}).then(function () {
Notify.unblockUI();
ctx.busy = false;
ctx.completed = 100;
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/pages/photos.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@
order: order,
q: q,
};
const settings = {view: view};
const settings = this.$config.settings();
if(settings.library.private) {
filter.public = true;
}
if(settings.library.review) {
filter.quality = 3;
}
return {
subscriptions: [],
Expand All @@ -96,7 +105,7 @@
offset: 0,
page: 0,
selection: this.$clipboard.selection,
settings: settings,
settings: {view: view},
filter: filter,
lastFilter: {},
routeName: routeName,
Expand Down

0 comments on commit a57ca79

Please sign in to comment.