Browse Source

Merge pull request 'bind tasks to a dashboard' (#8) from wrapping-up into master

Reviewed-on: #8
pull/9/head
rozetko 2 years ago
parent
commit
885bbc4ae1
  1. 10
      src/routes/tasks.ts
  2. 1
      src/types.ts

10
src/routes/tasks.ts

@ -21,6 +21,10 @@ type TRequest = {
};
async function getTasks(req, res) {
const query = req.query;
const dashboardUid = query.dashboardUid;
const resp: ExportTask[] = [];
fs.readdir(CSV_PATH, (err, items) => {
if(err) {
@ -35,8 +39,10 @@ async function getTasks(req, res) {
// TODO: read async
let data = fs.readFileSync(path.join(CSV_PATH, item), 'utf8');
try {
let status = JSON.parse(data);
resp.push(status);
let status: ExportTask = JSON.parse(data);
if(dashboardUid && status.dashboardUid === dashboardUid) {
resp.push(status);
}
} catch(e) {
console.log(`Cannot read file /exporter/${item}. if this error doesn't repeat, maybe the file is being updated at the moment`);
}

1
src/types.ts

@ -95,6 +95,7 @@ export type ExportProgress = {
};
export type ExportTask = {
dashboardUid: string;
username: string;
queries: DashboardQuery[];
timeRange: {

Loading…
Cancel
Save