Compare commits
No commits in common. "ai-dev" and "master" have entirely different histories.
@ -1,3 +1,4 @@
|
||||
|
||||
const db = require('../models');
|
||||
const FileDBApi = require('./file');
|
||||
const crypto = require('crypto');
|
||||
@ -12,23 +13,6 @@ const Sequelize = db.Sequelize;
|
||||
const Op = Sequelize.Op;
|
||||
|
||||
module.exports = class UsersDBApi {
|
||||
static async getFollowersCount(userId) {
|
||||
return await db.friendships.count({
|
||||
where: { addresseeId: userId, status: "accepted" }
|
||||
});
|
||||
}
|
||||
static async getFollowingCount(userId) {
|
||||
return await db.friendships.count({
|
||||
where: { requesterId: userId, status: "accepted" }
|
||||
});
|
||||
}
|
||||
static async isFollowing(requesterId, addresseeId) {
|
||||
const friendship = await db.friendships.findOne({
|
||||
where: { requesterId, addresseeId }
|
||||
});
|
||||
return !!friendship;
|
||||
}
|
||||
|
||||
|
||||
static async create(data, options) {
|
||||
const currentUser = (options && options.currentUser) || { id: null };
|
||||
@ -101,10 +85,6 @@ module.exports = class UsersDBApi {
|
||||
null
|
||||
,
|
||||
|
||||
bio: data.data.bio || null,
|
||||
birthday: data.data.birthday || null,
|
||||
education: data.data.education || null,
|
||||
|
||||
importHash: data.data.importHash || null,
|
||||
createdById: currentUser.id,
|
||||
updatedById: currentUser.id,
|
||||
@ -163,10 +143,7 @@ module.exports = class UsersDBApi {
|
||||
const usersData = data.map((item, index) => ({
|
||||
id: item.id || undefined,
|
||||
|
||||
firstName: item.firstName,
|
||||
bio: item.bio,
|
||||
birthday: item.birthday,
|
||||
education: item.education
|
||||
firstName: item.firstName
|
||||
||
|
||||
null
|
||||
,
|
||||
@ -228,10 +205,6 @@ module.exports = class UsersDBApi {
|
||||
null
|
||||
,
|
||||
|
||||
bio: item.bio || null,
|
||||
birthday: item.birthday || null,
|
||||
education: item.education || null,
|
||||
|
||||
importHash: item.importHash || null,
|
||||
createdById: currentUser.id,
|
||||
updatedById: currentUser.id,
|
||||
@ -325,9 +298,6 @@ module.exports = class UsersDBApi {
|
||||
|
||||
if (data.provider !== undefined) updatePayload.provider = data.provider;
|
||||
|
||||
if (data.bio !== undefined) updatePayload.bio = data.bio;
|
||||
if (data.birthday !== undefined) updatePayload.birthday = data.birthday;
|
||||
if (data.education !== undefined) updatePayload.education = data.education;
|
||||
|
||||
updatePayload.updatedById = currentUser.id;
|
||||
|
||||
@ -1016,4 +986,5 @@ module.exports = class UsersDBApi {
|
||||
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -1,25 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
/** @type {import('sequelize-cli').Migration} */
|
||||
module.exports = {
|
||||
async up (queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn('users', 'bio', {
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
});
|
||||
await queryInterface.addColumn('users', 'birthday', {
|
||||
type: Sequelize.DataTypes.DATEONLY,
|
||||
allowNull: true,
|
||||
});
|
||||
await queryInterface.addColumn('users', 'education', {
|
||||
type: Sequelize.DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
});
|
||||
},
|
||||
|
||||
async down (queryInterface, Sequelize) {
|
||||
await queryInterface.removeColumn('users', 'bio');
|
||||
await queryInterface.removeColumn('users', 'birthday');
|
||||
await queryInterface.removeColumn('users', 'education');
|
||||
}
|
||||
};
|
||||
@ -104,16 +104,6 @@ provider: {
|
||||
|
||||
},
|
||||
|
||||
bio: {
|
||||
type: DataTypes.TEXT,
|
||||
},
|
||||
birthday: {
|
||||
type: DataTypes.DATEONLY,
|
||||
},
|
||||
education: {
|
||||
type: DataTypes.TEXT,
|
||||
},
|
||||
|
||||
importHash: {
|
||||
type: DataTypes.STRING(255),
|
||||
allowNull: true,
|
||||
@ -345,9 +335,7 @@ function trimStringFields(users) {
|
||||
users.lastName = users.lastName
|
||||
? users.lastName.trim()
|
||||
: null;
|
||||
|
||||
users.bio = users.bio ? users.bio.trim() : null;
|
||||
users.education = users.education ? users.education.trim() : null;
|
||||
|
||||
return users;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,12 +8,6 @@ const menuAside: MenuAsideItem[] = [
|
||||
label: 'Dashboard',
|
||||
},
|
||||
|
||||
{
|
||||
href: '/timeline',
|
||||
icon: icon.mdiViewDashboard,
|
||||
label: 'Timeline',
|
||||
},
|
||||
|
||||
{
|
||||
href: '/users/users-list',
|
||||
label: 'Users',
|
||||
@ -48,7 +42,7 @@ const menuAside: MenuAsideItem[] = [
|
||||
},
|
||||
{
|
||||
href: '/timeline_posts/timeline_posts-list',
|
||||
label: 'Timeline posts (Admin)',
|
||||
label: 'Timeline posts',
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
icon: 'mdiPostOutline' in icon ? icon['mdiPostOutline' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
@ -126,11 +120,6 @@ const menuAside: MenuAsideItem[] = [
|
||||
icon: 'mdiAlertOctagonOutline' in icon ? icon['mdiAlertOctagonOutline' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable,
|
||||
permissions: 'READ_USER_REPORTS'
|
||||
},
|
||||
{
|
||||
href: '/media-gallery',
|
||||
label: 'Media Gallery',
|
||||
icon: icon.mdiImageMultiple,
|
||||
},
|
||||
{
|
||||
href: '/profile',
|
||||
label: 'Profile',
|
||||
|
||||
@ -1,60 +0,0 @@
|
||||
import { mdiImageMultiple } from '@mdi/js';
|
||||
import Head from 'next/head';
|
||||
import React, { ReactElement, useEffect, useState } from 'react';
|
||||
import CardBox from '../../components/CardBox';
|
||||
import LayoutAuthenticated from '../../layouts/Authenticated';
|
||||
import SectionMain from '../../components/SectionMain';
|
||||
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton';
|
||||
import { getPageTitle } from '../../config';
|
||||
import axios from 'axios';
|
||||
import ImageField from '../../components/ImageField';
|
||||
|
||||
const MediaGallery = () => {
|
||||
const [images, setImages] = useState<any[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
const fetchPosts = async () => {
|
||||
try {
|
||||
const response = await axios.get('/timeline_posts');
|
||||
const posts = response.data.rows || [];
|
||||
const galleryImages = posts.flatMap((post: any) => post.media_images || []);
|
||||
setImages(galleryImages);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch media:', error);
|
||||
}
|
||||
};
|
||||
fetchPosts();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Media Gallery')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiImageMultiple} title='Media Gallery' main>
|
||||
{''}
|
||||
</SectionTitleLineWithButton>
|
||||
<CardBox>
|
||||
<div className='grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4'>
|
||||
{images.map((image: any, index: number) => (
|
||||
<ImageField
|
||||
key={index}
|
||||
name={'Media'}
|
||||
image={image}
|
||||
className='w-full h-32 rounded-lg overflow-hidden'
|
||||
imageClassName='h-full w-full object-cover'
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
MediaGallery.getLayout = function getLayout(page: ReactElement) {
|
||||
return <LayoutAuthenticated>{page}</LayoutAuthenticated>;
|
||||
};
|
||||
|
||||
export default MediaGallery;
|
||||
@ -45,10 +45,7 @@ const EditUsers = () => {
|
||||
app_role: '',
|
||||
disabled: false,
|
||||
avatar: [],
|
||||
password: '',
|
||||
bio: '',
|
||||
birthday: null,
|
||||
education: ''
|
||||
password: ''
|
||||
};
|
||||
const [initialValues, setInitialValues] = useState(initVals);
|
||||
|
||||
@ -95,7 +92,6 @@ const EditUsers = () => {
|
||||
initialValues={initialValues}
|
||||
onSubmit={(values) => handleSubmit(values)}
|
||||
>
|
||||
{({ setFieldValue, values }) => (
|
||||
<Form>
|
||||
<FormField>
|
||||
<Field
|
||||
@ -128,23 +124,6 @@ const EditUsers = () => {
|
||||
<Field name='email' placeholder='E-Mail' disabled />
|
||||
</FormField>
|
||||
|
||||
<FormField label='Bio'>
|
||||
<Field name='bio' placeholder='Bio' component="textarea" />
|
||||
</FormField>
|
||||
|
||||
<FormField label='Birthday'>
|
||||
<DatePicker
|
||||
selected={values.birthday ? new Date(values.birthday) : null}
|
||||
onChange={(date) => setFieldValue('birthday', date)}
|
||||
className="px-3 py-2 max-w-full border-gray-700 rounded w-full focus:ring focus:ring-blue-600 focus:border-blue-600 border bg-white dark:bg-slate-800"
|
||||
placeholderText="Select a date"
|
||||
/>
|
||||
</FormField>
|
||||
|
||||
<FormField label='Education'>
|
||||
<Field name='education' placeholder='Education' />
|
||||
</FormField>
|
||||
|
||||
<FormField label='App Role' labelFor='app_role'>
|
||||
<Field
|
||||
name='app_role'
|
||||
@ -187,7 +166,6 @@ const EditUsers = () => {
|
||||
/>
|
||||
</BaseButtons>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
@ -199,4 +177,4 @@ EditUsers.getLayout = function getLayout(page: ReactElement) {
|
||||
return <LayoutAuthenticated>{page}</LayoutAuthenticated>;
|
||||
};
|
||||
|
||||
export default EditUsers;
|
||||
export default EditUsers;
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
import { mdiViewDashboard, mdiPlus } from '@mdi/js';
|
||||
import Head from 'next/head';
|
||||
import React, { ReactElement, useEffect, useState } from 'react';
|
||||
import CardBox from '../components/CardBox';
|
||||
import LayoutAuthenticated from '../layouts/Authenticated';
|
||||
import SectionMain from '../components/SectionMain';
|
||||
import SectionTitleLineWithButton from '../components/SectionTitleLineWithButton';
|
||||
import FormField from '../components/FormField';
|
||||
import BaseButton from '../components/BaseButton';
|
||||
import { useAppDispatch, useAppSelector } from '../stores/hooks';
|
||||
import { fetch, create } from '../stores/timeline_posts/timeline_postsSlice';
|
||||
import { getPageTitle } from '../config';
|
||||
|
||||
const TimelinePage = () => {
|
||||
const dispatch = useAppDispatch();
|
||||
const { timeline_posts, loading } = useAppSelector((state) => state.timeline_posts);
|
||||
const [content, setContent] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetch({}));
|
||||
}, [dispatch]);
|
||||
|
||||
const handlePost = () => {
|
||||
if (!content.trim()) return;
|
||||
dispatch(create({ content })).then(() => {
|
||||
setContent('');
|
||||
dispatch(fetch({}));
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{getPageTitle('Timeline')}</title>
|
||||
</Head>
|
||||
<SectionMain>
|
||||
<SectionTitleLineWithButton icon={mdiViewDashboard} title="Timeline" main />
|
||||
|
||||
<CardBox className="mb-6">
|
||||
<FormField label="What's on your mind?">
|
||||
<textarea
|
||||
className="w-full p-2 border border-gray-300 rounded"
|
||||
rows={3}
|
||||
value={content}
|
||||
onChange={(e) => setContent(e.target.value)}
|
||||
/>
|
||||
</FormField>
|
||||
<BaseButton label="Post" color="info" onClick={handlePost} icon={mdiPlus} />
|
||||
</CardBox>
|
||||
|
||||
<div className="space-y-4">
|
||||
{loading ? (
|
||||
<p>Loading posts...</p>
|
||||
) : (
|
||||
timeline_posts.map((post: any) => (
|
||||
<CardBox key={post.id}>
|
||||
<p className="text-gray-800">{post.content}</p>
|
||||
<small className="text-gray-500">{new Date(post.createdAt).toLocaleString()}</small>
|
||||
</CardBox>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</SectionMain>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
TimelinePage.getLayout = function getLayout(page: ReactElement) {
|
||||
return <LayoutAuthenticated>{page}</LayoutAuthenticated>;
|
||||
};
|
||||
|
||||
export default TimelinePage;
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user