This commit is contained in:
Flatlogic Bot 2026-04-05 16:01:59 +00:00
parent d2d9f2b743
commit 14079e71ec
5 changed files with 1244 additions and 10 deletions

View File

@ -1,7 +1,6 @@
const db = require('../models');
const FileDBApi = require('./file');
const crypto = require('crypto');
const Utils = require('../utils');
@ -66,6 +65,11 @@ module.exports = class Media_assetsDBApi {
null
,
sort_order: data.sort_order
||
null
,
is_primary: data.is_primary
||
false
@ -164,6 +168,11 @@ module.exports = class Media_assetsDBApi {
duration_seconds: item.duration_seconds
||
null
,
sort_order: item.sort_order
||
null
,
is_primary: item.is_primary
@ -250,6 +259,9 @@ module.exports = class Media_assetsDBApi {
if (data.duration_seconds !== undefined) updatePayload.duration_seconds = data.duration_seconds;
if (data.sort_order !== undefined) updatePayload.sort_order = data.sort_order;
if (data.is_primary !== undefined) updatePayload.is_primary = data.is_primary;
@ -407,10 +419,6 @@ module.exports = class Media_assetsDBApi {
offset = currentPage * limit;
const orderBy = null;
const transaction = (options && options.transaction) || undefined;
let include = [
{

View File

@ -0,0 +1,96 @@
module.exports = {
async up(queryInterface, Sequelize) {
const transaction = await queryInterface.sequelize.transaction();
try {
const tableRows = await queryInterface.sequelize.query(
"SELECT to_regclass('public.\"media_assets\"') AS regclass_name;",
{
transaction,
type: Sequelize.QueryTypes.SELECT,
},
);
const tableName = tableRows[0].regclass_name;
if (!tableName) {
await transaction.commit();
return;
}
const columnRows = await queryInterface.sequelize.query(
`SELECT column_name
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'media_assets'
AND column_name = 'sort_order';`,
{
transaction,
type: Sequelize.QueryTypes.SELECT,
},
);
if (columnRows.length) {
await transaction.commit();
return;
}
await queryInterface.addColumn(
'media_assets',
'sort_order',
{
type: Sequelize.DataTypes.INTEGER,
allowNull: true,
},
{ transaction },
);
await transaction.commit();
} catch (error) {
await transaction.rollback();
throw error;
}
},
async down(queryInterface, Sequelize) {
const transaction = await queryInterface.sequelize.transaction();
try {
const tableRows = await queryInterface.sequelize.query(
"SELECT to_regclass('public.\"media_assets\"') AS regclass_name;",
{
transaction,
type: Sequelize.QueryTypes.SELECT,
},
);
const tableName = tableRows[0].regclass_name;
if (!tableName) {
await transaction.commit();
return;
}
const columnRows = await queryInterface.sequelize.query(
`SELECT column_name
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'media_assets'
AND column_name = 'sort_order';`,
{
transaction,
type: Sequelize.QueryTypes.SELECT,
},
);
if (!columnRows.length) {
await transaction.commit();
return;
}
await queryInterface.removeColumn('media_assets', 'sort_order', { transaction });
await transaction.commit();
} catch (error) {
await transaction.rollback();
throw error;
}
},
};

View File

@ -1,8 +1,3 @@
const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');
module.exports = function(sequelize, DataTypes) {
const media_assets = sequelize.define(
@ -102,6 +97,13 @@ duration_seconds: {
},
sort_order: {
type: DataTypes.INTEGER,
},
is_primary: {

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@ import BaseIcon from '../components/BaseIcon';
import CardBox from '../components/CardBox';
import LayoutAuthenticated from '../layouts/Authenticated';
import LoadingSpinner from '../components/LoadingSpinner';
import MediaCenterUploadWidget from '../components/MediaCenterUploadWidget';
import SectionMain from '../components/SectionMain';
import SectionTitleLineWithButton from '../components/SectionTitleLineWithButton';
import { getPageTitle } from '../config';
@ -399,6 +400,8 @@ const MediaCenterPage = () => {
</div>
</CardBox>
<MediaCenterUploadWidget className='mb-6' />
{loading && <LoadingSpinner />}
{!loading && errorMessage && (