Skip to content

Commit

Permalink
Merge pull request #349 from Yatinaik/dev
Browse files Browse the repository at this point in the history
telemetry program added
  • Loading branch information
htvenkatesh authored Sep 12, 2023
2 parents 39ef8f1 + b0bcfbb commit a5872ae
Show file tree
Hide file tree
Showing 38 changed files with 1,539 additions and 20 deletions.
18 changes: 18 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ if (environment.loginNeeded) {
(module) => module.DashboardModule
)
},
{
path: 'telemetry',
loadChildren: () =>
import('./views/telemetry/telemetry.module').then(
(module) => module.TelemetryModule
),
canLoad: [AuthGuard],
data: { nameSpace: 'telemetry' }
},
{
path: 'teacher-attendance',
loadChildren: () =>
Expand Down Expand Up @@ -168,6 +177,15 @@ else {
// (module) => module.StudentAttendanceModule
// )
// },
{
path: 'telemetry',
loadChildren: () =>
import('./views/telemetry/telemetry.module').then(
(module) => module.TelemetryModule
),
canLoad: [AuthGuard],
data: { nameSpace: 'telemetry' }
},
{
path: 'teacher-attendance',
loadChildren: () =>
Expand Down
7 changes: 4 additions & 3 deletions src/app/core/config/configMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {config as ncf } from '../../views/ncf/config/ncf_config';
import {config as quiz} from '../../views/ncert-quiz/config/quiz_config';
import{config as microImprovement} from '../../views/micro-improvements/config/microimprovements_config';
import {config as nipunBharatConfig } from '../../views/nipun-bharat/config/nipun_bharat_config';


import { config as telemetryConfig} from '../../views/telemetry/config/telemetry_config';

export const configFiles = {
std_att: studentAttendaceConfig,
Expand All @@ -33,7 +32,9 @@ export const configFiles = {
ncf:ncf,
quiz:quiz,
micro_improvements:microImprovement,
nipun_bharat:nipunBharatConfig
nipun_bharat:nipunBharatConfig,
telemetry:telemetryConfig

};

export const programFolderNames = {
Expand Down
3 changes: 2 additions & 1 deletion src/app/core/guards/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivate, CanLoad, Route, Router, RouterStateSnapshot, UrlSegment, UrlTree } from '@angular/router';
import { Observable } from 'rxjs';
import { AuthenticationService } from '../services/authentication.service';
import { environment } from 'src/environments/environment';

@Injectable({
providedIn: 'root'
Expand All @@ -18,7 +19,7 @@ export class AuthGuard implements CanActivate, CanLoad {
if(allowedUser && !userRoles?.includes(allowedUser) ) {
programAccess = false;
}
return programAccess && this.isUserLoggedIn();
return programAccess && this.isUserLoggedIn() && environment.config === 'VSK';
}

canLoad(
Expand Down
3 changes: 2 additions & 1 deletion src/app/core/services/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ export class DataService {
},
ticks: {
callback: function (value, index, values) {
if (type !== 'horizontal') {
console.log(value);
if (type !== 'horizontal' && typeof value == 'string') {
let newValue = value?.split('_').map((word: any) => word[0].toUpperCase() + word.substring(1)).join(' ')
if (screen.width <= 768) {
return newValue.substr(0, 8) + '...';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export class TimeSeriesFilterPanelComponent implements OnInit {
prevStartDate: any;
prevEndDate: any;

constructor(private formBuilder: FormBuilder) {
constructor(private formBuilder: FormBuilder) {}


ngOnInit(): void {
let startDate, endDate;
this.range = this.formBuilder.group({
start: [startDate],
Expand All @@ -45,11 +48,6 @@ export class TimeSeriesFilterPanelComponent implements OnInit {
}, 100);
}
});

}


ngOnInit(): void {
}

private emitTimeSeriesUpdated(startDate: any, endDate: any): void {
Expand Down
17 changes: 13 additions & 4 deletions src/app/views/authentication/pages/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ export class LoginComponent implements OnInit {
async ngOnInit(): Promise<void> {
let uiConfig = config;
this.loginObj = uiConfig['loginObj'];
if(this.loginObj?.title === 'State Vidya Samiksha Kendra' && environment.config === 'NVSK') {
if (this.loginObj?.title === 'State Vidya Samiksha Kendra' && environment.config === 'NVSK') {
this.loginObj.title = 'NDEAR Vidya Samiksha Kendra'
}

let user = localStorage.getItem('user_roles')?.includes('private_user') ? 'private' : 'public'
if(user === 'public') {
if (user === 'public') {
localStorage.clear()
}

Expand Down Expand Up @@ -123,7 +123,16 @@ export class LoginComponent implements OnInit {
let results = await this._commonService.getUserAttributes(userId).toPromise();
let preferences = results?.['details']
let selectedRole = preferences?.['selectedRole']
if(preferences && preferences['selectedRole'] && (preferences['selectedRole'] == 1 || Object.keys(preferences).includes(String(selectedRole)))) {
if (userRoles.includes('admin')) {
this.preferences = { role: environment.config === 'VSK' ? 1 : 0, }
this.setStateDetails(this.preferences)
this.router.navigate(['/summary-statistics']);
}
else if(environment.config === 'NVSK') {
this.setStateDetails({})
this.router.navigate(['/summary-statistics']);
}
else if (preferences && preferences['selectedRole'] && (preferences['selectedRole'] == 1 || Object.keys(preferences).includes(String(selectedRole)))) {
this.preferences = {
role: preferences['selectedRole'],
...preferences?.[selectedRole]
Expand All @@ -143,7 +152,7 @@ export class LoginComponent implements OnInit {
else {
this.error = true
}


}

Expand Down
18 changes: 13 additions & 5 deletions src/app/views/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export class DashboardComponent implements OnInit {
// isNvsk = environment.config.toLocaleLowerCase() === 'nvsk';
isNvsk = false;
rbacDetails: any;
constructor(private spinner: NgxSpinnerService, private readonly _commonService: CommonService, private readonly _router: Router, private readonly rbac: RbacService, private _wrapperService: WrapperService, private _authService: AuthenticationService,private _rbacService: RbacService) {
constructor(private spinner: NgxSpinnerService, private readonly _commonService: CommonService, private readonly _router: Router, private readonly rbac: RbacService, private _wrapperService: WrapperService, private _authService: AuthenticationService, private _rbacService: RbacService) {
this._router.routeReuseStrategy.shouldReuseRoute = function () {
return false;
};

this.mySubscription = this._router.events.subscribe((event) => {
if (event instanceof NavigationEnd) {
// Trick the Router into believing it's last link wasn't previously loaded
Expand All @@ -49,8 +49,8 @@ export class DashboardComponent implements OnInit {
password: environment.guestPassword
}
let response = await this._authService.login(data).toPromise();
if(response && response['access_token']) {
if (response && response['access_token']) {

localStorage.clear()
const token = response['access_token']
const refreshToken = response['refresh_token']
Expand Down Expand Up @@ -222,7 +222,8 @@ export class DashboardComponent implements OnInit {
}

setStateDetails(details) {
let state_id, stateName;
if (environment.config === 'VSK') {
let state_id, stateName;
if (environment.stateCode) {
state_id = StateCodes.indexOf(environment.stateCode)
details.state = state_id
Expand All @@ -239,6 +240,13 @@ export class DashboardComponent implements OnInit {
...details,
state_name: stateName,
});
}
else {
this._rbacService.setRbacDetails({
...details
});
}

}

ngOnDestroy() {
Expand Down
Loading

0 comments on commit a5872ae

Please sign in to comment.