|
|
@@ -1,20 +1,10 @@
|
|
|
import { Component, ViewChild, OnInit } from '@angular/core';
|
|
|
import { Organization } from "@app/models/organization";
|
|
|
import { OrganizationsService } from "@app/services/organizations.service";
|
|
|
-
|
|
|
-import {HttpClient} from '@angular/common/http';
|
|
|
-import { Plant } from 'src/app/models/plant';
|
|
|
-import { PlantsService } from 'src/app/services/plants.service';
|
|
|
-import {MatPaginator} from '@angular/material/paginator';
|
|
|
-import {MatSort} from '@angular/material/sort';
|
|
|
-import {merge, Observable, of as observableOf} from 'rxjs';
|
|
|
-import {catchError, map, startWith, switchMap} from 'rxjs/operators';
|
|
|
-import {MatTableDataSource} from '@angular/material/table';
|
|
|
-
|
|
|
-import {NgbDate, NgbCalendar} from '@ng-bootstrap/ng-bootstrap';
|
|
|
-
|
|
|
-import {AngularMyDatePickerDirective,IAngularMyDpOptions, IMyDateModel} from 'angular-mydatepicker';
|
|
|
-
|
|
|
+import { MatPaginator } from '@angular/material/paginator';
|
|
|
+import { MatSort } from '@angular/material/sort';
|
|
|
+import { MatTableDataSource } from '@angular/material/table';
|
|
|
+import Swal from 'sweetalert2';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-organizations',
|
|
|
@@ -31,17 +21,23 @@ export class OrganizationsComponent implements OnInit {
|
|
|
listData: Organization[] = [];
|
|
|
listOrganization:any;
|
|
|
dataSource = new MatTableDataSource(this.listData);
|
|
|
-
|
|
|
resultsLength = 0;
|
|
|
isLoadingResults = true;
|
|
|
isRateLimitReached = false;
|
|
|
|
|
|
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
|
|
|
@ViewChild(MatSort, {static: true}) sort: MatSort;
|
|
|
+ role_number: any;
|
|
|
|
|
|
|
|
|
- constructor(
|
|
|
- private orgService: OrganizationsService) {}
|
|
|
+ constructor(private orgService: OrganizationsService) {
|
|
|
+ Swal.fire({
|
|
|
+ allowOutsideClick: false,
|
|
|
+ type: 'info',
|
|
|
+ text: 'Espere por favor...'
|
|
|
+ });
|
|
|
+ Swal.showLoading();
|
|
|
+ }
|
|
|
|
|
|
ngOnInit() {
|
|
|
this.orgService.getListOrganizations().subscribe(res =>
|
|
|
@@ -53,8 +49,67 @@ export class OrganizationsComponent implements OnInit {
|
|
|
this.dataSource.data = this.listOrganization;
|
|
|
this.dataSource.paginator = this.paginator;
|
|
|
this.dataSource.sort = this.sort;
|
|
|
-
|
|
|
+ }, (err) => {
|
|
|
+ Swal.fire({
|
|
|
+ type: 'error',
|
|
|
+ title: 'Error en el servidor',
|
|
|
+ text: "No su pudo obtener la informacion"
|
|
|
+ });
|
|
|
});
|
|
|
+
|
|
|
+ //this.chartjs = true;
|
|
|
+ setTimeout(()=>{
|
|
|
+ Swal.close();
|
|
|
+ }, 1200);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ delete_organization(id: string){
|
|
|
+ Swal.fire({
|
|
|
+ allowOutsideClick: false,
|
|
|
+ type: 'warning',
|
|
|
+ title: '¿Esta seguro?',
|
|
|
+ text: 'No podrá revertir esta acción',
|
|
|
+ showCancelButton: true,
|
|
|
+ confirmButtonColor: '#3085d6',
|
|
|
+ cancelButtonColor: '#d33',
|
|
|
+ confirmButtonText: 'Borrar registro',
|
|
|
+ })
|
|
|
+ .then((result) => {
|
|
|
+ if (result.value) {
|
|
|
+ this.delete_organization2(id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ delete_organization2(id: string){
|
|
|
+ this.orgService.deleteOrganization(id)
|
|
|
+ .subscribe(
|
|
|
+ data => {
|
|
|
+ if (data["success"] == true) {
|
|
|
+ //document.getElementById(id).remove();
|
|
|
+ Swal.fire({
|
|
|
+ allowOutsideClick: false,
|
|
|
+ type: 'success',
|
|
|
+ text: 'Registro eliminado con exito'
|
|
|
+ });
|
|
|
+ //window.location.href="#/organizations";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Swal.fire({
|
|
|
+ allowOutsideClick: false,
|
|
|
+ type: 'error',
|
|
|
+ text: "No tienes permiso para eliminar el registro"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ err => {
|
|
|
+ Swal.fire({
|
|
|
+ type: 'error',
|
|
|
+ title: 'Error en el servidor',
|
|
|
+ text: err.message
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
applyFilter(filterValue: string) {
|
|
|
@@ -64,4 +119,4 @@ export class OrganizationsComponent implements OnInit {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|