Newer
Older
import { Component, OnInit, ViewChild } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Router, ActivatedRoute } from '@angular/router';
import { LANG } from '../translate.component';
import { NotificationService } from '../notification.service';
import { MatPaginator,MatTableDataSource, MatSort } from '@angular/material';
declare function $j(selector: any) : any;
declare var angularGlobals : any;
templateUrl : angularGlobals['statuses-administrationView'],
export class StatusesAdministrationComponent implements OnInit {
displayedColumns = ['img_filename','id','label_status','identifier'];
dataSource = new MatTableDataSource(this.statuses);
@ViewChild(MatPaginator) paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort;
applyFilter(filterValue: string) {
filterValue = filterValue.trim(); // Remove whitespace
filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults to lowercase matches
this.dataSource.filter = filterValue;
}
constructor(public http: HttpClient, private notify: NotificationService) {
}
ngOnInit(): void {
this.coreUrl = angularGlobals.coreUrl;
this.http.get(this.coreUrl + 'rest/statuses')
this.updateBreadcrumb(angularGlobals.applicationName);
setTimeout(() => {
this.dataSource = new MatTableDataSource(this.statuses);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}, 0);
$j('#inner_content').remove();
}
updateBreadcrumb(applicationName: string){
$j('#ariane')[0].innerHTML = "<a href='index.php?reinit=true'>" + applicationName + "</a> > "+
"<a onclick='location.hash = \"/administration\"' style='cursor: pointer'>" + this.lang.administration + "</a> > " + this.lang.statuses;
deleteStatus(status : any){
var resp = confirm(this.lang.confirmAction+' '+this.lang.delete+' « '+status.id+' »');
this.http.delete(this.coreUrl + 'rest/statuses/'+status.identifier)
this.notify.success(this.lang.statusDeleted);
export interface Status {
id: string;
can_be_modified: string;
can_be_searchead: string;
identifier: number;
img_filename: string;
is_folder_status: string;
is_system: string;
label_status: string;
maarch_module: string;
}