2019-12-05 02:13:42 +00:00
|
|
|
import "core-js/stable";
|
|
|
|
import "regenerator-runtime/runtime";
|
2019-05-09 04:48:10 +00:00
|
|
|
import Api from "common/api";
|
2019-11-16 22:55:56 +00:00
|
|
|
import Notify from "common/notify";
|
2019-05-09 04:48:10 +00:00
|
|
|
import Config from "common/config";
|
2019-05-21 09:54:39 +00:00
|
|
|
import Clipboard from "common/clipboard";
|
2019-05-28 00:50:22 +00:00
|
|
|
import Components from "component/components";
|
2019-06-30 00:52:12 +00:00
|
|
|
import Dialogs from "dialog/dialogs";
|
2019-11-16 21:41:14 +00:00
|
|
|
import Event from "pubsub-js";
|
|
|
|
import GetTextPlugin from "vue-gettext";
|
2019-12-02 01:43:41 +00:00
|
|
|
import Log from "common/log";
|
2019-11-16 21:41:14 +00:00
|
|
|
import PhotoPrism from "photoprism.vue";
|
|
|
|
import Router from "vue-router";
|
|
|
|
import Routes from "routes";
|
2019-11-11 20:10:41 +00:00
|
|
|
import Session from "session";
|
2019-11-17 13:24:48 +00:00
|
|
|
import {Settings} from "luxon";
|
2019-11-16 21:41:14 +00:00
|
|
|
import Socket from "common/websocket";
|
|
|
|
import Viewer from "common/viewer";
|
|
|
|
import Vue from "vue";
|
|
|
|
import Vuetify from "vuetify";
|
2019-09-19 21:23:39 +00:00
|
|
|
import VueLuxon from "vue-luxon";
|
2019-06-09 02:37:02 +00:00
|
|
|
import VueFilters from "vue2-filters";
|
2019-11-16 21:41:14 +00:00
|
|
|
import VueFullscreen from "vue-fullscreen";
|
|
|
|
import VueInfiniteScroll from "vue-infinite-scroll";
|
2018-07-27 15:31:39 +00:00
|
|
|
|
2019-05-21 09:54:39 +00:00
|
|
|
// Initialize helpers
|
2019-11-17 05:21:43 +00:00
|
|
|
const config = new Config(window.localStorage, window.clientConfig);
|
2019-05-21 09:54:39 +00:00
|
|
|
const viewer = new Viewer();
|
|
|
|
const clipboard = new Clipboard(window.localStorage, "photo_clipboard");
|
2019-11-11 21:14:34 +00:00
|
|
|
const isPublic = config.getValue("public");
|
2018-07-27 15:31:39 +00:00
|
|
|
|
2019-05-21 09:54:39 +00:00
|
|
|
// Assign helpers to VueJS prototype
|
2018-07-27 15:31:39 +00:00
|
|
|
Vue.prototype.$event = Event;
|
2019-11-16 22:55:56 +00:00
|
|
|
Vue.prototype.$notify = Notify;
|
2019-05-21 09:54:39 +00:00
|
|
|
Vue.prototype.$viewer = viewer;
|
2019-11-11 20:10:41 +00:00
|
|
|
Vue.prototype.$session = Session;
|
2018-07-27 15:31:39 +00:00
|
|
|
Vue.prototype.$api = Api;
|
2019-12-02 01:43:41 +00:00
|
|
|
Vue.prototype.$log = Log;
|
2019-11-16 15:06:34 +00:00
|
|
|
Vue.prototype.$socket = Socket;
|
2018-09-13 08:23:06 +00:00
|
|
|
Vue.prototype.$config = config;
|
2019-05-21 09:54:39 +00:00
|
|
|
Vue.prototype.$clipboard = clipboard;
|
2018-07-27 15:31:39 +00:00
|
|
|
|
2019-05-07 00:05:01 +00:00
|
|
|
// Register Vuetify
|
2020-01-20 11:20:54 +00:00
|
|
|
Vue.use(Vuetify, {"theme": config.theme});
|
2018-09-06 21:58:16 +00:00
|
|
|
|
2019-12-02 18:03:41 +00:00
|
|
|
Vue.config.language = config.values.settings.language;
|
|
|
|
Settings.defaultLocale = config.values.settings.language;
|
2019-09-19 21:23:39 +00:00
|
|
|
|
2019-05-07 00:05:01 +00:00
|
|
|
// Register other VueJS plugins
|
2020-01-20 11:20:54 +00:00
|
|
|
Vue.use(GetTextPlugin, {
|
|
|
|
translations: config.translations,
|
|
|
|
silent: !config.values.debug,
|
|
|
|
defaultLanguage: Vue.config.language,
|
|
|
|
});
|
|
|
|
|
2019-09-19 21:23:39 +00:00
|
|
|
Vue.use(VueLuxon);
|
2019-06-09 02:37:02 +00:00
|
|
|
Vue.use(VueInfiniteScroll);
|
2018-09-25 07:45:06 +00:00
|
|
|
Vue.use(VueFullscreen);
|
2019-06-09 02:37:02 +00:00
|
|
|
Vue.use(VueFilters);
|
2019-05-07 00:05:01 +00:00
|
|
|
Vue.use(Components);
|
2019-06-30 00:52:12 +00:00
|
|
|
Vue.use(Dialogs);
|
2018-07-27 15:31:39 +00:00
|
|
|
Vue.use(Router);
|
|
|
|
|
2019-05-07 00:05:01 +00:00
|
|
|
// Configure client-side routing
|
2018-07-27 15:31:39 +00:00
|
|
|
const router = new Router({
|
2019-05-19 16:58:30 +00:00
|
|
|
routes: Routes,
|
2019-05-09 04:48:10 +00:00
|
|
|
mode: "history",
|
2018-07-27 15:31:39 +00:00
|
|
|
saveScrollPosition: true,
|
|
|
|
});
|
|
|
|
|
2019-11-08 05:53:40 +00:00
|
|
|
router.beforeEach((to, from, next) => {
|
2019-11-17 13:24:48 +00:00
|
|
|
if (to.matched.some(record => record.meta.admin)) {
|
2019-11-11 21:14:34 +00:00
|
|
|
if (isPublic || Session.isAdmin()) {
|
2019-11-08 05:53:40 +00:00
|
|
|
next();
|
|
|
|
} else {
|
|
|
|
next({
|
|
|
|
name: "login",
|
2019-11-17 13:24:48 +00:00
|
|
|
params: {nextUrl: to.fullPath},
|
2019-11-08 05:53:40 +00:00
|
|
|
});
|
|
|
|
}
|
2019-11-17 13:24:48 +00:00
|
|
|
} else if (to.matched.some(record => record.meta.auth)) {
|
2019-11-11 21:14:34 +00:00
|
|
|
if (isPublic || Session.isUser()) {
|
2019-11-08 05:53:40 +00:00
|
|
|
next();
|
|
|
|
} else {
|
|
|
|
next({
|
|
|
|
name: "login",
|
2019-11-17 13:24:48 +00:00
|
|
|
params: {nextUrl: to.fullPath},
|
2019-11-08 05:53:40 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-01-20 11:20:54 +00:00
|
|
|
router.afterEach((to) => {
|
|
|
|
if (to.meta.title) {
|
|
|
|
config.page.title = to.meta.title;
|
|
|
|
window.document.title = "PhotoPrism: " + to.meta.title;
|
|
|
|
} else {
|
|
|
|
config.page.title = "";
|
|
|
|
window.document.title = "PhotoPrism";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-05-07 00:05:01 +00:00
|
|
|
// Run app
|
2019-11-17 13:24:48 +00:00
|
|
|
new Vue({
|
2018-07-27 15:31:39 +00:00
|
|
|
router,
|
2019-05-19 16:58:30 +00:00
|
|
|
render: h => h(PhotoPrism),
|
2019-11-17 13:24:48 +00:00
|
|
|
}).$mount("#photoprism");
|