Sidebar-BasicComponent.js 3.64 KB
(function () {
  Sidebar.prototype.addThingsKitBasicComponentsPalette = function () {
    this.addBasicComponentsPalette()
  }

  const { COMPONENT_KEY, CATEGORY } = window.CellAttributeKeyEnum

  const dt = 'basicComponents'

  Sidebar.prototype.addBasicComponentsPalette = function () {

    function createUserObject(attribute) {
      attribute = Object.assign({ [COMPONENT_KEY]: '', [CATEGORY]: '' }, attribute || {})
      var xmlElement = mxUtils.createXmlDocument().createElement('UserObject');

      Object.keys(attribute).forEach(key => {
        xmlElement.setAttribute(key, attribute[key]);
      })
      return xmlElement
    }

    this.setCurrentSearchEntryLibrary(dt);

    this.addPaletteFunctions(dt, mxResources.get(dt), true,
      [
        // Title组件
        this.createVertexTemplateEntry("text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;", 40, 20, createUserObject({ label: 'Title', [COMPONENT_KEY]: 'Title', [CATEGORY]: 'BASIC' }), "Title", null, !0, "text textbox textarea label"),

        // 变量组件
        this.createVertexTemplateEntry("text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontSize=16;", 40, 20, createUserObject({ label: mxResources.get('variable'), [COMPONENT_KEY]: 'Variable', [CATEGORY]: 'BASIC' }), mxResources.get('variable'), null, !0, "text textbox textarea label"),

        // 水流
        this.createEdgeTemplateEntry("shape=mxgraph.thingskit/waterFlowComponent;edgeStyle=orthogonalEdgeStyle;strokeColor=#409eff;strokeWidth=8;endArrow=none;dashed=1;html=1;", 200, 200, createUserObject({ [COMPONENT_KEY]: 'WaterFlow', [CATEGORY]: 'BASIC' }), mxResources.get('waters'), null, !0, ""),

        // 数字时钟
        this.createVertexTemplateEntry("shape=mxgraph.thingskit/digitalClockComponent;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=16;", 250, 100, createUserObject({ label: '', [COMPONENT_KEY]: 'DigitalClock', [CATEGORY]: 'BASIC' }), mxResources.get('digitalClock'), null, !0, "digital clock"),

        // 告警列表
        this.createVertexTemplateEntry("shape=mxgraph.thingskit/alarmListComponent;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=16;", 290, 230, createUserObject({ label: '', [COMPONENT_KEY]: 'AlarmList', [CATEGORY]: 'BASIC' }), mxResources.get('alarmList'), null, !0, "alarm list"),

        // 视频组件
        this.createVertexTemplateEntry('shape=mxgraph.thingskit/videoComponent;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=16;', 300, 150, createUserObject({ label: '', [COMPONENT_KEY]: 'Video', [CATEGORY]: 'BASIC' }), mxResources.get('video'), null, !0, 'text textbox textarea label'),

        // 变量图片组件
        this.createVertexTemplateEntry('shape=mxgraph.thingskit/variableImageComponent;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=16;', 200, 200, createUserObject({ label: '', [COMPONENT_KEY]: 'VariableImage', [CATEGORY]: 'BASIC' }), mxResources.get('variableImage'), null, !0, 'variable image'),

        // 图片组件
        this.createVertexTemplateEntry('shape=mxgraph.thingskit/imageComponent;text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=16;', 200, 200, createUserObject({ label: '', [COMPONENT_KEY]: 'Image', [CATEGORY]: 'BASIC' }), mxResources.get('image'), null, !0, 'image'),
      ]
    );

    this.setCurrentSearchEntryLibrary();
  };

})();