committed by
GitHub
101 changed files with 1300 additions and 623 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,28 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.queue; |
|||
|
|||
import org.thingsboard.server.common.msg.queue.ServiceType; |
|||
|
|||
import java.util.Set; |
|||
|
|||
public interface QueueService { |
|||
|
|||
Set<String> getQueuesByServiceType(ServiceType serviceType); |
|||
|
|||
String resolve(ServiceType serviceType, String queueName); |
|||
|
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.queue; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.StringUtils; |
|||
import org.thingsboard.server.common.msg.queue.ServiceQueue; |
|||
import org.thingsboard.server.common.msg.queue.ServiceType; |
|||
import org.thingsboard.server.queue.settings.TbQueueRuleEngineSettings; |
|||
import org.thingsboard.server.queue.settings.TbRuleEngineQueueConfiguration; |
|||
|
|||
import javax.annotation.PostConstruct; |
|||
import java.util.Collections; |
|||
import java.util.LinkedHashSet; |
|||
import java.util.Set; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class DefaultQueueService implements QueueService { |
|||
|
|||
private final TbQueueRuleEngineSettings ruleEngineSettings; |
|||
private Set<String> ruleEngineQueues; |
|||
|
|||
@PostConstruct |
|||
public void init() { |
|||
ruleEngineQueues = ruleEngineSettings.getQueues().stream() |
|||
.map(TbRuleEngineQueueConfiguration::getName).collect(Collectors.toCollection(LinkedHashSet::new)); |
|||
} |
|||
|
|||
@Override |
|||
public Set<String> getQueuesByServiceType(ServiceType type) { |
|||
if (type == ServiceType.TB_RULE_ENGINE) { |
|||
return ruleEngineQueues; |
|||
} else { |
|||
return Collections.emptySet(); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public String resolve(ServiceType serviceType, String queueName) { |
|||
if (StringUtils.isEmpty(queueName) || !getQueuesByServiceType(serviceType).contains(queueName)) { |
|||
return ServiceQueue.MAIN; |
|||
} else { |
|||
return queueName; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
package org.thingsboard.server.common.transport.service; |
|||
|
|||
import lombok.Data; |
|||
import org.thingsboard.server.common.transport.SessionMsgListener; |
|||
import org.thingsboard.server.gen.transport.TransportProtos; |
|||
|
|||
import java.util.concurrent.ScheduledFuture; |
|||
|
|||
/** |
|||
* Created by ashvayka on 15.10.18. |
|||
*/ |
|||
@Data |
|||
public class SessionActivityData { |
|||
|
|||
private volatile TransportProtos.SessionInfoProto sessionInfo; |
|||
private volatile long lastActivityTime; |
|||
private volatile long lastReportedActivityTime; |
|||
|
|||
SessionActivityData(TransportProtos.SessionInfoProto sessionInfo) { |
|||
this.sessionInfo = sessionInfo; |
|||
} |
|||
|
|||
void updateLastActivityTime() { |
|||
this.lastActivityTime = System.currentTimeMillis(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2021 The Thingsboard Authors |
|||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); |
|||
you may not use this file except in compliance with the License. |
|||
You may obtain a copy of the License at |
|||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 |
|||
|
|||
Unless required by applicable law or agreed to in writing, software |
|||
distributed under the License is distributed on an "AS IS" BASIS, |
|||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
See the License for the specific language governing permissions and |
|||
limitations under the License. |
|||
|
|||
--> |
|||
<markdown [data]="markdownText" class="tb-markdown-view {{markdownClass}}" (click)="markdownClick($event)"></markdown> |
|||
@ -0,0 +1,130 @@ |
|||
/** |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
|
|||
.tb-markdown-view { |
|||
display: block; |
|||
::ng-deep { |
|||
h1 { |
|||
font-size: 32px; |
|||
padding-right: 60px; |
|||
} |
|||
|
|||
h1, h2, h3, h4, h5, h6 { |
|||
line-height: normal; |
|||
font-weight: 500; |
|||
margin-bottom: 30px; |
|||
padding-bottom: 10px; |
|||
border-bottom: 1px solid #ccc; |
|||
} |
|||
|
|||
p { |
|||
font-size: 16px; |
|||
font-weight: 400; |
|||
line-height: 1.25em; |
|||
margin: 0; |
|||
} |
|||
|
|||
p+p { |
|||
margin-top: 10px; |
|||
} |
|||
|
|||
table { |
|||
width: 100%; |
|||
border: 1px solid #ccc; |
|||
border-spacing: 0; |
|||
margin-top: 30px; |
|||
margin-bottom: 30px; |
|||
} |
|||
|
|||
thead { |
|||
background-color: #555; |
|||
color: #fff; |
|||
} |
|||
|
|||
th, td { |
|||
font-size: .85em; |
|||
padding: 8px; |
|||
margin: 0; |
|||
text-align: left; |
|||
} |
|||
|
|||
td[align=center], th[align=center] { |
|||
text-align: center; |
|||
} |
|||
|
|||
td[align=right], th[align=right] { |
|||
text-align: right; |
|||
} |
|||
|
|||
tr:nth-child(even) { |
|||
background-color: #f7f7f7; |
|||
} |
|||
|
|||
code:not([class*=language-]) { |
|||
background: #f5f5f5; |
|||
border-radius: 2px; |
|||
color: #dd4a68; |
|||
padding: 2px 4px; |
|||
} |
|||
|
|||
div.code-wrapper { |
|||
position: relative; |
|||
button.clipboard-btn { |
|||
cursor: pointer; |
|||
margin: 0; |
|||
border: 0; |
|||
outline: none; |
|||
position: absolute; |
|||
top: 5px; |
|||
right: 5px; |
|||
background: #fff; |
|||
box-shadow: 0 1px 8px 0 rgba(0,0,0,0.2), 0 3px 4px 0 rgba(0,0,0,0.14), 0 3px 3px -2px rgba(0,0,0,0.12); |
|||
border-radius: 5px; |
|||
opacity: 0; |
|||
transition: opacity .3s; |
|||
padding: 3px 6px; |
|||
line-height: 16px; |
|||
img { |
|||
width: 18px; |
|||
} |
|||
&:hover { |
|||
background: #f9f9f9; |
|||
} |
|||
&:active { |
|||
background-color: #ececec; |
|||
box-shadow: inset 1px -1px 4px 0px rgba(0,0,0,0.4); |
|||
} |
|||
} |
|||
&:hover { |
|||
button.clipboard-btn { |
|||
opacity: .85; |
|||
} |
|||
} |
|||
} |
|||
|
|||
th, td { |
|||
div.code-wrapper { |
|||
display: inline-block; |
|||
button.clipboard-btn { |
|||
top: -5px; |
|||
right: -30px; |
|||
padding: 0 3px; |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,116 @@ |
|||
///
|
|||
/// Copyright © 2016-2021 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core'; |
|||
import { PageComponent } from '@shared/components/page.component'; |
|||
import { WidgetContext } from '@home/models/widget-component.models'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { DatasourceData } from '@shared/models/widget.models'; |
|||
import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; |
|||
import { |
|||
fillPattern, flatData, |
|||
parseData, |
|||
parseFunction, |
|||
processPattern, |
|||
safeExecute |
|||
} from '@home/components/widget/lib/maps/common-maps-utils'; |
|||
import { FormattedData } from '@home/components/widget/lib/maps/map-models'; |
|||
import { hashCode, isNotEmptyStr } from '@core/utils'; |
|||
import cssjs from '@core/css/css'; |
|||
|
|||
interface MarkdownWidgetSettings { |
|||
markdownTextPattern: string; |
|||
useMarkdownTextFunction: boolean; |
|||
markdownTextFunction: string; |
|||
markdownCss: string; |
|||
} |
|||
|
|||
type MarkdownTextFunction = (data: FormattedData[]) => string; |
|||
|
|||
@Component({ |
|||
selector: 'tb-markdown-widget ', |
|||
templateUrl: './markdown-widget.component.html', |
|||
styleUrls: ['./markdown-widget.component.scss'] |
|||
}) |
|||
export class MarkdownWidgetComponent extends PageComponent implements OnInit { |
|||
|
|||
settings: MarkdownWidgetSettings; |
|||
markdownTextFunction: MarkdownTextFunction; |
|||
|
|||
@Input() |
|||
ctx: WidgetContext; |
|||
|
|||
markdownText: string; |
|||
|
|||
markdownClass: string; |
|||
|
|||
constructor(protected store: Store<AppState>, |
|||
private cd: ChangeDetectorRef) { |
|||
super(store); |
|||
} |
|||
|
|||
ngOnInit(): void { |
|||
this.ctx.$scope.markdownWidget = this; |
|||
this.settings = this.ctx.settings; |
|||
this.markdownTextFunction = this.settings.useMarkdownTextFunction ? parseFunction(this.settings.markdownTextFunction, ['data']) : null; |
|||
this.markdownClass = 'markdown-widget'; |
|||
const cssString = this.settings.markdownCss; |
|||
if (isNotEmptyStr(cssString)) { |
|||
const cssParser = new cssjs(); |
|||
cssParser.testMode = false; |
|||
this.markdownClass += '-' + hashCode(cssString); |
|||
cssParser.cssPreviewNamespace = 'tb-markdown-view.' + this.markdownClass; |
|||
cssParser.createStyleElement(this.markdownClass, cssString); |
|||
} |
|||
} |
|||
|
|||
public onDataUpdated() { |
|||
let initialData: DatasourceData[]; |
|||
if (this.ctx.data?.length) { |
|||
initialData = this.ctx.data; |
|||
} else if (this.ctx.datasources?.length) { |
|||
initialData = [ |
|||
{ |
|||
datasource: this.ctx.datasources[0], |
|||
dataKey: { |
|||
type: DataKeyType.attribute, |
|||
name: 'empty' |
|||
}, |
|||
data: [] |
|||
} |
|||
]; |
|||
} |
|||
let markdownText: string; |
|||
if (initialData) { |
|||
const data = parseData(initialData); |
|||
markdownText = this.settings.useMarkdownTextFunction ? |
|||
safeExecute(this.markdownTextFunction, [data]) : this.settings.markdownTextPattern; |
|||
const allData = flatData(data); |
|||
const replaceInfo = processPattern(markdownText, allData); |
|||
markdownText = fillPattern(markdownText, replaceInfo, allData); |
|||
} |
|||
if (this.markdownText !== markdownText) { |
|||
this.markdownText = markdownText; |
|||
this.cd.detectChanges(); |
|||
} |
|||
} |
|||
|
|||
markdownClick($event: MouseEvent) { |
|||
this.ctx.actionsApi.elementClick($event); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
/* |
|||
* Copyright © 2016-2021 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
import * as React from 'react'; |
|||
import ThingsboardAceEditor from './json-form-ace-editor'; |
|||
import { JsonFormFieldProps, JsonFormFieldState } from '@shared/components/json-form/react/json-form.models'; |
|||
|
|||
class ThingsboardMarkdown extends React.Component<JsonFormFieldProps, JsonFormFieldState> { |
|||
|
|||
constructor(props) { |
|||
super(props); |
|||
} |
|||
|
|||
render() { |
|||
return ( |
|||
<ThingsboardAceEditor {...this.props} mode='markdown' {...this.state}></ThingsboardAceEditor> |
|||
); |
|||
} |
|||
} |
|||
|
|||
export default ThingsboardMarkdown; |
|||
@ -0,0 +1,99 @@ |
|||
///
|
|||
/// Copyright © 2016-2021 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
|
|||
import { MarkedOptions, MarkedRenderer } from 'ngx-markdown'; |
|||
|
|||
export function markedOptionsFactory(): MarkedOptions { |
|||
const renderer = new MarkedRenderer(); |
|||
const renderer2 = new MarkedRenderer(); |
|||
|
|||
const copyCodeBlock = '{:copy-code}'; |
|||
|
|||
let id = 1; |
|||
|
|||
renderer.code = (code: string, language: string | undefined, isEscaped: boolean) => { |
|||
if (code.endsWith(copyCodeBlock)) { |
|||
code = code.substring(0, code.length - copyCodeBlock.length); |
|||
const content = renderer2.code(code, language, isEscaped); |
|||
id++; |
|||
return wrapCopyCode(id, content, code); |
|||
} else { |
|||
return renderer2.code(code, language, isEscaped); |
|||
} |
|||
}; |
|||
|
|||
renderer.tablecell = (content: string, flags: { |
|||
header: boolean; |
|||
align: 'center' | 'left' | 'right' | null; |
|||
}) => { |
|||
if (content.endsWith(copyCodeBlock)) { |
|||
content = content.substring(0, content.length - copyCodeBlock.length); |
|||
id++; |
|||
content = wrapCopyCode(id, content, content); |
|||
} |
|||
return renderer2.tablecell(content, flags); |
|||
}; |
|||
|
|||
return { |
|||
renderer, |
|||
headerIds: true, |
|||
gfm: true, |
|||
breaks: false, |
|||
pedantic: false, |
|||
smartLists: true, |
|||
smartypants: false, |
|||
}; |
|||
} |
|||
|
|||
function wrapCopyCode(id: number, content: string, code: string): string { |
|||
return '<div class="code-wrapper">' + content + '<span id="copyCodeId' + id + '" style="display: none;">' + code + '</span>' + |
|||
'<button id="copyCodeBtn' + id + '" onClick="markdownCopyCode(' + id + ')" ' + |
|||
'class="clipboard-btn"><img src="https://clipboardjs.com/assets/images/clippy.svg" alt="Copy to clipboard">' + |
|||
'</button></div>'; |
|||
} |
|||
|
|||
(window as any).markdownCopyCode = (id: number) => { |
|||
const text = $('#copyCodeId' + id).text(); |
|||
navigator.clipboard.writeText(text).then(() => { |
|||
import('tooltipster').then( |
|||
() => { |
|||
const copyBtn = $('#copyCodeBtn' + id); |
|||
if (!copyBtn.hasClass('tooltipstered')) { |
|||
copyBtn.tooltipster( |
|||
{ |
|||
content: 'Copied!', |
|||
theme: 'tooltipster-shadow', |
|||
delay: 0, |
|||
trigger: 'custom', |
|||
triggerClose: { |
|||
click: true, |
|||
tap: true, |
|||
scroll: true, |
|||
mouseleave: true |
|||
}, |
|||
side: 'bottom', |
|||
distance: 12, |
|||
trackOrigin: true |
|||
} |
|||
); |
|||
} |
|||
const tooltip = copyBtn.tooltipster('instance'); |
|||
tooltip.open(); |
|||
} |
|||
); |
|||
}); |
|||
}; |
|||
@ -1,275 +0,0 @@ |
|||
///
|
|||
/// Copyright © 2016-2021 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import * as leaflet from 'leaflet'; |
|||
|
|||
declare module 'leaflet' { |
|||
|
|||
/** |
|||
* Make geometries editable in Leaflet. |
|||
* |
|||
* This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to |
|||
* control editing of geometries. So you can easily build your own UI with your own needs and choices. |
|||
*/ |
|||
interface EditableStatic { |
|||
new (map: Map, options: EditOptions): Editable; |
|||
} |
|||
|
|||
/** |
|||
* Options to pass to L.Editable when instanciating. |
|||
*/ |
|||
interface EditOptions extends leaflet.MapOptions{ |
|||
/** |
|||
* Whether to create a L.Editable instance at map init or not. |
|||
*/ |
|||
editable: boolean; |
|||
/** |
|||
* Class to be used when creating a new Polyline. |
|||
*/ |
|||
polylineClass?: object; |
|||
|
|||
/** |
|||
* Class to be used when creating a new Polygon. |
|||
*/ |
|||
polygonClass?: object; |
|||
|
|||
/** |
|||
* Class to be used when creating a new Marker. |
|||
*/ |
|||
markerClass?: object; |
|||
|
|||
/** |
|||
* CSS class to be added to the map container while drawing. |
|||
*/ |
|||
drawingCSSClass?: string; |
|||
|
|||
/** |
|||
* Layer used to store edit tools (vertex, line guide…). |
|||
*/ |
|||
editLayer?: LayerGroup<leaflet.Layer>; |
|||
|
|||
/** |
|||
* Default layer used to store drawn features (marker, polyline…). |
|||
*/ |
|||
featuresLayer?: LayerGroup<Polyline|Polygon|Marker>; |
|||
|
|||
/** |
|||
* Class to be used as vertex, for path editing. |
|||
*/ |
|||
vertexMarkerClass?: object; |
|||
|
|||
/** |
|||
* Class to be used as middle vertex, pulled by the user to create a new point in the middle of a path. |
|||
*/ |
|||
middleMarkerClass?: object; |
|||
|
|||
/** |
|||
* Class to be used as Polyline editor. |
|||
*/ |
|||
polylineEditorClass?: object; |
|||
|
|||
/** |
|||
* Class to be used as Polygon editor. |
|||
*/ |
|||
polygonEditorClass?: object; |
|||
|
|||
/** |
|||
* Class to be used as Marker editor. |
|||
*/ |
|||
markerEditorClass?: object; |
|||
|
|||
/** |
|||
* Options to be passed to the line guides. |
|||
*/ |
|||
lineGuideOptions?: object; |
|||
|
|||
/** |
|||
* Set this to true if you don't want middle markers. |
|||
*/ |
|||
skipMiddleMarkers?: boolean; |
|||
} |
|||
|
|||
/** |
|||
* Make geometries editable in Leaflet. |
|||
* |
|||
* This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to |
|||
* control editing of geometries. So you can easily build your own UI with your own needs and choices. |
|||
*/ |
|||
interface Editable extends leaflet.Evented { |
|||
/** |
|||
* Options to pass to L.Editable when instanciating. |
|||
*/ |
|||
options: EditOptions; |
|||
|
|||
currentPolygon: Polyline|Polygon|Marker; |
|||
|
|||
/** |
|||
* Start drawing a polyline. If latlng is given, a first point will be added. In any case, continuing on user |
|||
* click. If options is given, it will be passed to the polyline class constructor. |
|||
*/ |
|||
startPolyline(latLng?: LatLng, options?: PolylineOptions): Polyline; |
|||
|
|||
/** |
|||
* Start drawing a polygon. If latlng is given, a first point will be added. In any case, continuing on user |
|||
* click. If options is given, it will be passed to the polygon class constructor. |
|||
*/ |
|||
startPolygon(latLng?: LatLng, options?: PolylineOptions): Polygon; |
|||
|
|||
/** |
|||
* Start adding a marker. If latlng is given, the marker will be shown first at this point. In any case, it |
|||
* will follow the user mouse, and will have a final latlng on next click (or touch). If options is given, |
|||
* it will be passed to the marker class constructor. |
|||
*/ |
|||
startMarker(latLng?: LatLng, options?: MarkerOptions): Marker; |
|||
|
|||
/** |
|||
* When you need to stop any ongoing drawing, without needing to know which editor is active. |
|||
*/ |
|||
stopDrawing(): void; |
|||
|
|||
/** |
|||
* When you need to commit any ongoing drawing, without needing to know which editor is active. |
|||
*/ |
|||
commitDrawing(): void; |
|||
} |
|||
|
|||
let Editable: EditableStatic; |
|||
|
|||
/** |
|||
* EditableMixin is included to L.Polyline, L.Polygon and L.Marker. It adds the following methods to them. |
|||
* |
|||
* When editing is enabled, the editor is accessible on the instance with the editor property. |
|||
*/ |
|||
interface EditableMixin { |
|||
/** |
|||
* Enable editing, by creating an editor if not existing, and then calling enable on it. |
|||
*/ |
|||
enableEdit(map: L.Map): any; |
|||
|
|||
/** |
|||
* Disable editing, also remove the editor property reference. |
|||
*/ |
|||
disableEdit(): void; |
|||
|
|||
/** |
|||
* Enable or disable editing, according to current status. |
|||
*/ |
|||
toggleEdit(): void; |
|||
|
|||
/** |
|||
* Return true if current instance has an editor attached, and this editor is enabled. |
|||
*/ |
|||
editEnabled(): boolean; |
|||
} |
|||
|
|||
interface Map { |
|||
|
|||
|
|||
/** |
|||
* Options to pass to L.Editable when instanciating. |
|||
*/ |
|||
editOptions: MapOptions; |
|||
|
|||
/** |
|||
* L.Editable plugin instance. |
|||
*/ |
|||
editTools: Editable; |
|||
} |
|||
|
|||
// tslint:disable-next-line:no-empty-interface
|
|||
interface Polyline extends EditableMixin {} |
|||
|
|||
namespace Map { |
|||
interface MapOptions { |
|||
/** |
|||
* Whether to create a L.Editable instance at map init or not. |
|||
*/ |
|||
editable?: boolean; |
|||
|
|||
/** |
|||
* Options to pass to L.Editable when instanciating. |
|||
*/ |
|||
editOptions?: MapOptions; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* When editing a feature (marker, polyline…), an editor is attached to it. This editor basically knows |
|||
* how to handle the edition. |
|||
*/ |
|||
interface BaseEditor { |
|||
/** |
|||
* Set up the drawing tools for the feature to be editable. |
|||
*/ |
|||
enable(): MarkerEditor|PolylineEditor|PolygonEditor; |
|||
|
|||
/** |
|||
* Remove editing tools. |
|||
*/ |
|||
disable(): MarkerEditor|PolylineEditor|PolygonEditor; |
|||
} |
|||
|
|||
/** |
|||
* Inherit from L.Editable.BaseEditor. |
|||
* Inherited by L.Editable.PolylineEditor and L.Editable.PolygonEditor. |
|||
*/ |
|||
interface PathEditor extends BaseEditor { |
|||
/** |
|||
* Rebuild edit elements (vertex, middlemarker, etc.). |
|||
*/ |
|||
reset(): void; |
|||
} |
|||
|
|||
/** |
|||
* Inherit from L.Editable.PathEditor. |
|||
*/ |
|||
interface PolylineEditor extends PathEditor { |
|||
/** |
|||
* Set up drawing tools to continue the line forward. |
|||
*/ |
|||
continueForward(): void; |
|||
|
|||
/** |
|||
* Set up drawing tools to continue the line backward. |
|||
*/ |
|||
continueBackward(): void; |
|||
} |
|||
|
|||
/** |
|||
* Inherit from L.Editable.PathEditor. |
|||
*/ |
|||
interface PolygonEditor extends PathEditor { |
|||
/** |
|||
* Set up drawing tools for creating a new hole on the polygon. If the latlng param is given, a first |
|||
* point is created. |
|||
*/ |
|||
newHole(latlng: LatLng): void; |
|||
} |
|||
|
|||
/** |
|||
* Inherit from L.Editable.BaseEditor. |
|||
*/ |
|||
// tslint:disable-next-line:no-empty-interface
|
|||
interface MarkerEditor extends BaseEditor {} |
|||
|
|||
interface Marker extends EditableMixin, MarkerEditor {} |
|||
|
|||
interface Polyline extends EditableMixin, PolylineEditor {} |
|||
|
|||
interface Polygon extends EditableMixin, PolygonEditor {} |
|||
|
|||
function map(element: string | HTMLElement, options?: EditOptions): Map; |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue