diff --git a/package-lock.json b/package-lock.json index 9dcb78011..22d00cc6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4364,7 +4364,8 @@ }, "ansi-regex": { "version": "2.1.1", - "bundled": true + "bundled": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -4729,7 +4730,8 @@ }, "safe-buffer": { "version": "5.1.1", - "bundled": true + "bundled": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -4777,6 +4779,7 @@ "strip-ansi": { "version": "3.0.1", "bundled": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -4815,11 +4818,13 @@ }, "wrappy": { "version": "1.0.2", - "bundled": true + "bundled": true, + "optional": true }, "yallist": { "version": "3.0.2", - "bundled": true + "bundled": true, + "optional": true } } }, diff --git a/packages/core/admin/package.json b/packages/core/admin/package.json index 842e0f490..5404feed1 100644 --- a/packages/core/admin/package.json +++ b/packages/core/admin/package.json @@ -19,7 +19,7 @@ "postinstall": "bower install" }, "dependencies": { - "request": "^2.87.0" + "request": "^2.88.0" }, "license": "MIT", "_id": "mean-admin@0.0.3", diff --git a/packages/custom/icu/server/controllers/task.js b/packages/custom/icu/server/controllers/task.js index 13fd86a6e..0a40c10f2 100644 --- a/packages/custom/icu/server/controllers/task.js +++ b/packages/custom/icu/server/controllers/task.js @@ -945,7 +945,7 @@ function GivenTasksOfNextWeekSummary(user) { * @param {*} columns what columns to display in the excel * @returns a promise that returns workbook */ -async function tasksToExcelServiceFormat(tasks,columns){ +async function tasksToExcelServiceFormat(tasks,columns,datesColumns){ let UpdateModel = require('../models/update'); tasks = _.map(tasks,task=>task._doc); let filteredTasks = _.filter(tasks,task=>task.title); @@ -972,7 +972,7 @@ async function tasksToExcelServiceFormat(tasks,columns){ .populate('creator', null, 'User'); let row = [ title, - due&&due.toLocaleString().substr(0, due.toLocaleString().indexOf(' ')), // * gives the date as "year-month-day time" and removes time + //due&&due.toLocaleString().substr(0, due.toLocaleString().indexOf(' ')), // * gives the date as "year-month-day time" and removes time status, assign&&assign.name, _.map(watchers,watcher=>watcher.name).join("\n"), @@ -987,7 +987,31 @@ async function tasksToExcelServiceFormat(tasks,columns){ return row; })); - return excelService.json2workbook({"rows":taskArray,columns,"columnsBold":true}); + let taskDatesArray = await Promise.all(_.map(filteredTasks,async (task)=>{ + let { + _id, + due, + } = task; + //console.log("%^$^%$^%$^"); + //console.log(task); + let updates = await UpdateModel + .find({ + issueId: _id, + type: "comment" + }) + .populate('creator', null, 'User'); + let lastUpdate = _.last(updates); + let lastUpdateDate = lastUpdate&&lastUpdate.updated + + let row = [ + due,//&&due.toLocaleString().substr(0, due.toLocaleString().indexOf(' ')), // * gives the date as "year-month-day time" and removes time + lastUpdateDate// _.map(updates,(update=>`:${update.updated&&update.updated.toLocaleString().substr(0, update.updated.toLocaleString().indexOf(' '))} - ${update.creator.name}`+"\n"+`${update.description}`) ).join("\n"), + ]; + + + return row; + })); + return excelService.json2workbookWithDates({"rows":taskArray,dates:taskDatesArray,columns,datesColumns,"columnsBold":true}); } @@ -999,12 +1023,17 @@ async function tasksToExcelServiceFormat(tasks,columns){ res.setHeader("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); //setting the name of the file to be downloaded res.attachment("Summary.xlsx"); - let columns = ["כותרת","תג"+"\""+"ב","סטטוס","אחראי","משתתפים","תיאור","יוצר המשימה","שם דיון","שם פרוייקט","עדכונים","תגיות"] + // let columns = ["כותרת","תג"+"\""+"ב","סטטוס","אחראי","משתתפים","תיאור","יוצר המשימה","שם דיון","שם פרוייקט","עדכונים","תגיות"] + let columns = ["כותרת","סטטוס","אחראי","משתתפים","תיאור","יוצר המשימה","שם דיון","שם פרוייקט","עדכונים","תגיות"] + let datesColumns = ["תג"+"\""+"ב","תאריך תגובה אחרון"] let tasks = req.locals.result; - tasksToExcelServiceFormat(tasks,columns).then(summary=>{ + tasksToExcelServiceFormat(tasks,columns,datesColumns).then(summary=>{ res.send(summary); }); }; + + + exports.byAssign = byAssign; exports.myTasksStatistics = myTasksStatistics; diff --git a/packages/custom/icu/server/routes/icu.js b/packages/custom/icu/server/routes/icu.js index 23d82aae3..b61c4b5fc 100644 --- a/packages/custom/icu/server/routes/icu.js +++ b/packages/custom/icu/server/routes/icu.js @@ -51,7 +51,7 @@ module.exports = function(Icu, app) { // /^((?!\/hi\/).)*$/ all routes without '/api/hi/*' app.route(/^((?!\/hi\/).)*$/).all(locals); - //omri uncomment app.route(/^((?!\/hi\/).)*$/).all(authorization); + app.route(/^((?!\/hi\/).)*$/).all(authorization); //app.route(/^((?!\/hi\/).)*$/).all(authorization, socket); diff --git a/packages/custom/icu/server/services/excel.js b/packages/custom/icu/server/services/excel.js index dec8d8de1..af6561a0b 100644 --- a/packages/custom/icu/server/services/excel.js +++ b/packages/custom/icu/server/services/excel.js @@ -6,10 +6,66 @@ json structure: columnsBold:true\false columns:[col1,col2,col3], array of arrays=== rows:[row1,row2,row3] + dates === rows:[row1,row2,row3] + datesColumns:[dcol1,dcol2] } aoa = aray of arays = [row1,row2,row3,...] =example= [row1=[1,2,3],row2=[4,5,6],...] */ +//same as json for json2workbook with additional datesColumns and aoa of dates +function json2workbookWithDates(json){ + return XlsxPopulate.fromBlankAsync() + .then((workbook)=>{ + let regColumnsLength = json.columns.length; + let datesColumnsLength = json.datesColumns.length; + + let sheet = workbook.sheet("Sheet1"); + + for(let j = 0;j{ + console.log(err); + }); + +} + + + /** * *Takes a json repesentation of excel and returs a workbook @@ -49,4 +105,5 @@ function json2workbook(json){ } -exports.json2workbook = json2workbook; \ No newline at end of file +exports.json2workbook = json2workbook; +exports.json2workbookWithDates =json2workbookWithDates \ No newline at end of file