Я не могу сделать пользовательский виджет в withersboardHtml

Программисты Html
Ответить
Anonymous
 Я не могу сделать пользовательский виджет в withersboard

Сообщение Anonymous »

Я пытаюсь создать пользовательский виджет в Witherboard v.4.0.2, который представляет собой поле, где пользователь может набрать текст и отправить его, если нет текста, он не может нажать кнопку. И я хочу сабиться с текстом, пользователя, который его отправляет, и они временные метки для визуализации его в таблице. Но у меня ошибки, и я недостаточно понимаю, чтобы исправить это. Это мой код: < /p>
self.onInit = funtion() {
const btn = document.getElementById('sendButton');
btn.onclick = function() {
const txt = document.getElementById('inputText').value.trim();
if (!txt) {
alert("Ingresar mensaje");
return;
}
const entityId = self.ctx.entityId;
if (!entityId) {
alert("Widget no está vinculado a dispositivo");
console.error('ctx.entityId:', self.ctx);
return;
}
const user = self.ctx.currentUser.userName;
const ts = new Date().toLocaleString();
const payload = { mensaje: txt, usuario: user, hora: ts };
self.ctx.attributeService.saveEntityTelemetry(
entityId,
"TELEMETRY",
[{ key: 'mensaje_log', value: JSON.stringify(payload) }]
).subscribe(
() => { document.getElementById('inputText').value = ''; alert("Enviado!"); },
err => { console.error(err); alert("Error al enviar"); }
);
};
};
< /code>
Но когда я отправляю текст, он говорит: «Виджет нет Está vinculado a dispositivo», как если If! EntityId, а после этого в консоли F12 была такая огромная ошибка, которая даже не подходит здесь: < /p>
VM10082:18
ctx.entityId:
Se {dashboard: ty, dashboardWidget: kp, widget: {…}, parentDashboard: null, popoverComponent: null, …}
$container
:
i.fn.init {0: tb-dynamic-component#container.ng-star-inserted, length: 1}
$containerParent
:
i.fn.init {0: div#widget-container.flex-1, length: 1}
$injector
:
vi {_tNode: {…}, _lView: Array(36)}
$scope
:
t {store: b, disabledOnLoadFormControls: Array(0), showMainLoadingBar: true, isLoading$: b, validators: ƒ, …}
$widgetElement
:
i.fn.init {0: div.tb-widget.mat-elevation-z4, length: 1}
actionsApi
:
{actionDescriptorsBySourceId: {…}, getActionDescriptors: ƒ, handleWidgetAction: ƒ, onWidgetAction: ƒ, elementClick: ƒ, …}
assetService
:
t {http: t}
attributeService
:
t {http: t}
authService
:
t {store: b, http: t, userService: t, timeService: t, router: t, …}
changeDetectorValue
:
_i {_lView: Array(96), _cdRefInjectingView: Array(96), notifyErrorHandler: true, _appRef: null, _attachedToViewContainer: false}
containerChangeDetectorValue
:
_i {_lView: Array(96), _cdRefInjectingView: Array(96), notifyErrorHandler: true, _appRef: null, _attachedToViewContainer: false}
controlApi
:
{sendOneWayCommand: ƒ, sendTwoWayCommand: ƒ, completedCommand: ƒ}
customDialog
:
t {dynamicComponentFactoryService: t, sharedModule: ƒ, sharedHomeComponentsModule: ƒ, homeComponentsModule: ƒ, widgetComponentsModule: ƒ, …}
customHeaderActions
:
[]
customerService
:
t {http: t}
dashboard
:
ty {store: b, disabledOnLoadFormControls: Array(0), showMainLoadingBar: true, isLoading$: b, utils: a, …}
dashboardService
:
t {http: t, router: t, window: Window, currentUrl: '/dashboards/6220a940-5c1d-11f0-a196-0b4825e40faf', stDiffObservable: e}
dashboardWidget
:
kp {dashboard: ty, widget: {…}, widgetLayoutValue: {…}, parentDashboard: null, popoverComponent: null, …}
date
:
t {locale: 'en-US', defaultTimezone: null, defaultOptions: null}
defaultSubscription
:
A_ {options: {…}, tsOffset: 0, cafs: {…}, hasResolvedData: true, subscribed: true, …}
destroyed
:
false
deviceService
:
t {http: t, resourcesService: t}
dialogs
:
t {translate: b, authService: t, dialog: t}
embedActionsPanel
:
false
embedTitlePanel
:
false
entityRelationService
:
t {http: t}
entityService
:
t {http: t, store: b, deviceService: t, edgeService: t, assetService: t, …}
entityViewService
:
t {http: t}
height
:
230
hideTitlePanel
:
false
http
:
t {handler: t}
imagePipe
:
t {imageService: t, sanitizer: t, zone: e}
inited
:
true
isEdit
:
false
isMobile
:
true
isPreview
:
undefined
labelPatterns
:
Map(1) {e => St}
milliSecondsToTimeString
:
t {translate: b}
ngZone
:
e {hasPendingMacrotasks: true, hasPendingMicrotasks: false, isStable: true, onUnstable: eD, onMicrotaskEmpty: eD, …}
overflowVisible
:
false
parentDashboard
:
null
popoverComponent
:
null
popoverComponents
:
[]
renderer
:
Xk {namespaceId: '', delegate: Ni, engine: t, ɵtype: 0, _onDestroy: ƒ}
resourceService
:
t {http: t, resourcesService: t}
router
:
t {disposed: false, console: t, stateManager: t, options: {…}, pendingTasks: t, …}
rxjs
:
{EMPTY: e, ArgumentOutOfRangeError: ƒ, AsyncSubject: ƒ, BehaviorSubject: ƒ, ConnectableObservable: ƒ, …}
sanitizer
:
t {_doc: document}
servicesMap
:
Map(37) {'broadcastService' => ƒ, 'deviceService' => ƒ, 'alarmService' => ƒ, 'alarmCommentService' => ƒ, 'assetService' => ƒ, …}
store
:
b {actionsObserver: b, reducerManager: b, source: b, state: ƒ}
subscriptionApi
:
{createSubscription: ƒ, createSubscriptionFromInfo: ƒ, removeSubscription: ƒ}
subscriptions
:
{064b5a86-ff19-5da6-01a1-72fb8a6bbac9: A_}
telemetryWsService
:
t {store: b, authService: t, ngZone: e, apiEndpoint: 'api/ws', cmdWrapper: M, …}
timewindowFunctions
:
{onUpdateTimewindow: ƒ, onResetTimewindow: ƒ}
toastTargetId
:
"widget-messages-e9a3e05b-3498-e4a9-4cd4-3cd162010b15"
translate
:
b {store: S2, currentLoader: t, compiler: t, parser: t, missingTranslationHandler: pS, …}
userService
:
t {http: t}
userSettingsService
:
t {http: t}
utils
:
{formatValue: ƒ, getEntityDetailsPageURL: ƒ}
utilsService
:
a {window: Window, document: document, zone: e, datePipe: t, translate: b, …}
widget
:
{typeFullFqn: 'tenant.reporte', type: 'rpc', sizeX: 4.5, sizeY: 2.5, config: {…}, …}
widgetContentContainer
:
t1 {_lContainer: Array(11), _hostTNode: {…}, _hostLView: Array(96)}
widgetNamespace
:
"widget-type-tenant-reporte"
width
:
862
aliasController
:
(...)
currentUser
:
(...)
dashboardContentElement
:
(...)
dashboardPageElement
:
(...)
dashboardTimewindow
:
(...)
decimals
:
(...)
settings
:
(...)
stateController
:
(...)
units
:
(...)
widgetConfig
:
(...)
[[Prototype]]
:
Object
btn.onclick @ VM10082:18
Kn @ polyfills-5W6QH7SK.js:1
invokeTask @ polyfills-5W6QH7SK.js:1
runTask @ polyfills-5W6QH7SK.js:1
invokeTask @ polyfills-5W6QH7SK.js:1
q @ polyfills-5W6QH7SK.js:1
$ @ polyfills-5W6QH7SK.js:1
x @ polyfills-5W6QH7SK.js:1


Подробнее здесь: https://stackoverflow.com/questions/797 ... hingsboard
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Html»