Commit 264999ab authored by Kaustubh Negi's avatar Kaustubh Negi

28-02-2023

parent dc3703e1
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
], ],
"styles": [ "styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"node_modules/ngx-toastr/toastr.css",
"src/styles.css","node_modules/bootstrap/dist/css/bootstrap.min.css" "src/styles.css","node_modules/bootstrap/dist/css/bootstrap.min.css"
], ],
"scripts": [ "src/assets/js/jquery.min.js", "scripts": [ "src/assets/js/jquery.min.js",
......
...@@ -7426,6 +7426,14 @@ ...@@ -7426,6 +7426,14 @@
"tslib": "^2.3.0" "tslib": "^2.3.0"
} }
}, },
"ngx-toastr": {
"version": "14.0.0",
"resolved": "https://registry.npmjs.org/ngx-toastr/-/ngx-toastr-14.0.0.tgz",
"integrity": "sha512-dnDzSY73pF6FvNyxdh6ftfvXvUg6SU7MAT3orPUCzA77t3ZcFslro06zk4NCA2g67RF7dBwM0OJ/y0SN6fdGYw==",
"requires": {
"tslib": "^2.1.0"
}
},
"nice-napi": { "nice-napi": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz", "resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz",
......
...@@ -32,8 +32,8 @@ const routes: Routes = [ ...@@ -32,8 +32,8 @@ const routes: Routes = [
path:'log',component:LogComponent path:'log',component:LogComponent
}, },
{path:'report',component:ReportComponent}, {path:'report',component:ReportComponent},
{path: "logout",component:LogoutComponent}, {path: "logout",component:LogoutComponent,canActivate:[AuthGuard]},
{path:"testlogout",component:TestLogoutComponent}, {path:"testlogout",component:TestLogoutComponent,canActivate:[AuthGuard]},
{path:"testlogin",component:TestLoginComponent}, {path:"testlogin",component:TestLoginComponent},
{path:"loggedin",component:TestStartedComponent}, {path:"loggedin",component:TestStartedComponent},
{path:"dashboard2",component:Dashboard2Component}, {path:"dashboard2",component:Dashboard2Component},
......
...@@ -50,6 +50,8 @@ import { Td2Component } from './td2/td2.component'; ...@@ -50,6 +50,8 @@ import { Td2Component } from './td2/td2.component';
import { AttendRepComponent } from './attend-rep/attend-rep.component'; import { AttendRepComponent } from './attend-rep/attend-rep.component';
import { NO_ERRORS_SCHEMA } from '@angular/compiler'; import { NO_ERRORS_SCHEMA } from '@angular/compiler';
import { AttendComponent } from './attend/attend.component'; import { AttendComponent } from './attend/attend.component';
import { ToastrModule } from 'ngx-toastr';
// import{name} from './test-dashboard/test-dashboard.component'; // import{name} from './test-dashboard/test-dashboard.component';
import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox';
...@@ -116,7 +118,10 @@ import "bootstrap"; ...@@ -116,7 +118,10 @@ import "bootstrap";
MatTableModule, MatTableModule,
MatTooltipModule, MatTooltipModule,
MatIconModule, MatIconModule,
MatCheckboxModule MatCheckboxModule,
BrowserAnimationsModule,
ToastrModule.forRoot()
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
$('.sub-menu ul').hide();
$(".sub-menu a").click(function () {
$(this).parent(".sub-menu").children("ul").slideToggle("100");
$(this).find(".right").toggleClass("fa-angle-up fa-angle-down");
});
window.onscroll = function() {myFunction()};
var header = document.getElementById("tableheader");
var sticky = header.offsetTop;
function myFunction() {
if (window.pageYOffset > sticky) {
header.classList.add("tablehdfixd");
} else {
header.classList.remove("tablehdfixd");
}
}
\ No newline at end of file
This diff is collapsed.
...@@ -11,9 +11,163 @@ ...@@ -11,9 +11,163 @@
<!-- <div id="MyChart" [highcharts]="chartOptions"></div> --> <!-- <div id="MyChart" [highcharts]="chartOptions"></div> -->
<!-- <div #chart [highcharts]="this.chartOptions" ></div> --> <!-- <div #chart [highcharts]="this.chartOptions" ></div> -->
<div style="width: 600px; height: 600px"> <!-- <div style="width: 600px; height: 600px">
<canvas id="myChart"></canvas> <canvas id="myChart"></canvas>
</div> </div> -->
<div class="dashboard-main">
<div class="calendar-main">
<div class="row">
<div class="col-md-12">
<div class="heading calendar-heading">Attendance Report </div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="attendance-disc">
<ul>
<li class="sat-bg">Saturday</li>
<li class="sun-bg">Sunday</li>
<li class="leav-bg">Leave</li>
<li class="holid-bg">Holidays</li>
<li class="pres-bg">Presents</li>
<li class="halfd-bg">Half Day</li>
<li class="abst-bg">Absent</li>
<li class="travl-bg">Travel</li>
</ul>
</div>
</div>
<div class="col-md-2">
<div class="atd-month">
<select name="month" id="month" class="form-select">
<option value="1">January</option>
<option value="2">Febuary</option>
<option selected="selected" value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
</div>
</div>
<div class="col-md-2">
<div class="atd-month">
<select name="year" id="year" class="form-select">
<option value="2012">2012</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option selected="selected" value="2023">2023</option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="attend-rep-table">
<div class="table-responsive">
<table class="table">
<tbody>
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td class="pres-bg">1</td>
<td class="pres-bg">2</td>
<td class="pres-bg">3</td>
<td class="pres-bg">4</td>
<td class="sat-bg">5</td>
</tr>
<tr>
<td class="sun-bg">6</td>
<td class="pres-bg">7</td>
<td class="pres-bg">8</td>
<td class="pres-bg">9</td>
<td class="abst-bg">10</td>
<td class="pres-bg">11</td>
<td class="sat-bg">12</td>
</tr>
<tr>
<td class="sun-bg">13</td>
<td class="pres-bg">14</td>
<td class="pres-bg">15</td>
<td class="halfd-bg">16</td>
<td class="pres-bg">17</td>
<td class="pres-bg">18</td>
<td class="sat-bg">19</td>
</tr>
<tr>
<td class="sun-bg">20</td>
<td class="pres-bg">21</td>
<td class="travl-bg">22</td>
<td class="pres-bg">23</td>
<td class="pres-bg">24</td>
<td class="leav-bg">25</td>
<td class="sat-bg">26</td>
</tr>
<tr>
<td class="sun-bg">27</td>
<td class="pres-bg">28</td>
<td class="holid-bg">29</td>
<td class="pres-bg">30</td>
<td class="pres-bg">31</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-4">
<div class="cald-month1">
<h4>Month Holidays</h4>
<ul>
<li>Maha Shivratri (01 Mar) , Tuesday</li>
<li>Holi (18 Mar) , Friday</li>
</ul>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -4,7 +4,7 @@ import { Component, OnInit } from '@angular/core'; ...@@ -4,7 +4,7 @@ import { Component, OnInit } from '@angular/core';
@Component({ @Component({
selector: 'app-attend-rep', selector: 'app-attend-rep',
templateUrl: './attend-rep.component.html', templateUrl: './attend-rep.component.html',
styleUrls: ['./attend-rep.component.css'] styleUrls: ['./assets/css/custom.css']
}) })
export class AttendRepComponent implements OnInit { export class AttendRepComponent implements OnInit {
......
...@@ -3,6 +3,8 @@ import { SendDateService } from '../send-date.service'; ...@@ -3,6 +3,8 @@ import { SendDateService } from '../send-date.service';
// import { interval } from 'rxjs'; // import { interval } from 'rxjs';
import { DatePipe } from '@angular/common'; import { DatePipe } from '@angular/common';
import "bootstrap"; import "bootstrap";
import { ToastrService } from 'ngx-toastr';
import { Router } from '@angular/router';
@Component({ @Component({
...@@ -16,8 +18,10 @@ export class AttendComponent implements OnInit { ...@@ -16,8 +18,10 @@ export class AttendComponent implements OnInit {
// constructor(private datePipe: DatePipe) {} // constructor(private datePipe: DatePipe) {}
constructor(private sendDateService: SendDateService){} constructor(private sendDateService: SendDateService, private toastr:ToastrService,private router: Router){}
ngOnInit(): void { ngOnInit(): void {
...@@ -26,23 +30,73 @@ export class AttendComponent implements OnInit { ...@@ -26,23 +30,73 @@ export class AttendComponent implements OnInit {
// const now = new Date(); // const now = new Date();
// this.currentTime = this.datePipe.transform(now, 'hh:mm:ss a'); // this.currentTime = this.datePipe.transform(now, 'hh:mm:ss a');
// }); // });
// const now = new Date();
// const savedStartTime = localStorage.getItem('startTime');
// if (savedStartTime) {
// this.startTime = new Date(savedStartTime);
// const timeDiff = now.getTime() - this.startTime.getTime();
// this.elapsedTime = this.msToTime(timeDiff);
// this.interval = setInterval(() => {
// const timeDiff = new Date().getTime() - this.startTime.getTime();
// this.elapsedTime = this.msToTime(timeDiff);
// }, 1000);
// }
} }
startTime: Date; startTime: Date;
endTime: Date; endTime: Date;
elapsedTime: string; elapsedTime: string;
interval: any; interval: any;
// startTimer() {
// this.startTime = new Date();
// localStorage.setItem('startTime', this.startTime.toString());
// this.interval = setInterval(() => {
// const timeDiff = new Date().getTime() - this.startTime.getTime();
// this.elapsedTime = this.msToTime(timeDiff);
// localStorage.setItem('elapsedTime', this.elapsedTime);
// }, 1000);
// console.log(this.startTime+" From the startTimer() function");
// this.startDay();
// }
// startTimer() {
// const now = new Date();
// this.startTime = localStorage.getItem('startTime') ? new Date(localStorage.getItem('startTime')) : now;
// localStorage.setItem('startTime', this.startTime.toISOString());
// const timeDiff = now.getTime() - this.startTime.getTime();
// this.elapsedTime = this.msToTime(timeDiff);
// this.interval = setInterval(() => {
// const timeDiff = new Date().getTime() - this.startTime.getTime();
// this.elapsedTime = this.msToTime(timeDiff);
// }, 1000);
// this.startDay();
// }
startTimer() { startTimer() {
this.startTime = new Date(); const now = new Date();
const startTimeFromStorage = localStorage.getItem('startTime');
if (startTimeFromStorage) {
this.startTime = new Date(startTimeFromStorage);
} else {
this.startTime = now;
localStorage.setItem('startTime', now.toISOString());
}
this.interval = setInterval(() => { this.interval = setInterval(() => {
const timeDiff = new Date().getTime() - this.startTime.getTime(); const timeDiff = new Date().getTime() - this.startTime.getTime();
this.elapsedTime = this.msToTime(timeDiff); this.elapsedTime = this.msToTime(timeDiff);
}, 1000); }, 1000);
console.log(this.startTime+" From the startTimer() function"); console.log(this.startTime + " From the startTimer() function");
this.startDay(); this.startDay();
} }
stopTimer() { stopTimer() {
...@@ -50,8 +104,10 @@ export class AttendComponent implements OnInit { ...@@ -50,8 +104,10 @@ export class AttendComponent implements OnInit {
console.log(this.endTime+" From the stopTimer() function"); console.log(this.endTime+" From the stopTimer() function");
this.endDay(); this.endDay();
clearInterval(this.interval); clearInterval(this.interval);
// this.endDay(); // this.endDay();
localStorage.removeItem('startTime');
localStorage.removeItem('elapsedTime');
} }
msToTime(duration: number): string { msToTime(duration: number): string {
...@@ -79,6 +135,11 @@ export class AttendComponent implements OnInit { ...@@ -79,6 +135,11 @@ export class AttendComponent implements OnInit {
endDay(){ endDay(){
this.sendDateService.postDate2(this.endTime).subscribe((data)=>{ this.sendDateService.postDate2(this.endTime).subscribe((data)=>{
// localStorage.clear();
this.router.navigate(['logout']);
this.toastr.info('Please Fill your Timesheet');
// this.toastr.success('Logout/Punchout successful');
console.log(data); console.log(data);
}) })
} }
......
<!-- <p>attendance-report works!</p> <!-- <p>attendance-report works!</p>
<p>attendance-report works!</p> --> <p>attendance-report works!</p> -->
<div class="chart-container"> <!-- <div class="chart-container">
<canvas id="MyChart" ></canvas> <canvas id="MyChart" ></canvas>
</div> </div> -->
<p>attendance-report works!</p> <p>attendance-report works!</p>
\ No newline at end of file
...@@ -11,6 +11,8 @@ html, body{ ...@@ -11,6 +11,8 @@ html, body{
text-decoration: none; text-decoration: none;
box-sizing: border-box; box-sizing: border-box;
font-family: 'Poppins', sans-serif; font-family: 'Poppins', sans-serif;
background: #f3f3f3c4;
background-color: #606060;
} }
.login-page { width:100%; } .login-page { width:100%; }
......
...@@ -140,7 +140,8 @@ html, body{ ...@@ -140,7 +140,8 @@ html, body{
body { body {
background:#F2F6F8; background:#f3f3f3c4;
/* background-color: #f3f3f3c4; */
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
...@@ -382,6 +383,9 @@ nav ul li ul li a:hover { ...@@ -382,6 +383,9 @@ nav ul li ul li a:hover {
.atd-table1 .table-responsive table tr th {background: #23384e;color: #fff;font-weight: 400;} .atd-table1 .table-responsive table tr th {background: #23384e;color: #fff;font-weight: 400;}
.atd-table1 .table-responsive table tr td {font-size: 14px;} .atd-table1 .table-responsive table tr td {font-size: 14px;}
:host {
background-color: #f3f3f3c4;
}
......
<div class ="logout-page"> <div class ="logout-page" style = "background-color: #f3f3f3c4;">
<div class = "container"> <div class = "container">
<div class = "row"> <div class = "row">
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
</button> </button>
<button type="reset" (click)="removeInput(i)" class="btn btn-outline-secondary"> <button type="reset" (click)="removeInput(i)" class="btn btn-outline-secondary">
<i class="fa fa-plus" aria-hidden="true"> <i class="fa fa-times" aria-hidden="true">
</i> </i>
</button> </button>
</td> </td>
......
...@@ -3,11 +3,15 @@ import { MatTabsModule } from '@angular/material/tabs'; ...@@ -3,11 +3,15 @@ import { MatTabsModule } from '@angular/material/tabs';
import { MatInputModule } from '@angular/material/input'; import { MatInputModule } from '@angular/material/input';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { ToastrService } from 'ngx-toastr';
import { ElementRef } from '@angular/core';
import { AfterViewInit } from '@angular/core';
import { Router } from '@angular/router';
@Component({ @Component({
selector: 'app-logout', selector: 'app-logout',
templateUrl: './logout.component.html', templateUrl: './logout.component.html',
styleUrls: ['./logout.component.css','./assets/css/font-awesome.min.css'] styleUrls: ['./assets/css/custom.css','./logout.component.css','./assets/css/font-awesome.min.css']
// styleUrls: ['./logout.component.css','./assets/css/bootstrap.min.css', './assets/css/custom.css', './assets/css/font-awesome.min.css'] // styleUrls: ['./logout.component.css','./assets/css/bootstrap.min.css', './assets/css/custom.css', './assets/css/font-awesome.min.css']
}) })
export class LogoutComponent implements OnInit { export class LogoutComponent implements OnInit {
...@@ -26,9 +30,13 @@ export class LogoutComponent implements OnInit { ...@@ -26,9 +30,13 @@ export class LogoutComponent implements OnInit {
minutes_worked: number = 0; minutes_worked: number = 0;
constructor(private http: HttpClient) { } constructor(private http: HttpClient,private router: Router,private toastr: ToastrService,private elementRef: ElementRef) { }
ngOnInit() { ngOnInit() {
this.elementRef.nativeElement.ownerDocument
.body.style.backgroundColor = '#f3f3f3';
this.fetchActivities(); this.fetchActivities();
this.getHours(); this.getHours();
this.getMinutes(); this.getMinutes();
...@@ -72,6 +80,12 @@ fetchActivities() { ...@@ -72,6 +80,12 @@ fetchActivities() {
saveInputs() { saveInputs() {
// Code to save the inputs // Code to save the inputs
if (!this.isValidInput()) {
// Display a toast message using ToastrService
this.toastr.warning('Kindly fill all the fields.', 'Missing Data');
return;
}
console.log(this.inputs); console.log(this.inputs);
this.postInput(); this.postInput();
} }
...@@ -97,6 +111,16 @@ postInput() { ...@@ -97,6 +111,16 @@ postInput() {
}; };
this.http.post(url, {inputs:this.inputs},{headers}).subscribe(response => { this.http.post(url, {inputs:this.inputs},{headers}).subscribe(response => {
console.log(response); console.log(response);
// Clear local storage
localStorage.clear();
// Redirect to testlogin route
this.router.navigate(['testlogin']);
// Show success message
this.toastr.success('Timesheet filled successfully');
this.toastr.success('Logout/Punchout successful');
}, error =>{
console.error(error);
this.toastr.error('Failed to fill timesheet');
}); });
} }
......
...@@ -2,13 +2,14 @@ import { Injectable } from '@angular/core'; ...@@ -2,13 +2,14 @@ import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router'; import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
import {ToastrService} from 'ngx-toastr';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class AuthGuard implements CanActivate { export class AuthGuard implements CanActivate {
constructor(private auth: AuthService, private router : Router){} constructor(private auth: AuthService, private router : Router,private toastr: ToastrService){}
// canActivate(){ // canActivate(){
// if(this.auth.isLoggedin()) // if(this.auth.isLoggedin())
...@@ -21,7 +22,8 @@ export class AuthGuard implements CanActivate { ...@@ -21,7 +22,8 @@ export class AuthGuard implements CanActivate {
if (this.auth.isLoggedin()) { if (this.auth.isLoggedin()) {
return true; return true;
} else { } else {
return this.router.parseUrl('/login'); this.toastr.error('Please Login first to continue');
return this.router.parseUrl('/testlogin');
} }
} }
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<li><a href='#'>Employee Logs</a></li> <li><a href='#'>Employee Logs</a></li>
</ul> --> </ul> -->
<ul [ngClass]="{'shown': isShown1, 'sub-menu-items': true}"> <ul [ngClass]="{'shown': isShown1, 'sub-menu-items': true}">
<li><a>Attendance Details</a></li> <li><a (click)="selectView('attendance_report')">Attendance Details</a></li>
<li><a>Hours Tracked</a></li> <li><a>Hours Tracked</a></li>
<li><a>Timeline</a></li> <li><a>Timeline</a></li>
<li><a>Employee Logs</a></li> <li><a>Employee Logs</a></li>
...@@ -158,8 +158,8 @@ ...@@ -158,8 +158,8 @@
<br> <br>
<li>&nbsp;&nbsp;Rohit Khanna</li> <li>&nbsp;&nbsp;Rohit Khanna</li>
<li><span>rohitkhanna@gmail.com</span></li> <li><span>rohitkhanna@gmail.com</span></li>
<li><a href="#">Profile Setting</a></li> <li><a >Profile Setting</a></li>
<li><button class="dropdown-item" type="button">Log Out</button></li> <li><button class="dropdown-item" type="button" (click)="showSuccess">Log Out</button></li>
</ul> </ul>
</div> </div>
</div> </div>
...@@ -187,6 +187,12 @@ ...@@ -187,6 +187,12 @@
</div> </div>
<div *ngIf="selectedView === 'attendance_report'">
<app-attend-rep></app-attend-rep>
</div>
<!-- <div> <!-- <div>
<app-logout> <app-logout>
</app-logout> </app-logout>
......
import { Component, AfterViewInit,ElementRef,ViewChild} from '@angular/core'; import { Component,OnInit, AfterViewInit,ElementRef,ViewChild} from '@angular/core';
import { FormControl } from '@angular/forms'; import { FormControl } from '@angular/forms';
import * as $ from 'jquery'; import * as $ from 'jquery';
import 'bootstrap'; import 'bootstrap';
import 'popper.js'; import 'popper.js';
import './assets/js/custom.js'; import './assets/js/custom.js';
import {ToastrService} from 'ngx-toastr'
// import 'bootstrap/dist/css/bootstrap.min.css'; // import 'bootstrap/dist/css/bootstrap.min.css';
// import 'bootstrap/dist/js/bootstrap.min.js'; // import 'bootstrap/dist/js/bootstrap.min.js';
...@@ -30,7 +31,7 @@ import 'popper.js/dist/popper.min.js'; ...@@ -30,7 +31,7 @@ import 'popper.js/dist/popper.min.js';
// styleUrls: ['./test-dashboard.component.css', './assets/css/bootstrap.min.css', './assets/css/font-awesome.min.css'] // styleUrls: ['./test-dashboard.component.css', './assets/css/bootstrap.min.css', './assets/css/font-awesome.min.css']
// styleUrls: ['./assets/css/custom.css'] // styleUrls: ['./assets/css/custom.css']
}) })
export class TestDashboardComponent implements AfterViewInit { export class TestDashboardComponent implements OnInit, AfterViewInit {
// @ViewChild('subMenuItems', { static: false }) subMenuItems: ElementRef; // @ViewChild('subMenuItems', { static: false }) subMenuItems: ElementRef;
// @ViewChild('subMenuItems1', { static: false }) subMenuItems1: ElementRef; // @ViewChild('subMenuItems1', { static: false }) subMenuItems1: ElementRef;
// @ViewChild('projectsLink', { static: true }) projectsLink: ElementRef; // @ViewChild('projectsLink', { static: true }) projectsLink: ElementRef;
...@@ -61,6 +62,14 @@ export class TestDashboardComponent implements AfterViewInit { ...@@ -61,6 +62,14 @@ export class TestDashboardComponent implements AfterViewInit {
public isVisible = false; public isVisible = false;
selectedView: string = 'dashboard'; selectedView: string = 'dashboard';
constructor(private toastr: ToastrService) { }
ngOnInit() {
this.showSuccess();
}
toggleSubMenu() { toggleSubMenu() {
this.isShown = !this.isShown; this.isShown = !this.isShown;
} }
...@@ -73,6 +82,7 @@ export class TestDashboardComponent implements AfterViewInit { ...@@ -73,6 +82,7 @@ export class TestDashboardComponent implements AfterViewInit {
// event.preventDefault(); // event.preventDefault();
// this.subMenuItems.nativeElement.classList.toggle('hidden'); // this.subMenuItems.nativeElement.classList.toggle('hidden');
// }); // });
// this.showSuccess();
} }
toggleDashb() { toggleDashb() {
this.showDashb = !this.showDashb; this.showDashb = !this.showDashb;
...@@ -86,6 +96,9 @@ export class TestDashboardComponent implements AfterViewInit { ...@@ -86,6 +96,9 @@ export class TestDashboardComponent implements AfterViewInit {
this.selectedView = view; this.selectedView = view;
} }
showSuccess() {
this.toastr.success('Login', 'Success!');
}
// test code // test code
......
import { TestBed } from '@angular/core/testing';
import { TimerServiceService } from './timer-service.service';
describe('TimerServiceService', () => {
let service: TimerServiceService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(TimerServiceService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class TimerService {
private timer$: Observable<number>;
private timerSubject = new Subject<number>();
private timerId: any;
private startTime: number;
constructor() {
this.timer$ = this.timerSubject.asObservable();
}
startTimer(): void {
this.startTime = Date.now();
this.timerId = setInterval(() => {
const elapsedTime = Date.now() - this.startTime;
this.timerSubject.next(elapsedTime);
}, 1000);
}
stopTimer(): void {
clearInterval(this.timerId);
this.timerSubject.next(0);
}
getTimer(): Observable<number> {
return this.timer$;
}
}
...@@ -2,7 +2,12 @@ ...@@ -2,7 +2,12 @@
/* @import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'); */ /* @import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'); */
html, body { height: 100%; } html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif;background-color: #f3f3f3c4;}
.toast-error {
background-color: #0d6efd;
color: #ffffff;
}
/* body, html { /* body, html {
margin: 0; margin: 0;
......
Markdown is supported
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