Skip to content

Commit

Permalink
Merge pull request #46 from AI4Bharat/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ishvindersethi22 authored Jan 27, 2024
2 parents 3b73ad4 + 876e018 commit 27c5fec
Show file tree
Hide file tree
Showing 149 changed files with 13,307 additions and 1,009 deletions.
591 changes: 567 additions & 24 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
"next": "^14.0.4",
"next-redux-wrapper": "^8.1.0",
"react": "^18",
"react-csv": "^2.2.2",
"react-date-range": "^2.0.0-alpha.4",
"react-dom": "^18",
"react-drag-drop-files": "^2.3.10",
"react-json-tree": "^0.18.0",
"react-redux": "^9.0.4",
"react-router-dom": "^6.21.2"
},
Expand Down
39 changes: 39 additions & 0 deletions src/Lib/Features/actions/getDatasetsByType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"
const initialState = {
data: [],
status: 'idle',
error: null,
};

export const fetchDatasetsByType = createAsyncThunk(
'getDatasetsByType/fetchDatasetsByType',
async (datasetType, { dispatch }) => {
const params = fetchParams(`${ENDPOINTS.getDatasets}instances/?dataset_type=${datasetType}`,"POST");
return fetch(params.url, params.options)
.then(response => response.json())
}
);

const getDatasetsByType = createSlice({
name: 'getDatasetsByType',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchDatasetsByType.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchDatasetsByType.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchDatasetsByType.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});

export default getDatasetsByType.reducer;
40 changes: 40 additions & 0 deletions src/Lib/Features/datasets/DatasetSearchPopup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"
const initialState = {
data: [],
status: 'idle',
error: null,
};

export const fetchDatasetSearchPopup = createAsyncThunk(
'DatasetSearchPopup/fetchDatasetSearchPopup',
async (taskObj, { dispatch }) => {
const body ={taskObj}
const params = fetchParams(`${ENDPOINTS.getDatasets}dataitems/get_data_items/`,"POST",body);
return fetch(params.url, params.options)
.then(response => response.json())
}
);

const DatasetSearchPopup = createSlice({
name: 'DatasetSearchPopup',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchDatasetSearchPopup.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchDatasetSearchPopup.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchDatasetSearchPopup.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});

export default DatasetSearchPopup.reducer;
46 changes: 46 additions & 0 deletions src/Lib/Features/datasets/GetDataitemsById.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"
const initialState = {
data: [],
status: 'idle',
error: null,
};

export const fetchDataitemsById = createAsyncThunk(
'GetDataitemsById/fetchDataitemsById',
async (instanceIds, datasetType,selectedFilters,pageNo, countPerPage, { dispatch }) => {
const body ={
instance_ids: instanceIds,
dataset_type: datasetType,
search_keys:selectedFilters
}
const queryString = `?${pageNo ? "&page="+pageNo : ""}${countPerPage ?"&records="+countPerPage : ""}`

const params = fetchParams(`${ENDPOINTS.getDatasets}dataitems/get_data_items/${queryString}`,"POST",body);
return fetch(params.url, params.options)
.then(response => response.json())
}
);

const GetDataitemsById = createSlice({
name: 'GetDataitemsById',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchDataitemsById.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchDataitemsById.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchDataitemsById.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});

export default GetDataitemsById.reducer;
52 changes: 52 additions & 0 deletions src/Lib/Features/datasets/GetDatasetDetailedReports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"
const initialState = {
data: [],
status: 'idle',
error: null,
};

export const fetchDatasetDetailedReports = createAsyncThunk(
'GetDatasetDetailedReports/fetchDatasetDetailedReports',
async (dataId, projectType, userId, statistics, { dispatch }) => {
const body={
dataset_id: dataId,
user_id: userId,
project_type: projectType,
}

if(statistics === 1){
body.annotation_statistics = true;
}else if(statistics === 2){
body["meta-info_statistics"] = true;
}else if(statistics === 3){
body.complete_statistics = true;
};
const params = fetchParams(`/functions/schedule_project_reports_email`,"POST",body);
return fetch(params.url, params.options)
.then(response => response.json())
}
);

