Commit 9fc85f16 authored by kazba anuarbekov's avatar kazba anuarbekov

#78 исправлены пути в конфиге

parents 823e03cc 2f839542
...@@ -17,10 +17,12 @@ module.exports = { ...@@ -17,10 +17,12 @@ module.exports = {
db: { db: {
// name: 'froot', // name: 'froot',
// name: 'test', // name: 'test',
//11 name:`${dbMongo}?authSource=${initDb}`, //docker // name:`${dbMongo}?authSource=${initDb}`, //docker
url: 'mongodb://localhost', name: process.env.MONGO_DB ? `${dbMongo}?authSource=${initDb}` : 'froot',
// url: 'mongodb://localhost',
// url: 'mongodb+srv://QWE123:QWE123@cluster0.rrd3k.mongodb.net', // Pasha's mongo address !! // url: 'mongodb+srv://QWE123:QWE123@cluster0.rrd3k.mongodb.net', // Pasha's mongo address !!
//11 url:`mongodb://${user}:${password}@${host}:${port}`, //docker // url:`mongodb://${user}:${password}@${host}:${port}`, //docker
url:process.env.MONGO_USER ? `mongodb://${user}:${password}@${host}:${port}` : 'mongodb://localhost',
// url: 'mongodb://104.248.198.29', // url: 'mongodb://104.248.198.29',
}, },
//11 baseUrlForTelegram: 'http://'+process.env.BOT_HOST, //docker //11 baseUrlForTelegram: 'http://'+process.env.BOT_HOST, //docker
......
...@@ -65,17 +65,27 @@ module.exports = { ...@@ -65,17 +65,27 @@ module.exports = {
}, },
screenshot: async (url, name) => { screenshot: async (url, name) => {
const browser = await puppeteer.launch(); try{
const device_width = 1920; const browser = await puppeteer.launch(
const device_height = 1080; {
const page = await browser.newPage(); headless: true,
await page.setViewport({ width: device_width, height: device_height }) args: ['--no-sandbox']
await page.goto(url, { waitUntil: 'domcontentloaded' }); }
await page.screenshot({ );
fullPage: true, const device_width = 1920;
path: `./public/uploads/${name}` const device_height = 1080;
}); const page = await browser.newPage();
await browser.close(); await page.setViewport({ width: device_width, height: device_height })
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.screenshot({
fullPage: true,
path: `./public/uploads/${name}`
});
await browser.close();
}
catch(e){
console.log(e);
}
}, },
buildContentlinksReportExcelFile: async (contentlinks) => { buildContentlinksReportExcelFile: async (contentlinks) => {
...@@ -172,7 +182,7 @@ module.exports = { ...@@ -172,7 +182,7 @@ module.exports = {
}); });
}; };
const filename = 'ContentReport_' + moment().format('DD-MM-YYYY-HH-mm-ss') + '.xlsx'; const filename = 'ContentReport_' + moment().format('DD-MM-YYYY') + '.xlsx';
await workbook.xlsx.writeFile('./public/files/' + filename); await workbook.xlsx.writeFile('./public/files/' + filename);
return usersObj; return usersObj;
......
...@@ -16,6 +16,10 @@ const NewsSchema = new Schema({ ...@@ -16,6 +16,10 @@ const NewsSchema = new Schema({
createDate: { createDate: {
type: String type: String
}, },
contentManager: {
type: Schema.Types.ObjectId,
ref: 'User',
},
status: { status: {
type: String, type: String,
required: true, required: true,
......
...@@ -73,7 +73,7 @@ const UserSchema = new Schema({ ...@@ -73,7 +73,7 @@ const UserSchema = new Schema({
type: [String], type: [String],
required: true, required: true,
default: ['viewAllPayments'], default: ['viewAllPayments'],
enum: ['viewAllPayments', 'addPayment', 'editPayment', 'approvePayment', 'payPayment', 'postponePayment', 'viewToBePaid', 'viewTodayPayments', 'initCancelApprovedPayment', 'cancelApprovedPayment', 'initCancelPayedPayment', 'cancelPayedPayment', 'deletePayment', 'stopRepeatabilityPayment', 'authorizeUser', 'editUser', 'deleteUser', 'viewUsers', 'bookMeetingRoom', 'editBookedMeetingRoom', 'deleteBookedMeetingRoom', 'viewBookingsMeetingRoom', 'addNewMeetingRoom', 'deleteMeetingRoom', 'addContentlink', 'viewOwnContentlinks', 'viewAllContentlinks', 'addNews', 'viewAllNews'] enum: ['viewAllPayments', 'addPayment', 'editPayment', 'approvePayment', 'payPayment', 'postponePayment', 'viewToBePaid', 'viewTodayPayments', 'initCancelApprovedPayment', 'cancelApprovedPayment', 'initCancelPayedPayment', 'cancelPayedPayment', 'deletePayment', 'stopRepeatabilityPayment', 'authorizeUser', 'editUser', 'deleteUser', 'viewUsers', 'bookMeetingRoom', 'editBookedMeetingRoom', 'deleteBookedMeetingRoom', 'viewBookingsMeetingRoom', 'addNewMeetingRoom', 'deleteMeetingRoom', 'addContentlink', 'viewOwnContentlinks', 'viewAllContentlinks', 'addNews', 'viewAllNews', 'changeStatusNews']
}, },
token: { token: {
type: [String], type: [String],
......
...@@ -29,7 +29,7 @@ const createRouter = () => { ...@@ -29,7 +29,7 @@ const createRouter = () => {
}); });
router.get('/', auth, async (req, res) => { router.get('/', auth, async (req, res) => {
try { try {
const news = await News.find().populate("user"); const news = await News.find().populate(["user", "contentManager"]);
res.send(news); res.send(news);
} catch (e) { } catch (e) {
res.status(500).send(e); res.status(500).send(e);
...@@ -38,7 +38,16 @@ const createRouter = () => { ...@@ -38,7 +38,16 @@ const createRouter = () => {
router.get('/:id/:status', auth, async (req, res) => { router.get('/:id/:status', auth, async (req, res) => {
try { try {
const newsItem = await News.findById(req.params.id) const newsItem = await News.findById(req.params.id)
newsItem.status = req.params.status if(!newsItem.contentManager || (newsItem.contentManager && String(newsItem.contentManager._id) === String(req.user._id))) {
newsItem.status = req.params.status
}else {
return res.send({message: 'Вы не можете изменить статус данной новости'})
}
if(String(newsItem.status) === 'Не сделано') {
newsItem.contentManager = null
}else{
newsItem.contentManager = req.user._id
}
await newsItem.save(); await newsItem.save();
res.send(newsItem); res.send(newsItem);
} catch (error) { } catch (error) {
......
...@@ -114,7 +114,8 @@ const AddRole = () => { ...@@ -114,7 +114,8 @@ const AddRole = () => {
] ]
const rolesForNews = [ const rolesForNews = [
{name: "addNews", text: "Добавить новость"}, {name: "addNews", text: "Добавить новость"},
{name: "viewAllNews", text: "Просмотреть все новсти"} {name: "viewAllNews", text: "Просмотреть все новости"},
{name: "changeStatusNews", text: "Поменять статус новости"}
] ]
const rolesForContentLinks = [ const rolesForContentLinks = [
{name: "addContentlink", text: "Создавать новые заявки"}, {name: "addContentlink", text: "Создавать новые заявки"},
......
...@@ -47,7 +47,7 @@ const ContenLinksReport=()=>{ ...@@ -47,7 +47,7 @@ const ContenLinksReport=()=>{
} }
</div> </div>
) )
const src=(apiURL+'/files/ContentReport_' + moment().format('DD-MM-YYYY-HH-mm-ss') + '.xlsx') const src=(apiURL+'/files/ContentReport_' + moment().format('DD-MM-YYYY') + '.xlsx')
return( return(
<> <>
<a href={src} download>Download Report</a> <a href={src} download>Download Report</a>
......
...@@ -58,7 +58,6 @@ const News = () => { ...@@ -58,7 +58,6 @@ const News = () => {
const closeModal = () => { const closeModal = () => {
setShowModal({ show: false }) setShowModal({ show: false })
} }
const today = moment().format('DD-MM-YYYY')
const modalBody = <> const modalBody = <>
<h3>Добавьте карту ввода или вывода</h3> <h3>Добавьте карту ввода или вывода</h3>
<form <form
...@@ -76,13 +75,15 @@ const News = () => { ...@@ -76,13 +75,15 @@ const News = () => {
<ButtonPink text="Добавить" /> <ButtonPink text="Добавить" />
</form> </form>
</> </>
const today = moment().format('DD-MM-YYYY')
let statuses = ['Не сделано', 'В работе', 'Сделано'] let statuses = ['Не сделано', 'В работе', 'Сделано']
return ( return (
<> <>
<div className="News flex-space"> <div className="News flex-space">
<h2 >Сегодня: {today} </h2> <h2 >Сегодня: {today} </h2>
<ButtonPink text="Добавить" onClickHandler={openModal}/> {user && user.role.includes('addNews') && <ButtonPink text="Добавить" onClickHandler={openModal}/>}
</div> </div>
{showModal.show && <Modal className="News__modal" {showModal.show && <Modal className="News__modal"
body={modalBody} body={modalBody}
...@@ -110,14 +111,14 @@ const News = () => { ...@@ -110,14 +111,14 @@ const News = () => {
{newsItem.user && newsItem.user.surname + " " + newsItem.user.name} {newsItem.user && newsItem.user.surname + " " + newsItem.user.name}
</td> </td>
<td> <td>
{user && user.role.includes('viewAllNews') && user.surname + " " + user.name} {user && user.role.includes('viewAllNews') && newsItem.contentManager? newsItem.contentManager.surname + " " + newsItem.contentManager.name : null}
</td> </td>
{user && user.role.includes('viewAllNews') && <td> <td>{user && user.role.includes('changeStatusNews')?
<Dropdown <Dropdown
dropdownTitle = {newsItem.status} dropdownTitle = {newsItem.status}
dropdownContents = {statuses.filter(s => String(s) !== String(newsItem.status)) } dropdownContents = {statuses.filter(s => String(s) !== String(newsItem.status)) }
changeContentHandler = {(e, )=>changeStatusHandler(e, newsItem._id)}/></td>} changeContentHandler = {(e, )=>changeStatusHandler(e, newsItem._id)}/> : newsItem.status}
</td>
</tr>))} </tr>))}
</tbody> </tbody>
</table> </table>
......
...@@ -134,7 +134,7 @@ const RegistryForAccountant = () => { ...@@ -134,7 +134,7 @@ const RegistryForAccountant = () => {
<a <a
className="RegistryForAccountant__downloads-btn" className="RegistryForAccountant__downloads-btn"
download download
href={"http://localhost:8000/files/" + today + ".xlsx"} href={apiURL+"/files/" + today + ".xlsx"}
> >
Формирование Excell Формирование Excell
</a> </a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment