Attendance

master
ansariakhtar 6 years ago
parent 2ff9b567aa
commit 2d58a2ab10

@ -1,26 +1,27 @@
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';
import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
const routes: Routes = [
{ path: '', redirectTo: 'authentication/login', pathMatch: 'full' },
{
path: 'authentication', loadChildren: './authentication/authentication.module#AuthenticationPageModule',
data: { preload: true, delay: 1000 }
},
{ path: 'home', loadChildren: './home/home.module#HomePageModule' },
{ path: 'profile', loadChildren: './profile/profile.module#ProfilePageModule' },
{ path: 'vacation-rule', loadChildren: './vacation-rule/vacation-rule.module#VacationRulePageModule' },
{ path: 'accrual-balances', loadChildren: './accrual-balances/accrual-balances.module#AccrualBalancesPageModule' }, { path: 'attendance', loadChildren: './attendance/attendance.module#AttendancePageModule' }
const routes: Routes = [
{ path: '', redirectTo: 'authentication/login', pathMatch: 'full' },
{
path: 'authentication', loadChildren: './authentication/authentication.module#AuthenticationPageModule',
data: { preload: true, delay: 1000 }
},
{ path: 'home', loadChildren: './home/home.module#HomePageModule' },
{ path: 'profile', loadChildren: './profile/profile.module#ProfilePageModule' },
{ path: 'vacation-rule', loadChildren: './vacation-rule/vacation-rule.module#VacationRulePageModule' },
{ path: 'accrual-balances', loadChildren: './accrual-balances/accrual-balances.module#AccrualBalancesPageModule' }
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule { }
];
@NgModule({
imports: [
RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules })
],
exports: [RouterModule]
})
export class AppRoutingModule { }

@ -9,6 +9,8 @@ import { StatusBar } from '@ionic-native/status-bar/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ZBar } from '@ionic-native/zbar/ngx';
import { Geolocation } from '@ionic-native/geolocation/ngx';
@NgModule({
declarations: [AppComponent],
entryComponents: [],
@ -24,6 +26,8 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
providers: [
StatusBar,
SplashScreen,
ZBar,
Geolocation,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]

@ -0,0 +1,33 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { Routes, RouterModule } from '@angular/router';
import { IonicModule } from '@ionic/angular';
import { AttendancePage } from './attendance.page';
import { HomeComponent } from './home/home.component';
const routes: Routes = [
{
path: '',
component: AttendancePage,
children: [
{
path: 'home',
component: HomeComponent
}
]
}
];
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
RouterModule.forChild(routes)
],
declarations: [AttendancePage, HomeComponent]
})
export class AttendancePageModule {}

@ -0,0 +1,5 @@
<ion-content>
<ion-router-outlet></ion-router-outlet>
</ion-content>

@ -0,0 +1,27 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AttendancePage } from './attendance.page';
describe('AttendancePage', () => {
let component: AttendancePage;
let fixture: ComponentFixture<AttendancePage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AttendancePage ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AttendancePage);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,16 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-attendance',
templateUrl: './attendance.page.html',
styleUrls: ['./attendance.page.scss'],
})
export class AttendancePage implements OnInit {
constructor() { }
ngOnInit() {
}
}

@ -0,0 +1,11 @@
<ion-header>
<ion-toolbar class="header-toolbar">
<ion-buttons slot="start">
<ion-back-button color="light" class="btnBack" defaultHref="/home"></ion-back-button>
</ion-buttons>
<ion-title color="light" >{{ts.trPK('attendance','attendance')}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content padding>
</ion-content>

@ -0,0 +1,27 @@
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HomeComponent } from './home.component';
describe('HomeComponent', () => {
let component: HomeComponent;
let fixture: ComponentFixture<HomeComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ HomeComponent ],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(HomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

@ -0,0 +1,51 @@
import { Component, OnInit } from '@angular/core';
import { Geolocation } from '@ionic-native/geolocation/ngx';
import { ZBar, ZBarOptions } from '@ionic-native/zbar/ngx';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss'],
})
export class HomeComponent implements OnInit {
zbarOptions:any;
scannedResult:any;
lat : any;
longt : any;
constructor(private zbar: ZBar, private geolocation: Geolocation) {
this.zbarOptions = {
flash: 'off',
drawSight: false
}
console.log("your currnt location is");
this.geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
console.log(resp.coords.latitude);
console.log(resp.coords.longitude);
}).catch((error) => {
console.log('Error getting location', error);
});
this.scanCode();
}
ngOnInit() {}
onClick()
{
this.scanCode();
}
scanCode(){
this.zbar.scan(this.zbarOptions)
.then(result => {
console.log(result); // Scanned code
this.scannedResult = result;
})
.catch(error => {
alert(error); // Error message
});
}
}

@ -1,7 +1,7 @@
<ion-header>
<ion-toolbar class="header-toolbar">
<ion-buttons slot="start">
<ion-back-button color="light" class="btnBack" ></ion-back-button>
<ion-back-button color="light" class="btnBack" defaultHref="/home"></ion-back-button>
</ion-buttons>
<ion-title color="light" > {{'changePassword,changePassword' | translate}}</ion-title>
</ion-toolbar>

