WARNING: Change migrations to fit NC names
Okay, promise this is the last timepull/37/head
parent
b02185ed9e
commit
829487cac7
82339
js/memories-main.js
82339
js/memories-main.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -153,10 +153,10 @@ class ApiController extends Controller {
|
|||
|
||||
// Map sub to JSON array
|
||||
$subdirArray = [
|
||||
"day_id" => -0.1,
|
||||
"dayid" => -0.1,
|
||||
"detail" => array_map(function ($node) {
|
||||
return [
|
||||
"file_id" => $node->getId(),
|
||||
"fileid" => $node->getId(),
|
||||
"name" => $node->getName(),
|
||||
"is_folder" => 1,
|
||||
"path" => $node->getPath(),
|
||||
|
|
|
@ -20,7 +20,7 @@ class TimelineQuery {
|
|||
*/
|
||||
private function processDays(&$days) {
|
||||
foreach($days as &$row) {
|
||||
$row["day_id"] = intval($row["day_id"]);
|
||||
$row["dayid"] = intval($row["dayid"]);
|
||||
$row["count"] = intval($row["count"]);
|
||||
}
|
||||
return $days;
|
||||
|
@ -35,14 +35,14 @@ class TimelineQuery {
|
|||
IConfig &$config,
|
||||
string &$user,
|
||||
): array {
|
||||
$sql = 'SELECT day_id, COUNT(file_id) AS count
|
||||
$sql = 'SELECT `*PREFIX*memories`.`dayid`, COUNT(`*PREFIX*memories`.`fileid`) AS count
|
||||
FROM `*PREFIX*memories`
|
||||
INNER JOIN `*PREFIX*filecache`
|
||||
ON `*PREFIX*filecache`.`fileid` = `*PREFIX*memories`.`file_id`
|
||||
ON `*PREFIX*filecache`.`fileid` = `*PREFIX*memories`.`fileid`
|
||||
AND `*PREFIX*filecache`.`path` LIKE ?
|
||||
WHERE user_id=?
|
||||
GROUP BY day_id
|
||||
ORDER BY day_id DESC';
|
||||
WHERE uid=?
|
||||
GROUP BY `*PREFIX*memories`.`dayid`
|
||||
ORDER BY `*PREFIX*memories`.`dayid` DESC';
|
||||
|
||||
$path = "files" . Exif::getPhotosPath($config, $user) . "%";
|
||||
$rows = $this->connection->executeQuery($sql, [$path, $user], [
|
||||
|
@ -56,13 +56,13 @@ class TimelineQuery {
|
|||
* @param int $folderId
|
||||
*/
|
||||
public function getDaysFolder(int &$folderId) {
|
||||
$sql = 'SELECT day_id, COUNT(file_id) AS count
|
||||
$sql = 'SELECT `*PREFIX*memories`.`dayid`, COUNT(`*PREFIX*memories`.`fileid`) AS count
|
||||
FROM `*PREFIX*memories`
|
||||
INNER JOIN `*PREFIX*filecache`
|
||||
ON `*PREFIX*filecache`.`fileid` = `*PREFIX*memories`.`file_id`
|
||||
ON `*PREFIX*filecache`.`fileid` = `*PREFIX*memories`.`fileid`
|
||||
AND (`*PREFIX*filecache`.`parent`=? OR `*PREFIX*filecache`.`fileid`=?)
|
||||
GROUP BY day_id
|
||||
ORDER BY day_id DESC';
|
||||
GROUP BY dayid
|
||||
ORDER BY dayid DESC';
|
||||
$rows = $this->connection->executeQuery($sql, [$folderId, $folderId], [
|
||||
\PDO::PARAM_INT, \PDO::PARAM_INT,
|
||||
])->fetchAll();
|
||||
|
@ -75,10 +75,10 @@ class TimelineQuery {
|
|||
*/
|
||||
private function processDay(&$day) {
|
||||
foreach($day as &$row) {
|
||||
$row["file_id"] = intval($row["file_id"]);
|
||||
$row["is_video"] = intval($row["is_video"]);
|
||||
if (!$row["is_video"]) {
|
||||
unset($row["is_video"]);
|
||||
$row["fileid"] = intval($row["fileid"]);
|
||||
$row["isvideo"] = intval($row["isvideo"]);
|
||||
if (!$row["isvideo"]) {
|
||||
unset($row["isvideo"]);
|
||||
}
|
||||
}
|
||||
return $day;
|
||||
|
@ -95,13 +95,13 @@ class TimelineQuery {
|
|||
string &$user,
|
||||
int &$dayId,
|
||||
): array {
|
||||
$sql = 'SELECT file_id, *PREFIX*filecache.etag, is_video
|
||||
$sql = 'SELECT `*PREFIX*memories`.`fileid`, *PREFIX*filecache.etag, `*PREFIX*memories`.`isvideo`
|
||||
FROM *PREFIX*memories
|
||||
INNER JOIN *PREFIX*filecache
|
||||
ON *PREFIX*filecache.fileid = *PREFIX*memories.file_id
|
||||
ON `*PREFIX*filecache`.`fileid` = `*PREFIX*memories`.`fileid`
|
||||
AND `*PREFIX*filecache`.`path` LIKE ?
|
||||
WHERE user_id = ? AND day_id = ?
|
||||
ORDER BY date_taken DESC';
|
||||
WHERE `*PREFIX*memories`.`uid` = ? AND `*PREFIX*memories`.`dayid` = ?
|
||||
ORDER BY `*PREFIX*memories`.`datetaken` DESC';
|
||||
|
||||
$path = "files" . Exif::getPhotosPath($config, $user) . "%";
|
||||
$rows = $this->connection->executeQuery($sql, [$path, $user, $dayId], [
|
||||
|
@ -119,12 +119,12 @@ class TimelineQuery {
|
|||
int &$folderId,
|
||||
int &$dayId,
|
||||
): array {
|
||||
$sql = 'SELECT file_id, *PREFIX*filecache.etag, is_video
|
||||
$sql = 'SELECT `*PREFIX*memories`.`fileid`, `*PREFIX*filecache`.`etag`, `*PREFIX*memories`.`isvideo`
|
||||
FROM `*PREFIX*memories`
|
||||
INNER JOIN `*PREFIX*filecache`
|
||||
ON `*PREFIX*filecache`.`fileid` = `*PREFIX*memories`.`file_id`
|
||||
ON `*PREFIX*filecache`.`fileid` = `*PREFIX*memories`.`fileid`
|
||||
AND (`*PREFIX*filecache`.`parent`=? OR `*PREFIX*filecache`.`fileid`=?)
|
||||
WHERE `*PREFIX*memories`.`day_id`=?';
|
||||
WHERE `*PREFIX*memories`.`dayid`=?';
|
||||
$rows = $this->connection->executeQuery($sql, [$folderId, $folderId, $dayId], [
|
||||
\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_INT,
|
||||
])->fetchAll();
|
||||
|
|
|
@ -28,8 +28,8 @@ class TimelineWrite {
|
|||
// Check if we want to process this file
|
||||
$mime = $file->getMimeType();
|
||||
$is_image = in_array($mime, Application::IMAGE_MIMES);
|
||||
$is_video = in_array($mime, Application::VIDEO_MIMES);
|
||||
if (!$is_image && !$is_video) {
|
||||
$isvideo = in_array($mime, Application::VIDEO_MIMES);
|
||||
if (!$is_image && !$isvideo) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class TimelineWrite {
|
|||
// Check if need to update
|
||||
$sql = 'SELECT `mtime`
|
||||
FROM *PREFIX*memories
|
||||
WHERE file_id = ? AND user_id = ?';
|
||||
WHERE `fileid` = ? AND `uid` = ?';
|
||||
$prevRow = $this->connection->executeQuery($sql, [
|
||||
$fileId, $user,
|
||||
], [
|
||||
|
@ -65,10 +65,10 @@ class TimelineWrite {
|
|||
if ($prevRow) {
|
||||
// Update existing row
|
||||
$sql = 'UPDATE *PREFIX*memories
|
||||
SET day_id = ?, date_taken = ?, is_video = ?, mtime = ?
|
||||
WHERE user_id = ? AND file_id = ?';
|
||||
SET `dayid` = ?, `datetaken` = ?, `isvideo` = ?, `mtime` = ?
|
||||
WHERE `uid` = ? AND `fileid` = ?';
|
||||
$this->connection->executeStatement($sql, [
|
||||
$dayId, $dateTaken, $is_video, $mtime,
|
||||
$dayId, $dateTaken, $isvideo, $mtime,
|
||||
$user, $fileId,
|
||||
], [
|
||||
\PDO::PARAM_INT, \PDO::PARAM_STR, \PDO::PARAM_BOOL, \PDO::PARAM_INT,
|
||||
|
@ -77,10 +77,10 @@ class TimelineWrite {
|
|||
} else {
|
||||
// Create new row
|
||||
$sql = 'INSERT
|
||||
INTO *PREFIX*memories (day_id, date_taken, is_video, mtime, user_id, file_id)
|
||||
INTO *PREFIX*memories (`dayid`, `datetaken`, `isvideo`, `mtime`, `uid`, `fileid`)
|
||||
VALUES (?, ?, ?, ?, ?, ?)';
|
||||
$this->connection->executeStatement($sql, [
|
||||
$dayId, $dateTaken, $is_video, $mtime,
|
||||
$dayId, $dateTaken, $isvideo, $mtime,
|
||||
$user, $fileId,
|
||||
], [
|
||||
\PDO::PARAM_INT, \PDO::PARAM_STR, \PDO::PARAM_BOOL, \PDO::PARAM_INT,
|
||||
|
@ -96,7 +96,7 @@ class TimelineWrite {
|
|||
public function deleteFile(File &$file) {
|
||||
$sql = 'DELETE
|
||||
FROM *PREFIX*memories
|
||||
WHERE file_id = ?';
|
||||
WHERE `fileid` = ?';
|
||||
$this->connection->executeStatement($sql, [$file->getId()], [\PDO::PARAM_INT]);
|
||||
}
|
||||
}
|
|
@ -50,21 +50,21 @@ class Version000000Date20220812163631 extends SimpleMigrationStep {
|
|||
'autoincrement' => true,
|
||||
'notnull' => true,
|
||||
]);
|
||||
$table->addColumn('user_id', 'string', [
|
||||
$table->addColumn('uid', 'string', [
|
||||
'notnull' => true,
|
||||
'length' => 200,
|
||||
]);
|
||||
$table->addColumn('date_taken', Types::DATETIME, [
|
||||
$table->addColumn('datetaken', Types::DATETIME, [
|
||||
'notnull' => false,
|
||||
]);
|
||||
$table->addColumn('file_id', Types::BIGINT, [
|
||||
$table->addColumn('fileid', Types::BIGINT, [
|
||||
'notnull' => true,
|
||||
'length' => 20,
|
||||
]);
|
||||
$table->addColumn('day_id', Types::INTEGER, [
|
||||
$table->addColumn('dayid', Types::INTEGER, [
|
||||
'notnull' => true,
|
||||
]);
|
||||
$table->addColumn('is_video', Types::BOOLEAN, [
|
||||
$table->addColumn('isvideo', Types::BOOLEAN, [
|
||||
'notnull' => false,
|
||||
'default' => false
|
||||
]);
|
||||
|
@ -73,9 +73,9 @@ class Version000000Date20220812163631 extends SimpleMigrationStep {
|
|||
]);
|
||||
|
||||
$table->setPrimaryKey(['id']);
|
||||
$table->addIndex(['user_id'], 'memories_user_id_index');
|
||||
$table->addIndex(['user_id', 'day_id'], 'memories_ud_index');
|
||||
$table->addUniqueIndex(['user_id', 'file_id'], 'memories_day_uf_ui');
|
||||
$table->addIndex(['uid'], 'memories_uid_index');
|
||||
$table->addIndex(['uid', 'dayid'], 'memories_ud_index');
|
||||
$table->addUniqueIndex(['uid', 'fileid'], 'memories_day_uf_ui');
|
||||
}
|
||||
|
||||
if ($schema->hasTable('filecache')) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
hasPreview: previewFileInfos.length > 0,
|
||||
onePreview: previewFileInfos.length === 1,
|
||||
}"
|
||||
@click="openFolder(data.file_id)"
|
||||
@click="openFolder(data.fileid)"
|
||||
v-bind:style="{
|
||||
width: rowHeight + 'px',
|
||||
height: rowHeight + 'px',
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<template>
|
||||
<div>
|
||||
<div v-if="data.is_video" class="icon-video-white"></div>
|
||||
<div v-if="data.isvideo" class="icon-video-white"></div>
|
||||
<img
|
||||
@click="openFile()"
|
||||
:src="data.ph ? undefined : getPreviewUrl(data.file_id, data.etag)"
|
||||
:key="data.file_id"
|
||||
:src="data.ph ? undefined : getPreviewUrl(data.fileid, data.etag)"
|
||||
:key="data.fileid"
|
||||
@load = "data.l = Math.random()"
|
||||
@error="(e) => e.target.src='/apps/memories/img/error.svg'"
|
||||
v-bind:style="{
|
||||
|
@ -48,7 +48,7 @@ export default {
|
|||
// Check if already loaded fileInfos or load
|
||||
let fileInfos = this.day.fileInfos;
|
||||
if (!fileInfos) {
|
||||
const ids = this.day.detail.map(p => p.file_id);
|
||||
const ids = this.day.detail.map(p => p.fileid);
|
||||
try {
|
||||
this.loading = true;
|
||||
fileInfos = await dav.getFiles(ids);
|
||||
|
@ -73,7 +73,7 @@ export default {
|
|||
}
|
||||
|
||||
// Get this photo in the fileInfos
|
||||
const photo = fileInfos.find(d => Number(d.fileid) === Number(this.data.file_id));
|
||||
const photo = fileInfos.find(d => Number(d.fileid) === Number(this.data.fileid));
|
||||
if (!photo) {
|
||||
alert('Cannot find this photo anymore!');
|
||||
return;
|
||||
|
|
|
@ -344,7 +344,7 @@ export default {
|
|||
}
|
||||
|
||||
// Make date string
|
||||
const dateTaken = new Date(Number(day.day_id)*86400*1000);
|
||||
const dateTaken = new Date(Number(day.dayid)*86400*1000);
|
||||
let dateStr = dateTaken.toLocaleDateString("en-US", { dateStyle: 'full', timeZone: 'UTC' });
|
||||
if (dateTaken.getUTCFullYear() === new Date().getUTCFullYear()) {
|
||||
// hack: remove last 6 characters of date string
|
||||
|
@ -354,7 +354,7 @@ export default {
|
|||
// Create tick if month changed
|
||||
const dtYear = dateTaken.getUTCFullYear();
|
||||
const dtMonth = dateTaken.getUTCMonth()
|
||||
if (Number.isInteger(day.day_id) && (dtMonth !== prevMonth || dtYear !== prevYear)) {
|
||||
if (Number.isInteger(day.dayid) && (dtMonth !== prevMonth || dtYear !== prevYear)) {
|
||||
// Format dateTaken as MM YYYY
|
||||
const dateTimeFormat = new Intl.DateTimeFormat('en-US', { month: 'short' });
|
||||
const monthName = dateTimeFormat.formatToParts(dateTaken)[0].value;
|
||||
|
@ -373,7 +373,7 @@ export default {
|
|||
prevYear = dtYear;
|
||||
|
||||
// Special headers
|
||||
if (day.day_id === -0.1) {
|
||||
if (day.dayid === -0.1) {
|
||||
dateStr = "Folders";
|
||||
}
|
||||
|
||||
|
@ -384,10 +384,10 @@ export default {
|
|||
size: 40,
|
||||
head: true,
|
||||
loadedImages: false,
|
||||
dayId: day.day_id,
|
||||
dayId: day.dayid,
|
||||
day: day,
|
||||
};
|
||||
this.heads[day.day_id] = head;
|
||||
this.heads[day.dayid] = head;
|
||||
this.list.push(head);
|
||||
currTopStatic += head.size;
|
||||
|
||||
|
@ -403,7 +403,7 @@ export default {
|
|||
for (let j = 0; j < rowCount; j++) {
|
||||
row.photos.push({
|
||||
ph: true, // placeholder
|
||||
file_id: `${day.day_id}-${i}-${j}`,
|
||||
fileid: `${day.dayid}-${i}-${j}`,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ export default {
|
|||
// Check preloads
|
||||
for (const day of data) {
|
||||
if (day.count && day.detail) {
|
||||
this.processDay(day.day_id, day.detail);
|
||||
this.processDay(day.dayid, day.detail);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -443,7 +443,7 @@ export default {
|
|||
const data = res.data;
|
||||
if (this.state !== startState) return;
|
||||
|
||||
this.days.find(d => d.day_id === dayId).detail = data;
|
||||
this.days.find(d => d.dayid === dayId).detail = data;
|
||||
this.processDay(dayId, data);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
@ -501,7 +501,7 @@ export default {
|
|||
id: ++this.numRows,
|
||||
photos: [],
|
||||
size: this.rowHeight,
|
||||
dayId: day.day_id,
|
||||
dayId: day.dayid,
|
||||
day: day,
|
||||
};
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue