1 ? { background: '#f5ae33' } : null} //check length of course in slot if greater than 1 then change its background and print the list
20 | className={slot.length > 0 ? 'border' : null}
21 | key={Math.random()}>
22 |
99 | )
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/layer0.config.js:
--------------------------------------------------------------------------------
1 | // This file was automatically added by layer0 init.
2 | // You should commit this file to source control.
3 | // Learn more about this file at https://docs.layer0.co/guides/layer0_config
4 | module.exports = {
5 | backends: {
6 | origin: {
7 | // The domain name or IP address of the origin server
8 | domainOrIp: 'layer0-origin.timetables.cf',
9 |
10 | // When provided, the following value will be sent as the host header when connecting to the origin.
11 | // If omitted, the host header from the browser will be forwarded to the origin.
12 | hostHeader: 'timetables.cf',
13 |
14 | // Uncomment the following line if TLS is not set up properly on the origin domain and you want to ignore TLS errors
15 | // disableCheckCert: true,
16 |
17 | // Overrides the default ports (80 for http and 443 for https) and instead use a specific port
18 | // when connecting to the origin
19 | // port: 1337,
20 | },
21 | },
22 |
23 | // The name of the site in Layer0 to which this app should be deployed.
24 | name: 'timetables.cf',
25 |
26 | // The name of the team in Layer0 to which this app should be deployed.
27 | // team: 'my-team-name',
28 |
29 | // Overrides the default path to the routes file. The path should be relative to the root of your app.
30 | // routes: 'routes.js',
31 |
32 | // The maximum number of URLs that will be concurrently prerendered during deployment when static prerendering is enabled.
33 | // Defaults to 200, which is the maximum allowed value.
34 | // prerenderConcurrency: 200,
35 |
36 | // A list of glob patterns identifying which source files should be uploaded when running layer0 deploy --includeSources.
37 | // This option is primarily used to share source code with Layer0 support personnel for the purpose of debugging. If omitted,
38 | // layer0 deploy --includeSources will result in all files which are not gitignored being uploaded to Layer0.
39 | //
40 | // sources : [
41 | // '**/*', // include all files
42 | // '!(**/secrets/**/*)', // except everything in the secrets directory
43 | // ],
44 |
45 | // Allows you to include additional resources in the bundle that is deployed to Layer0’s serverless JS workers.
46 | // Keys are globs, value can be a boolean or string. This is typically used to ensure that resources
47 | // that need to be dynamically required at runtime such as build manifests for server-side rendering
48 | // or other config files are present in the cloud.
49 | //
50 | // includeFiles: {
51 | // 'lang/**/*': true, // Just includes the specified files
52 | // 'content/**/*': 'another/dir/in/layer0/lambda', // Copies the files into specific directory within Layer0 build
53 | // },
54 |
55 | // Set to true to include all packages listed in the dependencies property of package.json when deploying to Layer0.
56 | // This option generally isn't needed as Layer0 automatically includes all modules imported by your code in the bundle that
57 | // is uploaded during deployment
58 | //
59 | // includeNodeModules: true,
60 | };
61 |
--------------------------------------------------------------------------------
/src/Components/Admin/Admin.js:
--------------------------------------------------------------------------------
1 | import React, { Component } from 'react'
2 | import Dataview from './Dataview';
3 | import Formview from './Formview';
4 | import CourseList from './CourseList';
5 | import { Col, Container, Input, Row } from 'reactstrap';
6 |
7 | class Admin extends Component {
8 | constructor(props) {
9 | super(props)
10 | this.state = {
11 | doc: [],
12 | course: {
13 | key: "",
14 | text: "",
15 | value: "",
16 | code: "",
17 | slots: []
18 | }
19 | }
20 | this.addCourse = this.addCourse.bind(this)
21 | this.deleteCourse = this.deleteCourse.bind(this)
22 | this.editCourse = this.editCourse.bind(this)
23 | this.onCoursechange = this.onCoursechange.bind(this)
24 | }
25 |
26 | componentDidMount() {
27 | document.title = "Admin"
28 | }
29 |
30 | onCoursechange(tag, val) {
31 | const temp = { ...this.state.course }
32 | temp[tag] = val
33 | this.setState({
34 | course: temp
35 | })
36 | }
37 |
38 | addCourse(e) {
39 | e.preventDefault()
40 | let key = 1;
41 | const doc = this.state.doc
42 | if (doc.length > 0)
43 | key = doc[doc.length - 1].key + 1
44 | const course = this.state.course
45 | course.key = key
46 | const temp = this.state.doc.concat(course)
47 |
48 | this.setState({
49 | doc: temp,
50 | course: {
51 | key: "",
52 | text: "",
53 | value: "",
54 | code: "",
55 | slots: []
56 | }
57 | })
58 | }
59 |
60 | deleteCourse(event, key) {
61 | event.preventDefault()
62 | const temp = this.state.doc.filter(course => course.key !== key)
63 | this.setState({
64 | doc: temp
65 | })
66 | }
67 |
68 | editCourse(event, key) {
69 | event.preventDefault();
70 | const temp = this.state.doc.filter(course => course.key === key)[0]
71 | this.deleteCourse(event, key)
72 | this.setState({
73 | course: temp
74 | })
75 |
76 | }
77 | fileHandler = (event) => {
78 | const file = event.target.files[0];
79 | console.log(file);
80 | const reader = new FileReader();
81 | reader.onload = (evt) => {
82 | const a=evt.target.result
83 |
84 | var rows=a.split()
85 | var data={}
86 | console.log(rows.length);
87 | };
88 | reader.readAsBinaryString(file);
89 |
90 | };
91 |
92 | render() {
93 | return (
94 |
95 |
96 |
97 |
102 | {/*
103 |
104 | */}
105 |
106 |
107 |
108 |
109 |
110 |
111 |
This Page is not available for Small Screens
112 |
113 |
114 | )
115 | }
116 | }
117 | export default Admin;
118 |
--------------------------------------------------------------------------------
/src/Components/Chat.js:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import {
3 | FormGroup,
4 | Alert,
5 | PopoverBody,
6 | Form,
7 | Input,
8 | Container,
9 | } from 'reactstrap';
10 | import { Button, Icon } from 'semantic-ui-react';
11 | import { origUrl } from '../shared/baseUrl';
12 | import axios from 'axios';
13 | import { UncontrolledPopover } from 'reactstrap';
14 | import '../App.css';
15 | import { firebaseAnalytics } from '../config/fire';
16 |
17 | function Chat(props) {
18 | const [state, setState] = useState({ message: '', showA: false, type: '' });
19 |
20 | const handleKeyDown = e => {
21 | e.target.style.height = 'inherit';
22 | e.target.style.height = `${Math.min(e.target.scrollHeight + 30, 800)}px`;
23 | // e.target.style.width = `${window.innerWidth / 2 - 40}px`
24 | };
25 |
26 | const showAlert = (type, message) => {
27 | // for showing success message in the chat
28 | setState({ ...state, showA: true, message: message, type: type });
29 | };
30 |
31 | const toggleAlert = () => {
32 | // toggling the success alert
33 | setState({ ...state, showA: !state.showA });
34 | };
35 |
36 | const onSubmit = e => {
37 | e.preventDefault();
38 | // submit the feedback form. sends a request to my flask api with all the data which in turn sends me a mail
39 | const data = {
40 | emailto: 'itissandeep98@gmail.com',
41 | message: state.feedback,
42 | subject: 'TimeTableManager: Message from ' + state.name,
43 | };
44 | axios.get(origUrl + 'sendmail', { params: data }).then(resp => {
45 | showAlert('info', 'Feedback Sent ;)');
46 | });
47 | // props.resetFeedbackform();
48 | firebaseAnalytics.logEvent('feedback_sent');
49 | };
50 |
51 | const onChange = e => {
52 | setState({ ...state, [e.target.name]: e.target.value });
53 | };
54 |
55 | return (
56 |
104 | );
105 | }
106 |
107 | export default Chat;
108 |
--------------------------------------------------------------------------------
/src/Components/TimeTable/Plot.js:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState } from 'react';
2 | import TableData from './Table';
3 | import { Dropdown, Segment } from 'semantic-ui-react';
4 | import { Spinner, Button, Container, Row } from 'reactstrap';
5 | import { baseSchedule } from '../../shared/Schedule';
6 | import '../../App.css';
7 |
8 | function Plot(props) {
9 | const [state, setState] = useState(JSON.parse(JSON.stringify(baseSchedule)));
10 |
11 | useEffect(() => {
12 | updateSchedule();
13 | //eslint-disable-next-line
14 | }, [props.selectedCourses]);
15 |
16 | const findpos = course => {
17 | // finds all the positions of a particular course in the schedule
18 | var schedule = props.schedule['monsoon'];
19 | var pos = [];
20 | for (let i = 1; i <= 5; i++) {
21 | for (let j = 1; j <= 7; j++) {
22 | if (schedule[i.toString()][j.toString()]?.includes(course)) {
23 | pos.push([i, j]);
24 | }
25 | }
26 | }
27 | return pos;
28 | };
29 |
30 | const updateSchedule = () => {
31 | var temp = JSON.parse(JSON.stringify(baseSchedule));
32 |
33 | for (let i = 0; i < props.selectedCourses.length; i++) {
34 | var allpos = findpos(props.selectedCourses[i]); //get all coordinates for a particular course
35 | for (let pos = 0; pos < allpos.length; pos++) {
36 | // update at all the coordinates
37 | var x = allpos[pos][0];
38 | var y = allpos[pos][1];
39 | temp[x][y].push(props.selectedCourses[i]);
40 | }
41 | }
42 | setState(temp);
43 | };
44 |
45 | const handleCourseChange = (event, result) => {
46 | // To handle the changes in the courses list
47 | var { value } = result || event.target;
48 | value = value.filter(course => props.info[course]);
49 |
50 | props.addCourse(value);
51 | };
52 |
53 | const share = () => {
54 | if (navigator.share) {
55 | navigator
56 | .share({
57 | title: 'Time Table Manager',
58 | text: 'My Selected courses',
59 | url: window.location.href,
60 | })
61 | .catch(console.error);
62 | } else {
63 | navigator.clipboard.writeText(`${window.location.href}`);
64 | }
65 | };
66 |
67 | var courselist = null;
68 | if (props.isLoading) {
69 | // Loading Icon in the List until data is fetched
70 | courselist = [
71 | { key: 'loading', value: 'loading', text: , disabled: true },
72 | ];
73 | } else if (props.errmess) {
74 | // Error message in the list if data could not be fetched
75 | courselist = [
76 | {
77 | key: 'error',
78 | value: props.errmess,
79 | text: props.errmess,
80 | onClick: () => window.location.reload(),
81 | },
82 | ];
83 | } else {
84 | courselist = Object.keys(props.info).map(acro => {
85 | const temp = {
86 | key: props.info[acro].id,
87 | text:
88 | props.info[acro].title + ' - ' + props.info[acro].code + ' - ' + acro,
89 | value: acro,
90 | };
91 | return temp;
92 | });
93 | }
94 | return (
95 |
96 |
101 |
106 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
135 |
136 |
137 | );
138 | }
139 |
140 | export default Plot;
141 |
--------------------------------------------------------------------------------
/src/serviceWorker.js:
--------------------------------------------------------------------------------
1 | // This optional code is used to register a service worker.
2 | // register() is not called by default.
3 |
4 | // This lets the app load faster on subsequent visits in production, and gives
5 | // it offline capabilities. However, it also means that developers (and users)
6 | // will only see deployed updates on subsequent visits to a page, after all the
7 | // existing tabs open on the page have been closed, since previously cached
8 | // resources are updated in the background.
9 |
10 | // To learn more about the benefits of this model and instructions on how to
11 | // opt-in, read https://bit.ly/CRA-PWA
12 |
13 | const isLocalhost = Boolean(
14 | window.location.hostname === 'localhost' ||
15 | // [::1] is the IPv6 localhost address.
16 | window.location.hostname === '[::1]' ||
17 | // 127.0.0.0/8 are considered localhost for IPv4.
18 | window.location.hostname.match(
19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
20 | )
21 | );
22 |
23 | export function register(config) {
24 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
25 | // The URL constructor is available in all browsers that support SW.
26 | const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
27 | if (publicUrl.origin !== window.location.origin) {
28 | // Our service worker won't work if PUBLIC_URL is on a different origin
29 | // from what our page is served on. This might happen if a CDN is used to
30 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374
31 | return;
32 | }
33 |
34 | window.addEventListener('load', () => {
35 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
36 |
37 | if (isLocalhost) {
38 | // This is running on localhost. Let's check if a service worker still exists or not.
39 | checkValidServiceWorker(swUrl, config);
40 |
41 | // Add some additional logging to localhost, pointing developers to the
42 | // service worker/PWA documentation.
43 | navigator.serviceWorker.ready.then(() => {
44 | console.log(
45 | 'This web app is being served cache-first by a service ' +
46 | 'worker. To learn more, visit https://bit.ly/CRA-PWA'
47 | );
48 | });
49 | } else {
50 | // Is not localhost. Just register service worker
51 | registerValidSW(swUrl, config);
52 | }
53 | });
54 | }
55 | }
56 |
57 | function registerValidSW(swUrl, config) {
58 | navigator.serviceWorker
59 | .register(swUrl)
60 | .then(registration => {
61 | registration.onupdatefound = () => {
62 | const installingWorker = registration.installing;
63 | if (installingWorker == null) {
64 | return;
65 | }
66 | installingWorker.onstatechange = () => {
67 | if (installingWorker.state === 'installed') {
68 | if (navigator.serviceWorker.controller) {
69 | // At this point, the updated precached content has been fetched,
70 | // but the previous service worker will still serve the older
71 | // content until all client tabs are closed.
72 | console.log(
73 | 'New content is available and will be used when all ' +
74 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
75 | );
76 |
77 | // Execute callback
78 | if (config && config.onUpdate) {
79 | config.onUpdate(registration);
80 | }
81 | } else {
82 | // At this point, everything has been precached.
83 | // It's the perfect time to display a
84 | // "Content is cached for offline use." message.
85 | console.log('Content is cached for offline use.');
86 |
87 | // Execute callback
88 | if (config && config.onSuccess) {
89 | config.onSuccess(registration);
90 | }
91 | }
92 | }
93 | };
94 | };
95 | })
96 | .catch(error => {
97 | console.error('Error during service worker registration:', error);
98 | });
99 | }
100 |
101 | function checkValidServiceWorker(swUrl, config) {
102 | // Check if the service worker can be found. If it can't reload the page.
103 | fetch(swUrl, {
104 | headers: { 'Service-Worker': 'script' },
105 | })
106 | .then(response => {
107 | // Ensure service worker exists, and that we really are getting a JS file.
108 | const contentType = response.headers.get('content-type');
109 | if (
110 | response.status === 404 ||
111 | (contentType != null && contentType.indexOf('javascript') === -1)
112 | ) {
113 | // No service worker found. Probably a different app. Reload the page.
114 | navigator.serviceWorker.ready.then(registration => {
115 | registration.unregister().then(() => {
116 | window.location.reload();
117 | });
118 | });
119 | } else {
120 | // Service worker found. Proceed as normal.
121 | registerValidSW(swUrl, config);
122 | }
123 | })
124 | .catch(() => {
125 | console.log(
126 | 'No internet connection found. App is running in offline mode.'
127 | );
128 | });
129 | }
130 |
131 | export function unregister() {
132 | if ('serviceWorker' in navigator) {
133 | navigator.serviceWorker.ready
134 | .then(registration => {
135 | registration.unregister();
136 | })
137 | .catch(error => {
138 | console.error(error.message);
139 | });
140 | }
141 | }
142 |
--------------------------------------------------------------------------------