const GetDatasetDetailedReports = createSlice({
name: 'GetDatasetDetailedReports',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchDatasetDetailedReports.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchDatasetDetailedReports.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchDatasetDetailedReports.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});

export default GetDatasetDetailedReports.reducer;
40 changes: 40 additions & 0 deletions src/Lib/Features/datasets/GetDatasetDownloadCSV.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"
const initialState = {
data: [],
status: 'idle',
error: null,
};

export const fetchDatasetDownloadCSV = createAsyncThunk(
'GetDatasetDownloadCSV/fetchDatasetDownloadCSV',
async (datasetId, { dispatch }) => {

const params = fetchParams(`}${ENDPOINTS.getDatasets}instances/${datasetId}/download/?export_type=CSV`);
return fetch(params.url, params.options)
.then(response => response.json())
}
);

const GetDatasetDownloadCSV = createSlice({
name: 'GetDatasetDownloadCSV',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchDatasetDownloadCSV.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchDatasetDownloadCSV.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchDatasetDownloadCSV.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});

export default GetDatasetDownloadCSV.reducer;
40 changes: 40 additions & 0 deletions src/Lib/Features/datasets/GetDatasetDownloadJSON.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"
const initialState = {
data: [],
status: 'idle',
error: null,
};

export const fetchDatasetDownloadJSON = createAsyncThunk(
'GetDatasetDownloadJSON/fetchDatasetDownloadJSON',
async (datasetId, { dispatch }) => {

const params = fetchParams(`}${ENDPOINTS.getDatasets}instances/${datasetId}/download/?export_type=JSON`);
return fetch(params.url, params.options)
.then(response => response.json())
}
);

const GetDatasetDownloadJSON = createSlice({
name: 'GetDatasetDownloadJSON',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchDatasetDownloadJSON.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchDatasetDownloadJSON.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchDatasetDownloadJSON.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});

export default GetDatasetDownloadJSON.reducer;
40 changes: 40 additions & 0 deletions src/Lib/Features/datasets/GetDatasetDownloadTSV.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"
const initialState = {
data: [],
status: 'idle',
error: null,
};

export const fetchDatasetDownloadTSV = createAsyncThunk(
'GetDatasetDownloadTSV/fetchDatasetDownloadTSV',
async (datasetId, { dispatch }) => {

const params = fetchParams(`}${ENDPOINTS.getDatasets}instances/${datasetId}/download/?export_type=TSV`);
return fetch(params.url, params.options)
.then(response => response.TSV())
}
);

const GetDatasetDownloadTSV = createSlice({
name: 'GetDatasetDownloadTSV',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchDatasetDownloadTSV.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchDatasetDownloadTSV.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchDatasetDownloadTSV.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});

export default GetDatasetDownloadTSV.reducer;
40 changes: 40 additions & 0 deletions src/Lib/Features/datasets/GetDatasetLogs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"
const initialState = {
data: [],
status: 'idle',
error: null,
};

export const fetchDatasetLogs = createAsyncThunk(
'GetDatasetLogs/fetchDatasetLogs',
async (instanceId, taskName, { dispatch }) => {

const params = fetchParams(`${ENDPOINTS.getDatasets}instances/${instanceId}/get_async_task_results/?task_name=${taskName}`);
return fetch(params.url, params.options)
.then(response => response.json())
}
);

const GetDatasetLogs = createSlice({
name: 'GetDatasetLogs',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchDatasetLogs.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchDatasetLogs.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchDatasetLogs.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});

export default GetDatasetLogs.reducer;
42 changes: 42 additions & 0 deletions src/Lib/Features/datasets/GetDatasetProjects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"
const initialState = {
data: [],
status: 'idle',
error: null,
};

export const fetchDatasetProjects = createAsyncThunk(
'GetDatasetProjects/fetchDatasetProjects',
async (datasetId, { dispatch }) => {

const params = fetchParams(`${
ENDPOINTS.getDatasets
}instances/${datasetId}/projects/`);
return fetch(params.url, params.options)
.then(response => response.json())
}
);

const GetDatasetProjects = createSlice({
name: 'GetDatasetProjects',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchDatasetProjects.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchDatasetProjects.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchDatasetProjects.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});

export default GetDatasetProjects.reducer;
Loading

0 comments on commit 27c5fec

Please sign in to comment.