diff --git a/app/components/account/account.module.ts b/app/components/account/account.module.ts index a2372cfa4b..faea599012 100644 --- a/app/components/account/account.module.ts +++ b/app/components/account/account.module.ts @@ -4,7 +4,6 @@ import { commonModules } from "app/common"; import { EditStorageAccountFormComponent } from "app/components/account/action/edit-storage-account"; import { AutoStorageAccountPickerComponent } from "app/components/account/base/auto-storage-account-picker"; import { PoolBaseModule } from "app/components/pool/base"; -import { BatchAccountCommands } from "./action"; import { BatchAccountCreateComponent } from "./action/add"; import { DeleteAccountDialogComponent } from "./action/delete/delete-account-dialog.component"; import { AccountBrowseModule } from "./browse"; @@ -35,9 +34,6 @@ const modules = [ DeleteAccountDialogComponent, EditStorageAccountFormComponent, ], - providers: [ - BatchAccountCommands, - ], }) export class AccountModule { } diff --git a/app/components/account/browse/account-list/account-list.component.spec.ts b/app/components/account/browse/account-list/account-list.component.spec.ts index da7f37ab54..1498697fd7 100644 --- a/app/components/account/browse/account-list/account-list.component.spec.ts +++ b/app/components/account/browse/account-list/account-list.component.spec.ts @@ -7,7 +7,7 @@ import { List } from "immutable"; import { Observable } from "rxjs"; import { FilterBuilder } from "@batch-flask/core"; -import { DialogService, InjectorFactory, NotificationService } from "@batch-flask/ui"; +import { DialogService, NotificationService } from "@batch-flask/ui"; import { BackgroundTaskService } from "@batch-flask/ui/background-task"; import { SidebarManager } from "@batch-flask/ui/sidebar"; import { AccountListComponent } from "app/components/account/browse"; @@ -68,7 +68,6 @@ describe("AccountListComponent", () => { { provide: BackgroundTaskService, useValue: null }, { provide: NotificationService, useValue: null }, { provide: DialogService, useValue: null }, - InjectorFactory, ], schemas: [NO_ERRORS_SCHEMA], }); diff --git a/app/components/account/browse/account-list/account-list.component.ts b/app/components/account/browse/account-list/account-list.component.ts index 3a37333eda..0f9414b446 100644 --- a/app/components/account/browse/account-list/account-list.component.ts +++ b/app/components/account/browse/account-list/account-list.component.ts @@ -6,7 +6,6 @@ import { Observable, Subscription } from "rxjs"; import { Filter, FilterMatcher, autobind } from "@batch-flask/core"; import { ListBaseComponent, ListSelection } from "@batch-flask/core/list"; -import { InjectorFactory } from "@batch-flask/ui"; import { BackgroundTaskService } from "@batch-flask/ui/background-task"; import { ContextMenu, ContextMenuItem } from "@batch-flask/ui/context-menu"; import { LoadingStatus } from "@batch-flask/ui/loading"; @@ -20,10 +19,13 @@ import { DeleteAccountDialogComponent, DeleteAccountTask } from "../../action/de @Component({ selector: "bl-account-list", templateUrl: "account-list.html", - providers: [{ - provide: ListBaseComponent, - useExisting: forwardRef(() => AccountListComponent), - }], + providers: [ + BatchAccountCommands, + { + provide: ListBaseComponent, + useExisting: forwardRef(() => AccountListComponent), + }, + ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class AccountListComponent extends ListBaseComponent implements OnDestroy { @@ -31,12 +33,11 @@ export class AccountListComponent extends ListBaseComponent implements OnDestroy public accounts: List = List([]); public displayedAccounts: List = List([]); public loadingStatus: LoadingStatus = LoadingStatus.Loading; - public commands: BatchAccountCommands; private _accountSub: Subscription; constructor( - public injectorFactory: InjectorFactory, + public commands: BatchAccountCommands, private accountService: AccountService, private dialog: MatDialog, private taskManager: BackgroundTaskService, @@ -45,7 +46,6 @@ export class AccountListComponent extends ListBaseComponent implements OnDestroy changeDetector: ChangeDetectorRef, subscriptionService: SubscriptionService) { super(changeDetector); - this.commands = injectorFactory.create(BatchAccountCommands); this._updateDisplayedAccounts(); this.accountService.accountsLoaded.subscribe(() => { diff --git a/app/components/application/browse/application-list.component.spec.ts b/app/components/application/browse/application-list.component.spec.ts index 83a10fb81f..a0494ff207 100644 --- a/app/components/application/browse/application-list.component.spec.ts +++ b/app/components/application/browse/application-list.component.spec.ts @@ -5,7 +5,7 @@ import { RouterTestingModule } from "@angular/router/testing"; import { Subject } from "rxjs"; import { FilterBuilder } from "@batch-flask/core"; -import { DialogService, InjectorFactory, NotificationService } from "@batch-flask/ui"; +import { DialogService, NotificationService } from "@batch-flask/ui"; import { BackgroundTaskService } from "@batch-flask/ui/background-task"; import { SidebarManager } from "@batch-flask/ui/sidebar"; import { ApplicationListComponent } from "app/components/application/browse"; @@ -51,7 +51,6 @@ describe("ApplicationListComponent", () => { { provide: PinnedEntityService, useValue: pinServiceSpy }, { provide: BackgroundTaskService, useValue: null }, { provide: SidebarManager, useValue: null }, - InjectorFactory, ], schemas: [NO_ERRORS_SCHEMA], }); diff --git a/app/components/application/browse/application-list.component.ts b/app/components/application/browse/application-list.component.ts index 68d88657fd..94b4c834ff 100644 --- a/app/components/application/browse/application-list.component.ts +++ b/app/components/application/browse/application-list.component.ts @@ -5,7 +5,7 @@ import { Observable, Subscription } from "rxjs"; import { Filter, autobind } from "@batch-flask/core"; import { ListBaseComponent } from "@batch-flask/core/list"; -import { InjectorFactory, LoadingStatus } from "@batch-flask/ui"; +import { LoadingStatus } from "@batch-flask/ui"; import { QuickListItemStatus } from "@batch-flask/ui/quick-list"; import { BatchApplication } from "app/models"; import { ApplicationListParams, ApplicationService } from "app/services"; @@ -17,7 +17,7 @@ import "./application-list.scss"; @Component({ selector: "bl-application-list", templateUrl: "application-list.html", - providers: [{ + providers: [BatchApplicationCommands, { provide: ListBaseComponent, useExisting: forwardRef(() => ApplicationListComponent), }], @@ -28,7 +28,6 @@ export class ApplicationListComponent extends ListBaseComponent implements OnIni public data: ListView; public applications: List; public displayedApplications: List; - public commands: BatchApplicationCommands; private _baseOptions = { maxresults: 50 }; private _subs: Subscription[] = []; @@ -36,11 +35,10 @@ export class ApplicationListComponent extends ListBaseComponent implements OnIni constructor( router: Router, changeDetector: ChangeDetectorRef, - injectorFactory: InjectorFactory, + public commands: BatchApplicationCommands, private applicationService: ApplicationService, - ) { + ) { super(changeDetector); - this.commands = injectorFactory.create(BatchApplicationCommands); this.data = this.applicationService.listView(this._baseOptions); this._subs.push(this.data.items.subscribe((applications) => { diff --git a/app/components/certificate/browse/certificate-list.component.ts b/app/components/certificate/browse/certificate-list.component.ts index 03090e5e1e..a78b6b3229 100644 --- a/app/components/certificate/browse/certificate-list.component.ts +++ b/app/components/certificate/browse/certificate-list.component.ts @@ -8,7 +8,6 @@ import { Observable, Subscription } from "rxjs"; import { Filter, FilterMatcher, autobind } from "@batch-flask/core"; import { ListBaseComponent, ListSelection } from "@batch-flask/core/list"; -import { InjectorFactory } from "@batch-flask/ui"; import { BackgroundTaskService } from "@batch-flask/ui/background-task"; import { LoadingStatus } from "@batch-flask/ui/loading"; import { QuickListItemStatus } from "@batch-flask/ui/quick-list"; @@ -24,13 +23,12 @@ import { selector: "bl-certificate-list", templateUrl: "certificate-list.html", changeDetection: ChangeDetectionStrategy.OnPush, - providers: [{ + providers: [CertificateCommands, { provide: ListBaseComponent, useExisting: forwardRef(() => CertificateListComponent), }], }) export class CertificateListComponent extends ListBaseComponent implements OnInit, OnDestroy { - public commands: CertificateCommands; public certificates: List; public displayedCertificates: List = List([]); public LoadingStatus = LoadingStatus; @@ -43,12 +41,11 @@ export class CertificateListComponent extends ListBaseComponent implements OnIni router: Router, activatedRoute: ActivatedRoute, changeDetector: ChangeDetectorRef, - injectorFactory: InjectorFactory, + public commands: CertificateCommands, private certificateService: CertificateService, private taskManager: BackgroundTaskService, ) { super(changeDetector); - this.commands = injectorFactory.create(CertificateCommands); this.data = this.certificateService.listView(); ComponentUtils.setActiveItem(activatedRoute, this.data); diff --git a/app/components/data/browse/data-container-list.component.ts b/app/components/data/browse/data-container-list.component.ts index 4abbb8d619..b22a8bf58f 100644 --- a/app/components/data/browse/data-container-list.component.ts +++ b/app/components/data/browse/data-container-list.component.ts @@ -6,7 +6,7 @@ import { ActivatedRoute, Router } from "@angular/router"; import { Filter, autobind } from "@batch-flask/core"; import { ListBaseComponent, ListSelection } from "@batch-flask/core/list"; import { - BackgroundTaskService, InjectorFactory, LoadingStatus, QuickListItemStatus, + BackgroundTaskService, LoadingStatus, QuickListItemStatus, } from "@batch-flask/ui"; import { List } from "immutable"; import { Observable, Subscription } from "rxjs"; @@ -26,14 +26,13 @@ const defaultListOptions = { @Component({ selector: "bl-data-container-list", templateUrl: "data-container-list.html", - providers: [{ + providers: [BlobContainerCommands, { provide: ListBaseComponent, useExisting: forwardRef(() => DataContainerListComponent), }], changeDetection: ChangeDetectionStrategy.OnPush, }) export class DataContainerListComponent extends ListBaseComponent implements OnInit, OnChanges, OnDestroy { - public commands: BlobContainerCommands; public LoadingStatus = LoadingStatus; @Input() public storageAccountId: string; @@ -47,13 +46,12 @@ export class DataContainerListComponent extends ListBaseComponent implements OnI constructor( router: Router, changeDetector: ChangeDetectorRef, - injectorFactory: InjectorFactory, + public commands: BlobContainerCommands, private activeRoute: ActivatedRoute, private taskManager: BackgroundTaskService, private storageContainerService: StorageContainerService) { super(changeDetector); - this.commands = injectorFactory.create(BlobContainerCommands); this.data = this.storageContainerService.listView(); ComponentUtils.setActiveItem(activeRoute, this.data); diff --git a/app/components/job-schedule/browse/job-schedule-list.component.ts b/app/components/job-schedule/browse/job-schedule-list.component.ts index be77604866..c2bd5d79ab 100644 --- a/app/components/job-schedule/browse/job-schedule-list.component.ts +++ b/app/components/job-schedule/browse/job-schedule-list.component.ts @@ -9,7 +9,6 @@ import { Observable, Subscription } from "rxjs"; import { Filter, autobind } from "@batch-flask/core"; import { ListBaseComponent, ListSelection } from "@batch-flask/core/list"; -import { InjectorFactory } from "@batch-flask/ui"; import { BackgroundTaskService } from "@batch-flask/ui/background-task"; import { ContextMenu, ContextMenuItem } from "@batch-flask/ui/context-menu"; import { LoadingStatus } from "@batch-flask/ui/loading"; @@ -33,13 +32,12 @@ import { selector: "bl-job-schedule-list", templateUrl: "job-schedule-list.html", changeDetection: ChangeDetectionStrategy.OnPush, - providers: [{ + providers: [JobScheduleCommands, { provide: ListBaseComponent, useExisting: forwardRef(() => JobScheduleListComponent), }], }) export class JobScheduleListComponent extends ListBaseComponent implements OnInit, OnDestroy { - public commands: JobScheduleCommands; public jobSchedules: List; public LoadingStatus = LoadingStatus; @@ -53,7 +51,7 @@ export class JobScheduleListComponent extends ListBaseComponent implements OnIni router: Router, activatedRoute: ActivatedRoute, changeDetector: ChangeDetectorRef, - injectorFactory: InjectorFactory, + public commands: JobScheduleCommands, private sidebarManager: SidebarManager, private dialog: MatDialog, private jobScheduleService: JobScheduleService, @@ -61,7 +59,6 @@ export class JobScheduleListComponent extends ListBaseComponent implements OnIni private taskManager: BackgroundTaskService) { super(changeDetector); - this.commands = injectorFactory.create(JobScheduleCommands); this.data = this.jobScheduleService.listView(); ComponentUtils.setActiveItem(activatedRoute, this.data); this.data.items.subscribe((jobSchedules) => { diff --git a/app/components/job/action/disable/disable-job.command.ts b/app/components/job/action/disable/disable-job.command.ts index 91394c66c0..9ea86b8bb8 100644 --- a/app/components/job/action/disable/disable-job.command.ts +++ b/app/components/job/action/disable/disable-job.command.ts @@ -1,4 +1,4 @@ -import { Injectable, Injector } from "@angular/core"; +import { Injector } from "@angular/core"; import { autobind } from "@batch-flask/core"; import { DialogService, EntityCommand } from "@batch-flask/ui"; @@ -6,20 +6,24 @@ import { Job, JobState } from "app/models"; import { JobService } from "app/services"; import { DisableJobDialogComponent } from "./disable-job-dialog.component"; -@Injectable() export class DisableJobCommand extends EntityCommand { - constructor(injector: Injector, jobService: JobService, private dialog: DialogService) { + private _dialog: DialogService; + + constructor(injector: Injector) { + const jobService = injector.get(JobService); + super(injector, { label: "Disable", action: (job: Job, option: string) => jobService.disable(job.id, option), enabled: (job) => job.state !== JobState.completed && job.state !== JobState.disabled, confirm: (x) => this._confirmAndGetInfo(x), }); + this._dialog = injector.get(DialogService); } @autobind() private _confirmAndGetInfo(entities: Job[]) { - const dialogRef = this.dialog.open(DisableJobDialogComponent); + const dialogRef = this._dialog.open(DisableJobDialogComponent); dialogRef.componentInstance.jobs = entities; return dialogRef.componentInstance.onSubmit; } diff --git a/app/components/job/action/terminate/terminate-job.command.ts b/app/components/job/action/terminate/terminate-job.command.ts index b4ebda658b..4ebfb29ca0 100644 --- a/app/components/job/action/terminate/terminate-job.command.ts +++ b/app/components/job/action/terminate/terminate-job.command.ts @@ -6,7 +6,9 @@ import { JobService } from "app/services"; @Injectable() export class TerminateJobCommand extends EntityCommand { - constructor(injector: Injector, jobService: JobService) { + constructor(injector: Injector) { + const jobService = injector.get(JobService); + super(injector, { label: "Terminate", action: (job: Job) => jobService.terminate(job.id), diff --git a/app/components/job/browse/job-list.component.ts b/app/components/job/browse/job-list.component.ts index 73f8a6b8cf..dbb6c1807b 100644 --- a/app/components/job/browse/job-list.component.ts +++ b/app/components/job/browse/job-list.component.ts @@ -5,7 +5,6 @@ import { Observable, Subscription } from "rxjs"; import { Filter, autobind } from "@batch-flask/core"; import { ListBaseComponent, ListSelection } from "@batch-flask/core/list"; -import { InjectorFactory } from "@batch-flask/ui"; import { BackgroundTaskService } from "@batch-flask/ui/background-task"; import { LoadingStatus } from "@batch-flask/ui/loading"; import { QuickListItemStatus } from "@batch-flask/ui/quick-list"; @@ -25,7 +24,7 @@ import { @Component({ selector: "bl-job-list", templateUrl: "job-list.html", - providers: [{ + providers: [JobCommands, { provide: ListBaseComponent, useExisting: forwardRef(() => JobListComponent), }], @@ -37,7 +36,6 @@ export class JobListComponent extends ListBaseComponent implements OnInit, OnDes public data: ListView; public searchQuery = new FormControl(); - public commands: JobCommands; // todo: ask tim about setting difference select options for list and details. private _baseOptions = {}; @@ -46,12 +44,11 @@ export class JobListComponent extends ListBaseComponent implements OnInit, OnDes router: Router, activatedRoute: ActivatedRoute, changeDetector: ChangeDetectorRef, - injectorFactory: InjectorFactory, + public commands: JobCommands, private sidebarManager: SidebarManager, private jobService: JobService, private taskManager: BackgroundTaskService) { super(changeDetector); - this.commands = injectorFactory.create(JobCommands); this.data = this.jobService.listView(); ComponentUtils.setActiveItem(activatedRoute, this.data); this.data.items.subscribe((jobs) => { diff --git a/app/components/job/details/job-details.component.ts b/app/components/job/details/job-details.component.ts index 8a3273858a..bf92e5e2d3 100644 --- a/app/components/job/details/job-details.component.ts +++ b/app/components/job/details/job-details.component.ts @@ -17,12 +17,13 @@ import { PatchJobComponent, } from "../action"; -import { ElectronRemote, InjectorFactory } from "@batch-flask/ui"; +import { ElectronRemote } from "@batch-flask/ui"; import "./job-details.scss"; @Component({ selector: "bl-job-details", templateUrl: "job-details.html", + providers: [JobCommands], }) export class JobDetailsComponent implements OnInit, OnDestroy { public static breadcrumb({ id }, { tab }) { @@ -40,19 +41,17 @@ export class JobDetailsComponent implements OnInit, OnDestroy { public data: EntityView; public JobState = JobState; public hasHookTask = false; - public jobCommands: JobCommands; private _paramsSubscriber: Subscription; constructor( - private injectorFactory: InjectorFactory, + public jobCommands: JobCommands, private activatedRoute: ActivatedRoute, private fs: FileSystemService, private remote: ElectronRemote, private sidebarManager: SidebarManager, private jobService: JobService, private router: Router) { - this.jobCommands = this.injectorFactory.create(JobCommands); this.data = this.jobService.view(); this.data.item.subscribe((job) => { diff --git a/app/components/pool/browse/pool-list.component.ts b/app/components/pool/browse/pool-list.component.ts index 199a29689c..93917f4dcf 100644 --- a/app/components/pool/browse/pool-list.component.ts +++ b/app/components/pool/browse/pool-list.component.ts @@ -7,7 +7,6 @@ import { Observable, Subscription } from "rxjs"; import { Filter, autobind } from "@batch-flask/core"; import { ListBaseComponent, ListSelection } from "@batch-flask/core/list"; -import { InjectorFactory } from "@batch-flask/ui"; import { BackgroundTaskService } from "@batch-flask/ui/background-task"; import { LoadingStatus } from "@batch-flask/ui/loading"; import { QuickListItemStatus } from "@batch-flask/ui/quick-list"; @@ -23,7 +22,7 @@ import { DeletePoolTask, PoolCommands } from "../action"; selector: "bl-pool-list", templateUrl: "pool-list.html", changeDetection: ChangeDetectionStrategy.OnPush, - providers: [{ + providers: [PoolCommands, { provide: ListBaseComponent, useExisting: forwardRef(() => PoolListComponent), }], @@ -31,7 +30,6 @@ import { DeletePoolTask, PoolCommands } from "../action"; export class PoolListComponent extends ListBaseComponent implements OnInit, OnDestroy { public LoadingStatus = LoadingStatus; public data: ListView; - public commands: PoolCommands; public tableConfig: TableConfig = { showCheckbox: true, @@ -44,11 +42,10 @@ export class PoolListComponent extends ListBaseComponent implements OnInit, OnDe private poolService: PoolService, activatedRoute: ActivatedRoute, router: Router, - injectorFactory: InjectorFactory, + public commands: PoolCommands, changeDetector: ChangeDetectorRef, private taskManager: BackgroundTaskService) { super(changeDetector); - this.commands = injectorFactory.create(PoolCommands); this.data = this.poolService.listView(); ComponentUtils.setActiveItem(activatedRoute, this.data); diff --git a/app/components/pool/details/pool-details.component.ts b/app/components/pool/details/pool-details.component.ts index 7ef11caa22..cb6d7d07f1 100644 --- a/app/components/pool/details/pool-details.component.ts +++ b/app/components/pool/details/pool-details.component.ts @@ -1,7 +1,7 @@ import { Component, OnDestroy, OnInit } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { autobind } from "@batch-flask/core"; -import { ElectronRemote, InjectorFactory } from "@batch-flask/ui"; +import { ElectronRemote } from "@batch-flask/ui"; import { List } from "immutable"; import { Observable, Subscription } from "rxjs"; @@ -19,6 +19,7 @@ import "./pool-details.scss"; @Component({ selector: "bl-pool-details", templateUrl: "pool-details.html", + providers: [PoolCommands], }) export class PoolDetailsComponent implements OnInit, OnDestroy { public static breadcrumb({ id }, { tab }) { @@ -39,13 +40,12 @@ export class PoolDetailsComponent implements OnInit, OnDestroy { public get pool() { return this._pool; } public data: EntityView; public estimatedCost = "-"; - public commands: PoolCommands; private _paramsSubscriber: Subscription; private _pool: Pool; constructor( - injectorFactory: InjectorFactory, + public commands: PoolCommands, private router: Router, private activatedRoute: ActivatedRoute, private batchLabs: BatchLabsService, @@ -54,7 +54,6 @@ export class PoolDetailsComponent implements OnInit, OnDestroy { private remote: ElectronRemote, private pricingService: PricingService, private poolService: PoolService) { - this.commands = injectorFactory.create(PoolCommands); this.data = this.poolService.view(); this.data.item.subscribe((pool) => { diff --git a/app/components/task/browse/display/task-list-display.component.ts b/app/components/task/browse/display/task-list-display.component.ts index 8103fb86da..91b3c59b6b 100644 --- a/app/components/task/browse/display/task-list-display.component.ts +++ b/app/components/task/browse/display/task-list-display.component.ts @@ -5,7 +5,6 @@ import { import { List } from "immutable"; import { ListBaseComponent } from "@batch-flask/core/list"; -import { InjectorFactory } from "@batch-flask/ui"; import { LoadingStatus } from "@batch-flask/ui/loading"; import { QuickListItemStatus } from "@batch-flask/ui/quick-list"; import { TaskCommands } from "app/components/task/action"; @@ -17,6 +16,7 @@ import { DateUtils } from "app/utils"; selector: "bl-task-list-display", templateUrl: "task-list-display.html", changeDetection: ChangeDetectionStrategy.OnPush, + providers: [TaskCommands], }) export class TaskListDisplayComponent extends ListBaseComponent implements OnChanges { @Input() public jobId: string; @@ -27,11 +27,8 @@ export class TaskListDisplayComponent extends ListBaseComponent implements OnCha @Output() public scrollBottom = new EventEmitter(); - public commands: TaskCommands; - - constructor(injectorFactory: InjectorFactory, changeDetector: ChangeDetectorRef) { + constructor(public commands: TaskCommands, changeDetector: ChangeDetectorRef) { super(changeDetector); - this.commands = injectorFactory.create(TaskCommands); } public ngOnChanges(changes) { diff --git a/app/components/task/details/task-dependencies/task-dependencies.component.spec.ts b/app/components/task/details/task-dependencies/task-dependencies.component.spec.ts index 764197b071..26fd2792a5 100644 --- a/app/components/task/details/task-dependencies/task-dependencies.component.spec.ts +++ b/app/components/task/details/task-dependencies/task-dependencies.component.spec.ts @@ -5,7 +5,7 @@ import { RouterTestingModule } from "@angular/router/testing"; import { List } from "immutable"; import { Observable } from "rxjs"; -import { ContextMenuService, InjectorFactory } from "@batch-flask/ui"; +import { ContextMenuService } from "@batch-flask/ui"; import { TableCellComponent, TableColumnComponent, TableComponent, TableHeadComponent, } from "@batch-flask/ui/table"; @@ -57,7 +57,6 @@ describe("TaskDependenciesComponent", () => { providers: [ { provide: TaskService, useValue: taskServiceSpy }, { provide: ContextMenuService, useValue: null }, - InjectorFactory, ], schemas: [NO_ERRORS_SCHEMA], }); diff --git a/docs/context-menu.md b/docs/context-menu.md index c16d528d4c..0bece2c560 100644 --- a/docs/context-menu.md +++ b/docs/context-menu.md @@ -36,8 +36,7 @@ In the template In the model ```typescript - constructor(injectorFactory: InjectorFactory) { - this.commands = injectorFactory.create(JobCommands); + constructor(public commands: JobCommands) { } ``` diff --git a/src/@batch-flask/ui/batchui.module.ts b/src/@batch-flask/ui/batchui.module.ts index 8f653bd13f..a4a3f76a55 100644 --- a/src/@batch-flask/ui/batchui.module.ts +++ b/src/@batch-flask/ui/batchui.module.ts @@ -26,7 +26,6 @@ import { FormModule } from "./form"; import { GraphsModule } from "./graphs"; import { IconComponent } from "./icon"; import { InfoBoxModule } from "./info-box"; -import { InjectorFactoryModule } from "./injector-factory"; import { DeleteSelectedItemsDialogComponent, EntityDetailsListComponent, } from "./list-and-show-layout"; @@ -85,7 +84,6 @@ const modules = [ VirtualScrollModule, VTabsModule, ElectronModule, - InjectorFactoryModule, ]; // Add subcomponnent not in a module here diff --git a/src/@batch-flask/ui/entity-commands/entity-commands.ts b/src/@batch-flask/ui/entity-commands/entity-commands.ts index a51c944a65..b64df731b6 100644 --- a/src/@batch-flask/ui/entity-commands/entity-commands.ts +++ b/src/@batch-flask/ui/entity-commands/entity-commands.ts @@ -6,7 +6,6 @@ import { Observable } from "rxjs"; import { ListSelection } from "@batch-flask/core/list/list-selection"; import { BackgroundTaskService } from "@batch-flask/ui/background-task"; import { ContextMenu, ContextMenuItem } from "@batch-flask/ui/context-menu"; -import { InjectorFactory } from "@batch-flask/ui/injector-factory"; import { log } from "@batch-flask/utils"; import { EntityCommand, EntityCommandAttributes } from "./entity-command"; @@ -24,10 +23,8 @@ export abstract class EntityCommands>; - private _injectorFactory: InjectorFactory; constructor(private injector: Injector, public typeName: string) { - this._injectorFactory = injector.get(InjectorFactory); this.notificationService = injector.get(NotificationService); this.dialogService = injector.get(DialogService); this.backgroundTaskService = injector.get(BackgroundTaskService); @@ -97,7 +94,7 @@ export abstract class EntityCommands>(type: Type): T { - const command = this._injectorFactory.create(type); + const command = new type(this.injector); command.definition = this; return command; } diff --git a/src/@batch-flask/ui/index.ts b/src/@batch-flask/ui/index.ts index 2a7331ef81..d0c5799c08 100644 --- a/src/@batch-flask/ui/index.ts +++ b/src/@batch-flask/ui/index.ts @@ -11,5 +11,4 @@ export * from "./context-menu"; export * from "./sidebar"; export * from "./permission"; export * from "./vtabs"; -export * from "./injector-factory"; export * from "./entity-commands"; diff --git a/src/@batch-flask/ui/injector-factory/index.ts b/src/@batch-flask/ui/injector-factory/index.ts deleted file mode 100644 index 67d756045d..0000000000 --- a/src/@batch-flask/ui/injector-factory/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./injector-factory.service"; -export * from "./injector-factory.module"; diff --git a/src/@batch-flask/ui/injector-factory/injector-factory.module.ts b/src/@batch-flask/ui/injector-factory/injector-factory.module.ts deleted file mode 100644 index 2310d29fbe..0000000000 --- a/src/@batch-flask/ui/injector-factory/injector-factory.module.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { NgModule } from "@angular/core"; -import { InjectorFactory } from "./injector-factory.service"; - -const publicComponents = []; -const privateComponents = []; - -@NgModule({ - imports: [], - declarations: [...publicComponents, ...privateComponents], - exports: publicComponents, - entryComponents: [], - providers: [ - InjectorFactory, - ], -}) -export class InjectorFactoryModule { -} diff --git a/src/@batch-flask/ui/injector-factory/injector-factory.service.ts b/src/@batch-flask/ui/injector-factory/injector-factory.service.ts deleted file mode 100644 index 90d7e7b020..0000000000 --- a/src/@batch-flask/ui/injector-factory/injector-factory.service.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Injectable, Injector, ReflectiveInjector, Type } from "@angular/core"; - -/** - * Helper class to create a new instance of an object using dependency injection - */ -@Injectable() -export class InjectorFactory { - constructor(private injector: Injector) { } - - public create(type: Type): T { - return ReflectiveInjector.resolveAndCreate([type], this.injector).resolveAndInstantiate(type); - } -}