Add video icon

pull/37/head
Varun Patil 2022-08-16 00:46:36 +00:00
parent b8e5901aaf
commit b4bda3744e
3 changed files with 35 additions and 9 deletions

View File

@ -44,7 +44,9 @@ class Util {
public function processFile(string $user, File $file): void { public function processFile(string $user, File $file): void {
$mime = $file->getMimeType(); $mime = $file->getMimeType();
if (!in_array($mime, Application::IMAGE_MIMES) && !in_array($mime, Application::VIDEO_MIMES)) { $is_image = in_array($mime, Application::IMAGE_MIMES);
$is_video = in_array($mime, Application::VIDEO_MIMES);
if (!$is_image && !$is_video) {
return; return;
} }
@ -65,15 +67,19 @@ class Util {
// Insert or update file // Insert or update file
if ($exists) { if ($exists) {
$sql = 'UPDATE oc_betterphotos SET $sql = 'UPDATE oc_betterphotos SET
day_id = ?, date_taken = ? day_id = ?, date_taken = ?, is_video = ?
WHERE user_id = ? AND file_id = ?'; WHERE user_id = ? AND file_id = ?';
} else { } else {
$sql = 'INSERT $sql = 'INSERT
INTO oc_betterphotos (day_id, date_taken, user_id, file_id) INTO oc_betterphotos (day_id, date_taken, is_video, user_id, file_id)
VALUES (?, ?, ?, ?)'; VALUES (?, ?, ?, ?, ?)';
} }
$res = $this->connection->executeStatement($sql, [ $res = $this->connection->executeStatement($sql, [
$dayId, $dateTaken, $user, $fileId, $dayId, $dateTaken, $is_video,
$user, $fileId,
], [
\PDO::PARAM_INT, \PDO::PARAM_INT, \PDO::PARAM_BOOL,
\PDO::PARAM_STR, \PDO::PARAM_INT,
]); ]);
// Change of day // Change of day
@ -140,7 +146,7 @@ class Util {
string $user, string $user,
int $dayId, int $dayId,
): array { ): array {
$sql = 'SELECT file_id, oc_filecache.etag $sql = 'SELECT file_id, oc_filecache.etag, is_video
FROM oc_betterphotos FROM oc_betterphotos
LEFT JOIN oc_filecache LEFT JOIN oc_filecache
ON oc_filecache.fileid = oc_betterphotos.file_id ON oc_filecache.fileid = oc_betterphotos.file_id
@ -148,7 +154,16 @@ class Util {
ORDER BY date_taken DESC'; ORDER BY date_taken DESC';
$rows = $this->connection->executeQuery($sql, [$user, $dayId], [ $rows = $this->connection->executeQuery($sql, [$user, $dayId], [
\PDO::PARAM_STR, \PDO::PARAM_INT, \PDO::PARAM_STR, \PDO::PARAM_INT,
]); ])->fetchAll();
return $rows->fetchAll();
foreach($rows as &$row) {
$row["file_id"] = intval($row["file_id"]);
$row["is_video"] = intval($row["is_video"]);
if (!$row["is_video"]) {
unset($row["is_video"]);
}
}
return $rows;
} }
} }

View File

@ -40,6 +40,10 @@
$table->addColumn('day_id', Types::INTEGER, [ $table->addColumn('day_id', Types::INTEGER, [
'notnull' => true, 'notnull' => true,
]); ]);
$table->addColumn('is_video', Types::BOOLEAN, [
'notnull' => false,
'default' => false
]);
$table->setPrimaryKey(['id']); $table->setPrimaryKey(['id']);
$table->addIndex(['user_id'], 'betterphotos_user_id_index'); $table->addIndex(['user_id'], 'betterphotos_user_id_index');

View File

@ -21,6 +21,7 @@
v-bind:style="{ height: rowHeight + 'px' }"> v-bind:style="{ height: rowHeight + 'px' }">
<div class="photo" v-for="img of item.photos"> <div class="photo" v-for="img of item.photos">
<div v-if="img.is_video" class="icon-video-white"></div>
<img <img
@click="openFile(img, item)" @click="openFile(img, item)"
:src="img.src" :key="img.file_id" :src="img.src" :key="img.file_id"
@ -264,6 +265,7 @@ export default {
this.list[rowIdx].photos.push({ this.list[rowIdx].photos.push({
id: p.file_id, id: p.file_id,
src: `/core/preview?fileId=${p.file_id}&c=${p.etag}&x=250&y=250&forceIcon=0&a=0`, src: `/core/preview?fileId=${p.file_id}&c=${p.etag}&x=250&y=250&forceIcon=0&a=0`,
is_video: p.is_video || undefined,
}); });
} }
@ -410,6 +412,11 @@ export default {
opacity: 1; opacity: 1;
} }
.photo-row .photo .icon-video-white {
position: absolute;
top: 8px; right: 8px;
}
.head-row { .head-row {
height: 40px; height: 40px;
padding-top: 13px; padding-top: 13px;