Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added analytics page #55

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
509 changes: 504 additions & 5 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,30 @@
"@mui/material": "^5.14.18",
"@mui/styles": "^5.14.18",
"@mui/x-date-pickers-pro": "^6.18.4",
"@react-hook/media-query": "^1.1.1",
"@reduxjs/toolkit": "^2.0.1",
"axios": "^1.6.3",
"date-fns": "^3.2.0",
"chart.js": "^4.4.1",
"date-fns": "^3.3.1",
"firebase": "^10.7.1",
"firebase-auth": "^0.1.2",
"html2canvas": "^1.4.1",
"jspdf": "^2.5.1",
"mui-datatables": "^4.3.0",
"next": "^14.0.4",
"next-redux-wrapper": "^8.1.0",
"react": "^18",
"react-chartjs-2": "^5.2.0",
"react-csv": "^2.2.2",
"react-date-range": "^2.0.0-alpha.4",
"react-dom": "^18",
"react-drag-drop-files": "^2.3.10",
"react-hook": "^0.0.1",
"react-json-tree": "^0.18.0",
"react-markdown": "^9.0.1",
"react-redux": "^9.0.4",
"react-router-dom": "^6.21.2"
"react-router-dom": "^6.21.2",
"recharts": "^2.12.0"
},
"devDependencies": {
"autoprefixer": "^10.4.16",
Expand Down
43 changes: 43 additions & 0 deletions src/Lib/Features/Analytics/getMetaAnalyticsData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"

const initialState = {
data: [],
status: 'idle',
error: null,
};
export const fetchMetaAnalyticsData = createAsyncThunk(
'getMetaAnalyticsData/fetchMetaAnalyticsData',
async ({project_type_filter,progressObj}) => {
let endpoint ;
const body = progressObj
project_type_filter=='AllTypes'?
endpoint = `${ENDPOINTS.getOrganizations}public/${OrgId}/cumulative_tasks_count/?metainfo=true`
:
endpoint = `${ENDPOINTS.getOrganizations}public/${OrgId}/cumulative_tasks_count/?metainfo=true&project_type_filter=${project_type_filter}`
const params = fetchParams(endpoint);
return fetch(params.url, params.options)
.then(response => response.json())
}
);
const getMetaAnalyticsData = createSlice({
name: 'getMetaAnalyticsData',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchMetaAnalyticsData.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchMetaAnalyticsData.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchMetaAnalyticsData.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});
export default getMetaAnalyticsData.reducer;
44 changes: 44 additions & 0 deletions src/Lib/Features/Analytics/getTaskAnalyticsData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
import fetchParams from '../../fetchParams';
import ENDPOINTS from "../../../config/apiendpoint"

const initialState = {
data: [],
status: 'idle',
error: null,
};
export const fetchTaskAnalyticsData = createAsyncThunk(
'getTaskAnalyticsData/fetchTaskAnalyticsData',
async ({project_type_filter,progressObj}) => {
let endpoint ;
const body = progressObj
project_type_filter=='AllTypes'?
endpoint = `${ENDPOINTS.getOrganizations}public/1/cumulative_tasks_count/`
:
endpoint = `${ENDPOINTS.getOrganizations}public/1/cumulative_tasks_count/?project_type_filter=${project_type_filter}`
const params = fetchParams(endpoint);
return fetch(params.url, params.options)
.then(response => response.json())
}
);
const getTaskAnalyticsData = createSlice({
name: 'getTaskAnalyticsData',
initialState,
reducers: {},
extraReducers: (builder) => {
builder
.addCase(fetchTaskAnalyticsData.pending, (state) => {
state.status = 'loading';
})
.addCase(fetchTaskAnalyticsData.fulfilled, (state, action) => {
state.status = 'succeeded';
state.data = action.payload;
})
.addCase(fetchTaskAnalyticsData.rejected, (state, action) => {
state.status = 'failed';
state.error = action.error.message;
});
},
});

export default getTaskAnalyticsData.reducer;
4 changes: 4 additions & 0 deletions 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 getTaskAnalyticsData from './Features/Analytics/getTaskAnalyticsData';
import getMetaAnalyticsData from './Features/Analytics/getMetaAnalyticsData';
import GetGuestWokspaces from './Features/GetGuestWorkspaces';

const makeStore = () => {
Expand Down Expand Up @@ -118,6 +120,8 @@ const makeStore = () => {
getWorkspaceData:getWorkspaceData,
getOrganizationUsers:getOrganizationUsers,
getProjectDetails:getProjectDetails,
getTaskAnalyticsData: getTaskAnalyticsData,
getMetaAnalyticsData: getMetaAnalyticsData,
GetGuestWokspaces: GetGuestWokspaces,
},
});
Expand Down
42 changes: 42 additions & 0 deletions src/app/actions/api/Progress/CumulativeTasks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import API from "../../api";
import ENDPOINTS from "../../../../config/apiendpoint"
import constants from "../../constants";

