93 lines
2.4 KiB
TypeScript
93 lines
2.4 KiB
TypeScript
/**
|
|
* Copyright since 2025 Mifos Initiative
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
import { Component, OnInit, inject } from '@angular/core';
|
|
import {
|
|
MatDialogRef,
|
|
MatDialogTitle,
|
|
MatDialogContent,
|
|
MatDialogActions,
|
|
MatDialogClose,
|
|
MatDialog
|
|
} from '@angular/material/dialog';
|
|
import { ShortcutSuggestionService } from '../../core/services/shortcut-suggestion.service';
|
|
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
|
|
import { MatButton } from '@angular/material/button';
|
|
import {
|
|
MatTable,
|
|
MatColumnDef,
|
|
MatHeaderCellDef,
|
|
MatHeaderCell,
|
|
MatCellDef,
|
|
MatCell,
|
|
MatHeaderRowDef,
|
|
MatHeaderRow,
|
|
MatRowDef,
|
|
MatRow
|
|
} from '@angular/material/table';
|
|
import { InlineCreateShortcutDialogComponent } from './inline-create-shortcut-dialog.component';
|
|
|
|
@Component({
|
|
selector: 'mifosx-shortcut-usage-dialog',
|
|
templateUrl: './shortcut-usage-dialog.component.html',
|
|
styleUrls: ['./shortcut-usage-dialog.component.scss'],
|
|
imports: [
|
|
...STANDALONE_SHARED_IMPORTS,
|
|
MatDialogTitle,
|
|
MatDialogContent,
|
|
MatDialogActions,
|
|
MatDialogClose,
|
|
MatButton,
|
|
MatTable,
|
|
MatColumnDef,
|
|
MatHeaderCellDef,
|
|
MatHeaderCell,
|
|
MatCellDef,
|
|
MatCell,
|
|
MatHeaderRowDef,
|
|
MatHeaderRow,
|
|
MatRowDef,
|
|
MatRow
|
|
]
|
|
})
|
|
export class ShortcutUsageDialogComponent implements OnInit {
|
|
dialogRef = inject<MatDialogRef<ShortcutUsageDialogComponent>>(MatDialogRef);
|
|
private shortcutSuggestionService = inject(ShortcutSuggestionService);
|
|
private dialog = inject(MatDialog);
|
|
|
|
usageData: { route: string; pageName: string; visits: number; hasShortcut: boolean }[] = [];
|
|
displayedColumns: string[] = [
|
|
'page',
|
|
'visits',
|
|
'status'
|
|
];
|
|
|
|
ngOnInit() {
|
|
this.refreshData();
|
|
}
|
|
|
|
refreshData() {
|
|
this.usageData = this.shortcutSuggestionService.getUsageData();
|
|
}
|
|
|
|
createShortcut(item: { pageName: string; route: string }) {
|
|
const inlineDialogRef = this.dialog.open(InlineCreateShortcutDialogComponent, {
|
|
data: item,
|
|
width: '400px',
|
|
disableClose: true
|
|
});
|
|
|
|
inlineDialogRef.afterClosed().subscribe((saved) => {
|
|
if (saved) {
|
|
this.shortcutSuggestionService.markAsDismissed(item.route);
|
|
this.refreshData(); // update the table so the checkmark appears!
|
|
}
|
|
});
|
|
}
|
|
}
|