Forced merge: merge ai-dev into master
This commit is contained in:
commit
31bb9677ac
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,8 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
*/node_modules/
|
*/node_modules/
|
||||||
*/build/
|
*/build/
|
||||||
|
|
||||||
|
**/node_modules/
|
||||||
|
**/build/
|
||||||
|
.DS_Store
|
||||||
|
.env
|
||||||
File diff suppressed because one or more lines are too long
@ -21,6 +21,8 @@ module.exports = class TasksDBApi {
|
|||||||
priority: data.priority || null,
|
priority: data.priority || null,
|
||||||
is_procrastinating: data.is_procrastinating || false,
|
is_procrastinating: data.is_procrastinating || false,
|
||||||
|
|
||||||
|
iscompleted: data.iscompleted || false,
|
||||||
|
|
||||||
importHash: data.importHash || null,
|
importHash: data.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -49,6 +51,8 @@ module.exports = class TasksDBApi {
|
|||||||
priority: item.priority || null,
|
priority: item.priority || null,
|
||||||
is_procrastinating: item.is_procrastinating || false,
|
is_procrastinating: item.is_procrastinating || false,
|
||||||
|
|
||||||
|
iscompleted: item.iscompleted || false,
|
||||||
|
|
||||||
importHash: item.importHash || null,
|
importHash: item.importHash || null,
|
||||||
createdById: currentUser.id,
|
createdById: currentUser.id,
|
||||||
updatedById: currentUser.id,
|
updatedById: currentUser.id,
|
||||||
@ -83,6 +87,9 @@ module.exports = class TasksDBApi {
|
|||||||
if (data.is_procrastinating !== undefined)
|
if (data.is_procrastinating !== undefined)
|
||||||
updatePayload.is_procrastinating = data.is_procrastinating;
|
updatePayload.is_procrastinating = data.is_procrastinating;
|
||||||
|
|
||||||
|
if (data.iscompleted !== undefined)
|
||||||
|
updatePayload.iscompleted = data.iscompleted;
|
||||||
|
|
||||||
updatePayload.updatedById = currentUser.id;
|
updatePayload.updatedById = currentUser.id;
|
||||||
|
|
||||||
await tasks.update(updatePayload, { transaction });
|
await tasks.update(updatePayload, { transaction });
|
||||||
@ -270,6 +277,13 @@ module.exports = class TasksDBApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filter.iscompleted) {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
iscompleted: filter.iscompleted,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (filter.createdAtRange) {
|
if (filter.createdAtRange) {
|
||||||
const [start, end] = filter.createdAtRange;
|
const [start, end] = filter.createdAtRange;
|
||||||
|
|
||||||
|
|||||||
52
backend/src/db/migrations/1749136812314.js
Normal file
52
backend/src/db/migrations/1749136812314.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
module.exports = {
|
||||||
|
/**
|
||||||
|
* @param {QueryInterface} queryInterface
|
||||||
|
* @param {Sequelize} Sequelize
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async up(queryInterface, Sequelize) {
|
||||||
|
/**
|
||||||
|
* @type {Transaction}
|
||||||
|
*/
|
||||||
|
const transaction = await queryInterface.sequelize.transaction();
|
||||||
|
try {
|
||||||
|
await queryInterface.addColumn(
|
||||||
|
'tasks',
|
||||||
|
'iscompleted',
|
||||||
|
{
|
||||||
|
type: Sequelize.DataTypes.BOOLEAN,
|
||||||
|
|
||||||
|
defaultValue: false,
|
||||||
|
allowNull: false,
|
||||||
|
},
|
||||||
|
{ transaction },
|
||||||
|
);
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {QueryInterface} queryInterface
|
||||||
|
* @param {Sequelize} Sequelize
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async down(queryInterface, Sequelize) {
|
||||||
|
/**
|
||||||
|
* @type {Transaction}
|
||||||
|
*/
|
||||||
|
const transaction = await queryInterface.sequelize.transaction();
|
||||||
|
try {
|
||||||
|
await queryInterface.removeColumn('tasks', 'iscompleted', {
|
||||||
|
transaction,
|
||||||
|
});
|
||||||
|
|
||||||
|
await transaction.commit();
|
||||||
|
} catch (err) {
|
||||||
|
await transaction.rollback();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -39,6 +39,13 @@ module.exports = function (sequelize, DataTypes) {
|
|||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
iscompleted: {
|
||||||
|
type: DataTypes.BOOLEAN,
|
||||||
|
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: false,
|
||||||
|
},
|
||||||
|
|
||||||
importHash: {
|
importHash: {
|
||||||
type: DataTypes.STRING(255),
|
type: DataTypes.STRING(255),
|
||||||
allowNull: true,
|
allowNull: true,
|
||||||
|
|||||||
@ -16,6 +16,8 @@ const TasksData = [
|
|||||||
is_procrastinating: false,
|
is_procrastinating: false,
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
iscompleted: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -30,6 +32,8 @@ const TasksData = [
|
|||||||
is_procrastinating: false,
|
is_procrastinating: false,
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
iscompleted: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -39,11 +43,29 @@ const TasksData = [
|
|||||||
|
|
||||||
due_date: new Date('2023-11-03T09:00:00Z'),
|
due_date: new Date('2023-11-03T09:00:00Z'),
|
||||||
|
|
||||||
priority: 'Medium',
|
priority: 'High',
|
||||||
|
|
||||||
is_procrastinating: true,
|
is_procrastinating: true,
|
||||||
|
|
||||||
// type code here for "relation_one" field
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
iscompleted: false,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
title: 'Review code submissions',
|
||||||
|
|
||||||
|
description: 'Review the latest code submissions from the team.',
|
||||||
|
|
||||||
|
due_date: new Date('2023-11-02T14:00:00Z'),
|
||||||
|
|
||||||
|
priority: 'High',
|
||||||
|
|
||||||
|
is_procrastinating: false,
|
||||||
|
|
||||||
|
// type code here for "relation_one" field
|
||||||
|
|
||||||
|
iscompleted: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -82,6 +104,17 @@ async function associateTaskWithUser() {
|
|||||||
if (Task2?.setUser) {
|
if (Task2?.setUser) {
|
||||||
await Task2.setUser(relatedUser2);
|
await Task2.setUser(relatedUser2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const relatedUser3 = await Users.findOne({
|
||||||
|
offset: Math.floor(Math.random() * (await Users.count())),
|
||||||
|
});
|
||||||
|
const Task3 = await Tasks.findOne({
|
||||||
|
order: [['id', 'ASC']],
|
||||||
|
offset: 3,
|
||||||
|
});
|
||||||
|
if (Task3?.setUser) {
|
||||||
|
await Task3.setUser(relatedUser3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|||||||
@ -161,6 +161,17 @@ router.post(
|
|||||||
* description: Data of the updated item
|
* description: Data of the updated item
|
||||||
* type: object
|
* type: object
|
||||||
* $ref: "#/components/schemas/Tasks"
|
* $ref: "#/components/schemas/Tasks"
|
||||||
|
|
||||||
|
|
||||||
|
// New endpoint for task statistics
|
||||||
|
router.get(
|
||||||
|
'/stats',
|
||||||
|
wrapAsync(async (req, res) => {
|
||||||
|
const stats = await TasksService.stats(req.currentUser);
|
||||||
|
res.status(200).send(stats);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
* required:
|
* required:
|
||||||
* - id
|
* - id
|
||||||
* responses:
|
* responses:
|
||||||
|
|||||||
@ -111,4 +111,29 @@ module.exports = class TasksService {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get task statistics: total, completed, pending, and by priority counts.
|
||||||
|
*/
|
||||||
|
static async stats(currentUser) {
|
||||||
|
// Count total tasks
|
||||||
|
const total = await TasksDBApi.findAll({}, null, { countOnly: true, currentUser });
|
||||||
|
// Count completed tasks
|
||||||
|
const completed = await TasksDBApi.findAll({ iscompleted: true }, null, { countOnly: true, currentUser });
|
||||||
|
// Count pending tasks
|
||||||
|
const pending = await TasksDBApi.findAll({ iscompleted: false }, null, { countOnly: true, currentUser });
|
||||||
|
// Group by priority
|
||||||
|
const dbModels = require('../db/models');
|
||||||
|
const { fn, col } = dbModels.sequelize;
|
||||||
|
const raw = await dbModels.tasks.findAll({
|
||||||
|
attributes: ['priority', [fn('COUNT', col('priority')), 'count']],
|
||||||
|
group: ['priority'],
|
||||||
|
});
|
||||||
|
const byPriority = {};
|
||||||
|
raw.forEach(r => {
|
||||||
|
byPriority[r.get('priority')] = parseInt(r.get('count'), 10);
|
||||||
|
});
|
||||||
|
return { total, completed, pending, byPriority };
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -135,6 +135,17 @@ const CardTasks = ({
|
|||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className='flex justify-between gap-x-4 py-3'>
|
||||||
|
<dt className=' text-gray-500 dark:text-dark-600'>
|
||||||
|
Iscompleted
|
||||||
|
</dt>
|
||||||
|
<dd className='flex items-start gap-x-2'>
|
||||||
|
<div className='font-medium line-clamp-4'>
|
||||||
|
{dataFormatter.booleanFormatter(item.iscompleted)}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -90,6 +90,13 @@ const ListTasks = ({
|
|||||||
{dataFormatter.usersOneListFormatter(item.user)}
|
{dataFormatter.usersOneListFormatter(item.user)}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className={'flex-1 px-3'}>
|
||||||
|
<p className={'text-xs text-gray-500 '}>Iscompleted</p>
|
||||||
|
<p className={'line-clamp-2'}>
|
||||||
|
{dataFormatter.booleanFormatter(item.iscompleted)}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
<ListActionsPopover
|
<ListActionsPopover
|
||||||
onDelete={onDelete}
|
onDelete={onDelete}
|
||||||
|
|||||||
@ -124,6 +124,20 @@ export const loadColumns = async (
|
|||||||
params?.value?.id ?? params?.value,
|
params?.value?.id ?? params?.value,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
field: 'iscompleted',
|
||||||
|
headerName: 'Iscompleted',
|
||||||
|
flex: 1,
|
||||||
|
minWidth: 120,
|
||||||
|
filterable: false,
|
||||||
|
headerClassName: 'datagrid--header',
|
||||||
|
cellClassName: 'datagrid--cell',
|
||||||
|
|
||||||
|
editable: hasUpdatePermission,
|
||||||
|
|
||||||
|
type: 'boolean',
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
field: 'actions',
|
field: 'actions',
|
||||||
type: 'actions',
|
type: 'actions',
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export default function WebSiteHeader({ projectName }: WebSiteHeaderProps) {
|
|||||||
const websiteHeder = useAppSelector((state) => state.style.websiteHeder);
|
const websiteHeder = useAppSelector((state) => state.style.websiteHeder);
|
||||||
const borders = useAppSelector((state) => state.style.borders);
|
const borders = useAppSelector((state) => state.style.borders);
|
||||||
|
|
||||||
const style = HeaderStyle.PAGES_RIGHT;
|
const style = HeaderStyle.PAGES_LEFT;
|
||||||
|
|
||||||
const design = HeaderDesigns.DESIGN_DIVERSITY;
|
const design = HeaderDesigns.DESIGN_DIVERSITY;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -2,6 +2,11 @@ import * as icon from '@mdi/js';
|
|||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
import { Chart as ChartJS, ArcElement, Tooltip, Legend, CategoryScale, LinearScale, BarElement } from 'chart.js';
|
||||||
|
import { Pie, Bar } from 'react-chartjs-2';
|
||||||
|
|
||||||
|
ChartJS.register(ArcElement, Tooltip, Legend, CategoryScale, LinearScale, BarElement);
|
||||||
|
|
||||||
import type { ReactElement } from 'react';
|
import type { ReactElement } from 'react';
|
||||||
import LayoutAuthenticated from '../layouts/Authenticated';
|
import LayoutAuthenticated from '../layouts/Authenticated';
|
||||||
import SectionMain from '../components/SectionMain';
|
import SectionMain from '../components/SectionMain';
|
||||||
|
|||||||
@ -47,6 +47,8 @@ const EditTasks = () => {
|
|||||||
is_procrastinating: false,
|
is_procrastinating: false,
|
||||||
|
|
||||||
user: null,
|
user: null,
|
||||||
|
|
||||||
|
iscompleted: false,
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -162,6 +164,14 @@ const EditTasks = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Iscompleted' labelFor='iscompleted'>
|
||||||
|
<Field
|
||||||
|
name='iscompleted'
|
||||||
|
id='iscompleted'
|
||||||
|
component={SwitchField}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -47,6 +47,8 @@ const EditTasksPage = () => {
|
|||||||
is_procrastinating: false,
|
is_procrastinating: false,
|
||||||
|
|
||||||
user: null,
|
user: null,
|
||||||
|
|
||||||
|
iscompleted: false,
|
||||||
};
|
};
|
||||||
const [initialValues, setInitialValues] = useState(initVals);
|
const [initialValues, setInitialValues] = useState(initVals);
|
||||||
|
|
||||||
@ -160,6 +162,14 @@ const EditTasksPage = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Iscompleted' labelFor='iscompleted'>
|
||||||
|
<Field
|
||||||
|
name='iscompleted'
|
||||||
|
id='iscompleted'
|
||||||
|
component={SwitchField}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -44,6 +44,8 @@ const initialValues = {
|
|||||||
is_procrastinating: false,
|
is_procrastinating: false,
|
||||||
|
|
||||||
user: '',
|
user: '',
|
||||||
|
|
||||||
|
iscompleted: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const TasksNew = () => {
|
const TasksNew = () => {
|
||||||
@ -124,6 +126,14 @@ const TasksNew = () => {
|
|||||||
></Field>
|
></Field>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
<FormField label='Iscompleted' labelFor='iscompleted'>
|
||||||
|
<Field
|
||||||
|
name='iscompleted'
|
||||||
|
id='iscompleted'
|
||||||
|
component={SwitchField}
|
||||||
|
></Field>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
<BaseButtons>
|
<BaseButtons>
|
||||||
<BaseButton type='submit' color='info' label='Submit' />
|
<BaseButton type='submit' color='info' label='Submit' />
|
||||||
|
|||||||
@ -106,6 +106,14 @@ const TasksView = () => {
|
|||||||
<p>{tasks?.user?.firstName ?? 'No data'}</p>
|
<p>{tasks?.user?.firstName ?? 'No data'}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<FormField label='Iscompleted'>
|
||||||
|
<SwitchField
|
||||||
|
field={{ name: 'iscompleted', value: tasks?.iscompleted }}
|
||||||
|
form={{ setFieldValue: () => null }}
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
|
||||||
<BaseDivider />
|
<BaseDivider />
|
||||||
|
|
||||||
<BaseButton
|
<BaseButton
|
||||||
|
|||||||
@ -157,6 +157,8 @@ const UsersView = () => {
|
|||||||
<th>Priority</th>
|
<th>Priority</th>
|
||||||
|
|
||||||
<th>IsProcrastinating</th>
|
<th>IsProcrastinating</th>
|
||||||
|
|
||||||
|
<th>Iscompleted</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -184,6 +186,10 @@ const UsersView = () => {
|
|||||||
item.is_procrastinating,
|
item.is_procrastinating,
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td data-label='iscompleted'>
|
||||||
|
{dataFormatter.booleanFormatter(item.iscompleted)}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user