Enable image map on trip animation widget - thingsboard

Image map is not available for the trip animation widget
widget map provider
and upon checking on the github of thingsboard I found out it was disabled/ignored.
https://github.com/thingsboard/thingsboard/blob/088f971e3cc211925385433655d2f8da2fe9ee41/ui-ngx/src/app/modules/home/components/widget/lib/settings/map/trip-animation-widget-settings.component.html
github
<tb-map-provider-settings
[ignoreImageMap]="true"
[aliasController]="aliasController"
formControlName="mapProviderSettings">
</tb-map-provider-settings>
If I make if 'false', will it have an effect on my instance of thingsboard?
Other option is creating custom widget; however, there is no official documentation of the map widget.

Related

How to update Forge UI Issue Panel with JIRA Issue update event listener function?

We have created an Issue panel on JIRA issue view screen. What we need to render is a list of issue keys (which fetched by an API call).
This is how we define the Forge library manifest.yml file:
modules:
jira:issuePanel:
- key: dylan-hello-world-app-hello-world-panel
function: main
title: Forge App by Dylan
icon: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg
trigger:
- key: issue-updated-trigger
events:
- avi:jira:updated:issue
function: issue-trigger-func
function:
- key: main
handler: index.run
- key: issue-trigger-func
handler: index.issueUpdatedTrigger
app:
id: our cloud app id
name: dylan-hello-world-app
permissions:
scopes:
- read:jira-work
My run() function does the the rendering part of the panel (initial render).
The issueUpdateTrigger(event, context) function will be triggered when issue updated event happens. By default, this function will automatically received event and context parameters from JIRA.
In the issueUpdateTrigger, we would like to call API again by passing in context to retrieve new issue keys list and also update the context of our existing panel. May I know how can we perform the regarding actions?
(I think It is a must to expose both run() and issueUpdatedTrigger() functions in the index file, cause this is how Forge reads the function, and therefore these two functions might not be able to share a common ancestor function.)
Appreciate your help and do let me know if more information is needed :D
Based on your jira:issuePanel module having a function key and value, my answer assumes that you are using Forge's UI Kit and not Custom UI.
With UI Kit, there is not a way to force a refresh of the UI component without a user click. The work around is to add a "Refresh" button that, when clicks, refreshes the component.
You could use Custom UI to handle this situation, but that is a much more involved solution as you'd be responsible for building the UI (as opposed to using the components provided by Forge).
You may also find other feedback and advice in the Atlassian Developer Community category specifically for Forge: https://community.developer.atlassian.com/c/forge/45

In WidgetKit with dynamic data, how to specify the default IntentConfiguration for new widgets?

The desirable example is exhibited by the Apple Notes widgets. When adding an Apple Notes widget, WidgetKit goes ahead and assigns an IntentConfiguration to the new widget. You can see this by editing the widget and noticing that the selection element does not read "Choose" but instead includes the name of the note or folder that was automatically selected as default for the new widget. You'll also notice that this placeholder widget's data source does not change from one source to another – the assigned IntentConfiguration is respected.
How can we do this in our Widgets? It should look like this: someone creates a new widget, we use their most recent data item for the placeholder, and that item is 1) persisted in the Widget until they change it 2) reflected in the edit widget dialogue.
I was looking for same, trying to set a default for the dynamic type, so idea is set a default just like you can with enums in the intent definition file.
short answer we need to set the dynamic type default in code.
so after some digging around came across this(I command clicked on my ConfigurationIntent reference in my code and got to apples auto generated ConfigurationIntent.swift)
/*! #abstract Default values for parameters with dynamic options
#discussion Called to query the parameter default value.
*/
#available(iOS 14.0, macOS 10.16, watchOS 7.0, *)
#objc(defaultChartTypeForConfiguration:)
optional func defaultChartType(for intent: ConfigurationIntent) -> Chart?
here we have "optional fund defaultChartType"
so I've implanted that in the intenthandler.swift that will be generated for you in which you then have to add code to retrieve and return dynamic types. that should be covered in any tutorial on displaying dynamics in the widget configuration screen.
so now here in this file too I've just added the optional func above.
ChartType is my dynamic type I created in the intentDefinition file. yours will be different to match your names
and its working this way. hope that helps and you can follow it.

