139 lines
3.5 KiB
TypeScript
139 lines
3.5 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { AuthService } from '../services/auth.service';
|
|
import { ActionSheetController } from '@ionic/angular';
|
|
@Component({
|
|
selector: 'app-admin-page',
|
|
templateUrl: './admin-page.page.html',
|
|
styleUrls: ['./admin-page.page.scss'],
|
|
})
|
|
export class AdminPagePage implements OnInit {
|
|
|
|
carrers = [];
|
|
secretarys = [];
|
|
symptoms = [];
|
|
|
|
constructor(
|
|
private auth:AuthService,
|
|
public actionSheetController: ActionSheetController) { }
|
|
|
|
ngOnInit() {
|
|
this.auth.store.get("user/get-careers").subscribe(
|
|
res => {
|
|
this.carrers = res;
|
|
});
|
|
this.auth.store.get("admin/listSecretaries").subscribe(
|
|
res => {
|
|
this.secretarys = res;
|
|
});
|
|
this.auth.store.get("symptoms").subscribe(
|
|
res => {
|
|
this.symptoms = res;
|
|
});
|
|
}
|
|
|
|
async presentActionSheet(data) {
|
|
const actionSheet = await this.actionSheetController.create({
|
|
header: data.name,
|
|
buttons: [{
|
|
text: 'Deshabilitar',
|
|
role: 'destructive',
|
|
icon: 'trash',
|
|
handler: () => {
|
|
if(data.email!= undefined){
|
|
this.auth.store.create(`admin/disableSecretary/${data.id}`).subscribe()
|
|
this.secretarys = this.secretarys.filter(function(value, index, arr){
|
|
return value.id != data.id;
|
|
});
|
|
|
|
}
|
|
else {
|
|
this.auth.store.create(`admin/disableCarer/${data.id}`)
|
|
this.carrers = this.carrers.filter(function(value, index, arr){
|
|
return value.id != data.id;
|
|
});
|
|
}
|
|
|
|
console.log('Delete clicked');
|
|
}
|
|
}, {
|
|
text: 'Asignar',
|
|
icon: 'flask',
|
|
handler: () => {
|
|
console.log('Favorite clicked');
|
|
}
|
|
}, {
|
|
text: 'Cancel',
|
|
icon: 'close',
|
|
role: 'cancel',
|
|
handler: () => {
|
|
console.log('clicked', data.email!=undefined);
|
|
}
|
|
}]
|
|
});
|
|
await actionSheet.present();
|
|
}
|
|
|
|
async sympthomActionSheet(data) {
|
|
const actionSheet = await this.actionSheetController.create({
|
|
header: data.description,
|
|
buttons: [{
|
|
text: 'Deshabilitar',
|
|
role: 'destructive',
|
|
icon: 'trash',
|
|
handler: () => {
|
|
this.auth.store.create(`admin/disableSymptom/${data.id}`).subscribe(
|
|
res =>
|
|
console.log(res, data)
|
|
);
|
|
this.symptoms = this.symptoms.filter(function(value, index, arr){
|
|
return value.id != data.id;
|
|
});
|
|
console.log('Delete clicked');
|
|
}
|
|
},{
|
|
text: 'Cancel',
|
|
icon: 'close',
|
|
role: 'cancel',
|
|
handler: () => {
|
|
console.log("cancel");
|
|
}
|
|
}]
|
|
});
|
|
await actionSheet.present();
|
|
}
|
|
|
|
|
|
async addSomeThing() {
|
|
const actionSheet = await this.actionSheetController.create({
|
|
header: 'Agregar',
|
|
buttons: [{
|
|
text: 'Secretario',
|
|
icon: 'nutrition',
|
|
handler: () => {
|
|
console.log('secretario clicked');
|
|
}
|
|
}, {
|
|
text: 'Carrera',
|
|
icon: 'school',
|
|
handler: () => {
|
|
console.log('carrera clicked');
|
|
}
|
|
},{
|
|
text: 'Sintoma',
|
|
icon: 'pulse',
|
|
handler: () => {
|
|
console.log('sintoma clicked');
|
|
}
|
|
}, {
|
|
text: 'Cancel',
|
|
icon: 'close',
|
|
role: 'cancel',
|
|
handler: () => {
|
|
console.log('Cancel clicked');
|
|
}
|
|
}]
|
|
});
|
|
await actionSheet.present();
|
|
}
|
|
}
|