2019-08-14 19:55:24 +03:00
|
|
|
///
|
|
|
|
|
/// Copyright © 2016-2019 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.
|
|
|
|
|
///
|
|
|
|
|
|
2019-09-05 21:15:40 +03:00
|
|
|
import { ExceptionData } from '@shared/models/error.models';
|
|
|
|
|
import { IDashboardComponent } from '@home/models/dashboard-component.models';
|
|
|
|
|
import { WidgetActionDescriptor, WidgetConfig, WidgetConfigSettings, widgetType } from '@shared/models/widget.models';
|
|
|
|
|
import { Timewindow } from '@shared/models/time/time.models';
|
|
|
|
|
import {
|
|
|
|
|
EntityInfo,
|
|
|
|
|
IWidgetSubscription,
|
|
|
|
|
SubscriptionInfo,
|
|
|
|
|
WidgetSubscriptionOptions,
|
|
|
|
|
IStateController,
|
|
|
|
|
IAliasController,
|
|
|
|
|
TimewindowFunctions,
|
|
|
|
|
WidgetSubscriptionApi,
|
|
|
|
|
RpcApi,
|
|
|
|
|
WidgetActionsApi,
|
|
|
|
|
IWidgetUtils
|
|
|
|
|
} from '@core/api/widget-api.models';
|
|
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
import { EntityId } from '@shared/models/id/entity-id';
|
|
|
|
|
|
2019-09-03 19:31:16 +03:00
|
|
|
export interface IWidgetAction {
|
2019-09-05 21:15:40 +03:00
|
|
|
name: string;
|
2019-09-03 19:31:16 +03:00
|
|
|
icon: string;
|
|
|
|
|
onAction: ($event: Event) => void;
|
|
|
|
|
}
|
2019-08-14 19:55:24 +03:00
|
|
|
|
2019-09-03 19:31:16 +03:00
|
|
|
export interface WidgetHeaderAction extends IWidgetAction {
|
|
|
|
|
displayName: string;
|
2019-09-05 21:15:40 +03:00
|
|
|
descriptor: WidgetActionDescriptor;
|
2019-08-14 19:55:24 +03:00
|
|
|
}
|
|
|
|
|
|
2019-09-03 19:31:16 +03:00
|
|
|
export interface WidgetAction extends IWidgetAction {
|
|
|
|
|
show: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-05 21:15:40 +03:00
|
|
|
export interface IDynamicWidgetComponent {
|
|
|
|
|
widgetContext: WidgetContext;
|
|
|
|
|
widgetErrorData: ExceptionData;
|
|
|
|
|
loadingData: boolean;
|
|
|
|
|
[key: string]: any;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 19:31:16 +03:00
|
|
|
export interface WidgetContext {
|
2019-09-05 21:15:40 +03:00
|
|
|
inited?: boolean;
|
|
|
|
|
$container?: any;
|
|
|
|
|
$containerParent?: any;
|
|
|
|
|
width?: number;
|
|
|
|
|
height?: number;
|
|
|
|
|
$scope?: IDynamicWidgetComponent;
|
2019-09-03 19:31:16 +03:00
|
|
|
hideTitlePanel?: boolean;
|
2019-09-05 21:15:40 +03:00
|
|
|
isEdit?: boolean;
|
|
|
|
|
isMobile?: boolean;
|
|
|
|
|
dashboard?: IDashboardComponent;
|
|
|
|
|
widgetConfig?: WidgetConfig;
|
|
|
|
|
settings?: WidgetConfigSettings;
|
|
|
|
|
units?: string;
|
|
|
|
|
decimals?: number;
|
|
|
|
|
subscriptions?: {[id: string]: IWidgetSubscription};
|
|
|
|
|
defaultSubscription?: IWidgetSubscription;
|
|
|
|
|
dashboardTimewindow?: Timewindow;
|
|
|
|
|
timewindowFunctions?: TimewindowFunctions;
|
|
|
|
|
subscriptionApi?: WidgetSubscriptionApi;
|
|
|
|
|
controlApi?: RpcApi;
|
|
|
|
|
utils?: IWidgetUtils;
|
|
|
|
|
actionsApi?: WidgetActionsApi;
|
|
|
|
|
stateController?: IStateController;
|
|
|
|
|
aliasController?: IAliasController;
|
|
|
|
|
activeEntityInfo?: EntityInfo;
|
|
|
|
|
widgetTitleTemplate?: string;
|
2019-09-03 19:31:16 +03:00
|
|
|
widgetTitle?: string;
|
|
|
|
|
customHeaderActions?: Array<WidgetHeaderAction>;
|
|
|
|
|
widgetActions?: Array<WidgetAction>;
|
2019-08-14 19:55:24 +03:00
|
|
|
}
|