Skip to content

Commit

Permalink
Merge pull request #8 from gdsclpu/voice-responses
Browse files Browse the repository at this point in the history
improved polices and added some voice responses
  • Loading branch information
RamanSharma100 authored Jun 13, 2022
2 parents a4ffe1e + 1813731 commit d42c026
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 24 deletions.
15 changes: 1 addition & 14 deletions src/app/organisations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,7 @@ export class OrganisationsService {
isLoading: boolean = true;
private organisationsStateListener = new Subject<IOrganisations[]>();

constructor(private firestore: AngularFirestore) {
this.firestore
.collection('organisations')
.snapshotChanges()
.subscribe((organisations: any) => {
organisations.forEach((organisation: any) => {
this.organisations.push(organisation.payload.doc.data());
});
this.isLoading = false;
this.organisationsStateListener.next(
this.organisations.slice(this.start, this.end)
);
});
}
constructor(private firestore: AngularFirestore) {}
init() {
this.firestore
.collection('organisations')
Expand Down
55 changes: 46 additions & 9 deletions src/app/organisations/organisations.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ <h1 class="text-center my-5">Loading...</h1>
<div
class="card rounded-6"
(click)="showDetails(organisation)"
style="cursor: pointer"
style="cursor: pointer; height: 380px !important"
>
<div class="card-header">
<div class="d-flex justify-content-center mx-auto bg-white">
<img
src="{{organisation['Logo'] ? organisation['Logo'] : 'assets/img/org.png'}}"
src="{{
organisation['Logo']
? organisation['Logo']
: 'assets/img/org.png'
}}"
alt="avatar"
class="rounded-circle img-fluid"
style="width: 80px; height: 80px"
Expand All @@ -34,7 +38,11 @@ <h3 class="text-center small mt-5 fw-bold">
</p>
<div>
<img
src="{{organisation['Student Image'] ? organisation['Student Image'] : 'assets/img/Avatar.png'}}"
src="{{
organisation['Student Image']
? organisation['Student Image']
: 'assets/img/Avatar.png'
}}"
alt="img"
class="rounded-circle"
width="25px"
Expand All @@ -44,7 +52,11 @@ <h3 class="text-center small mt-5 fw-bold">
</div>
<div>
<img
src="{{organisation['Facilitator Image'] ? organisation['Facilitator Image'] : 'assets/img/Avatar.png'}}"
src="{{
organisation['Facilitator Image']
? organisation['Facilitator Image']
: 'assets/img/Avatar.png'
}}"
alt="img"
class="rounded-circle"
width="25px"
Expand All @@ -58,31 +70,51 @@ <h3 class="text-center small mt-5 fw-bold">
<div class="d-flex justify-content-center">
<div class="row d-inline">
<a
href="mailto:{{organisation['Email'] ? organisation['Email'] : '[email protected]'}}"
href="mailto:{{
organisation['Email']
? organisation['Email']
: '[email protected]'
}}"
class="text-dark"
target="_blank"
><i class="fa fa-envelope"></i>
</a>
<a
href="{{organisation['Facebook'] ? organisation['Facebook'] : 'http://facebook.com/'}}"
href="{{
organisation['Facebook']
? organisation['Facebook']
: 'http://facebook.com/'
}}"
class="text-dark"
target="_blank"
><i class="col fa-brands fa-facebook-f"></i
></a>
<a
href="{{organisation['Instagram'] ? organisation['Instagram'] : 'http://instagram.com/'}}"
href="{{
organisation['Instagram']
? organisation['Instagram']
: 'http://instagram.com/'
}}"
class="text-dark"
target="_blank"
><i class="col fa-brands fa-instagram"></i
></a>
<a
href="{{organisation['LinkedIn'] ? organisation['LinkedIn'] : 'http://linkedIn.com/'}}"
href="{{
organisation['LinkedIn']
? organisation['LinkedIn']
: 'http://linkedIn.com/'
}}"
class="text-dark"
target="_blank"
><i class="col fa-brands fa-linkedin-in"></i
></a>
<a
href="{{organisation['Website'] ? organisation['Website'] : 'http://lpu.in/'}}"
href="{{
organisation['Website']
? organisation['Website']
: 'http://lpu.in/'
}}"
class="text-dark"
target="_blank"
><i class="fa fa-globe"></i
Expand All @@ -98,6 +130,11 @@ <h3 class="text-center small mt-5 fw-bold">
Prev
</button>

