-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added DbxFirebaseDevelopmentSchedulerWidgetComponent
- Loading branch information
Showing
9 changed files
with
213 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/dbx-firebase/src/lib/development/development.scheduler.list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Guestbook } from '@dereekb/demo-firebase'; | ||
import { Component, Inject } from '@angular/core'; | ||
import { AbstractDbxSelectionListWrapperDirective, AbstractDbxValueListViewItemComponent, AbstractDbxSelectionListViewDirective, DEFAULT_LIST_WRAPPER_DIRECTIVE_TEMPLATE, DbxSelectionValueListViewConfig, provideDbxListView, DEFAULT_DBX_SELECTION_VALUE_LIST_DIRECTIVE_TEMPLATE, DbxValueAsListItem, provideDbxListViewWrapper, DBX_VALUE_LIST_VIEW_ITEM, DbxValueListItem } from '@dereekb/dbx-web'; | ||
import { from, of } from 'rxjs'; | ||
import { ScheduledFunctionDevelopmentFirebaseFunctionListEntry } from '@dereekb/firebase'; | ||
import { DbxFirebaseDevelopmentSchedulerService } from './development.scheduler.service'; | ||
import { HandleActionWithContext } from '@dereekb/dbx-core'; | ||
|
||
export type ScheduledFunctionDevelopmentFirebaseFunctionListEntryWithSelection = DbxValueAsListItem<ScheduledFunctionDevelopmentFirebaseFunctionListEntry>; | ||
|
||
@Component({ | ||
selector: 'dbx-firebase-development-scheduler-list', | ||
template: DEFAULT_LIST_WRAPPER_DIRECTIVE_TEMPLATE, | ||
providers: provideDbxListViewWrapper(DbxFirebaseDevelopmentSchedulerListComponent) | ||
}) | ||
export class DbxFirebaseDevelopmentSchedulerListComponent extends AbstractDbxSelectionListWrapperDirective<ScheduledFunctionDevelopmentFirebaseFunctionListEntry> { | ||
constructor() { | ||
super({ | ||
componentClass: DbxFirebaseDevelopmentSchedulerListViewComponent, | ||
defaultSelectionMode: 'view' | ||
}); | ||
} | ||
} | ||
|
||
@Component({ | ||
template: DEFAULT_DBX_SELECTION_VALUE_LIST_DIRECTIVE_TEMPLATE, | ||
providers: provideDbxListView(DbxFirebaseDevelopmentSchedulerListViewComponent) | ||
}) | ||
export class DbxFirebaseDevelopmentSchedulerListViewComponent extends AbstractDbxSelectionListViewDirective<ScheduledFunctionDevelopmentFirebaseFunctionListEntry> { | ||
readonly config: DbxSelectionValueListViewConfig<ScheduledFunctionDevelopmentFirebaseFunctionListEntryWithSelection> = { | ||
componentClass: DbxFirebaseDevelopmentSchedulerListViewItemComponent, | ||
mapValuesToItemValues: (x) => of(x.map((y) => ({ ...y, icon: y.icon, itemValue: y }))) | ||
}; | ||
} | ||
|
||
@Component({ | ||
template: ` | ||
<div dbxAction dbxActionValue fastTrigger [dbxActionHandler]="handleRun"> | ||
<dbx-button dbxActionButton [text]="'Run ' + name"></dbx-button> | ||
<dbx-success *dbxActionHasSuccess="3000" dbxActionSuccess>Success</dbx-success> | ||
</div> | ||
` | ||
}) | ||
export class DbxFirebaseDevelopmentSchedulerListViewItemComponent extends AbstractDbxValueListViewItemComponent<ScheduledFunctionDevelopmentFirebaseFunctionListEntry> { | ||
get name() { | ||
return this.itemValue.name; | ||
} | ||
|
||
constructor(@Inject(DBX_VALUE_LIST_VIEW_ITEM) item: DbxValueListItem<ScheduledFunctionDevelopmentFirebaseFunctionListEntry>, readonly dbxFirebaseDevelopmentSchedulerService: DbxFirebaseDevelopmentSchedulerService) { | ||
super(item); | ||
} | ||
|
||
readonly handleRun: HandleActionWithContext<unknown, unknown> = (value, context) => { | ||
context.startWorkingWithObservable(from(this.dbxFirebaseDevelopmentSchedulerService.runScheduledFunction(this.name))); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.