Skip to content

Commit

Permalink
Merge pull request #100 from sdslabs/ui-fixes
Browse files Browse the repository at this point in the history
UI fixes
  • Loading branch information
ayanchoudhary authored Oct 9, 2021
2 parents d186778 + 0b881ab commit 1888aee
Show file tree
Hide file tree
Showing 87 changed files with 4,215 additions and 14,091 deletions.
3 changes: 3 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[] generate download link from a utils function

[x] make no activity page
[x] changes in sidebar
[x] fonts and spacing changes
3,918 changes: 2,271 additions & 1,647 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 4 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,12 @@
"node-sass": "^4.13.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"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",
"react-toastify": "^7.0.3",
"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
37 changes: 37 additions & 0 deletions src/actions/adminPanelActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
SWITCH_SUB_MENU,
SWITCH_MAIN_MENU,
SWITCH_TAB,
SET_TABLE_DATA,
RESET_ADMIN_MENU,
TOGGLE_ADMIN_LOADER,
} 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,
});

export const ToggleAdminLoader = (data) => ({
type: TOGGLE_ADMIN_LOADER,
payload: data,
});
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 };
15 changes: 13 additions & 2 deletions src/api/notificationApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,18 @@ function getNewNotification(token) {
}
function deleteNotification(notification) {
return axiosInstance
.delete('/notifications', { params: { notification } })
.delete('/notifications', { params: { notification: notification, userid: 'null' } })
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}
function deleteAllNotifications(userid) {
return axiosInstance
.delete('/notifications', { params: { notification: 'null', userid: userid } })
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
Expand All @@ -40,4 +51,4 @@ function deleteNotification(notification) {
});
}

export { getNewNotification, getAllNotifications, deleteNotification };
export { getNewNotification, getAllNotifications, deleteNotification, deleteAllNotifications };
14 changes: 13 additions & 1 deletion src/api/searchApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,16 @@ function getSearchResults(query) {
});
}

export { getSearchResults };
function getSearchCourseResults(query, dept, user) {
return axiosInstance
.get(`/filtercourse`, { params: { q: query, format: 'json', dept: dept, user: user } })
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

export { getSearchResults, getSearchCourseResults };
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 };
Loading

0 comments on commit 1888aee

Please sign in to comment.