Skip to content

Commit

Permalink
feat(): update project select
Browse files Browse the repository at this point in the history
  • Loading branch information
develite98 committed Nov 28, 2023
1 parent b94d3de commit a0352cd
Show file tree
Hide file tree
Showing 24 changed files with 391 additions and 166 deletions.
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@

.angular

/.nx/cache
/.nx/cache

*.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
Subject,
debounceTime,
distinctUntilChanged,
filter,
forkJoin,
map,
take,
Expand All @@ -45,7 +44,6 @@ import {
} from 'rxjs';
import { CMS_ROUTES } from '../../../app.routes';

import { SuccessFilter } from '@mixcore/share/base';
import { ListPageKit } from '../../../shares/kits/list-page-kit.component';
import { DatabaseDataStore } from '../../../stores/database-data.store';
import { CustomActionCellComponent } from './components/custom-action-cell/custom-action-cell.component';
Expand Down Expand Up @@ -149,7 +147,6 @@ export class DatabaseDataComponent
public onGridReady(params: GridReadyEvent) {
this.gridApi = params.api;
this.rowData$ = this.store.vm$.pipe(
filter(SuccessFilter),
tap((s) => {
if (s.db) {
this.allColumnDefs = s.db.columns.map(
Expand All @@ -162,7 +159,6 @@ export class DatabaseDataComponent
dataType: x.dataType,
columnType: 'value',
},
editable: true,
}
);
this.columnNames = s.db.columns.map((x) => x.displayName);
Expand All @@ -175,7 +171,9 @@ export class DatabaseDataComponent
];
}
}),
map((s) => s.data),
map((s) => {
return s.data;
}),
takeUntil(this.destroy$)
);

Expand Down Expand Up @@ -383,10 +381,7 @@ export class DatabaseDataComponent
});

