This file contains hidden or 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
New-UDButton -Text "Add marker to cluster" -OnClick { | |
Add-UDElement -ParentId 'cluster-layer' -Content { | |
$Random = Get-Random -Minimum 0 -Maximum 100 | |
$RandomLat = $Random + 400 | |
New-UDMapMarker -Latitude "51.$RandomLat" -Longitude "-0.$Random" | |
} | |
} | |
New-UDButton -Text "Clear cluster" -OnClick { |
This file contains hidden or 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
import UDHelmet from './helmet'; | |
UniversalDashboard.register("ud-helmet", UDHelmet); |
This file contains hidden or 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
var element = renderComponent(this.props.component, this.props.history, true); |
This file contains hidden or 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
componentWillMount() { | |
var script = document.createElement('script'); | |
script.onload = function() { | |
this.setState({loading:false}); | |
}.bind(this) | |
script.src = getApiPath() + "/" + this.props.component.assetId; | |
document.head.appendChild(script); | |
} |
This file contains hidden or 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
renderComponent: function(component, history, dynamicallyLoaded) { | |
if (component == null) return <React.Fragment/>; | |
if (Array.isArray(component)) { | |
return component.map(x => this.renderComponent(x, history)); | |
} | |
var existingComponent = this.components.find(x => x.type === component.type); | |
if (existingComponent != null) { |
This file contains hidden or 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
{ | |
'assetId': 'index.as3sdfq23afa.bundle.js', | |
'isPlugin': true, | |
'type': 'ud-helmet', | |
'id': 'myHelmet' | |
} |
This file contains hidden or 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
function New-UDHelmet { | |
param( | |
[Parameter()] | |
[string]$Id = (New-Guid).ToString(), | |
[Parameter(Mandatory = $true)] | |
[scriptblock]$Content | |
) | |
End { | |
@{ |
This file contains hidden or 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
app.UseStatusCodePages(async context => { | |
if (context.HttpContext.Response.StatusCode == 404 && !context.HttpContext.Request.Path.StartsWithSegments("/api")) | |
{ | |
var fileName = context.HttpContext.Request.Path.ToString().Split('/').Last(); | |
var asset = AssetService.Instance.FindAsset(fileName); | |
if (asset != null) | |
{ | |
var response = context.HttpContext.Response; | |
response.StatusCode = 200; | |
var file = File.ReadAllBytes(asset); |
This file contains hidden or 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
[Route("{asset}")] | |
public IActionResult Index(string asset) | |
{ | |
var filePath = AssetService.Instance.FindAsset(asset); | |
if (filePath == null) | |
{ | |
Log.Warn($"Unknown element script: {asset}"); | |
return StatusCode(404); | |
} |
This file contains hidden or 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
$AssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($IndexJs.FullName) |