export default class CumulativeTasksAPI extends API {
constructor(progressObj1, OrgId, metaInfo, timeout = 2000) {
super("POST", timeout, false);
this.progressObj1 = progressObj1;
this.type = constants.CUMULATIVE_TASK_DATA;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getOrganizations}${OrgId}/cumulative_tasks_count/${metaInfo ? "?metainfo=true" : ""}`;
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.CumulativeTasks = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {
return this.progressObj1;
}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization": `JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}

getPayload() {
return this.CumulativeTasks;
}
}

45 changes: 45 additions & 0 deletions src/app/actions/api/Progress/MetaAnalytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import API from "../../api";
import ENDPOINTS from "../../../../config/apiendpoint"
import C from "../../constants";

export default class MetaAnalyticsDataAPI extends API {
constructor(OrgId,project_type_filter,progressObj, timeout = 2000) {
super("GET", timeout, false);
this.progressObj = progressObj;
this.type = C.FETCH_META_ANALYTICS_DATA;
project_type_filter=='AllTypes'?
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getOrganizations}public/${OrgId}/cumulative_tasks_count/?metainfo=true`
:
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getOrganizations}public/${OrgId}/cumulative_tasks_count/?metainfo=true&project_type_filter=${project_type_filter}`
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.fetchMetaAnalyticsData = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {
return this.progressObj;
}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization": `JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}


getPayload() {
return this.fetchMetaAnalyticsData;
}
}
41 changes: 41 additions & 0 deletions src/app/actions/api/Progress/PerformanceAnalytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import API from "../../api";
import ENDPOINTS from "../../../../config/apiendpoint"
import constants from "../../constants";

export default class PerformanceAnalyticsAPI extends API {
constructor(progressObj, OrgId, metaInfo, timeout = 2000) {
super("POST", timeout, false);
this.progressObj = progressObj;
this.type = constants.PERFORMANCE_ANALYTICS_DATA;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getOrganizations}${OrgId}/performance_analytics_data/${metaInfo ? "?metainfo=true" : ""}`;
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.PerformanceAnalytics = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {
return this.progressObj;
}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization": `JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}

getPayload() {
return this.PerformanceAnalytics;
}
}
42 changes: 42 additions & 0 deletions src/app/actions/api/Progress/PeriodicalTasks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import API from "../../api";
import ENDPOINTS from "../../../../config/apiendpoint"
import constants from "../../constants";

export default class PeriodicalTasksAPI extends API {
constructor(progressObj, OrgId, metaInfo, timeout = 2000) {
super("POST", timeout, false);
this.progressObj = progressObj;
this.type = constants.PERODICAL_TASK_DATA;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS. getOrganizations}${OrgId}/periodical_tasks_count/${metaInfo ? "?metainfo=true" : ""}`;
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.PeriodicalTasks = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {
return this.progressObj;
}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization": `JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}

getPayload() {
return this.PeriodicalTasks;
}
}

45 changes: 45 additions & 0 deletions src/app/actions/api/Progress/TaskAnalytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import API from "../../api";
import ENDPOINTS from "../../../../config/apiendpoint"
import C from "../../constants";

export default class TaskAnalyticsDataAPI extends API {
constructor(project_type_filter,progressObj, timeout = 2000) {
super("GET", timeout, false);
this.progressObj = progressObj;
this.type = C.FETCH_TASK_ANALYTICS_DATA;
project_type_filter=='AllTypes'?
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getOrganizations}public/1/cumulative_tasks_count/`
:
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.getOrganizations}public/1/cumulative_tasks_count/?project_type_filter=${project_type_filter}`
}

processResponse(res) {
super.processResponse(res);
if (res) {
this.fetchTaskAnalyticsData = res;
}
}

apiEndPoint() {
return this.endpoint;
}

getBody() {
return this.progressObj;
}

getHeaders() {
this.headers = {
headers: {
"Content-Type": "application/json",
"Authorization": `JWT ${localStorage.getItem('shoonya_access_token')}`
},
};
return this.headers;
}


getPayload() {
return this.fetchTaskAnalyticsData;
}
}
Loading
Loading