dialogRef.afterClosed$.subscribe((value) => {
if (value) {
this.store.updateData(dataIndex, value);
this.gridApi.refreshCells();
}
if (value) this.store.updateData(dataIndex, value);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { CommonModule } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Input,
inject,
} from '@angular/core';
import { MixApiFacadeService } from '@mixcore/share/api';
import { BaseComponent } from '@mixcore/share/base';
import { MixButtonComponent } from '@mixcore/ui/button';

@Component({
selector: 'mix-backup-table-btn',
standalone: true,
imports: [CommonModule, MixButtonComponent],
template: `
<mix-button
[loading]="loadingState() === 'Loading'"
(click)="backupSingleTable()"
>Backup table</mix-button
>
<div>
When you activate this button, the system will automatically backup your
data in case you need it in the future.
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BackupTableButtonComponent extends BaseComponent {
@Input() public dbSysName?: string;
public mixApi = inject(MixApiFacadeService);

public backupSingleTable() {
this.mixApi.databaseApi
.backupTable(this.dbSysName!)
.pipe(this.observerLoadingStateSignal())
.subscribe();
}
}

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@
import { CommonModule } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Input,
inject,
} from '@angular/core';
import { MixApiFacadeService } from '@mixcore/share/api';
import { BaseComponent } from '@mixcore/share/base';
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { MixButtonComponent } from '@mixcore/ui/button';
import { BackupTableButtonComponent } from './backup-table-btn.component';
import { MigrateTableButtonComponent } from './migrate-table-btn.component';
import { RestoreTableButtonComponent } from './restore-table-btn.component';
import { UpdateTableButtonComponent } from './update-table-btn.component';

@Component({
selector: 'mix-database-migration',
standalone: true,
imports: [CommonModule, MixButtonComponent],
templateUrl: './database-migration.component.html',
styleUrl: './database-migration.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DatabaseMigrationComponent extends BaseComponent {
@Input() public dbSysName?: string;
public mixApi = inject(MixApiFacadeService);

public migrateSingleTable() {
this.mixApi.databaseApi
.migrateToSingleTable(this.dbSysName!)
.pipe(this.observerLoadingStateSignal())
.subscribe();
}
imports: [
CommonModule,
MixButtonComponent,
UpdateTableButtonComponent,
MigrateTableButtonComponent,
BackupTableButtonComponent,
RestoreTableButtonComponent,
],
template: `
@if (!dbSysName) {
<div class="mt-1 mb-2 notification --info">
Create your db first to run some migrations
</div>
} @else {
<div class="mb-3 mt-1">
<mix-migrate-table-btn [dbSysName]="dbSysName"></mix-migrate-table-btn>
</div>
public updateSingleTable() {
this.mixApi.databaseApi
.updateDataTable(this.dbSysName!)
.pipe(this.observerLoadingStateSignal())
.subscribe();
}
<div class="mb-3">
<mix-backup-table-btn [dbSysName]="dbSysName"></mix-backup-table-btn>
</div>
public backupSingleTable() {
this.mixApi.databaseApi
.backupTable(this.dbSysName!)
.pipe(this.observerLoadingStateSignal())
.subscribe();
}
<div class="mb-3">
<mix-restore-table-btn [dbSysName]="dbSysName"></mix-restore-table-btn>
</div>
public restoreSingleTable() {
this.mixApi.databaseApi
.restoreTable(this.dbSysName!)
.pipe(this.observerLoadingStateSignal())
.subscribe();
}
<div class="mb-3">
<mix-update-table-btn [dbSysName]="dbSysName"></mix-update-table-btn>
</div>
}
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DatabaseMigrationComponent {
@Input() public dbSysName?: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { CommonModule } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Input,
inject,
} from '@angular/core';
import { MixApiFacadeService } from '@mixcore/share/api';
import { BaseComponent } from '@mixcore/share/base';
import { MixButtonComponent } from '@mixcore/ui/button';

@Component({
selector: 'mix-migrate-table-btn',
standalone: true,
imports: [CommonModule, MixButtonComponent],
template: `
<mix-button
[loading]="loadingState() === 'Loading'"
(click)="migrateSingleTable()"
>Migrate to single table</mix-button
>
<div>
Before using a database that you have created for the first time, it must
be migrated into a single table.
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MigrateTableButtonComponent extends BaseComponent {
@Input() public dbSysName?: string;
public mixApi = inject(MixApiFacadeService);

public migrateSingleTable() {
this.mixApi.databaseApi
.migrateToSingleTable(this.dbSysName!)
.pipe(this.observerLoadingStateSignal())
.subscribe();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { CommonModule } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Input,
inject,
} from '@angular/core';
import { MixApiFacadeService } from '@mixcore/share/api';
import { BaseComponent } from '@mixcore/share/base';
import { MixButtonComponent } from '@mixcore/ui/button';

@Component({
selector: 'mix-restore-table-btn',
standalone: true,
imports: [CommonModule, MixButtonComponent],
template: `
<mix-button
[type]="'danger'"
[loading]="loadingState() === 'Loading'"
(click)="restoreSingleTable()"
>Restore table</mix-button
>
<div>
Depending on when you last backed up the data, the system will restore it.
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class RestoreTableButtonComponent extends BaseComponent {
@Input() public dbSysName?: string;
public mixApi = inject(MixApiFacadeService);

public restoreSingleTable() {
this.mixApi.databaseApi
.restoreTable(this.dbSysName!)
.pipe(this.observerLoadingStateSignal())
.subscribe();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { CommonModule } from '@angular/common';
import {
ChangeDetectionStrategy,
Component,
Input,
inject,
} from '@angular/core';
import { MixApiFacadeService } from '@mixcore/share/api';
import { BaseComponent } from '@mixcore/share/base';
import { MixButtonComponent } from '@mixcore/ui/button';

@Component({
selector: 'mix-update-table-btn',
standalone: true,
imports: [CommonModule, MixButtonComponent],
template: `
<mix-button
[loading]="loadingState() === 'Loading'"
(click)="updateSingleTable()"
>Update data table</mix-button
>
<div>
When you wish to make changes to your database or add new columns, run
this migration.
</div>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class UpdateTableButtonComponent extends BaseComponent {
@Input() public dbSysName?: string;
public mixApi = inject(MixApiFacadeService);

public updateSingleTable() {
this.mixApi.databaseApi
.updateDataTable(this.dbSysName!)
.pipe(this.observerLoadingStateSignal())
.subscribe();
}
}
Loading

1 comment on commit a0352cd

@vercel
Copy link

@vercel vercel bot commented on a0352cd Nov 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.