Update Setting Router

This commit is contained in:
Trinity X Solution 2023-02-04 17:59:05 +08:00
parent b66f3720cf
commit 187056380e
10 changed files with 255 additions and 7 deletions

View file

@ -13,7 +13,7 @@
"ng": "ng",
"conventional-changelog": "conventional-changelog",
"start": "ng serve",
"build": "ng build",
"build": "ng build --base-href \"/SEO/\"",
"build:prod": "npm run build -- --configuration production --aot",
"test": "ng test",
"test:coverage": "rimraf coverage && npm run test -- --code-coverage",

View file

@ -37,7 +37,7 @@ export const MENU_ITEMS: NbMenuItem[] = [
{
title: 'Keywords Dictionary',
icon: 'book-outline',
link: '',
link: '/pages/settings/keywordsdictionary',
},
{
title: 'Image Similarity',

View file

@ -3,7 +3,7 @@ import { NgModule } from '@angular/core';
import { PagesComponent } from './pages.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { ECommerceComponent } from './e-commerce/e-commerce.component';
import { SettingsComponent } from './settings/settings.component';
import { NotFoundComponent } from './miscellaneous/not-found/not-found.component';
const routes: Routes = [{
@ -12,11 +12,12 @@ const routes: Routes = [{
children: [
{
path: 'dashboard',
component: ECommerceComponent,
component: DashboardComponent,
},
{
path: 'iot-dashboard',
component: DashboardComponent,
path: 'settings',
loadChildren: () => import('./settings/settings.module')
.then(m => m.SettingsModule),
},
{
path: 'layout',

View file

@ -0,0 +1,34 @@
<nb-card>
<nb-card-body>
<label class="search-label" for="search">Search:</label>
<input nbInput [nbFilterInput]="dataSource" id="search" class="search-input">
<table [nbTreeGrid]="dataSource" [nbSort]="dataSource" (sort)="updateSort($event)">
<tr nbTreeGridHeaderRow *nbTreeGridHeaderRowDef="allColumns"></tr>
<tr nbTreeGridRow *nbTreeGridRowDef="let row; columns: allColumns"></tr>
<ng-container [nbTreeGridColumnDef]="customColumn">
<th nbTreeGridHeaderCell [nbSortHeader]="getSortDirection(customColumn)" *nbTreeGridHeaderCellDef>
{{customColumn}}
</th>
<td nbTreeGridCell *nbTreeGridCellDef="let row">
<ngx-fs-icon [kind]="row.data.kind" [expanded]="row.expanded"></ngx-fs-icon>
{{row.data[customColumn]}}
</td>
</ng-container>
<ng-container *ngFor="let column of defaultColumns; let index = index"
[nbTreeGridColumnDef]="column"
[showOn]="getShowOn(index)">
<th nbTreeGridHeaderCell [nbSortHeader]="getSortDirection(column)" *nbTreeGridHeaderCellDef>
{{column}}
</th>
<td nbTreeGridCell *nbTreeGridCellDef="let row">{{row.data[column] || '-'}}</td>
</ng-container>
</table>
</nb-card-body>
</nb-card>

View file

@ -0,0 +1,55 @@
@import '../../../@theme/styles/themes';
@include nb-install-component() {
button[nbTreeGridRowToggle] {
background: transparent;
border: none;
padding: 0;
}
.search-label {
display: block;
}
.search-input {
margin-bottom: 1rem;
}
.nb-column-name {
width: 100%;
}
::ng-deep .row-toggle-button {
color: nb-theme(text-basic-color);
}
.nb-tree-grid-header-cell,
.nb-tree-grid-header-cell button {
text-transform: capitalize;
}
@media screen and (min-width: 400px) {
.nb-column-name,
.nb-column-size {
width: 50%;
}
}
@media screen and (min-width: 500px) {
.nb-column-name,
.nb-column-size,
.nb-column-kind {
width: 33.333%;
}
}
@media screen and (min-width: 600px) {
.nb-column-name {
width: 31%;
}
.nb-column-size,
.nb-column-kind,
.nb-column-items {
width: 23%;
}
}
}

View file

@ -0,0 +1,98 @@
import { Component, Input } from '@angular/core';
import { NbSortDirection, NbSortRequest, NbTreeGridDataSource, NbTreeGridDataSourceBuilder } from '@nebular/theme';
interface TreeNode<T> {
data: T;
children?: TreeNode<T>[];
expanded?: boolean;
}
interface FSEntry {
name: string;
size: string;
kind: string;
items?: number;
}
@Component({
selector: 'ngx-tree-grid',
templateUrl: './keywordsdictionary.component.html',
styleUrls: ['./keywordsdictionary.component.scss'],
})
export class KeywordsDictionaryComponent {
customColumn = 'name';
defaultColumns = [ 'size', 'kind', 'items' ];
allColumns = [ this.customColumn, ...this.defaultColumns ];
dataSource: NbTreeGridDataSource<FSEntry>;
sortColumn: string;
sortDirection: NbSortDirection = NbSortDirection.NONE;
constructor(private dataSourceBuilder: NbTreeGridDataSourceBuilder<FSEntry>) {
this.dataSource = this.dataSourceBuilder.create(this.data);
}
updateSort(sortRequest: NbSortRequest): void {
this.sortColumn = sortRequest.column;
this.sortDirection = sortRequest.direction;
}
getSortDirection(column: string): NbSortDirection {
if (this.sortColumn === column) {
return this.sortDirection;
}
return NbSortDirection.NONE;
}
private data: TreeNode<FSEntry>[] = [
{
data: { name: 'Projects', size: '1.8 MB', items: 5, kind: 'dir' },
children: [
{ data: { name: 'project-1.doc', kind: 'doc', size: '240 KB' } },
{ data: { name: 'project-2.doc', kind: 'doc', size: '290 KB' } },
{ data: { name: 'project-3', kind: 'txt', size: '466 KB' } },
{ data: { name: 'project-4.docx', kind: 'docx', size: '900 KB' } },
],
},
{
data: { name: 'Reports', kind: 'dir', size: '400 KB', items: 2 },
children: [
{ data: { name: 'Report 1', kind: 'doc', size: '100 KB' } },
{ data: { name: 'Report 2', kind: 'doc', size: '300 KB' } },
],
},
{
data: { name: 'Other', kind: 'dir', size: '109 MB', items: 2 },
children: [
{ data: { name: 'backup.bkp', kind: 'bkp', size: '107 MB' } },
{ data: { name: 'secret-note.txt', kind: 'txt', size: '2 MB' } },
],
},
];
getShowOn(index: number) {
const minWithForMultipleColumns = 400;
const nextColumnStep = 100;
return minWithForMultipleColumns + (nextColumnStep * index);
}
}
@Component({
selector: 'ngx-fs-icon',
template: `
<nb-tree-grid-row-toggle [expanded]="expanded" *ngIf="isDir(); else fileIcon">
</nb-tree-grid-row-toggle>
<ng-template #fileIcon>
<nb-icon icon="file-text-outline"></nb-icon>
</ng-template>
`,
})
export class FsIconComponent {
@Input() kind: string;
@Input() expanded: boolean;
isDir(): boolean {
return this.kind === 'dir';
}
}

View file

@ -0,0 +1,27 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { SettingsComponent } from './settings.component';
import { KeywordsDictionaryComponent } from './keywordsdictionary/keywordsdictionary.component';
const routes: Routes = [{
path: '',
component: SettingsComponent,
children: [
{
path: 'keywordsdictionary',
component: KeywordsDictionaryComponent,
},
],
}];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class SettingsRoutingModule { }
export const routedComponents = [
SettingsComponent,
KeywordsDictionaryComponent,
];

View file

@ -0,0 +1,8 @@
import { Component } from '@angular/core';
@Component({
selector: 'ngx-tables',
template: `<router-outlet></router-outlet>`,
})
export class SettingsComponent {
}

View file

@ -0,0 +1,24 @@
import { NgModule } from '@angular/core';
import { NbCardModule, NbIconModule, NbInputModule, NbTreeGridModule } from '@nebular/theme';
import { Ng2SmartTableModule } from 'ng2-smart-table';
import { ThemeModule } from '../../@theme/theme.module';
import { SettingsRoutingModule, routedComponents } from './settings-routing.module';
import { FsIconComponent } from './keywordsdictionary/keywordsdictionary.component';
@NgModule({
imports: [
NbCardModule,
NbTreeGridModule,
NbIconModule,
NbInputModule,
ThemeModule,
SettingsRoutingModule,
Ng2SmartTableModule,
],
declarations: [
...routedComponents,
FsIconComponent,
],
})
export class SettingsModule { }

View file

@ -4,7 +4,8 @@
<meta charset="utf-8">
<title>Klikx SEO Admin Portal</title>
<base href="/">
<base href="/SEO/">
<!-- <base href="/"> -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="favicon.png">