faltas.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { createApp, reactive } from 'https://unpkg.com/petite-vue?module';
  2. // define that $ has type any
  3. declare const $: any;
  4. const filter = reactive({
  5. facultad: -1,
  6. profesor: '',
  7. porcentaje: 0
  8. });
  9. const app = createApp({
  10. filter,
  11. facultades: [],
  12. profesores: [],
  13. faltas: [],
  14. openModal() {
  15. const modal = document.getElementById('cargando');
  16. $(modal).modal('show');
  17. },
  18. closeModal() {
  19. const modal = document.getElementById('cargando');
  20. $(modal).modal('hide');
  21. },
  22. async refresh() {
  23. alert(`Facultad: ${filter.facultad} - Profesor: ${filter.profesor} - Porcentaje: ${filter.porcentaje}%`
  24. if(filter.facultad == -1 || filter.porcetaje < 10) {
  25. return;
  26. }
  27. this.openModal();
  28. this.faltas = await fetch(`action/profesor_faltas.php?facultad=${this.filter.facultad}&profesor=${this.filter.profesor}&porcentaje=${this.filter.porcentaje}`).then(res => res.json());
  29. this.closeModal();
  30. },
  31. async mounted() {
  32. this.facultades = await fetch('action/action_facultad.php').then(res => res.json());
  33. this.profesores = await fetch('action/action_profesor.php').then(res => res.json());
  34. }
  35. }).mount('#app');