2020-10-27 01:10:18 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2020-11-04 19:28:08 +01:00
|
|
|
import { FormControl, FormGroup } from '@angular/forms';
|
2020-12-14 19:26:36 +01:00
|
|
|
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view';
|
2020-11-04 19:28:08 +01:00
|
|
|
import { GENERAL_SETTINGS } from 'src/app/data/storage-keys';
|
|
|
|
|
import { DocumentListViewService } from 'src/app/services/document-list-view.service';
|
2020-12-14 19:26:36 +01:00
|
|
|
import { SavedViewService } from 'src/app/services/rest/saved-view.service';
|
2020-10-27 01:10:18 +01:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-settings',
|
|
|
|
|
templateUrl: './settings.component.html',
|
2020-11-22 14:43:59 +01:00
|
|
|
styleUrls: ['./settings.component.scss']
|
2020-10-27 01:10:18 +01:00
|
|
|
})
|
2020-12-14 20:59:18 +01:00
|
|
|
export class SettingsComponent {
|
2020-10-27 01:10:18 +01:00
|
|
|
|
2020-11-04 19:28:08 +01:00
|
|
|
settingsForm = new FormGroup({
|
|
|
|
|
'documentListItemPerPage': new FormControl(+localStorage.getItem(GENERAL_SETTINGS.DOCUMENT_LIST_SIZE) || GENERAL_SETTINGS.DOCUMENT_LIST_SIZE_DEFAULT)
|
|
|
|
|
})
|
|
|
|
|
|
2020-10-30 22:46:43 +01:00
|
|
|
constructor(
|
2020-12-14 19:26:36 +01:00
|
|
|
public savedViewService: SavedViewService,
|
2020-12-14 20:59:18 +01:00
|
|
|
private documentListViewService: DocumentListViewService
|
2020-10-30 22:46:43 +01:00
|
|
|
) { }
|
|
|
|
|
|
2020-12-14 19:26:36 +01:00
|
|
|
deleteSavedView(savedView: PaperlessSavedView) {
|
|
|
|
|
this.savedViewService.delete(savedView).subscribe(() => {})
|
2020-10-30 22:46:43 +01:00
|
|
|
}
|
|
|
|
|
|
2020-11-04 19:28:08 +01:00
|
|
|
saveSettings() {
|
|
|
|
|
localStorage.setItem(GENERAL_SETTINGS.DOCUMENT_LIST_SIZE, this.settingsForm.value.documentListItemPerPage)
|
|
|
|
|
this.documentListViewService.updatePageSize()
|
|
|
|
|
}
|
2020-10-27 01:10:18 +01:00
|
|
|
}
|