Skip to content

Commit

Permalink
Merge pull request #87 from sdslabs/admin-WIP
Browse files Browse the repository at this point in the history
Admin panel
  • Loading branch information
mhk19 authored Jul 6, 2021
2 parents 4faeef3 + 4cb3aa4 commit 5f1e4f4
Show file tree
Hide file tree
Showing 47 changed files with 15,189 additions and 11,560 deletions.
2 changes: 2 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[] generate download link from a utils function

[x] make no activity page
[x] changes in sidebar
[x] fonts and spacing changes
892 changes: 884 additions & 8 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.11.3",
"@material-ui/icons": "^4.11.2",
"antd": "^4.13.1",
"axios": "^0.19.2",
"jquery": "^3.4.1",
Expand All @@ -17,10 +19,13 @@
"node-sass": "^4.13.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-google-docs-viewer": "^1.0.1",
"react-lottie": "^1.2.3",
"react-redux": "^7.1.1",
"react-router-dom": "^5.0.0",
"react-scripts": "3.0.1",
"react-select": "^4.2.1",
"react-swipeable-views": "^0.13.9",
"redux": "^4.0.4",
"websocket": "^1.0.31"
},
Expand Down
4 changes: 2 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import ErrorPage from 'pages/error';
import MyCourseRouter from 'routers/MyCourseRouter';
import ActivityRouter from 'routers/ActivityRouter';
import DepartmentRouter from 'routers/DepartmentRouter';
import AdminRouter from 'routers/AdminRouter';
import { Router, Switch, Route } from 'react-router-dom';
import { createBrowserHistory } from 'history';
import { getDepartmentsList } from 'api/departmentApi';
import { getUser } from 'utils/getUser';
import { ADD_DEPARTMENTS, RESET_APP } from './constants/action-types';
import { ADD_DEPARTMENTS, RESET_APP } from 'constants/action-types';
import AdminRouter from 'routers/AdminRouter';

function mapStateToProps(state) {
return {
Expand Down
31 changes: 31 additions & 0 deletions src/actions/adminPanelActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {
SWITCH_SUB_MENU,
SWITCH_MAIN_MENU,
SWITCH_TAB,
SET_TABLE_DATA,
RESET_ADMIN_MENU,
} from 'constants/action-types';

export const SwitchMainMenu = (data) => ({
type: SWITCH_MAIN_MENU,
payload: data,
});

export const SwitchSubMenu = (data) => ({
type: SWITCH_SUB_MENU,
payload: data,
});

export const SwitchTab = (data) => ({
type: SWITCH_TAB,
payload: data,
});

export const SetTableData = (data) => ({
type: SET_TABLE_DATA,
payload: data,
});

export const ResetAdminMenu = () => ({
type: RESET_ADMIN_MENU,
});
81 changes: 81 additions & 0 deletions src/api/courseRequestApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { axiosInstance } from './axiosInstance';
import { CONFIG } from 'config/config';
import $ from 'jquery';

function getCourseRequests(token) {
return axiosInstance
.get('/admin/courserequests/', {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
})
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

function approveCourseRequest(id, token) {
return axiosInstance
.put(
'/admin/courserequests',
{ request: id, status: 2 },
{
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
},
)
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

function addCourse(id, token) {
const status = 3;
return $.ajax({
method: 'PUT',
url: `${CONFIG.nexusRoot}/admin/courserequests`,
data: { request: id, status: status },
dataType: 'json',
beforeSend(xhr) {
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
},
}).done((res) => {
return res;
});
}

function rejectCourseRequest(id, token) {
return axiosInstance
.delete('/admin/courserequests', {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
data: {
request: id,
},
})
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

export { getCourseRequests, approveCourseRequest, addCourse, rejectCourseRequest };
87 changes: 87 additions & 0 deletions src/api/fileRequestApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { axiosInstance } from './axiosInstance';
import { CONFIG } from 'config/config';
import $ from 'jquery';

function getFileRequests(token) {
return axiosInstance
.get('/admin/filerequests/', {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
})
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

function approveFileRequest(id, token) {
return axiosInstance
.put(
'/admin/filerequests',
{ request: id, status: 2 },
{
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
},
)
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

function uploadFile(id, file, name, filetype, token) {
const status = 3;
var formData = new FormData();
formData.append('request', id);
formData.append('file', file, name);
formData.append('name', name);
formData.append('filetype', filetype);
formData.append('status', status);
return $.ajax({
method: 'PUT',
url: `${CONFIG.nexusRoot}/admin/filerequests`,
data: formData,
processData: false,
contentType: false,
beforeSend(xhr) {
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
},
}).done((res) => {
return res;
});
}

function rejectFileRequest(id, token) {
return axiosInstance
.delete('/admin/filerequests/', {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
data: {
request: id,
},
})
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}
export { getFileRequests, approveFileRequest, uploadFile, rejectFileRequest };
86 changes: 86 additions & 0 deletions src/api/uploadsApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { axiosInstance } from './axiosInstance';

function getUploads(token) {
return axiosInstance
.get('/admin/uploads/', {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
})
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

function approveUpload(id, token) {
return axiosInstance
.put(
'/admin/uploads',
{ file_id: id, status: 2 },
{
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
},
)
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

function addUpload(id, token) {
return axiosInstance
.put(
'/admin/uploads',
{ upload: id, status: 3 },
{
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
},
)
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

function deleteUpload(id, token) {
return axiosInstance
.delete('/admin/uploads', {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
data: {
upload: id,
},
})
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

export { getUploads, approveUpload, addUpload, deleteUpload };
3 changes: 3 additions & 0 deletions src/assets/approveIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/approve_confirmed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/downloadCloud.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/file_preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/previewIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/rejectIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/reject_confirmed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/assets/reloadIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5f1e4f4

Please sign in to comment.