consul/ui/packages/consul-ui/app
John Cowen 8b12d0d09d
ui: DataSource Decorator (#9746)
We use a `<DataSource @src={{url}} />` component throughout our UI for when we want to load data from within our components. The URL specified as the `@src` is used to map/lookup what is used in to retrieve data, for example we mostly use our repository methods wrapped with our Promise backed `EventSource` implementation, but DataSource URLs can also be mapped to EventTarget backed `EventSource`s and native `EventSource`s or `WebSockets` if we ever need to use those (for example these are options for potential streaming support with the Consul backend).

The URL to function/method mapping previous to this PR used a very naive humongous `switch` statement which was a temporary 'this is fine for the moment' solution, although we'd always wanted to replace with something more manageable.

Here we add `wayfarer` as a dependency - a very small (1kb), very fast, radix trie based router, and use that to perform the URL to function/method mapping.

This essentially turns every `DataSource` into a very small SPA - change its URL and the view of data changes. When the data itself changes, either the yielded view of data changes or the `onchange` event is fired with the changed data, making the externally sourced view of data completely reactive.

```javascript
// use the new decorator a service somewhere to annotate/decorate
// a method with the URL that can be used to access this method
@dataSource('/:ns/:dc/services')
async findAllByDatacenter(params) {
  // get the data
}

// can use with JS in a route somewhere
async model() {
  return this.data.source(uri => uri`/${nspace}/${dc}/services`)
}
```

```hbs
{{!-- or just straight in a template using the component --}}
<DataSource @src="/default/dc1/services" @onchange="" />
```

This also uses a new `container` Service to automatically execute/import certain services yet not execute them. This new service also provides a lookup that supports both standard ember DI lookup plus Class based lookup or these specific services. Lastly we also provide another debug function called DataSourceRoutes() which can be called from console which gives you a list of URLs and their mappings.
2021-02-23 08:56:42 +00:00
..
abilities ui: Restrict the viewing/editing of certain UI elements based on the users ACLs (#9687) 2021-02-19 16:42:16 +00:00
adapters ui: DataSource Decorator (#9746) 2021-02-23 08:56:42 +00:00
components ui: Restrict the viewing/editing of certain UI elements based on the users ACLs (#9687) 2021-02-19 16:42:16 +00:00
controllers ui: Misc changes for Catalog area (#9414) 2020-12-17 16:35:01 +00:00
decorators ui: DataSource Decorator (#9746) 2021-02-23 08:56:42 +00:00
filter/predicates ui: Auth Methods List view (#9617) 2021-02-17 13:56:56 -05:00
forms ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
helpers ui: Adds unique-id helper (#9676) 2021-02-02 10:03:46 +00:00
initializers ui: Remove unnecessay reopens from sort and form services (#9146) 2020-11-10 14:36:27 +00:00
instance-initializers ui: DataSource Decorator (#9746) 2021-02-23 08:56:42 +00:00
mixins ui: DataSource Decorator (#9746) 2021-02-23 08:56:42 +00:00
models ui: Restrict the viewing/editing of certain UI elements based on the users ACLs (#9687) 2021-02-19 16:42:16 +00:00
modifiers ui: Restrict the viewing/editing of certain UI elements based on the users ACLs (#9687) 2021-02-19 16:42:16 +00:00
routes ui: DataSource Decorator (#9746) 2021-02-23 08:56:42 +00:00
routing ui: DataSource Decorator (#9746) 2021-02-23 08:56:42 +00:00
search/predicates ui: Auth Methods List view (#9617) 2021-02-17 13:56:56 -05:00
serializers ui: Restrict the viewing/editing of certain UI elements based on the users ACLs (#9687) 2021-02-19 16:42:16 +00:00
services ui: DataSource Decorator (#9746) 2021-02-23 08:56:42 +00:00
sort/comparators ui: Auth Methods List view (#9617) 2021-02-17 13:56:56 -05:00
styles ui: Restrict the viewing/editing of certain UI elements based on the users ACLs (#9687) 2021-02-19 16:42:16 +00:00
templates ui: Restrict the viewing/editing of certain UI elements based on the users ACLs (#9687) 2021-02-19 16:42:16 +00:00
utils ui: [BUGFIX] Replace all replaceAll with split.join for older browsers without replaceAll (#9715) 2021-02-11 09:49:39 +00:00
validations ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
app.js ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
env.js ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
formats.js ui: Install ember-intl (#9399) 2020-12-15 18:29:32 +00:00
index.html ui: Move to Workspaced Structure (#8994) 2020-10-21 15:23:16 +01:00
router.js ui: Restrict the viewing/editing of certain UI elements based on the users ACLs (#9687) 2021-02-19 16:42:16 +00:00