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 {
$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;
}
@ -65,15 +67,19 @@ class Util {
// Insert or update file
if ($exists) {
$sql = 'UPDATE oc_betterphotos SET
day_id = ?, date_taken = ?
day_id = ?, date_taken = ?, is_video = ?
WHERE user_id = ? AND file_id = ?';
} else {
$sql = 'INSERT
INTO oc_betterphotos (day_id, date_taken, user_id, file_id)
VALUES (?, ?, ?, ?)';
INTO oc_betterphotos (day_id, date_taken, is_video, user_id, file_id)
VALUES (?, ?, ?, ?, ?)';
}
$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
@ -140,7 +146,7 @@ class Util {
string $user,
int $dayId,
): array {
$sql = 'SELECT file_id, oc_filecache.etag
$sql = 'SELECT file_id, oc_filecache.etag, is_video
FROM oc_betterphotos
LEFT JOIN oc_filecache
ON oc_filecache.fileid = oc_betterphotos.file_id
@ -148,7 +154,16 @@ class Util {
ORDER BY date_taken DESC';
$rows = $this->connection->executeQuery($sql, [$user, $dayId], [
\PDO::PARAM_STR, \PDO::PARAM_INT,
]);
return $rows->fetchAll();
])->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, [
'notnull' => true,
]);
$table->addColumn('is_video', Types::BOOLEAN, [
'notnull' => false,
'default' => false
]);
$table->setPrimaryKey(['id']);
$table->addIndex(['user_id'], 'betterphotos_user_id_index');

View File

@ -21,6 +21,7 @@
v-bind:style="{ height: rowHeight + 'px' }">
<div class="photo" v-for="img of item.photos">
<div v-if="img.is_video" class="icon-video-white"></div>
<img
@click="openFile(img, item)"
:src="img.src" :key="img.file_id"
@ -264,6 +265,7 @@ export default {
this.list[rowIdx].photos.push({
id: p.file_id,
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;
}
.photo-row .photo .icon-video-white {
position: absolute;
top: 8px; right: 8px;
}
.head-row {
height: 40px;
padding-top: 13px;