How to query WidgetKit if my widgets are being used?

I would like to check if the user added my widgets to the Home Screen, is there an API for this? I could not find one. WidgetCenter.getCurrentConfigurations returns all available widgets served by the app, not the used ones.
The reasons I look for such an API are:
I would like to report usages of the widgets.
I would like to decide if I should trigger timeline reloads via WidgetCenter when state changes happen in the app.
Method WidgetCenter.shared.getCurrentConfigurations does return the number of user configured widgets:
WidgetCenter.shared.getCurrentConfigurations { widgets
if let widgets = widgets, widgets.count > 0 {
// User did configure at least one widgets
}
}
This is also according the documentation:
Retrieves information about user-configured widgets.
Unfortunately, I don't think such an API exists (yet).
For 1. I would write something that identifies the widget in a shared user defaults container. Hooks for that would be getSnapshot(for:,in:,completion:) or getTimeline(for:,in:,completion:) with context.isPreview == false. Now the difficult part is that you don't get any id for the widget so you cannot distinguish two widgets with the same configuration (afaik).
For 2. I think this is (and will be) opaque, so you just tell the WidgetCenter to reload specific or all configurations and when no widget is currently placed on the home screen nothing happens.

How to remove a widget from tree

I want to be able to remove a widget from tree, or remove a child of a widget. I tried to use states to change a widget to null but it's returning an error. Is there a solution ?
Here is the error
https://gist.github.com/litekangel/e2037cf5dc4dbd9c0c0a9860ad3b0270
I finally found a solution to hide/remove a widget : I just replaced it by an empty widget (may be I will add a small animation) but I am still looking for a cleaner way to do this.
In flutter you don't really update a tree of widget you actually generate a new tree every time you need to change it. So you only have to change the returned value of your widget build function.
If you want an empty widget, Container() is a good choice.
Another good approach to replace widgets in the tree is to give your widgets a key.
(Flutter will rebuild the subtree if the key changes.)
So let's say you have a StreamBuilder, and for, whatever reason, need the child widget to be built from scratch every time (maybe due to dependency injection, where one of the dependencies change), you can do this:
StreamBuilder(
stream: bloc.myDependencyChanged, // A hypothetical bloc which notifies when a relevant dependency has changed.
builder: (_, snap) {
final dep = MyChangingDependency();
// MyWidget will NOT get reused by flutter if the key changes.
return MyWidget(dep, key: ValueKey(dep.getId()));
},
);

Turn off Openlayers 3 Geolocation

So, my idea of turning off the Geolocation functionality in an Openlayers 3.9.0 map is to have a toggle button that when is clicked it stops the tracking and removes the feature from the geolocation layer
geolocation.setTracking('false');
featuresOverlay.getSource().clear();
and then to turn it on again it turns the tracking on, adds a feature to the geolocation layer, sets its coordinates and re-centers the map
geolocation.setTracking('true');
featuresOverlay.getSource().addFeature(positionFeature);
var coordinates = geolocation.getPosition();
positionFeature.setGeometry(coordinates ? new ol.geom.Point(coordinates) : null);
view.setCenter(coordinates);
Well, this technically does not count as turning on/off the geolocation because it removes all the visual elements, it does not actually turns on/off the API. Is there such a possibility, or the above are enough?
Sure it does, after one minor change.
Assuming that geolocation in your code references an instance of ol.Geolocation, calling geolocation.setTracking(false) will make the geolocation call clearWatch on the browsers geolocation API. The relevant code is here.
However, setTracking expects a boolean value. You send the string 'false', which is interpreted as a truthy value (since it's a non-empty string). Remove the quotation marks from the setTracking paramters, and it should work as expected.

Resources