<p class="lead small">
showing <strong>{{ start + 1 }} - {{ end }}</strong> of
<strong>{{ length }}</strong> organisations
</p>

<button class="btn btn-primary" [disabled]="end >= length" (click)="next()">
Next
</button>
Expand Down
61 changes: 60 additions & 1 deletion src/app/organisations/organisations.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { Component, NgZone, OnInit } from '@angular/core';
import { ModalComponent } from '../modal/modal.component';
import { MdbModalRef, MdbModalService } from 'mdb-angular-ui-kit/modal';
import { IOrganisations, OrganisationsService } from '../organisations.service';
import {
MdbNotificationRef,
MdbNotificationService,
} from 'mdb-angular-ui-kit/notification';
import { SpeechSynthesisService } from '../speech-synthesis.service';
import { ToastComponent } from '../toast/toast.component';

@Component({
selector: 'app-organisations',
Expand All @@ -15,13 +21,17 @@ export class OrganisationsComponent implements OnInit {
start = 0;
end = 16;
length = 0;
notificationRef: MdbNotificationRef<ToastComponent> | null = null;

constructor(
private modalService: MdbModalService,
private organisationsService: OrganisationsService,
private ngZone: NgZone
private ngZone: NgZone,
private notificationService: MdbNotificationService,
private speechSynthesisService: SpeechSynthesisService
) {
this.organisationsService.init();
this.organisations = [];
this.ngZone.run(() => {
this.organisationsService
.getOrganisationsStateListener()
Expand All @@ -41,19 +51,68 @@ export class OrganisationsComponent implements OnInit {
this.modalRef = this.modalService.open(ModalComponent, {
data: { organisation },
});
this.speechSynthesisService.speak({
text: `Opened details of organization, ${organisation['Organization Name']}`,
});
this.notificationRef = this.notificationService.open(ToastComponent, {
data: {
text: `Opened details of organization, ${organisation['Organization Name']}`,
type: 'success',
},
delay: 3000,
stacking: true,
position: 'top-right',
autohide: true,
});
}

next() {
this.organisationsService.setOrganisationsPaginated(
this.organisationsService.getOrganisationsStart() + 16,
this.organisationsService.getOrganisationsEnd() + 16
);
this.notificationRef = this.notificationService.open(ToastComponent, {
data: {
text: `Showing ${this.start + 1} - ${
this.end
} of ${this.organisationsService.getOrganisationsLength()} organisations!`,
type: 'success',
},
delay: 3000,
stacking: true,
position: 'top-right',
autohide: true,
});

this.speechSynthesisService.speak({
text: `Showing ${this.start + 1} - ${
this.end
} of ${this.organisationsService.getOrganisationsLength()} organisations!`,
});
}

prev() {
this.organisationsService.setOrganisationsPaginated(
this.organisationsService.getOrganisationsStart() - 16,
this.organisationsService.getOrganisationsEnd() - 16
);
this.notificationRef = this.notificationService.open(ToastComponent, {
data: {
text: `Showing ${this.start + 1} - ${
this.end
} of ${this.organisationsService.getOrganisationsLength()} organisations!`,
type: 'success',
},
delay: 3000,
stacking: true,
position: 'top-right',
autohide: true,
});

this.speechSynthesisService.speak({
text: `Showing ${this.start + 1} - ${
this.end
} of ${this.organisationsService.getOrganisationsLength()} organisations!`,
});
}
}

0 comments on commit d42c026

Please sign in to comment.