├── .gitattributes ├── README.md ├── api └── DjangoAPI │ ├── DjangoAPI │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ ├── settings.cpython-39.pyc │ │ ├── urls.cpython-39.pyc │ │ └── wsgi.cpython-39.pyc │ ├── asgi.py │ ├── settings.py │ ├── urls.py │ └── wsgi.py │ ├── EmployeeApp │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-39.pyc │ │ ├── admin.cpython-39.pyc │ │ ├── apps.cpython-39.pyc │ │ ├── models.cpython-39.pyc │ │ ├── serializers.cpython-39.pyc │ │ ├── urls.cpython-39.pyc │ │ └── views.cpython-39.pyc │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ ├── 0001_initial.py │ │ ├── __init__.py │ │ └── __pycache__ │ │ │ ├── 0001_initial.cpython-39.pyc │ │ │ └── __init__.cpython-39.pyc │ ├── models.py │ ├── serializers.py │ ├── tests.py │ ├── urls.py │ └── views.py │ ├── Photos │ └── anonymous.PNG │ ├── db.sqlite3 │ └── manage.py └── ui └── my-app ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── App.css ├── App.js ├── App.test.js ├── Department.js ├── Employee.js ├── Home.js ├── Variables.js ├── index.css ├── index.js ├── logo.svg ├── reportWebVitals.js └── setupTests.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ReactJs-Django-SQLite 2 | 3 | -------------------------------------------------------------------------------- /api/DjangoAPI/DjangoAPI/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/DjangoAPI/__init__.py -------------------------------------------------------------------------------- /api/DjangoAPI/DjangoAPI/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/DjangoAPI/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/DjangoAPI/__pycache__/settings.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/DjangoAPI/__pycache__/settings.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/DjangoAPI/__pycache__/urls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/DjangoAPI/__pycache__/urls.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/DjangoAPI/__pycache__/wsgi.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/DjangoAPI/__pycache__/wsgi.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/DjangoAPI/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for DjangoAPI project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DjangoAPI.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /api/DjangoAPI/DjangoAPI/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for DjangoAPI project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.2.4. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.2/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | import os 15 | 16 | BASE_DIR=Path(__file__).resolve(strict=True).parent.parent 17 | MEDIA_URL='/Photos/' 18 | MEDIA_ROOT=os.path.join(BASE_DIR,"Photos") 19 | 20 | 21 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 22 | BASE_DIR = Path(__file__).resolve().parent.parent 23 | 24 | 25 | # Quick-start development settings - unsuitable for production 26 | # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ 27 | 28 | # SECURITY WARNING: keep the secret key used in production secret! 29 | SECRET_KEY = 'django-insecure-@oxx-o(4f=mxha%-tlv97)x9m7x_fw=(@*k=*29q%r7c8*)%-&' 30 | 31 | # SECURITY WARNING: don't run with debug turned on in production! 32 | DEBUG = True 33 | 34 | ALLOWED_HOSTS = [] 35 | 36 | 37 | # Application definition 38 | 39 | INSTALLED_APPS = [ 40 | 'django.contrib.admin', 41 | 'django.contrib.auth', 42 | 'django.contrib.contenttypes', 43 | 'django.contrib.sessions', 44 | 'django.contrib.messages', 45 | 'django.contrib.staticfiles', 46 | 'rest_framework', 47 | 'corsheaders', 48 | 'EmployeeApp.apps.EmployeeappConfig' 49 | ] 50 | 51 | CORS_ORIGIN_ALLOW_ALL = True 52 | 53 | MIDDLEWARE = [ 54 | 'corsheaders.middleware.CorsMiddleware', 55 | 'django.middleware.security.SecurityMiddleware', 56 | 'django.contrib.sessions.middleware.SessionMiddleware', 57 | 'django.middleware.common.CommonMiddleware', 58 | 'django.middleware.csrf.CsrfViewMiddleware', 59 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 60 | 'django.contrib.messages.middleware.MessageMiddleware', 61 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 62 | ] 63 | 64 | ROOT_URLCONF = 'DjangoAPI.urls' 65 | 66 | TEMPLATES = [ 67 | { 68 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 69 | 'DIRS': [], 70 | 'APP_DIRS': True, 71 | 'OPTIONS': { 72 | 'context_processors': [ 73 | 'django.template.context_processors.debug', 74 | 'django.template.context_processors.request', 75 | 'django.contrib.auth.context_processors.auth', 76 | 'django.contrib.messages.context_processors.messages', 77 | ], 78 | }, 79 | }, 80 | ] 81 | 82 | WSGI_APPLICATION = 'DjangoAPI.wsgi.application' 83 | 84 | 85 | # Database 86 | # https://docs.djangoproject.com/en/3.2/ref/settings/#databases 87 | 88 | DATABASES = { 89 | 'default': { 90 | 'ENGINE': 'django.db.backends.sqlite3', 91 | 'NAME': BASE_DIR / 'db.sqlite3', 92 | } 93 | } 94 | 95 | 96 | # Password validation 97 | # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators 98 | 99 | AUTH_PASSWORD_VALIDATORS = [ 100 | { 101 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 102 | }, 103 | { 104 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 105 | }, 106 | { 107 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 108 | }, 109 | { 110 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 111 | }, 112 | ] 113 | 114 | 115 | # Internationalization 116 | # https://docs.djangoproject.com/en/3.2/topics/i18n/ 117 | 118 | LANGUAGE_CODE = 'en-us' 119 | 120 | TIME_ZONE = 'UTC' 121 | 122 | USE_I18N = True 123 | 124 | USE_L10N = True 125 | 126 | USE_TZ = True 127 | 128 | 129 | # Static files (CSS, JavaScript, Images) 130 | # https://docs.djangoproject.com/en/3.2/howto/static-files/ 131 | 132 | STATIC_URL = '/static/' 133 | 134 | # Default primary key field type 135 | # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field 136 | 137 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 138 | -------------------------------------------------------------------------------- /api/DjangoAPI/DjangoAPI/urls.py: -------------------------------------------------------------------------------- 1 | """DjangoAPI URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path 18 | 19 | from django.conf.urls import url,include 20 | 21 | urlpatterns = [ 22 | path('admin/', admin.site.urls), 23 | url(r'^',include('EmployeeApp.urls')) 24 | ] 25 | -------------------------------------------------------------------------------- /api/DjangoAPI/DjangoAPI/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for DjangoAPI project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DjangoAPI.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/__init__.py -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/__pycache__/admin.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/__pycache__/admin.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/__pycache__/apps.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/__pycache__/apps.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/__pycache__/models.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/__pycache__/models.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/__pycache__/serializers.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/__pycache__/serializers.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/__pycache__/urls.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/__pycache__/urls.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/__pycache__/views.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/__pycache__/views.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class EmployeeappConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'EmployeeApp' 7 | -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.4 on 2021-06-27 04:25 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Departments', 16 | fields=[ 17 | ('DepartmentId', models.AutoField(primary_key=True, serialize=False)), 18 | ('DepartmentName', models.CharField(max_length=500)), 19 | ], 20 | ), 21 | migrations.CreateModel( 22 | name='Employees', 23 | fields=[ 24 | ('EmployeeId', models.AutoField(primary_key=True, serialize=False)), 25 | ('EmployeeName', models.CharField(max_length=500)), 26 | ('Department', models.CharField(max_length=500)), 27 | ('DateOfJoining', models.DateField()), 28 | ('PhotoFileName', models.CharField(max_length=500)), 29 | ], 30 | ), 31 | ] 32 | -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/migrations/__init__.py -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/migrations/__pycache__/0001_initial.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/migrations/__pycache__/0001_initial.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/migrations/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/EmployeeApp/migrations/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | 5 | class Departments(models.Model): 6 | DepartmentId = models.AutoField(primary_key=True) 7 | DepartmentName = models.CharField(max_length=500) 8 | 9 | class Employees(models.Model): 10 | EmployeeId = models.AutoField(primary_key=True) 11 | EmployeeName = models.CharField(max_length=500) 12 | Department = models.CharField(max_length=500) 13 | DateOfJoining = models.DateField() 14 | PhotoFileName = models.CharField(max_length=500) -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/serializers.py: -------------------------------------------------------------------------------- 1 | from rest_framework import serializers 2 | from EmployeeApp.models import Departments,Employees 3 | 4 | class DepartmentSerializer(serializers.ModelSerializer): 5 | class Meta: 6 | model=Departments 7 | fields=('DepartmentId','DepartmentName') 8 | 9 | class EmployeeSerializer(serializers.ModelSerializer): 10 | class Meta: 11 | model=Employees 12 | fields=('EmployeeId','EmployeeName','Department','DateOfJoining','PhotoFileName') -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import url 2 | from EmployeeApp import views 3 | 4 | from django.conf.urls.static import static 5 | from django.conf import settings 6 | 7 | urlpatterns=[ 8 | url(r'^department$',views.departmentApi), 9 | url(r'^department/([0-9]+)$',views.departmentApi), 10 | 11 | url(r'^employee$',views.employeeApi), 12 | url(r'^employee/([0-9]+)$',views.employeeApi), 13 | 14 | url(r'^employee/savefile',views.SaveFile) 15 | ]+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT) -------------------------------------------------------------------------------- /api/DjangoAPI/EmployeeApp/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.views.decorators.csrf import csrf_exempt 3 | from rest_framework.parsers import JSONParser 4 | from django.http.response import JsonResponse 5 | 6 | from EmployeeApp.models import Departments,Employees 7 | from EmployeeApp.serializers import DepartmentSerializer,EmployeeSerializer 8 | 9 | from django.core.files.storage import default_storage 10 | 11 | # Create your views here. 12 | 13 | @csrf_exempt 14 | def departmentApi(request,id=0): 15 | if request.method=='GET': 16 | departments = Departments.objects.all() 17 | departments_serializer=DepartmentSerializer(departments,many=True) 18 | return JsonResponse(departments_serializer.data,safe=False) 19 | elif request.method=='POST': 20 | department_data=JSONParser().parse(request) 21 | departments_serializer=DepartmentSerializer(data=department_data) 22 | if departments_serializer.is_valid(): 23 | departments_serializer.save() 24 | return JsonResponse("Added Successfully",safe=False) 25 | return JsonResponse("Failed to Add",safe=False) 26 | elif request.method=='PUT': 27 | department_data=JSONParser().parse(request) 28 | department=Departments.objects.get(DepartmentId=department_data['DepartmentId']) 29 | departments_serializer=DepartmentSerializer(department,data=department_data) 30 | if departments_serializer.is_valid(): 31 | departments_serializer.save() 32 | return JsonResponse("Updated Successfully",safe=False) 33 | return JsonResponse("Failed to Update") 34 | elif request.method=='DELETE': 35 | department=Departments.objects.get(DepartmentId=id) 36 | department.delete() 37 | return JsonResponse("Deleted Successfully",safe=False) 38 | 39 | @csrf_exempt 40 | def employeeApi(request,id=0): 41 | if request.method=='GET': 42 | employees = Employees.objects.all() 43 | employees_serializer=EmployeeSerializer(employees,many=True) 44 | return JsonResponse(employees_serializer.data,safe=False) 45 | elif request.method=='POST': 46 | employee_data=JSONParser().parse(request) 47 | employees_serializer=EmployeeSerializer(data=employee_data) 48 | if employees_serializer.is_valid(): 49 | employees_serializer.save() 50 | return JsonResponse("Added Successfully",safe=False) 51 | return JsonResponse("Failed to Add",safe=False) 52 | elif request.method=='PUT': 53 | employee_data=JSONParser().parse(request) 54 | employee=Employees.objects.get(EmployeeId=employee_data['EmployeeId']) 55 | employees_serializer=EmployeeSerializer(employee,data=employee_data) 56 | if employees_serializer.is_valid(): 57 | employees_serializer.save() 58 | return JsonResponse("Updated Successfully",safe=False) 59 | return JsonResponse("Failed to Update") 60 | elif request.method=='DELETE': 61 | employee=Employees.objects.get(EmployeeId=id) 62 | employee.delete() 63 | return JsonResponse("Deleted Successfully",safe=False) 64 | 65 | @csrf_exempt 66 | def SaveFile(request): 67 | file=request.FILES['file'] 68 | file_name=default_storage.save(file.name,file) 69 | return JsonResponse(file_name,safe=False) -------------------------------------------------------------------------------- /api/DjangoAPI/Photos/anonymous.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/Photos/anonymous.PNG -------------------------------------------------------------------------------- /api/DjangoAPI/db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/api/DjangoAPI/db.sqlite3 -------------------------------------------------------------------------------- /api/DjangoAPI/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DjangoAPI.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /ui/my-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /ui/my-app/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /ui/my-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my-app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.14.1", 7 | "@testing-library/react": "^11.2.7", 8 | "@testing-library/user-event": "^12.8.3", 9 | "react": "^17.0.2", 10 | "react-dom": "^17.0.2", 11 | "react-router-dom": "^5.2.0", 12 | "react-scripts": "4.0.3", 13 | "web-vitals": "^1.1.2" 14 | }, 15 | "scripts": { 16 | "start": "react-scripts start", 17 | "build": "react-scripts build", 18 | "test": "react-scripts test", 19 | "eject": "react-scripts eject" 20 | }, 21 | "eslintConfig": { 22 | "extends": [ 23 | "react-app", 24 | "react-app/jest" 25 | ] 26 | }, 27 | "browserslist": { 28 | "production": [ 29 | ">0.2%", 30 | "not dead", 31 | "not op_mini all" 32 | ], 33 | "development": [ 34 | "last 1 chrome version", 35 | "last 1 firefox version", 36 | "last 1 safari version" 37 | ] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ui/my-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/ui/my-app/public/favicon.ico -------------------------------------------------------------------------------- /ui/my-app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 14 | 15 | 19 | 20 | 29 | React App 30 | 31 | 32 | 33 |
34 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /ui/my-app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/ui/my-app/public/logo192.png -------------------------------------------------------------------------------- /ui/my-app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArtOfEngineer/ReactJs-Django-SQLite/bfb1c3d99dabe0af6c8876ff0cd030e6341b10a3/ui/my-app/public/logo512.png -------------------------------------------------------------------------------- /ui/my-app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /ui/my-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /ui/my-app/src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ui/my-app/src/App.js: -------------------------------------------------------------------------------- 1 | import logo from './logo.svg'; 2 | import './App.css'; 3 | import {Home} from './Home'; 4 | import {Department} from './Department'; 5 | import {Employee} from './Employee'; 6 | import {BrowserRouter, Route, Switch,NavLink} from 'react-router-dom'; 7 | 8 | function App() { 9 | return ( 10 | 11 |
12 |

13 | React JS Frontend 14 |

15 | 16 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 | ); 44 | } 45 | 46 | export default App; 47 | -------------------------------------------------------------------------------- /ui/my-app/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /ui/my-app/src/Department.js: -------------------------------------------------------------------------------- 1 | import React,{Component} from 'react'; 2 | import {variables} from './Variables.js'; 3 | 4 | export class Department extends Component{ 5 | 6 | constructor(props){ 7 | super(props); 8 | 9 | this.state={ 10 | departments:[], 11 | modalTitle:"", 12 | DepartmentName:"", 13 | DepartmentId:0, 14 | 15 | DepartmentIdFilter:"", 16 | DepartmentNameFilter:"", 17 | departmentsWithoutFilter:[] 18 | } 19 | } 20 | 21 | FilterFn(){ 22 | var DepartmentIdFilter=this.state.DepartmentIdFilter; 23 | var DepartmentNameFilter = this.state.DepartmentNameFilter; 24 | 25 | var filteredData=this.state.departmentsWithoutFilter.filter( 26 | function(el){ 27 | return el.DepartmentId.toString().toLowerCase().includes( 28 | DepartmentIdFilter.toString().trim().toLowerCase() 29 | )&& 30 | el.DepartmentName.toString().toLowerCase().includes( 31 | DepartmentNameFilter.toString().trim().toLowerCase() 32 | ) 33 | } 34 | ); 35 | 36 | this.setState({departments:filteredData}); 37 | 38 | } 39 | 40 | sortResult(prop,asc){ 41 | var sortedData=this.state.departmentsWithoutFilter.sort(function(a,b){ 42 | if(asc){ 43 | return (a[prop]>b[prop])?1:((a[prop]a[prop])?1:((b[prop]{ 54 | this.state.DepartmentIdFilter=e.target.value; 55 | this.FilterFn(); 56 | } 57 | changeDepartmentNameFilter = (e)=>{ 58 | this.state.DepartmentNameFilter=e.target.value; 59 | this.FilterFn(); 60 | } 61 | 62 | refreshList(){ 63 | fetch(variables.API_URL+'department') 64 | .then(response=>response.json()) 65 | .then(data=>{ 66 | this.setState({departments:data,departmentsWithoutFilter:data}); 67 | }); 68 | } 69 | 70 | componentDidMount(){ 71 | this.refreshList(); 72 | } 73 | 74 | changeDepartmentName =(e)=>{ 75 | this.setState({DepartmentName:e.target.value}); 76 | } 77 | 78 | addClick(){ 79 | this.setState({ 80 | modalTitle:"Add Department", 81 | DepartmentId:0, 82 | DepartmentName:"" 83 | }); 84 | } 85 | editClick(dep){ 86 | this.setState({ 87 | modalTitle:"Edit Department", 88 | DepartmentId:dep.DepartmentId, 89 | DepartmentName:dep.DepartmentName 90 | }); 91 | } 92 | 93 | createClick(){ 94 | fetch(variables.API_URL+'department',{ 95 | method:'POST', 96 | headers:{ 97 | 'Accept':'application/json', 98 | 'Content-Type':'application/json' 99 | }, 100 | body:JSON.stringify({ 101 | DepartmentName:this.state.DepartmentName 102 | }) 103 | }) 104 | .then(res=>res.json()) 105 | .then((result)=>{ 106 | alert(result); 107 | this.refreshList(); 108 | },(error)=>{ 109 | alert('Failed'); 110 | }) 111 | } 112 | 113 | 114 | updateClick(){ 115 | fetch(variables.API_URL+'department',{ 116 | method:'PUT', 117 | headers:{ 118 | 'Accept':'application/json', 119 | 'Content-Type':'application/json' 120 | }, 121 | body:JSON.stringify({ 122 | DepartmentId:this.state.DepartmentId, 123 | DepartmentName:this.state.DepartmentName 124 | }) 125 | }) 126 | .then(res=>res.json()) 127 | .then((result)=>{ 128 | alert(result); 129 | this.refreshList(); 130 | },(error)=>{ 131 | alert('Failed'); 132 | }) 133 | } 134 | 135 | deleteClick(id){ 136 | if(window.confirm('Are you sure?')){ 137 | fetch(variables.API_URL+'department/'+id,{ 138 | method:'DELETE', 139 | headers:{ 140 | 'Accept':'application/json', 141 | 'Content-Type':'application/json' 142 | } 143 | }) 144 | .then(res=>res.json()) 145 | .then((result)=>{ 146 | alert(result); 147 | this.refreshList(); 148 | },(error)=>{ 149 | alert('Failed'); 150 | }) 151 | } 152 | } 153 | 154 | render(){ 155 | const { 156 | departments, 157 | modalTitle, 158 | DepartmentId, 159 | DepartmentName 160 | }=this.state; 161 | 162 | return( 163 |
164 | 165 | 172 | 173 | 174 | 175 | 200 | 223 | 226 | 227 | 228 | 229 | {departments.map(dep=> 230 | 231 | 232 | 233 | 254 | 255 | )} 256 | 257 |
176 |
177 | 178 | 179 | 182 | 183 | 189 | 190 | 196 | 197 |
198 | DepartmentId 199 |
201 |
202 | 205 | 206 | 212 | 213 | 219 |
220 | DepartmentName 221 | 222 |
224 | Options 225 |
{dep.DepartmentId}{dep.DepartmentName} 234 | 244 | 245 | 252 | 253 |
258 | 259 | 295 | 296 | 297 |
298 | ) 299 | } 300 | } -------------------------------------------------------------------------------- /ui/my-app/src/Employee.js: -------------------------------------------------------------------------------- 1 | import React,{Component} from 'react'; 2 | import {variables} from './Variables.js'; 3 | 4 | export class Employee extends Component{ 5 | 6 | constructor(props){ 7 | super(props); 8 | 9 | this.state={ 10 | departments:[], 11 | employees:[], 12 | modalTitle:"", 13 | EmployeeId:0, 14 | EmployeeName:"", 15 | Department:"", 16 | DateOfJoining:"", 17 | PhotoFileName:"anonymous.png", 18 | PhotoPath:variables.PHOTO_URL 19 | } 20 | } 21 | 22 | refreshList(){ 23 | 24 | fetch(variables.API_URL+'employee') 25 | .then(response=>response.json()) 26 | .then(data=>{ 27 | this.setState({employees:data}); 28 | }); 29 | 30 | fetch(variables.API_URL+'department') 31 | .then(response=>response.json()) 32 | .then(data=>{ 33 | this.setState({departments:data}); 34 | }); 35 | } 36 | 37 | componentDidMount(){ 38 | this.refreshList(); 39 | } 40 | 41 | changeEmployeeName =(e)=>{ 42 | this.setState({EmployeeName:e.target.value}); 43 | } 44 | changeDepartment =(e)=>{ 45 | this.setState({Department:e.target.value}); 46 | } 47 | changeDateOfJoining =(e)=>{ 48 | this.setState({DateOfJoining:e.target.value}); 49 | } 50 | 51 | addClick(){ 52 | this.setState({ 53 | modalTitle:"Add Employee", 54 | EmployeeId:0, 55 | EmployeeName:"", 56 | Department:"", 57 | DateOfJoining:"", 58 | PhotoFileName:"anonymous.png" 59 | }); 60 | } 61 | editClick(emp){ 62 | this.setState({ 63 | modalTitle:"Edit Employee", 64 | EmployeeId:emp.EmployeeId, 65 | EmployeeName:emp.EmployeeName, 66 | Department:emp.Department, 67 | DateOfJoining:emp.DateOfJoining, 68 | PhotoFileName:emp.PhotoFileName 69 | }); 70 | } 71 | 72 | createClick(){ 73 | fetch(variables.API_URL+'employee',{ 74 | method:'POST', 75 | headers:{ 76 | 'Accept':'application/json', 77 | 'Content-Type':'application/json' 78 | }, 79 | body:JSON.stringify({ 80 | EmployeeName:this.state.EmployeeName, 81 | Department:this.state.Department, 82 | DateOfJoining:this.state.DateOfJoining, 83 | PhotoFileName:this.state.PhotoFileName 84 | }) 85 | }) 86 | .then(res=>res.json()) 87 | .then((result)=>{ 88 | alert(result); 89 | this.refreshList(); 90 | },(error)=>{ 91 | alert('Failed'); 92 | }) 93 | } 94 | 95 | 96 | updateClick(){ 97 | fetch(variables.API_URL+'employee',{ 98 | method:'PUT', 99 | headers:{ 100 | 'Accept':'application/json', 101 | 'Content-Type':'application/json' 102 | }, 103 | body:JSON.stringify({ 104 | EmployeeId:this.state.EmployeeId, 105 | EmployeeName:this.state.EmployeeName, 106 | Department:this.state.Department, 107 | DateOfJoining:this.state.DateOfJoining, 108 | PhotoFileName:this.state.PhotoFileName 109 | }) 110 | }) 111 | .then(res=>res.json()) 112 | .then((result)=>{ 113 | alert(result); 114 | this.refreshList(); 115 | },(error)=>{ 116 | alert('Failed'); 117 | }) 118 | } 119 | 120 | deleteClick(id){ 121 | if(window.confirm('Are you sure?')){ 122 | fetch(variables.API_URL+'employee/'+id,{ 123 | method:'DELETE', 124 | headers:{ 125 | 'Accept':'application/json', 126 | 'Content-Type':'application/json' 127 | } 128 | }) 129 | .then(res=>res.json()) 130 | .then((result)=>{ 131 | alert(result); 132 | this.refreshList(); 133 | },(error)=>{ 134 | alert('Failed'); 135 | }) 136 | } 137 | } 138 | 139 | imageUpload=(e)=>{ 140 | e.preventDefault(); 141 | 142 | const formData=new FormData(); 143 | formData.append("file",e.target.files[0],e.target.files[0].name); 144 | 145 | fetch(variables.API_URL+'employee/savefile',{ 146 | method:'POST', 147 | body:formData 148 | }) 149 | .then(res=>res.json()) 150 | .then(data=>{ 151 | this.setState({PhotoFileName:data}); 152 | }) 153 | } 154 | 155 | render(){ 156 | const { 157 | departments, 158 | employees, 159 | modalTitle, 160 | EmployeeId, 161 | EmployeeName, 162 | Department, 163 | DateOfJoining, 164 | PhotoPath, 165 | PhotoFileName 166 | }=this.state; 167 | 168 | return( 169 |
170 | 171 | 178 | 179 | 180 | 181 | 184 | 187 | 190 | 193 | 196 | 197 | 198 | 199 | {employees.map(emp=> 200 | 201 | 202 | 203 | 204 | 205 | 226 | 227 | )} 228 | 229 |
182 | EmployeeId 183 | 185 | EmployeeName 186 | 188 | Department 189 | 191 | DOJ 192 | 194 | Options 195 |
{emp.EmployeeId}{emp.EmployeeName}{emp.Department}{emp.DateOfJoining} 206 | 216 | 217 | 224 | 225 |
230 | 231 | 297 | 298 | 299 |
300 | ) 301 | } 302 | } -------------------------------------------------------------------------------- /ui/my-app/src/Home.js: -------------------------------------------------------------------------------- 1 | import React,{Component} from 'react'; 2 | 3 | export class Home extends Component{ 4 | render(){ 5 | return( 6 |
7 |

This is Home page

8 |
9 | ) 10 | } 11 | } -------------------------------------------------------------------------------- /ui/my-app/src/Variables.js: -------------------------------------------------------------------------------- 1 | export const variables={ 2 | API_URL:"http://127.0.0.1:8000/", 3 | PHOTO_URL:"http://127.0.0.1:8000/Photos/" 4 | } -------------------------------------------------------------------------------- /ui/my-app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /ui/my-app/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /ui/my-app/src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ui/my-app/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /ui/my-app/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | --------------------------------------------------------------------------------