import React from 'react';
import PandaConfigurationView from '../index';
import { service } from '@wisdom-utils/utils';

const REQUEST_HTTP = 'http';
const REQUEST_METHOD_GET = 'get';
const REQUEST_METHOD_POST = 'post';

const GET_SKETCHPAD_LIST =
  'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/PandaCore/GCK/SketchPad/List';
const GET_FILE_SKETCHPAD_CONTENT =
  'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/PandaCore/GCK/SketchPad/SketchContent';
const GET_POINT_ADDRESS =
  'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/PandaCore/GCK/PointAddress/GetPointAddress';
const GET_HISTORY_INFO =
  'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/PandaCore/Monitor/Device/SensorsDataForStation'; //获取历史信息
const GET_DICTIONARY_LIST =
  'https://www.fastmock.site/mock/162c15dca15c4dba9ba51e0a0b76929b/api/PandaCore/OMS/Data/GetDataDictionaryList'; //获取数据字典信息

// const GET_SKETCHPAD_LIST = '/api/PandaCore/GCK/SketchPad/List'; //获取画板列表接口
// const GET_FILE_SKETCHPAD_CONTENT = '/api/PandaCore/GCK/SketchPad/SketchContent'; //获取画板JSON
// const GET_POINT_ADDRESS = '/api/PandaCore/GCK/PointAddress/GetPointAddress'; //获取点表地址信息
// const GET_HISTORY_INFO = '/api/PandaCore/GCK/Device/SensorsDataForStation'; //获取历史信息
// const GET_DICTIONARY_LIST = '/api/PandaCore/OMS/DataManger/GetDataDictionaryList'; //获取数据字典信息

const configurationService = {
  getSketchPadList: {
    url: GET_SKETCHPAD_LIST, // 获取画板列表接口
    method: REQUEST_METHOD_GET,
    type: REQUEST_HTTP,
  },
  getSketchPadContent: {
    url: GET_FILE_SKETCHPAD_CONTENT, // 获取画板JSON
    method: REQUEST_METHOD_GET,
    type: REQUEST_HTTP,
  },
  getPointAddress: {
    url: GET_POINT_ADDRESS, // 获取点表地址信息
    method: REQUEST_METHOD_GET,
    type: REQUEST_HTTP,
  },
  getHistoryInfo: {
    url: GET_HISTORY_INFO,
    method: REQUEST_METHOD_POST,
    type: REQUEST_HTTP,
  },
  getDictionaryList: {
    url: GET_DICTIONARY_LIST,
    method: REQUEST_METHOD_GET,
    type: REQUEST_HTTP,
  },
};

const cvService = service(configurationService);

const getPointAddress = cvService.getPointAddress;
const getSketchPadContent = cvService.getSketchPadContent;
const getSketchPadList = cvService.getSketchPadList;
const getHistoryInfo = cvService.getHistoryInfo;
const getDictionaryList = cvService.getDictionaryList;

const Demo = () => {
  return (
    <div style={{ width: '100%', height: '600px', background: '#242835' }}>
      <PandaConfigurationView
        name={'组态测试'}
        devices={['ZTCS00000001', 'ZTCS00000002', 'ZTCS00000003', 'ZTCS00000004']}
        pointAddressService={getPointAddress}
        sketchPadListService={getSketchPadList}
        sketchPadContentService={getSketchPadContent}
        sketchPadListParams={{
          _site: '',
          siteCode: '151_ReactWeb5',
          queryInfo: '',
          version: '全部',
          name: '组态测试',
        }}
        historyInfoService={getHistoryInfo}
        dictionaryService={getDictionaryList}
        dictionaryParams={{ nodeID: 149 }}
        globalConfig={globalConfig}
      />
    </div>
  );
};

export default Demo;

const globalConfig = {
  baseURI: 'http://192.168.12.71:8080',
  userInfo: {
    site: '',
  },
  token: 'a1372ef0ce7b4e4884d31cfd99fe92f6',
  mqtt_iotIP: '192.168.12.9:8083',
  mqtt_path: '/mqtt',
  mqtt_IsSSL: false,
  mqtt_mess: {
    MessageLevel: '1.0',
    TcpIP: '192.168.12.9',
    TcpPort: 8083,
    site_code: '151_ReactWeb5',
  },
};