@ -121,6 +121,7 @@ export class ConnectorService {
if (!this.cs.validResponse(result)) {
// not authorized
console.log(result.MessageStatus);
console.log("erroe")
if (result.ErrorType === 2) {
//console.log("error expired");
} else {

@ -6,6 +6,12 @@ import { AuthenticatedUser } from "src/app/hmg-common/services/authentication/mo
import { MenuService } from "src/app/hmg-common/services/menu/menuservice.service";
import { MenuResponse } from "src/app/hmg-common/services/menu/models/menu-response";
import { CommonService } from "src/app/hmg-common/services/common/common.service";
import { Geolocation } from '@ionic-native/geolocation/ngx';
import { ZBar, ZBarOptions } from '@ionic-native/zbar/ngx';
import { Device } from '@ionic-native/device/ngx';
import { attendanceSwipeScannerRequest } from './models/attendanceSwipe.Request';
import { Response } from "src/app/hmg-common/services/models/response";
import { AttendanceService } from './services/attendance.services';
@Component({
selector: "app-home",
@ -16,18 +22,49 @@ export class HomePage implements OnInit {
userData: any = {};
user_image: any = "../assets/imgs/profile.png";
menuList: any = [];
zbarOptions:any;
scannedResult:any;
lat : any;
longt : any;
deviceID: string;
constructor(
public ts: TranslatorService,
public menu: MenuController,
public authService: AuthenticationService,
public menuService: MenuService,
public common: CommonService,
public events:Events
) {}
public events:Events,
private device: Device,
private zbar: ZBar,
private geolocation: Geolocation,
private attendance_service:AttendanceService
) {
}
ngOnInit() {
this.getUserDetails();
this.getMenu();
this.geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
console.log(resp.coords.latitude);
console.log(resp.coords.longitude);
}).catch((error) => {
console.log('Error getting location', error);
});
}
ionViewDidLoad()
{
this.geolocation.getCurrentPosition().then((resp) => {
// resp.coords.latitude
// resp.coords.longitude
console.log(resp.coords.latitude);
console.log(resp.coords.longitude);
}).catch((error) => {
console.log('Error getting location', error);
});
}
private openMenu() {
this.menu.toggle();
@ -68,4 +105,52 @@ export class HomePage implements OnInit {
private Change_password(){
this.common.openChangePassword();
}
private attendance(){
this.zbarOptions = {
flash: 'off',
drawSight: false
}
console.log("your currnt location is");
this.scanCode();
}
scanCode(){
this.zbar.scan(this.zbarOptions)
.then(result => {
console.log(result); // Scanned code
let strResult = JSON.parse(result);
console.log(strResult.QRValue);
this.scannedResult = result;
this.deviceID = this.device.uuid;
this.swipeAttendance();
})
.catch(error => {
alert(error); // Error message
});
}
swipeAttendance(){
let request: attendanceSwipeScannerRequest = new attendanceSwipeScannerRequest();
request.Latitude = this.lat;
request.Longitude = this.longt;
request.QRValue = this.scannedResult;
request.UID = this.deviceID;
request.UserName = this.userData.EMPLOYEE_NUMBER;
console.log("request");
console.log(JSON.stringify(request));
this.attendance_service.attendanceSwipeScanner(
request,()=>{
console.log("Error inside in swipe attendance");
}).
subscribe((result: Response) => {
if (this.common.validResponse(result)) {
console.log("response");
console.log(result);
this.common.presentAlert(this.ts.trPK('home', 'swipeAlertSuccess'));
} else {
this.common.presentAlert(this.ts.trPK('home', 'swipeAlertFailed'));
}
});
}
}

@ -0,0 +1,23 @@
import { Request } from 'src/app/hmg-common/services/models/request';
export class attendanceSwipeScannerRequest extends Request{
public static SHARED_DATA = 'attendanceSwipeScanner-request';
public P_USER_NAME:string;
public P_PASSWORD: string;
public UserName: string;
public CompanyID:number;
public BranchID: number;
public UID:string;
public Latitude:number;
public Longitude:number;
public QRValue: string;
public MemberID:number;
public EmployeeID: number;
public IPAdress: string;
public UserID: string;
}

@ -0,0 +1,20 @@
import { Injectable } from "@angular/core";
import { Observable } from "rxjs";
import { ConnectorService } from "src/app/hmg-common/services/connector/connector.service";
import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service";
import { attendanceSwipeScannerRequest } from '../models/attendanceSwipe.Request';
@Injectable({
providedIn: "root"
})
export class AttendanceService {
public AttendanceSwipeURL : string ='Services/SWP.svc/REST/AuthenticateAndSwipeUser';
constructor(
public con: ConnectorService,
public authService: AuthenticationService
) {}
public attendanceSwipeScanner(attendanceSwipeScanner: attendanceSwipeScannerRequest, onError?: any, errorLabel?: string): Observable<any> {
const request = attendanceSwipeScanner;
this.authService.authenticateRequest(request);
return this.con.post(this.AttendanceSwipeURL,request,onError,errorLabel);
}
}
Loading…
Cancel
Save