Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit, ViewChild, AfterViewInit } from '@angular/core';
- import { MatPaginator } from '@angular/material/paginator';
- import { MatSort } from '@angular/material/sort';
- import { MatTableDataSource } from '@angular/material/table';
- import { UserData, DataService } from '../data.service';
- import { SelectionModel } from '@angular/cdk/collections';
- import { CoverNoteService } from 'src/app/services/cover-note.service';
- import { HttpErrorResponse } from '@angular/common/http';
- import { TglPlusSatu } from 'src/app/services/tglplussatu';
- import icEye from '@iconify/icons-ic/twotone-remove-red-eye';
- import icMoreHoriz from '@iconify/icons-ic/twotone-more-horiz';
- import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
- import icSearch from '@iconify/icons-ic/twotone-search';
- import icFile from '@iconify/icons-ic/sharp-file-open';
- import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
- import { DialogJaminanComponent } from '../dialog-jaminan/dialog-jaminan.component';
- @Component({
- selector: 'app-tables',
- templateUrl: './tables.component.html',
- styleUrls: ['./tables.component.scss']
- })
- export class TablesComponent implements OnInit {
- icEye = icEye;
- icFile = icFile
- icSearch= icSearch
- icMoreHoriz = icMoreHoriz;
- loadingPage: boolean = true;
- pesanError: string;
- isToastGagal: boolean;
- isToastSukses: boolean;
- tglMulai: string = '';
- tglAkhir: string = '';
- size: string = '20';
- page: string = '1';
- tglFilter: any = { startDate: '1990-12-25', endDate: '1990-12-25' };
- sliceAwal: number = 0;
- sliceAkhir: number = 10;
- pageSize: number = 100;
- id: string = '';
- arrayAdendum: any[] = [{}];
- isAddAdendum: boolean = true;
- tampungSession: any;
- tglStart: any;
- blnStart: any;
- thnStart: any;
- tbls:any[] = []
- tglEnd: any;
- hariStart: string;
- blnEnd: any;
- thnEnd: any;
- debounceTimer:any;
- hariEnd: string;
- tglMulaiDepan: string;
- tglAkhirDepan: string;
- search:any;
- debounceTime = 500;
- ShiftForm:FormGroup
- endDate:any;
- startDate:any
- constructor(private readonly dataService: DataService, private HelperTglDefault: TglPlusSatu,
- private dashboardCovernote: CoverNoteService, private formBuilder: FormBuilder, public dialog: MatDialog) {
- localStorage.removeItem('LSparameter');
- localStorage.removeItem('isLogs');
- // this.tglMulai = this.HelperTglDefault.defaultThnMinusSatu(this.tglMulai)
- this.tglMulai = '01/01/2018';
- this.tglAkhir = this.HelperTglDefault.defaultTglHariIni(this.tglMulai);
- this.tglFilter = this.HelperTglDefault.generateTglUtkFilter(this.tglFilter);
- }
- ngOnInit() {
- this.getNew();
- this.initForm()
- this.startDate = new FormControl(new Date());
- this.endDate = new FormControl(new Date());
- }
- get f() {
- return this.ShiftForm.controls;
- }
- initForm(){
- this.ShiftForm = this.formBuilder.group({
- startDate : new FormControl(new Date()),
- endDate : new FormControl(new Date())
- })
- this.ShiftForm.get('startDate').patchValue(this.formatDate(new Date()));
- this.ShiftForm.get('endDate').patchValue(this.formatDate(new Date()));
- }
- private formatDate(date) {
- const d = new Date(date);
- let month = '' + (d.getMonth() + 1);
- let day = '' + d.getDate();
- const year = d.getFullYear();
- if (month.length < 2) month = '0' + month;
- if (day.length < 2) day = '0' + day;
- return [year, month, day].join('-');
- }
- selectTampilakanData(event: any) {
- this.size = event.target.value;
- }
- gantiFormatTgl1(evt: any) {
- let formatTglAngular = new Date(evt.target.value);
- let year = formatTglAngular.getFullYear();
- let month = formatTglAngular.getMonth() + 1;
- let day = formatTglAngular.getDate();
- let Hari = day.toString();
- let Bln = month.toString();
- if (Hari.length === 1) {
- Hari = '0' + Hari;
- }
- if (Bln.length === 1) {
- Bln = '0' + Bln;
- }
- this.tglFilter.startDate = year + '-' + Bln + '-' + Hari;
- this.tglMulai = year + '/' + Bln + '/' + Hari;
- }
- detailDataBank(id) {
- // this.router.navigate([this.router.url + '/detail-data-bank/' + id]);
- }
- getNew() {
- this.tglStart = this.tglMulai.slice(3, 5);
- this.blnStart = this.tglMulai.slice(0, 2);
- this.thnStart = this.tglMulai.slice(6, 10);
- this.tglMulaiDepan =
- this.thnStart + '-' + this.blnStart + '-' + this.tglStart;
- this.tglEnd = this.tglAkhir.slice(3, 5);
- this.blnEnd = this.tglAkhir.slice(0, 2);
- this.thnEnd = this.tglAkhir.slice(6, 10);
- this.tglAkhirDepan = this.thnEnd + '-' + this.blnEnd + '-' + this.tglEnd;
- this.loadingPage = true;
- this.dashboardCovernote
- .getTblDashboardCovernote(
- this.tglMulai,
- this.tglAkhir,
- this.page,
- this.size
- )
- .subscribe(
- (data) => {
- this.tbls = data;
- this.loadingPage = false
- console.log(this.tbls)
- },
- (error: HttpErrorResponse) => {
- if (error.status === 401) {
- this.pesanError = '401 Unauthorized';
- } else if (error.status === 403) {
- this.pesanError = '403 Tidak Di Izinkan';
- } else if (error.status === 408) {
- this.pesanError = '408 Request Timeout';
- } else if (error.status === 400) {
- this.pesanError = '400 Java Springboot Error';
- } else {
- this.pesanError = 'Koneksi Buruk';
- }
- // this.isToastGagal = true;
- // setTimeout(() => {
- // this.isToastGagal = false;
- // }, 5000);
- }
- );
- }
- btnFilter() {
- this.tglStart = this.tglMulaiDepan.slice(8, 10);
- this.blnStart = this.tglMulaiDepan.slice(5, 7);
- this.thnStart = this.tglMulaiDepan.slice(0, 4);
- this.hariStart = this.blnStart + '/' + this.tglStart + '/' + this.thnStart;
- this.tglEnd = this.tglAkhirDepan.slice(8, 10);
- this.blnEnd = this.tglAkhirDepan.slice(5, 7);
- this.thnEnd = this.tglAkhirDepan.slice(0, 4);
- this.hariEnd = this.blnEnd + '/' + this.tglEnd + '/' + this.thnEnd;
- this.tglMulai = this.HelperTglDefault.defaultThnMinusSatu(this.tglMulai);
- this.loadingPage = true;
- this.dashboardCovernote
- .getTblDashboardCovernote(
- this.hariStart,
- this.hariEnd,
- this.page,
- this.size
- )
- .subscribe(
- (data) => {
- this.tbls = data;
- this.loadingPage = false
- },
- (error: HttpErrorResponse) => {
- if (error.status === 401) {
- this.pesanError = '401 Unauthorized';
- } else if (error.status === 403) {
- this.pesanError = '403 Tidak Di Izinkan';
- } else if (error.status === 408) {
- this.pesanError = '408 Request Timeout';
- } else if (error.status === 400) {
- this.pesanError = '400 Java Springboot Error';
- } else {
- this.pesanError = 'Koneksi Buruk';
- }
- this.isToastGagal = true;
- setTimeout(() => {
- this.isToastGagal = false;
- }, 5000);
- }
- );
- }
- onInputSearch(value: string) {
- const input = value;
- clearTimeout(this.debounceTimer);
- this.debounceTimer = setTimeout(() => {
- this.search = input;
- this.getNew();
- }, this.debounceTime);
- }
- dialogJumlahRekening(id:any) {
- const index = this.tbls.findIndex(item => item['jumlahRekeningSelish'] === id);
- const modelData = this.tbls[id];
- const dialogConfig = new MatDialogConfig();
- dialogConfig.disableClose = true;
- dialogConfig.width = '1200px';
- dialogConfig.data = {
- function: 'Edit',
- id,
- };
- const dialogRef = this.dialog.open(DialogJaminanComponent, dialogConfig);
- dialogRef.afterClosed().subscribe(result => {
- if (result == true) {
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement