Skip to content

Commit

Permalink
Merge pull request #51 from AI4Bharat/guest_workspace
Browse files Browse the repository at this point in the history
Guest workspace
  • Loading branch information
aparna-aa authored Feb 14, 2024
2 parents 9f71083 + 3b4280e commit 16d7abe
Show file tree
Hide file tree
Showing 55 changed files with 1,096 additions and 432 deletions.
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export',
images: { unoptimized: true }
images: { unoptimized: true },
}

module.exports = nextConfig
40 changes: 40 additions & 0 deletions src/Lib/Features/GetGuestWorkspaces.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 fetchGuestWorkspaceData = createAsyncThunk(
'getGuestWorkspace/fetchGuestWorkspaceData',
async (pageNumber, { dispatch }) => {
//list_guest_workspaces
const params = fetchParams(`${ENDPOINTS.getWorkspaces}`);
return fetch(params.url, params.options)
.then(response => response.json())
}
);

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

export default getGuestWorkspace.reducer;
2 changes: 1 addition & 1 deletion src/Lib/Features/datasets/DatasetSearchPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const fetchDatasetSearchPopup = createAsyncThunk(
'DatasetSearchPopup/fetchDatasetSearchPopup',
async (taskObj, { dispatch }) => {
const body ={taskObj}
const params = fetchParams(`${ENDPOINTS.getDatasets}dataitems/get_data_items/`,"POST",body);
const params = fetchParams(`${ENDPOINTS.getDatasets}dataitems/get_data_items/`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Features/datasets/GetDataitemsById.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const initialState = {

export const fetchDataitemsById = createAsyncThunk(
'GetDataitemsById/fetchDataitemsById',
async (instanceIds, datasetType,selectedFilters,pageNo, countPerPage, { dispatch }) => {
async ({instanceIds, datasetType,selectedFilters,pageNo, countPerPage}) => {
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);
const params = fetchParams(`${ENDPOINTS.getDatasets}dataitems/get_data_items/${queryString}`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Features/datasets/GetDatasetDetailedReports.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const initialState = {

export const fetchDatasetDetailedReports = createAsyncThunk(
'GetDatasetDetailedReports/fetchDatasetDetailedReports',
async (dataId, projectType, userId, statistics, { dispatch }) => {
async ({dataId, projectType, userId, statistics}) => {
const body={
dataset_id: dataId,
user_id: userId,
Expand All @@ -23,7 +23,7 @@ export const fetchDatasetDetailedReports = createAsyncThunk(
}else if(statistics === 3){
body.complete_statistics = true;
};
const params = fetchParams(`/functions/schedule_project_reports_email`,"POST",body);
const params = fetchParams(`/functions/schedule_project_reports_email`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Features/datasets/GetDatasetLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const initialState = {

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

const params = fetchParams(`${ENDPOINTS.getDatasets}instances/${instanceId}/get_async_task_results/?task_name=${taskName}`);
return fetch(params.url, params.options)
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Features/datasets/GetDatasetType.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const initialState = {

export const fetchDatasetType = createAsyncThunk(
'GetDatasetType/fetchDatasetType',
async (datasetType,{ dispatch }) => {
async (datasetType) => {
const params = fetchParams(`${ENDPOINTS.getDatasets}instances/dataset_types/`);
return fetch(params.url, params.options)
.then(response => response.json())
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Features/datasets/GetDatasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const initialState = {

export const fetchDatasets = createAsyncThunk(
'GetDatasets/fetchDatasets',
async (selectedFilters, { dispatch }) => {
async (selectedFilters) => {
let queryString = "";

for (let key in selectedFilters) {
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Features/datasets/getDatasetProjectReports.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ const initialState = {

export const fetchDatasetProjectReports = createAsyncThunk(
'getDatasetProjectReports/fetchDatasetProjectReports',
async (datasetId, projectType, language, { dispatch }) => {
async ({datasetId, projectType, language}) => {
const body=language === "all" ? {
project_type: projectType
} : {
project_type: projectType,
tgt_language: language,
}
const params = fetchParams(`${ENDPOINTS.getDatasets}instances/${datasetId}/project_analytics/`,"POST",body);
const params = fetchParams(`${ENDPOINTS.getDatasets}instances/${datasetId}/project_analytics/`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Features/getProjectReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const fetchProjectReport = createAsyncThunk(
to_date: endDate,
reports_type: reports_type,
};
const params = fetchParams(`${ENDPOINTS.getProjects}${projectId}/get_analytics/`,"POST",body);
const params = fetchParams(`${ENDPOINTS.getProjects}${projectId}/get_analytics/`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Features/projects/DownloadJSONProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const initialState = {

export const fetchDownloadJSONProject = createAsyncThunk(
'DownloadJSONProject/fetchDownloadJSONProject',
async (projectId, taskStatus ,downloadMetadataToggle,{ dispatch }) => {
async ({projectId, taskStatus ,downloadMetadataToggle}) => {
const projectBody={}
const body = {
projectBody
}
const params = fetchParams(`${ENDPOINTS.getProjects}${projectId}/download/?export_type=JSON&task_status=${taskStatus}&include_input_data_metadata_json=${downloadMetadataToggle}`,"POST",body);
const params = fetchParams(`${ENDPOINTS.getProjects}${projectId}/download/?export_type=JSON&task_status=${taskStatus}&include_input_data_metadata_json=${downloadMetadataToggle}`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Features/projects/DownloadProjectCsv.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const initialState = {

export const fetchDownloadCSVProject = createAsyncThunk(
'DownloadCSVProject/fetchDownloadCSVProject',
async (projectId, taskStatus ,downloadMetadataToggle,{ dispatch }) => {
async ({projectId, taskStatus ,downloadMetadataToggle}) => {
const projectBody={}
const body = {
projectBody
}
const params = fetchParams(`${ENDPOINTS.getProjects}${projectId}/download/?export_type=CSV&task_status=${taskStatus}&include_input_data_metadata_json=${downloadMetadataToggle}`,"POST",body);
const params = fetchParams(`${ENDPOINTS.getProjects}${projectId}/download/?export_type=CSV&task_status=${taskStatus}&include_input_data_metadata_json=${downloadMetadataToggle}`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Features/projects/DownloadProjectTsv.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const initialState = {

export const fetchDownloadTSVProject = createAsyncThunk(
'DownloadTSVProject/fetchDownloadTSVProject',
async (projectId, taskStatus ,downloadMetadataToggle,{ dispatch }) => {
async ({projectId, taskStatus ,downloadMetadataToggle}) => {
const projectBody={}
const body = {
projectBody
}
const params = fetchParams(`${ENDPOINTS.getProjects}${projectId}/download/?export_type=CSV&task_status=${taskStatus}&include_input_data_metadata_json=${downloadMetadataToggle}`,"POST",body);
const params = fetchParams(`${ENDPOINTS.getProjects}${projectId}/download/?export_type=CSV&task_status=${taskStatus}&include_input_data_metadata_json=${downloadMetadataToggle}`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const initialState = {

export const fetchOrganizationDetailedProjectReports = createAsyncThunk(
'getOrganizationDetailedProjectReports/fetchOrganizationDetailedProjectReports',
async (orgId, projectType, userId, statistics, { dispatch }) => {
async ({orgId, projectType, userId, statistics}) => {
const body = {
organization_id: orgId,
user_id: userId,
Expand All @@ -23,7 +23,7 @@ export const fetchOrganizationDetailedProjectReports = createAsyncThunk(
}else if(statistics === 3){
body.complete_statistics = true;
}
const params = fetchParams(`/functions/schedule_project_reports_email`,"POST",body);
const params = fetchParams(`/functions/schedule_project_reports_email`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Features/projects/GetOrganizationProjectReports.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const initialState = {

export const fetchOrganizationProjectReports = createAsyncThunk(
'GetOrganizationProjectReports/fetchOrganizationProjectReports',
async (orgId, projectType, targetLanguage, userId, sendMail, sortByColumn, descOrder, { dispatch }) => {
async ({orgId, projectType, targetLanguage, userId, sendMail, sortByColumn, descOrder}) => {
const body = {
project_type: projectType,
tgt_language: targetLanguage === "all" ? undefined : targetLanguage,
Expand All @@ -18,7 +18,7 @@ export const fetchOrganizationProjectReports = createAsyncThunk(
user_id: userId,
send_mail: sendMail,
};
const params = fetchParams(`${ENDPOINTS.getOrganizations}${orgId}/project_analytics/`,"POST",body);
const params = fetchParams(`${ENDPOINTS.getOrganizations}${orgId}/project_analytics/`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
4 changes: 2 additions & 2 deletions src/Lib/Features/projects/GetOrganizationUserReports.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const initialState = {

export const fetchOrganizationUserReports = createAsyncThunk(
'GetOrganizationUserReports/fetchOrganizationUserReports',
async (orgId, projectType, startDate, endDate,reportsType, targetLanguage, sendMail, onlyReviewProjects,sortByColumn, descOrder, { dispatch }) => {
async ({orgId, projectType, startDate, endDate,reportsType, targetLanguage, sendMail, onlyReviewProjects,sortByColumn, descOrder}) => {
const body = {
project_type: projectType,
from_date: startDate,
Expand All @@ -21,7 +21,7 @@ export const fetchOrganizationUserReports = createAsyncThunk(
reports_type: reportsType,
send_mail: sendMail ?? false,
};
const params = fetchParams(`${ENDPOINTS.getOrganizations}${orgId}/user_analytics/`,"POST",body);
const params = fetchParams(`${ENDPOINTS.getOrganizations}${orgId}/user_analytics/`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
19 changes: 11 additions & 8 deletions src/Lib/Features/projects/GetTasksByProjectId.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ const initialState = {
error: null,
};

export const fetchTasksByProjectId = createAsyncThunk(
'getTasksByProjectId/fetchTasksByProjectId',
async (projectId, pageNo, countPerPage, selectedFilters, taskType, pullvalue,rejected,pull, { dispatch }) => {
let queryString = `?project_id=${projectId}${pageNo ? "&page="+pageNo : ""}${countPerPage ?"&records="+countPerPage : ""}`;
export const fetchTasksByProjectId = createAsyncThunk(
'GetTasksByProjectId/fetchTasksByProjectId',
async (payload) => {
const { id, currentPageNumber, currentRowPerPage, selectedFilters, taskType, pullvalue,rejected,pull } = payload;

let queryString = `?project_id=${id}${currentPageNumber ? "&page="+currentPageNumber : ""}${currentRowPerPage ?"&records="+currentRowPerPage : ""}`;
let querystr = pull === "All" ?"": `&editable=${pullvalue}`
let querystr1 = rejected === true ?`&rejected=`+"True":""
for (let key in selectedFilters) {
Expand All @@ -27,19 +29,20 @@ export const fetchTasksByProjectId = createAsyncThunk(
break;
default:
queryString +=`&${key}=${selectedFilters[key]}`

}
}
}



const params = fetchParams(`${ENDPOINTS.getTasks+queryString}`);
return fetch(params.url, params.options)
.then(response => response.json())
}
);

const getTasksByProjectId = createSlice({
name: 'getTasksByProjectId',
const GetTasksByProjectId = createSlice({
name: 'GetTasksByProjectId',
initialState,
reducers: {},
extraReducers: (builder) => {
Expand All @@ -58,4 +61,4 @@ const getTasksByProjectId = createSlice({
},
});

export default getTasksByProjectId.reducer;
export default GetTasksByProjectId.reducer;
2 changes: 1 addition & 1 deletion src/Lib/Features/projects/SendOrganizationUserReports.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const fetchSendOrganizationUserReports = createAsyncThunk(
from_date: fromDate,
to_date: toDate
};
const params = fetchParams(`${ENDPOINTS.getOrganizations}${orgId}/send_user_analytics/`,"POST",body);
const params = fetchParams(`${ENDPOINTS.getOrganizations}${orgId}/send_user_analytics/`,"POST",JSON.stringify(body));
return fetch(params.url, params.options)
.then(response => response.json())
}
Expand Down
5 changes: 3 additions & 2 deletions src/Lib/Features/projects/getAllTaskData.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ const initialState = {

export const fetchAllTaskData = createAsyncThunk(
'getAllTaskData/fetchAllTaskData',
async (projectId,pageNo,selectedFilters,currentRowPerPage,{ dispatch }) => {
let queryString = `?project_id=${projectId}${pageNo ? "&page="+pageNo : ""}${currentRowPerPage ?"&records="+currentRowPerPage : ""}`;
async (payload) => {
const{id,currentPageNumber,currentRowPerPage,selectedFilters}=payload
let queryString = `?project_id=${id}${currentPageNumber ? "&page="+currentPageNumber : ""}${currentRowPerPage ?"&records="+currentRowPerPage : ""}`;
for (let key in selectedFilters) {
if (selectedFilters[key] && selectedFilters[key] !== -1) {
if(key=="task_status"){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const initialState = {

export const fetchFindAndReplaceWordsInAnnotation = createAsyncThunk(
'getFindAndReplaceWordsInAnnotation/fetchFindAndReplaceWordsInAnnotation',
async (projectId,AnnotationObj, { dispatch }) => {
async ({projectId,AnnotationObj}) => {
const params = fetchParams(`${ENDPOINTS.getTasks}${projectId}/find_and_replace_words_in_annotation/`,"POST",AnnotationObj);
return fetch(params.url, params.options)
.then(response => response.json())
Expand Down
2 changes: 2 additions & 0 deletions src/Lib/Features/projects/getTaskFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ const getTaskFilter = createSlice({

export const { setTaskFilter } = getTaskFilter.actions;


export default getTaskFilter.reducer;

4 changes: 3 additions & 1 deletion src/Lib/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ import GetDatasetDownloadJSON from './Features/datasets/GetDatasetDownloadJSON';
import GetFileTypes from './Features/datasets/GetFileTypes';
import DatasetSearchPopup from './Features/datasets/DatasetSearchPopup';
import searchProjectCard from './Features/searchProjectCard';
import GetGuestWokspaces from './Features/GetGuestWorkspaces';

const makeStore = () => {
return configureStore({
reducer: {
Expand Down Expand Up @@ -116,7 +118,7 @@ const makeStore = () => {
getWorkspaceData:getWorkspaceData,
getOrganizationUsers:getOrganizationUsers,
getProjectDetails:getProjectDetails,

GetGuestWokspaces: GetGuestWokspaces,
},
});
};
Expand Down
1 change: 0 additions & 1 deletion src/Lib/apiTransport/apitransport.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ function apiStatusAsync(progress, errors, message, res = null, unauthrized = fal
function success(res, api, dispatch) {
api.processResponse(res.data);
if (api.type) {
console.log(res,"res",api)

dispatch(dispatchAPIAsync(api));
dispatch(apiStatusAsync(false, false, res.data.message ? res.data.message : api.successMsg, res.data, null, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
super("GET", timeout, false);
this.projectObj = projectObj;
const queryString = radiobutton === "annotation" ? `unassign_tasks/?annotator_id=${annotatorsUser}&annotation_status=["${annotationStatus}"]` : radiobutton === "review"? `unassign_review_tasks/?reviewer_id=${reviewerssUser}&review_status=["${reviewStatus}"]`:`unassign_supercheck_tasks/?superchecker_id=${superCheckUser}&supercheck_status=["${SuperCheckStatus}"]`;
console.log(queryString,"queryStringqueryString")
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getProjects}${projectId}/${queryString}`;
}

Expand Down
1 change: 0 additions & 1 deletion src/app/actions/api/Projects/GetWorkspaceSaveButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
constructor(id,workspaceObj, timeout = 2000) {
super("PUT", timeout, false);
this.workspaceObj = workspaceObj;
console.log(workspaceObj)
// this.type = constants.GET_SAVE_BUTTON;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getWorkspaces}${id}/`;
}
Expand Down
1 change: 0 additions & 1 deletion src/app/actions/api/user/FetchRecentTasksAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

export default class FetchRecentTasksAPI extends API {
constructor(id,task_type, pageNo, filter,countPerPage, timeout = 2000) {
console.log(task_type,"task_typetask_type")
super("GET", timeout, false);
this.taskType = task_type;
this.id = id;
Expand Down
1 change: 1 addition & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ body {
overflow-x: hidden;
}


body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
Expand Down
Loading

0 comments on commit 16d7abe

Please sign in to comment.