import { Component , Injector } from '@angular/core' ; import { PagedListingComponentBase , PagedRequestDto , } from '@shared/common/paged-listing-component-base' ; import { ApplicationLanguageListDto , LanguageServiceProxy , SetDefaultLanguageInput , } from '@shared/service-proxies/service-proxies' ; import { Router } from '@angular/router' ; import { CreateOrEditLanguageModalComponent } from './create-or-edit-language-modal.component' ; import { finalize } from 'rxjs/operators' ; @ Component ( { selector : 'app-languages' , templateUrl : './languages.component.html' , styles : [ ] , } ) export class LanguagesComponent extends PagedListingComponentBase < ApplicationLanguageListDto > { defaultLanguageName : string ; constructor ( injector , private _languageService , private router ) { super ( injector ) ; } changeTexts ( language ) { const self = this ; setTimeout ( ( ) => { self . router . navigate ( [ 'app/admin/languagetexts' , language . name , 'texts' ] ) ; } , 300 ) ; } setAsDefaultLanguage ( language ) { const input = new SetDefaultLanguageInput ( ) ; input . name = language . name ; this . _languageService . setDefaultLanguage ( input ) . subscribe ( ( ) => { this . refresh ( ) ; this . notify . success ( this . l ( 'SuccessfullySaved' ) ) ; } ) ; } deleteLanguage ( language ) { this . _languageService . deleteLanguage ( language . id ) . subscribe ( ( ) => { this . refresh ( ) ; this . notify . success ( this . l ( 'SuccessfullyDeleted' ) ) ; } ) ; } createOrEditLanguage ( languageId ? ) { this . modalHelper . createStatic ( CreateOrEditLanguageModalComponent , { languageId : languageId } ) . subscribe ( res => { if ( res ) { this . refresh ( ) ; } } ) ; } protected fetchDataList ( request , pageNumber , finishedCallback ) { this . _languageService . getLanguages ( ) . pipe ( finalize ( finishedCallback ) ) . subscribe ( result => { this . dataList = result . items ; this . defaultLanguageName = result . defaultLanguageName ; this . pageSize = result . items . length ; } ) ; } delete ( language ) { this . _languageService . deleteLanguage ( language . id ) . subscribe ( ( ) => { this . refresh ( ) ; this . notify . success ( this . l ( 'SuccessfullyDeleted' ) ) ; } ) ; } batchDelete ( ) { this . message . warn ( 'method not implement!' ) ; } }