Commit 5fe285f2 authored by shyam sathali's avatar shyam sathali
Browse files

project files uploaded..

parent ca8898e9
Showing with 12796 additions and 1 deletion
+12796 -1
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# For the full list of supported browsers by the Angular framework, please see:
# https://angular.io/guide/browser-support
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 1 Chrome version
last 1 Firefox version
last 2 Edge major versions
last 2 Safari major versions
last 2 iOS major versions
Firefox ESR
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.ts]
quote_type = single
[*.md]
max_line_length = off
trim_trailing_whitespace = false
.gitignore 0 → 100644
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events*.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
# Angular
# ToDos
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.0.3.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"cli": {
"analytics": false
},
"version": 1,
"newProjectRoot": "projects",
"projects": {
"to-dos": {
"projectType": "application",
"schematics": {
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/to-dos",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css",
"./node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
"./node_modules/bootstrap/dist/js/bootstrap.min.js"
]
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "to-dos:build:production"
},
"development": {
"browserTarget": "to-dos:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "to-dos:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.css"
],
"scripts": []
}
}
}
}
},
"defaultProject": "to-dos"
}
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage/to-dos'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "to-dos",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "~12.0.3",
"@angular/common": "~12.0.3",
"@angular/compiler": "~12.0.3",
"@angular/core": "~12.0.3",
"@angular/forms": "~12.0.3",
"@angular/platform-browser": "~12.0.3",
"@angular/platform-browser-dynamic": "~12.0.3",
"@angular/router": "~12.0.3",
"bootstrap": "^5.0.0-beta3",
"rxjs": "~6.6.0",
"tslib": "^2.1.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~12.0.3",
"@angular/cli": "~12.0.3",
"@angular/compiler-cli": "~12.0.3",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"jasmine-core": "~3.7.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"typescript": "~4.2.3"
}
}
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AuthenticationComponent } from './authentication/authentication.component';
import { TodoFormComponent } from './todo-form/todo-form.component';
const routes: Routes = [
{path:"", component:TodoFormComponent},
{path:"auth", component:AuthenticationComponent},
{path:":id/edit", component:TodoFormComponent}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
strong{
font-weight: bold;
font-size: 2.4rem;
color: blueviolet;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
\ No newline at end of file
<div class="container">
<div class="row">
<div class="col-xs-12">
<strong>Todo App</strong>
<div class="row">
<div class="col-md-6">
<router-outlet></router-outlet>
</div>
<div class="col-md-6" *ngIf="isLogin">
<b style="color: rgb(187, 20, 187); font-size: 20px;">All Todos</b>
<app-todos></app-todos>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
});
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'to-dos'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
expect(app.title).toEqual('to-dos');
});
it('should render title', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.nativeElement;
expect(compiled.querySelector('.content span').textContent).toContain('to-dos app is running!');
});
});
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Subscription } from 'rxjs';
import { AuthService } from './authentication/auth.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit, OnDestroy{
isLoginSub! : Subscription;
isLogin:boolean = false;
constructor(private authService:AuthService, private router:Router){}
ngOnInit(): void {
this.isLoginSub = this.authService.isLogin.subscribe(isLogin=>{
this.isLogin = isLogin;
console.log(`islogin is: ${isLogin}`);
if(!this.isLogin){
this.router.navigate(["auth"])
}else{
this.router.navigate([""])
}
})
if(!this.isLogin){
this.authService.logout();
}
}
title = 'to-dos';
ngOnDestroy(){
this.isLoginSub.unsubscribe();
}
}
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule} from '@angular/common/http'
import { AppComponent } from './app.component';
import { TodoFormComponent } from './todo-form/todo-form.component';
import { TodosComponent } from './todos/todos.component';
import { LoadingRipleComponent } from './centraldata/loading-indicator/loading-riple.component';
import { AuthenticationComponent } from './authentication/authentication.component';
import { AppRoutingModule } from './app-routing.module';
@NgModule({
declarations: [
AppComponent,
TodoFormComponent,
TodosComponent,
LoadingRipleComponent,
AuthenticationComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
HttpClientModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Subject } from "rxjs";
@Injectable({providedIn:"root"})
export class AuthService{
constructor(private http:HttpClient){}
isLogin : Subject<boolean> = new Subject<boolean>();
login(user:User){
return this.http.post<AuthResponseData>("http://localhost:3000/api/auth/login",user);
}
register(user:User){
return this.http.post<AuthResponseData>("http://localhost:3000/api/auth/register",user);
}
autoLogin(){
let token = localStorage.getItem('token');
if(token){
this.isLogin.next(true)
}else{
this.isLogin.next(false);
}
}
logout(){
console.log("logout");
localStorage.removeItem('token');
this.isLogin.next(false);
}
}
export interface User{
username?:string,
email:String,
password:String
}
export interface AuthResponseData{
message:string,
success:boolean,
token?:string,
data?: User
}
\ No newline at end of file
input.ng-invalid.ng-touched{
border: 2px solid orangered;
}
span{
color: orangered;
}
\ No newline at end of file
<div class="row mt-5">
<div class="col-xs-12">
<div class="border-right-2">
<form #authForm="ngForm" (ngSubmit)="onSubmit()">
<div class="row" *ngIf="!isLoginMode">
<div class="col-xs-5">
<div class="form-group">
<label for="username"> <strong>Username</strong> </label>
<input type="text" class="form-control" id="username" required name="username" ngModel #username="ngModel">
<span *ngIf="username.invalid && username.touched">Please enter your username</span>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-5">
<div class="form-group">
<label for="email"> <strong>Email</strong> </label>
<input type="email" class="form-control" id="email" required name="email" ngModel #email="ngModel">
<span *ngIf="email.invalid && email.touched">Please enter your email</span>
</div>
</div>
</div>
<div class="row mt-2">
<div class="col-xs-12">
<div class="form-group">
<label for="password"> <strong>password</strong> </label>
<input type="password" class="form-control" id="password" required name="password" ngModel #password="ngModel" [minlength]="6" >
<span *ngIf="password.invalid && password.touched">Please enter your password</span>
</div>
</div>
</div>
<div class="row mt-5">
<div class="form-group">
<button class="btn btn-primary" type="submit" [disabled]="authForm.invalid"> {{isLoginMode ? "Login" : "Sign Up"}} </button>
<button class="btn btn-danger mx-3" type="button" (click)= "switchMode()">Swith to {{isLoginMode ? "Sign Up" : "Login"}} </button>
</div>
</div>
</form>
</div>
</div>
</div>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AuthenticationComponent } from './authentication.component';
describe('AuthenticationComponent', () => {
let component: AuthenticationComponent;
let fixture: ComponentFixture<AuthenticationComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AuthenticationComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AuthenticationComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';
import { AuthService } from './auth.service';
@Component({
selector: 'app-authentication',
templateUrl: './authentication.component.html',
styleUrls: ['./authentication.component.css']
})
export class AuthenticationComponent implements OnInit {
@ViewChild('authForm') authForm!:NgForm;
constructor(private authService:AuthService) { }
isLoginMode = true;
ngOnInit(): void {
}
onSubmit(){
// console.log(`IsLogin ${this.isLoginMode}`);
// console.log(this.authForm.value);
//this.authService.isLogin.next(true);
if(this.isLoginMode){
this.authService.login(this.authForm.value).subscribe(responseData=>{
console.log(responseData);
if(responseData.success){
this.authService.isLogin.next(true);
localStorage.setItem('token',responseData.token!)
}else{
console.log(responseData.message);
}
});
}else{
this.isLoginMode=true;
this.authService.register(this.authForm.value).subscribe(responseData=>{
console.log(responseData);
if(responseData.success){
this.authService.isLogin.next(true);
localStorage.setItem('token',responseData.token!)
}else{
console.log(responseData.message);
}
});
}
}
switchMode(){
this.isLoginMode = !this.isLoginMode
}
}
import { HttpClient, HttpParams } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { ResponseData, Todo } from "../todo.service";
@Injectable({providedIn:'root'})
export class DataStoreService{
constructor(private http:HttpClient){}
// saveData(todos:Todo[]){
// this.http.put("https://angulardemo-3a75a-default-rtdb.firebaseio.com/todos.json", todos).subscribe(respData=>{
// console.log(respData);
// })
// }
// fetchData(){
// return this.http.get("https://angulardemo-3a75a-default-rtdb.firebaseio.com/todos.json");
// }
saveTodo(todo:Todo){
return this.http.post<ResponseData>("http://localhost:3000/api/todos/save",todo);
};
fetchAllTodos(){
return this.http.get<ResponseData>("http://localhost:3000/api/todos/all");
}
deleteTodo(id:string){
return this.http.delete<ResponseData>("http://localhost:3000/api/todos/delete/"+id);
}
updateTodo(id:string, updatedTodo:Todo){
return this.http.put<ResponseData>("http://localhost:3000/api/todos/update/"+id, updatedTodo);
}
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment