Dashboard Plugin

Overview

This article is aimed at InLong Dashboard plug-in developers, trying to describe the process of developing a Dashboard plug-in as comprehensively as possible, helping developers quickly add a data storage LoadNode, and making plug-in development easier. The InLong Dashboard itself acts as a front-end console, built with the React framework.

Basic

Design Summary

This is a schematic diagram of the design of the InLong Dashboard plugin. We treat the plugin as a separate level, and each page uses different plugins for consumption. Data and View are abstract classes provided by the system, and plugins are derived classes one by one.

Dashboard_Plugin

Directory Structure

  1. |
  2. |- defaults: default public plugins provided by the InLong community
  3. |- extends: The extension plug-in during privatization deployment, as an internal plug-in, will not be released to the community
  4. |- common: the common design of the plugin, e.g. the design of `BasicInfo`

Data Class

We provide two basic data classes, and each plugin can only implement one of them to implement the data model. At the same time, in the basic data class, a @I18n is provided, which can be used to describe the field.

  • DataStatic static data class
  • DataWithBackend communicates with the backend data class

View Class

On the view, we provide two basic view classes, each plugin can implement one or more of them to implement the view model.

  • RenderRow, in which @FieldDecorator is provided to describe the row data view
  • RenderList, in which @ColumnDecorator is provided to describe the column data view

Example

Below is a basic example, in the plugin, a class that communicates with backend is implemented, containing 3 fields (username, password, format). Among them, BasicInfo comes from their different base type classes.

  1. import { DataWithBackend } from '@/metas/DataWithBackend';
  2. import { RenderRow } from '@/metas/RenderRow';
  3. import { RenderList } from '@/metas/RenderList';
  4. import { BasicInfo } from '../common/BasicInfo';
  5. const { I18n } = DataWithBackend;
  6. const { FieldDecorator } = RenderRow;
  7. const { ColumnDecorator } = RenderList;
  8. export default class Example extends BasicInfo implements DataWithBackend, RenderRow, RenderList {
  9. @FieldDecorator({
  10. type: 'input',
  11. rules: [{ required: true }],
  12. })
  13. @I18n('meta.Sinks.Username')
  14. username: string;
  15. @FieldDecorator({
  16. type: 'password',
  17. rules: [{ required: true }],
  18. })
  19. @I18n('meta.Sinks.Password')
  20. password: string;
  21. @FieldDecorator({
  22. type: 'radio',
  23. initialValue: 'TextFile',
  24. rules: [{ required: true }],
  25. props: {
  26. options: [
  27. {
  28. label: 'TextFile',
  29. value: 'TextFile',
  30. },
  31. {
  32. label: 'SequenceFile',
  33. value: 'SequenceFile',
  34. },
  35. ],
  36. },
  37. })
  38. @I18n('meta.Sinks.Example.Format')
  39. format: string;
  40. }

Extend ExtractNode

In the inlong-dashboard/src/metas/sources/defaults directory, create a new Example.ts file as a new plugin, and export it in the index.ts file in the current directory (refer to Existing writing method), which completes a new ExtractNode named Example.

Extend LoadNode

In the inlong-dashboard/src/metas/sinks/defaults directory, create a new Example.ts file as a new plugin, and export it in the index.ts file in the current directory (refer to The existing writing method), which completes a new LoadNode named Example.