-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324 from openziti/323-more-actions-extensions
Allow ZAC extensions to define additional items for the "More Actions" drop down
- Loading branch information
Showing
20 changed files
with
168 additions
and
46 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
26 changes: 26 additions & 0 deletions
26
projects/app-ziti-console/src/app/examples/extension-service/README.md
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,26 @@ | ||
# Extension Service | ||
|
||
Below is an example of how to define and use an extension service. | ||
|
||
In the file `example-extension.service.ts` is an exported class that implements the `ExtensionService` interface. | ||
|
||
Each create/edit form (ie. `identity-form.component.ts`, `edge-router-form.component.ts` etc...) injects an instance of an `ExtensionService` implementation. | ||
|
||
To use a specific implementation of an extension service, you must define a provider for it in `app.module.ts`. See below for an example of how to do this: | ||
|
||
``` | ||
// In the "providers" secion of app.module.ts, use the relevant injection token to decalre which instance of the extesnsion service to provide | ||
import { ExampleExtensionService } from "./examples/extension-service/example-extension.service"; | ||
@NgModule({ | ||
declarations: [AppComponent], | ||
providers: [ | ||
// Here we can chose to use the example-extension.service.ts | ||
{ provide: EDGE_ROUTER_EXTENSION_SERVICE, useClass: ExampleExtensionService }, | ||
] | ||
}) | ||
``` | ||
|
||
In `example-extension.service.ts` are examples of how the various properties, functions, and events are defined. If you open the EdgeRouter create/edit form | ||
(either by clicking on an existing router from the list page, or by adding a new one), you should then see the "Edit Form Action" item display as an option in the "More Actions" dropdown |
51 changes: 51 additions & 0 deletions
51
projects/app-ziti-console/src/app/examples/extension-service/example-extension.service.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,51 @@ | ||
import {EventEmitter, Injectable} from '@angular/core'; | ||
import {ExtensionService} from "ziti-console-lib"; | ||
import {BehaviorSubject} from "rxjs"; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class ExampleExtensionService implements ExtensionService { | ||
|
||
moreActions = [ | ||
{label: 'Example Action', action: 'more-action', callback: this.executeMoreAction.bind(this)}, | ||
] | ||
listActions = [ | ||
{label: 'Example Action', action: 'list-action', callback: this.executeListAction.bind(this)}, | ||
] | ||
closeAfterSave: boolean; | ||
closed: EventEmitter<any>; | ||
formDataChanged: BehaviorSubject<any>; | ||
|
||
extendAfterViewInits(extentionPoints: any): void { | ||
// This function will execute after the edit form is initialized | ||
// Uncomment the alert below to see when this function is called | ||
//alert('ExampleExtensionService "extendAfterViewInits()" function executed'); | ||
} | ||
|
||
formDataSaved(data: any): Promise<any> { | ||
// This function will execute before form data is saved in order to do check if extension data is valid | ||
// Uncomment the alert below to see when this function is called | ||
// alert('ExampleExtensionService "formDataSaved()" function executed'); | ||
return Promise.resolve(undefined); | ||
} | ||
|
||
updateFormData(data: any): void { | ||
// This function will pass in a reference to the root data model of the entity being edited | ||
// Uncomment the alert below to see when this function is called | ||
// alert('ExampleExtensionService "updateFormData()" function executed'); | ||
} | ||
|
||
validateData(): Promise<any> { | ||
// This function will execute before form data is saved in order to do check if extension data is valid | ||
// Uncomment the alert below to see when this function is called | ||
// alert('ExampleExtensionService "validateData()" function executed'); | ||
return Promise.resolve(undefined); | ||
} | ||
|
||
executeMoreAction() { | ||
alert('Example action executed from "More Actions" drop down'); | ||
} | ||
|
||
executeListAction() { | ||
alert('Example action executed from list page menu items'); | ||
} | ||
} |
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
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
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
Oops, something went wrong.