2022-10-25 04:30:43 +00:00
|
|
|
<template>
|
2022-10-28 19:08:34 +00:00
|
|
|
<NcContent app-name="memories">
|
|
|
|
<NcAppContent>
|
|
|
|
<div class="outer fill-block" :class="{ show }">
|
|
|
|
<div class="title">
|
|
|
|
<img :src="banner" />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="text">
|
|
|
|
{{ t("memories", "A better photos experience awaits you") }} <br />
|
|
|
|
{{
|
|
|
|
t("memories", "Choose the root folder of your timeline to begin")
|
|
|
|
}}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="admin-text" v-if="isAdmin">
|
|
|
|
{{ t("memories", "If you just installed Memories, run:") }}
|
|
|
|
<br />
|
|
|
|
<code>occ memories:index</code>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="error" v-if="error">
|
|
|
|
{{ error }}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="info" v-if="info">
|
|
|
|
{{ info }} <br />
|
|
|
|
|
|
|
|
<NcButton @click="finish" class="button" type="primary">
|
|
|
|
{{ t("memories", "Continue to Memories") }}
|
|
|
|
</NcButton>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<NcButton @click="begin" class="button" v-if="info">
|
|
|
|
{{ t("memories", "Choose again") }}
|
|
|
|
</NcButton>
|
|
|
|
<NcButton @click="begin" class="button" type="primary" v-else>
|
|
|
|
{{ t("memories", "Click here to start") }}
|
|
|
|
</NcButton>
|
|
|
|
|
|
|
|
<div class="footer">
|
|
|
|
{{ t("memories", "You can always change this later in settings") }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</NcAppContent>
|
|
|
|
</NcContent>
|
2022-10-25 04:30:43 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2022-10-28 19:08:34 +00:00
|
|
|
import { Component, Mixins } from "vue-property-decorator";
|
2022-11-24 19:54:29 +00:00
|
|
|
|
|
|
|
import NcContent from "@nextcloud/vue/dist/Components/NcContent";
|
|
|
|
import NcAppContent from "@nextcloud/vue/dist/Components/NcAppContent";
|
|
|
|
import NcButton from "@nextcloud/vue/dist/Components/NcButton";
|
|
|
|
|
2022-10-28 19:08:34 +00:00
|
|
|
import { getFilePickerBuilder } from "@nextcloud/dialogs";
|
|
|
|
import { getCurrentUser } from "@nextcloud/auth";
|
|
|
|
import axios from "@nextcloud/axios";
|
2022-10-25 04:30:43 +00:00
|
|
|
|
2022-10-28 19:08:34 +00:00
|
|
|
import GlobalMixin from "../mixins/GlobalMixin";
|
|
|
|
import UserConfig from "../mixins/UserConfig";
|
2022-10-25 04:30:43 +00:00
|
|
|
|
|
|
|
import banner from "../assets/banner.svg";
|
2022-10-28 19:08:34 +00:00
|
|
|
import { IDay } from "../types";
|
2022-12-03 07:10:40 +00:00
|
|
|
import { API } from "../services/API";
|
2022-10-25 04:30:43 +00:00
|
|
|
|
|
|
|
@Component({
|
2022-10-28 19:08:34 +00:00
|
|
|
components: {
|
|
|
|
NcContent,
|
|
|
|
NcAppContent,
|
|
|
|
NcButton,
|
|
|
|
},
|
2022-10-25 04:30:43 +00:00
|
|
|
})
|
|
|
|
export default class FirstStart extends Mixins(GlobalMixin, UserConfig) {
|
2022-10-28 19:08:34 +00:00
|
|
|
banner = banner;
|
|
|
|
error = "";
|
|
|
|
info = "";
|
|
|
|
show = false;
|
|
|
|
chosenPath = "";
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
window.setTimeout(() => {
|
|
|
|
this.show = true;
|
|
|
|
}, 300);
|
|
|
|
}
|
|
|
|
|
|
|
|
get isAdmin() {
|
|
|
|
return getCurrentUser().isAdmin;
|
|
|
|
}
|
|
|
|
|
|
|
|
async begin() {
|
|
|
|
const path = await this.chooseFolder(
|
|
|
|
this.t("memories", "Choose the root of your timeline"),
|
|
|
|
"/"
|
|
|
|
);
|
|
|
|
|
|
|
|
// Get folder days
|
|
|
|
this.error = "";
|
|
|
|
this.info = "";
|
|
|
|
const query = new URLSearchParams();
|
|
|
|
query.set("timelinePath", path);
|
2022-12-03 07:10:40 +00:00
|
|
|
let url = API.Q(API.DAYS(), query);
|
2022-10-28 19:08:34 +00:00
|
|
|
const res = await axios.get<IDay[]>(url);
|
|
|
|
|
|
|
|
// Check response
|
|
|
|
if (res.status !== 200) {
|
|
|
|
this.error = this.t(
|
|
|
|
"memories",
|
|
|
|
"The selected folder does not seem to be valid. Try again."
|
|
|
|
);
|
|
|
|
return;
|
2022-10-25 04:30:43 +00:00
|
|
|
}
|
|
|
|
|
2022-10-28 19:08:34 +00:00
|
|
|
// Count total photos
|
2022-11-25 14:55:46 +00:00
|
|
|
const n = res.data.reduce((acc, day) => acc + day.count, 0);
|
|
|
|
this.info = this.n(
|
|
|
|
"memories",
|
|
|
|
"Found {n} item in {path}",
|
|
|
|
"Found {n} items in {path}",
|
|
|
|
n,
|
|
|
|
{
|
|
|
|
n,
|
|
|
|
path,
|
|
|
|
}
|
|
|
|
);
|
2022-10-28 19:08:34 +00:00
|
|
|
this.chosenPath = path;
|
|
|
|
}
|
|
|
|
|
|
|
|
async finish() {
|
|
|
|
this.show = false;
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
|
|
this.config_timelinePath = this.chosenPath;
|
|
|
|
await this.updateSetting("timelinePath");
|
|
|
|
}
|
|
|
|
|
|
|
|
async chooseFolder(title: string, initial: string) {
|
|
|
|
const picker = getFilePickerBuilder(title)
|
|
|
|
.setMultiSelect(false)
|
|
|
|
.setModal(true)
|
|
|
|
.setType(1)
|
|
|
|
.addMimeTypeFilter("httpd/unix-directory")
|
|
|
|
.allowDirectories()
|
|
|
|
.startAt(initial)
|
|
|
|
.build();
|
|
|
|
|
|
|
|
return await picker.pick();
|
|
|
|
}
|
2022-10-25 04:30:43 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.outer {
|
2022-10-28 19:08:34 +00:00
|
|
|
padding: 20px;
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
transition: opacity 1s ease;
|
|
|
|
opacity: 0;
|
|
|
|
&.show {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
.title {
|
|
|
|
font-size: 2.8em;
|
|
|
|
line-height: 1.1em;
|
|
|
|
font-family: cursive;
|
|
|
|
font-weight: 500;
|
|
|
|
margin-top: 10px;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
width: 100%;
|
|
|
|
filter: var(--background-invert-if-dark);
|
|
|
|
|
|
|
|
> img {
|
|
|
|
max-width: calc(100vw - 40px);
|
2022-10-25 04:30:43 +00:00
|
|
|
}
|
2022-10-28 19:08:34 +00:00
|
|
|
}
|
2022-10-25 04:30:43 +00:00
|
|
|
|
2022-10-28 19:08:34 +00:00
|
|
|
.admin-text {
|
|
|
|
margin-top: 10px;
|
|
|
|
}
|
2022-10-25 04:30:43 +00:00
|
|
|
|
2022-10-28 19:08:34 +00:00
|
|
|
.error {
|
|
|
|
color: red;
|
|
|
|
}
|
2022-10-25 04:30:43 +00:00
|
|
|
|
2022-10-28 19:08:34 +00:00
|
|
|
.info {
|
|
|
|
margin-top: 10px;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
2022-10-25 04:30:43 +00:00
|
|
|
|
2022-10-28 19:08:34 +00:00
|
|
|
.button {
|
|
|
|
display: inline-block;
|
|
|
|
margin: 15px;
|
|
|
|
}
|
2022-10-25 04:30:43 +00:00
|
|
|
|
2022-10-28 19:08:34 +00:00
|
|
|
.footer {
|
|
|
|
font-size: 0.8em;
|
|
|
|
}
|
2022-10-25 04:30:43 +00:00
|
|
|
}
|
|
|
|
</style>
|