Skip to content

Commit

Permalink
Page navigation Enh
Browse files Browse the repository at this point in the history
Page navigation
  • Loading branch information
AnsahMohammad authored Sep 13, 2023
2 parents d9e2f6b + 71a5702 commit 3a8709a
Show file tree
Hide file tree
Showing 67 changed files with 192 additions and 56 deletions.
Empty file modified .eslintrc.json
100644 → 100755
Empty file.
Empty file modified .github/workflows/django.yml
100644 → 100755
Empty file.
Empty file modified .github/workflows/pylint.yml
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified StudySenseAILogo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/dashboard.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/shot1.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified assets/shot2.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified client.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ cd ../studySenseClient
# npm install bootstrap
# npm install react-pdf @react-pdf/renderer
# npm install semantic-ui-react semantic-ui-css
npm install react-apexcharts apexcharts
# npm install react-apexcharts apexcharts
npm install
npm run dev -- --port 5173
18 changes: 9 additions & 9 deletions package-lock.json
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified package.json
100644 → 100755
Empty file.
Empty file modified requirements-dev.txt
100644 → 100755
Empty file.
Empty file modified requirements.txt
100644 → 100755
Empty file.
Empty file modified studySenseClient/credits.md
100644 → 100755
Empty file.
Empty file modified studySenseClient/index.html
100644 → 100755
Empty file.
Empty file modified studySenseClient/logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 43 additions & 31 deletions studySenseClient/package-lock.json
100644 → 100755

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions studySenseClient/package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
},
"dependencies": {
"@react-pdf/renderer": "^3.1.12",
"apexcharts": "^3.41.0",
"bootstrap": "^5.3.0",
"mdb-react-ui-kit": "^6.1.0",
"apexcharts": "^3.42.0",
"bootstrap": "^5.3.1",
"mdb-react-ui-kit": "^6.2.0",
"mdb-ui-kit": "^6.4.0",
"react": "^18.2.0",
"react-apexcharts": "^1.4.0",
"react-apexcharts": "^1.4.1",
"react-cookie": "^4.1.1",
"react-dom": "^18.2.0",
"react-pdf": "^7.1.2",
"react-pdf": "^7.3.3",
"react-router-dom": "^6.13.0",
"semantic-ui-css": "^2.5.0",
"semantic-ui-react": "^2.1.4",
Expand Down
Empty file modified studySenseClient/src/App.jsx
100644 → 100755
Empty file.
Empty file modified studySenseClient/src/Assets/cover.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified studySenseClient/src/Assets/login.jpeg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified studySenseClient/src/Assets/register.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified studySenseClient/src/Graph.jsx
100644 → 100755
Empty file.
Empty file modified studySenseClient/src/LoginPage.jsx
100644 → 100755
Empty file.
16 changes: 16 additions & 0 deletions studySenseClient/src/Menu.jsx
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const SelectedItem = ({ selectedItem, selectedPDFUrl, goHome }) => {
const [zoom, setZoom] = useState(1.8);
const [startTime, setStartTime] = useState(null);
const [endTime, setEndTime] = useState(null);
const [targetPage, setTargetPage] = useState(currentPage);
const cookies = new Cookies();
const user = cookies.get("user");
const PDFUrl = "http://localhost:8000" + selectedPDFUrl;
Expand Down Expand Up @@ -105,6 +106,12 @@ const SelectedItem = ({ selectedItem, selectedPDFUrl, goHome }) => {
setEndTime(new Date());
};

const handlePageNavigation = (targetPage) => {
if (targetPage >= 1 && targetPage <= numPages) {
setCurrentPage(targetPage);
}
};

useEffect(() => {
if (endTime !== null) {
const totalTime = endTime - startTime;
Expand Down Expand Up @@ -160,6 +167,15 @@ const SelectedItem = ({ selectedItem, selectedPDFUrl, goHome }) => {
<button onClick={goToNextPage} disabled={currentPage === numPages}>
Next
</button>
<MDBInput
type="number"
value={targetPage}
onChange={(e) => setTargetPage(parseInt(e.target.value))}
/>
<span>
<button onClick={() => handlePageNavigation(targetPage)}>Go</button>
</span>

<button onClick={handleFinishReading}>Finish Reading</button>
</div>
<div className="pdf-container" style={{ border: "1px solid #ccc" }}>
Expand Down
Empty file modified studySenseClient/src/Register.jsx
100644 → 100755
Empty file.
Empty file modified studySenseClient/src/Styling/App.css
100644 → 100755
Empty file.
Empty file modified studySenseClient/src/Styling/Charts.css
100644 → 100755
Empty file.
Empty file modified studySenseClient/src/Styling/Login.css
100644 → 100755
Empty file.
Empty file modified studySenseClient/src/Styling/Menu.css
100644 → 100755
Empty file.
Empty file modified studySenseClient/src/Styling/page.css
100644 → 100755
Empty file.
Empty file modified studySenseClient/src/main.jsx
100644 → 100755
Empty file.
Empty file modified studySenseClient/vite.config.js
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file modified study_sense/__init__.py
100644 → 100755
Empty file.
Empty file modified study_sense/client_worker/__init__.py
100644 → 100755
Empty file.
Empty file modified study_sense/client_worker/apps.py
100644 → 100755
Empty file.
Empty file modified study_sense/client_worker/models.py
100644 → 100755
Empty file.
Empty file modified study_sense/client_worker/serializers.py
100644 → 100755
Empty file.
Empty file modified study_sense/client_worker/tests.py
100644 → 100755
Empty file.
Empty file modified study_sense/client_worker/urls.py
100644 → 100755
Empty file.
Empty file modified study_sense/client_worker/views.py
100644 → 100755
Empty file.
Empty file modified study_sense/gunicorn_config.py
100644 → 100755
Empty file.
Empty file modified study_sense/manage.py
100644 → 100755
Empty file.
Empty file modified study_sense/static/images/favicon.ico
100644 → 100755
Empty file.
Empty file modified study_sense/static/images/logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified study_sense/study_sense/__init__.py
100644 → 100755
Empty file.
Empty file modified study_sense/study_sense/asgi.py
100644 → 100755
Empty file.
Empty file modified study_sense/study_sense/settings.py
100644 → 100755
Empty file.
Empty file modified study_sense/study_sense/urls.py
100644 → 100755
Empty file.
Empty file modified study_sense/study_sense/wsgi.py
100644 → 100755
Empty file.
Empty file modified study_sense/tracker/__init__.py
100644 → 100755
Empty file.
Empty file modified study_sense/tracker/admin.py
100644 → 100755
Empty file.
Empty file modified study_sense/tracker/apps.py
100644 → 100755
Empty file.
Empty file modified study_sense/tracker/models.py
100644 → 100755
Empty file.
Empty file modified study_sense/tracker/serializers.py
100644 → 100755
Empty file.
Empty file modified study_sense/tracker/templates/display.html
100644 → 100755
Empty file.
Empty file modified study_sense/tracker/templates/home.html
100644 → 100755
Empty file.
10 changes: 0 additions & 10 deletions study_sense/tracker/tests.py

This file was deleted.

Binary file added study_sense/tracker/tests/test.pdf
Binary file not shown.
118 changes: 118 additions & 0 deletions study_sense/tracker/tests/test_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"""
Unittest for Tracker Model
"""
from django.test import TestCase
from django.contrib.auth.models import User
from tracker.models import Category, Book, TimeTracking
from datetime import datetime, timedelta


class CategoryModelTestCase(TestCase):
"""category model test"""
def setUp(self):
"""set up"""
self.user = User.objects.create(username='testuser')
self.category = Category.objects.create(
name='Test Category',
total_time=0,
user=self.user
)

def test_category_name(self):
"""Test the name field of the Category model"""
self.assertEqual(self.category.name, 'Test Category')

def test_category_total_time(self):
"""Test the total_time field of the Category model"""
self.assertEqual(self.category.total_time, 0)

def test_category_user(self):
"""Test the user field of the Category model"""
self.assertEqual(self.category.user, self.user)


class BookModelTestCase(TestCase):
"""Unittest class"""
def setUp(self):
"""seting up tests"""
self.user = User.objects.create(username='testuser')
self.category = Category.objects.create(
name='Test Category',
total_time=0,
user=self.user
)
self.book = Book.objects.create(
name='Test Book',
category=self.category,
file='test.pdf',
total_time=0,
user=self.user
)

def test_book_name(self):
"""Test the name field of the Book model"""
self.assertEqual(self.book.name, 'Test Book')

def test_book_category(self):
"""Test the category field of the Book model"""
self.assertEqual(self.book.category, self.category)

def test_book_file(self):
"""Test the file field of the Book model"""
self.assertEqual(self.book.file, 'test.pdf')

def test_book_total_time(self):
"""Test the total_time field of the Book model"""
self.assertEqual(self.book.total_time, 0)

def test_book_user(self):
"""Test the user field of the Book model"""
self.assertEqual(self.book.user, self.user)


class TimeTrackingModelTestCase(TestCase):
"""Unittest class"""
def setUp(self):
"""seting up tests"""
self.user = User.objects.create(username='testuser')
self.category = Category.objects.create(
name='Test Category',
total_time=0,
user=self.user
)
self.book = Book.objects.create(
name='Test Book',
category=self.category,
file='test.pdf',
total_time=0,
user=self.user
)
self.start_time = datetime.now()
self.end_time = self.start_time + timedelta(hours=1)
self.time_tracking = TimeTracking.objects.create(
user=self.user,
book=self.book,
start_time=self.start_time,
end_time=self.end_time,
total_time=timedelta(hours=1)
)

def test_time_tracking_user(self):
"""Test the user field of the TimeTracking model"""
self.assertEqual(self.time_tracking.user, self.user)

def test_time_tracking_book(self):
"""Test the book field of the TimeTracking model"""
self.assertEqual(self.time_tracking.book, self.book)

def test_time_tracking_start_time(self):
"""Test the start_time field of the TimeTracking model"""
self.assertEqual(self.time_tracking.start_time, self.start_time)

def test_time_tracking_end_time(self):
"""Test the end_time field of the TimeTracking model"""
self.assertEqual(self.time_tracking.end_time, self.end_time)

def test_time_tracking_total_time(self):
"""Test the total_time field of the TimeTracking model"""
self.assertEqual(self.time_tracking.total_time, timedelta(hours=1))
Empty file modified study_sense/tracker/urls.py
100644 → 100755
Empty file.
Empty file modified study_sense/tracker/views.py
100644 → 100755
Empty file.

0 comments on commit 3a8709a

Please sign in to comment.