1.1.1 • Published 4 years ago

ssq-emulator v1.1.1

Weekly downloads
53
License
ISC
Repository
-
Last release
4 years ago

TOC

Insrtallationn

npm i ssq-emulator

AS400 Component

EmulatorController

เป็น function controller สำหรับจัดการการทำงานของ Emulator ประกอบไปด้วย

Method

NameReturnTypeDesc
getHighlightDefault(rowSize, colSize)textHighlightStringเป็น function สำหรับดึงค่าตั้งต้นของ highlight
setSelectionRange(elStr, selectionStart, selectionEnd)-เป็น function สำหรับข้อความและตำแหน่งของข้อมูลที่ถูกเลือก
getIndexByRowCol(row, colSize)indexNumberเป็น function สำหรับดึงค่า  index ของตำแหน่งบนหน้าจอ AS400
getAS400Cursor(index){ row: 1, col:1}Stringเป็น function สำหรับดึงค่าตำแหน่งของ cursor
getRowNumberByIndex(elStr, index)rowNumberเป็น function สำหรับดึงค่าแถวที่ถูกเลือก
getColNumberByIndex(elStr, index, colSize)colNumberเป็น function สำหรับดึงค่าคอลัมน์ที่ถูกเลือก
getStartSelection(elStr, colSize){ row: 1, col:1}Objectเป็น function สำหรับดึงค่าตำแหน่งเริ่มต้นที่ถูกเลือก
getEndSelection(elStr, colSize){ row: 1, col:1}Objectเป็น function สำหรับดึงค่าตำแหน่งสิ้นสุดที่ถูกเลือก
getSelectionRange(elStr, selectionStart, selectionEnd)textSelectionStringเป็น function สำหรับดึงค่าข้อความที่ถูกเลือก
initScreen(id, row, col)-เป็น function สำหรับ initail หน้าจอ AS400
setAs400Screen(id, text)-เป็น function สำหรับแสดงข้อความบนหน้าจอ AS400
setAs400Style(id, text, style)-เป็น function สำหรับแสดงของข้อความบนหน้าจอ AS400
setAS400Cursor(id, cursor)-เป็น function สำหรับระบุตำแน่งของ cursor
markAllCheckStringOnScreen(id, markListData)-เป็น function สำหรับ highlight ข้อมูลบนหน้าจอ AS400

Emulator

emulator

Properties

NameDefaultTypeDesc
idrandomStringId สำหรับอ้างอิง component
row24Numberจำนวนแถว
col80Numberจำนวนคอลัมน์
textDefaultStringข้อความที่แสดงบนหน้าจอ as400
styleDefaultStringสีของข้อความที่แสดงบนหน้าจอ as400
cursor"0,0"Stringตำแหน่งของ cursor
hiddenInfofaseBooleanflag สำหรับปิดการแสดงผลข้อความบนหน้าจอ as400 Information
readOnlyfalseBooleanflag สำหรับปิดการแก้ไขข้อความบนหน้าจอ as400

Method

NameReturnTypeDesc
initScreen(id, row, col)-เป็น function สำหรับ initail หน้าจอ AS400
setAs400Screen(id, text)-เป็น function สำหรับแสดงข้อความบนหน้าจอ AS400
setAs400Style(id, text, style)-เป็น function สำหรับแสดงของข้อความบนหน้าจอ AS400
setAS400Cursor(id, cursor)-เป็น function สำหรับระบุตำแน่งของ cursor

Example

import { Emulator } from "ssq-emulator";

const data = {
  HEADER: {
    tokenId: "EWI112233445566",
    requestId: "ABC123456789",
    deviceId: "UUID9988776655"
  },
  DATA: {
    screen: { row: 24, col: 80 },
    Text:
      "                                   Sign On                                      \n                                               System  . . . . . :   S101CD3M   \n                                               Subsystem . . . . :   QINTER     \n                                               Display . . . . . :   QPADEV003R \n                                                                                \n                User  . . . . . . . . . . . . . .                               \n                Password  . . . . . . . . . . . .                               \n                Program/procedure . . . . . . . .                               \n                Menu  . . . . . . . . . . . . . .                               \n                Current library . . . . . . . . .                               \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                        (C) COPYRIGHT IBM CORP. 1980, 2005.     ",
    Style:
      ".................................RRRRRRRRRRRRR..................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n.........................................................UUUUUUUUUU.............\n.........................................................HHHHHHHHHH.............\n.........................................................UUUUUUUUUU.............\n.........................................................UUUUUUUUUU.............\n.........................................................UUUUUUUUUU.............\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................",
    Cursor: "5,53"
  }
};

const id = "flow";
const { row, col } = data.DATA.screen;
const { Text: text, Style: style, Cursor: cursor } = data.DATA;

class DemoEmulator extends Component {
  render() {
    return (
      <Emulator
        id={id}
        row={row}
        col={col}
        text={text}
        style={style}
        cursor={cursor}
        // hiddenInfo
        // readOnly
      />
    );
  }
}
export default DemoEmulator;

Screen Mapping

screen-mapping

Screen Mapping extend มาจาก Emulator comonent

เมื่อ double click หรือ ลาก mouse คลุมข้อความ หน้าจอ AS400 จะต้องทำการกำหนด markType ที่ต้องการโดยการกดปุ่ม

Properties

NameDefaultTypeDesc
highlightList{}objectjson object ของการ highlight screen
markType-Stringคือ type ของ highlight ประกอบด้วย "mark-1", "mark-2", "mark-3" โดยแต่ละ  type จะมีสีที่แตกต่างกัน
markList-objectlist json data ของข้อมูลที่ต้องการการ highlight
highlight-objectjson data ของข้อมูลที่ต้องการการ highlight
lastSelection-objectjson data ของข้อมูลที่ถูกเลือกครั้งล่าสุด

Method

NameReturnDesc
getHighlight(markType)markDataเป็น function สำหรับดึงค่าข้อมูลที่ถูก Highlight ตาม type ที่ระบุ
setHighlight(markType, highlight)-เป็น function สำหรับ highlight ข้อความ ตาม type ที่ระบุ
clearHighlight(markType)-เป็น function สำหรับ clear Highlight ตาม type ที่ระบุ
getHighlightList()markListเป็น function สำหรับดึงค่าข้อมูลที่ถูก Highlight ทั้งหมด
setHighlightList(highlightList)-เป็น function สำหรับ highlight ข้อความทั้งหมด
clearHighlightList()-เป็น function สำหรับ clear Highlight ทั้งหมด
getLastSelection()lastSelectionเป็น function สำหรับดึงค่าของข้อมูลที่ถูกเลือกครั้งล่าสุด

Example

import React, { Component } from "react";
import Axios from "axios";

import { ScreenMapping, EmulatorController } from "ssq-emulator";

const data = {
  HEADER: {
    tokenId: "EWI112233445566",
    requestId: "ABC123456789",
    deviceId: "UUID9988776655"
  },
  DATA: {
    screen: { row: 24, col: 80 },
    Text:
      "                                   Sign On                                      \n                                               System  . . . . . :   S101CD3M   \n                                               Subsystem . . . . :   QINTER     \n                                               Display . . . . . :   QPADEV003R \n                                                                                \n                User  . . . . . . . . . . . . . .                               \n                Password  . . . . . . . . . . . .                               \n                Program/procedure . . . . . . . .                               \n                Menu  . . . . . . . . . . . . . .                               \n                Current library . . . . . . . . .                               \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                        (C) COPYRIGHT IBM CORP. 1980, 2005.     ",
    Style:
      ".................................RRRRRRRRRRRRR..................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n.........................................................UUUUUUUUUU.............\n.........................................................HHHHHHHHHH.............\n.........................................................UUUUUUUUUU.............\n.........................................................UUUUUUUUUU.............\n.........................................................UUUUUUUUUU.............\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................",
    Cursor: "5,53"
  }
};

const id = "flow2";
const { row, col } = data.DATA.screen;
const { Text: text, Style: style, Cursor: cursor } = data.DATA;
const highlightList = {
  mark1: {
    text: "Sign On",
    row: 1,
    col: 36
  },
  mark2: {
    text: "User",
    row: 6,
    col: 17
  },
  mark3: {
    text: "(C) COPYRIGHT IBM CORP. 1980, 2005.",
    row: 24,
    col: 41
  }
};

const MARK1 = "mark-1";
const MARK2 = "mark-2";
const MARK3 = "mark-3";

const onDblClickHandler = event => {
  // console.log(`| ========== ${event.type} ========== |`);
  let eventKey = event.key;
  if (event.keyCode >= 8 && event.keyCode < 48) {
    eventKey = `[' + ${eventKey.toLowerCase()} + ']`;
  }
  const selected = EmulatorController.getStartSelection(id, col);
  const dataForApi = {
    HEADER: {
      tokenId: "EWI112233445566",
      requestId: "ABC123456789",
      deviceId: "UUID9988776655"
      // requestCount: this.resultCount
    },
    DATA: {
      Event: "SELECTION",
      KeyValue: eventKey,
      Cursor: `${selected.row},${selected.col}`
    }
  };

  Axios({
    method: "post",
    url: "http://localhost:8085/emulator",
    data: JSON.stringify(dataForApi),
    headers: { "Content-Type": "application/json" }
  })
    .then(response => {
      // handle success
      const data = response.data.DATA;

      EmulatorController.setAs400Screen(id, data.Text);
      EmulatorController.setAs400Style(id, data.Text, data.Style);
      EmulatorController.setAS400Cursor(id, data.Cursor);

      const fields = data.Fields;
      let selection = null;

      const index = EmulatorController.getAS400Cursor(data.Cursor);
      fields.forEach(f => {
        if (Math.abs(f.EndRow - f.StartRow) === 0) {
          if (
            index.col >= f.StartCol &&
            index.col <= f.EndCol &&
            f.StartRow === index.row
          ) {
            selection = f;
          }
        }
      });

      const selectionStart = EmulatorController.getIndexByRowCol(
        selection.StartRow,
        selection.StartCol
      );
      const selectionEnd = EmulatorController.getIndexByRowCol(
        selection.EndRow,
        selection.EndCol
      );

      EmulatorController.setSelectionRange(id, selectionStart, selectionEnd);
    })
    .catch(response => {
      // handle error
      console.log(`response: ${response}`);
    });
};

const onMouseUpHandler = event => {
  // console.log(`| ========== ${event.type} ========== | `);
  if (event.keyCode === 9 || (event.keyCode > 111 && event.keyCode !== 123)) {
    event.preventDefault();
  }

  let eventKey = event.key;

  const selected = EmulatorController.getStartSelection(id, col);
  if (event.keyCode >= 8 && event.keyCode < 48) {
    eventKey = `[' + ${eventKey.toLowerCase()} + ']`;
  }
  const dataForApi = {
    HEADER: {
      tokenId: "EWI112233445566",
      requestId: "ABC123456789",
      deviceId: "UUID9988776655"
      // requestCount: this.resultCount
    },
    DATA: {
      Event: "KEYDOWN",
      KeyValue: eventKey,
      Cursor: `${selected.row},${selected.col}`
    }
  };

  Axios({
    method: "post",
    url: "http://localhost:8085/emulator",
    data: JSON.stringify(dataForApi),
    headers: { "Content-Type": "application/json" }
  })
    .then(response => {
      // handle success
      const data = response.data.DATA;

      EmulatorController.setAs400Screen(id, data.Text);
      EmulatorController.setAs400Style(id, data.Text, data.Style);
      EmulatorController.setAS400Cursor(id, data.Cursor);

      // this.clearAllMarkChackString(id);
    })
    .catch(response => {
      // handle error
      console.log(`response: ${response}`);
    });
};

class ScreenMappingPage extends Component {
  constructor(props) {
    super(props);

    this.smRef = React.createRef();
  }

  render() {
    return (
      <div>
        <ScreenMapping
          id={id}
          ref={this.smRef}
          row={row}
          col={col}
          text={text}
          style={style}
          cursor={cursor}
          highlight={highlightList}
          onDoubleClick={onDblClickHandler}
          onMouseUp={onMouseUpHandler}
        />
        <button
          onClick={() => this.smRef.current.setHighlightList(highlightList)}
        >
          highlight list
        </button>
        <button
          onClick={() => {
            console.log(this.smRef.current.getHighlightList());
          }}
        >
          get mark list
        </button>
        <button onClick={() => this.smRef.current.clearHighlightList()}>
          clear mark list
        </button>
        <br />
        <button
          onClick={() => {
            const highlight = this.smRef.current.getLastSelection();
            this.smRef.current.setHighlight(MARK1, highlight);
          }}
        >
          mark 1
        </button>
        <button
          onClick={() => {
            console.log(this.smRef.current.getHighlight(MARK1));
          }}
        >
          get mark 1
        </button>
        <button
          onClick={() => {
            this.smRef.current.clearHighlight(MARK1);
          }}
        >
          clear mark 1
        </button>
        <br />
        <button
          onClick={() => {
            const highlight = this.smRef.current.getLastSelection();
            this.smRef.current.setHighlight(MARK2, highlight);
          }}
        >
          mark 2
        </button>
        <button
          onClick={() => {
            console.log(this.smRef.current.getHighlight(MARK2));
          }}
        >
          get mark 2
        </button>
        <button
          onClick={() => {
            this.smRef.current.clearHighlight(MARK2);
          }}
        >
          clear mark 2
        </button>
        <br />
        <button
          onClick={() => {
            const highlight = this.smRef.current.getLastSelection();
            this.smRef.current.setHighlight(MARK3, highlight);
          }}
        >
          mark 3
        </button>
        <button
          onClick={() => {
            console.log(this.smRef.current.getHighlight(MARK3));
          }}
        >
          get mark 3
        </button>
        <button
          onClick={() => {
            this.smRef.current.clearHighlight(MARK3);
          }}
        >
          clear mark 3
        </button>
      </div>
    );
  }
}
export default ScreenMappingPage;

Fields Mapping

field-mapping

Fields Mapping extend มาจาก Emulator comonent

เมื่อ double click หรือ ลาก  mouse คลุมข้อความ หน้าจอ AS400 จะทำการ highlight ให้อัตโนมัติ โดยใช้ markType เป็น "mark-1

Properties

NameDefaultTypeDesc
markList-objectlist json data ของข้อมูลที่ต้องการการ highlight

Method

NameReturnDesc
getFieldHighlight()markDataเป็น function สำหรับดึงค่าข้อมูลที่ถูก Highlight ตาม type ที่ระบุ
clearFieldHighlight()-เป็น function สำหรับ highlight ข้อความ ตาม type ที่ระบุ
onDoubleClick-เป็น callback function สำหรับจัดการ event เช่นการ call api เป็นต้น
onMouseUp-เป็น callback function สำหรับจัดการ event เช่นการ call api เป็นต้น

Example

import React, { Component } from "react";
import Axios from "axios";

import { FieldsMapping, EmulatorController } from "ssq-emulator";

const data = {
  HEADER: {
    tokenId: "EWI112233445566",
    requestId: "ABC123456789",
    deviceId: "UUID9988776655"
  },
  DATA: {
    screen: { row: 24, col: 80 },
    Text:
      "                                   Sign On                                      \n                                               System  . . . . . :   S101CD3M   \n                                               Subsystem . . . . :   QINTER     \n                                               Display . . . . . :   QPADEV003R \n                                                                                \n                User  . . . . . . . . . . . . . .                               \n                Password  . . . . . . . . . . . .                               \n                Program/procedure . . . . . . . .                               \n                Menu  . . . . . . . . . . . . . .                               \n                Current library . . . . . . . . .                               \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                        (C) COPYRIGHT IBM CORP. 1980, 2005.     ",
    Style:
      ".................................RRRRRRRRRRRRR..................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n.........................................................UUUUUUUUUU.............\n.........................................................HHHHHHHHHH.............\n.........................................................UUUUUUUUUU.............\n.........................................................UUUUUUUUUU.............\n.........................................................UUUUUUUUUU.............\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................",
    Cursor: "5,53"
  }
};

const id = "flow3";
const { row, col } = data.DATA.screen;
const { Text: text, Style: style, Cursor: cursor } = data.DATA;
const highlightList = {
  mark1: { text: "          ", row: 6, col: 58 }
};

const onDblClickHandler = event => {
  // console.log(`| ========== ${event.type} ========== |`);
  let eventKey = event.key;
  if (event.keyCode >= 8 && event.keyCode < 48) {
    eventKey = `[' + ${eventKey.toLowerCase()} + ']`;
  }
  const selected = EmulatorController.getStartSelection(id, col);
  const dataForApi = {
    HEADER: {
      tokenId: "EWI112233445566",
      requestId: "ABC123456789",
      deviceId: "UUID9988776655"
      // requestCount: this.resultCount
    },
    DATA: {
      Event: "SELECTION",
      KeyValue: eventKey,
      Cursor: `${selected.row},${selected.col}`
    }
  };

  Axios({
    method: "post",
    url: "http://localhost:8085/emulator",
    data: JSON.stringify(dataForApi),
    headers: { "Content-Type": "application/json" }
  })
    .then(response => {
      // handle success
      const data = response.data.DATA;

      EmulatorController.setAs400Screen(id, data.Text);
      EmulatorController.setAs400Style(id, data.Text, data.Style);
      EmulatorController.setAS400Cursor(id, data.Cursor);

      //    clearAllMarkChackString(id);

      const fields = data.Fields;
      let selection = null;

      const index = EmulatorController.getAS400Cursor(data.Cursor);
      fields.forEach(f => {
        if (Math.abs(f.EndRow - f.StartRow) === 0) {
          if (
            index.col >= f.StartCol &&
            index.col <= f.EndCol &&
            f.StartRow === index.row
          ) {
            selection = f;
          }
        }
      });

      const selectionStart = EmulatorController.getIndexByRowCol(
        selection.StartRow,
        selection.StartCol
      );
      const selectionEnd = EmulatorController.getIndexByRowCol(
        selection.EndRow,
        selection.EndCol
      );

      EmulatorController.setSelectionRange(id, selectionStart, selectionEnd);
    })
    .catch(response => {
      // handle error
      console.log(`response: ${response}`);
    });
};

const onMouseUpHandler = event => {
  // console.log(`| ========== ${event.type} ========== | `);
  if (event.keyCode === 9 || (event.keyCode > 111 && event.keyCode !== 123)) {
    event.preventDefault();
  }

  let eventKey = event.key;
  const selected = EmulatorController.getStartSelection(id, col);
  if (event.keyCode >= 8 && event.keyCode < 48) {
    eventKey = `[' + ${eventKey.toLowerCase()} + ']`;
  }
  const dataForApi = {
    HEADER: {
      tokenId: "EWI112233445566",
      requestId: "ABC123456789",
      deviceId: "UUID9988776655"
      // requestCount: this.resultCount
    },
    DATA: {
      Event: "KEYDOWN",
      KeyValue: eventKey,
      Cursor: `${selected.row},${selected.col}`
    }
  };

  Axios({
    method: "post",
    url: "http://localhost:8085/emulator",
    data: JSON.stringify(dataForApi),
    headers: { "Content-Type": "application/json" }
  })
    .then(response => {
      // console.log(`| ========== ${event.type} ========== | `);
      const startSelection = EmulatorController.getStartSelection(id, col);
      const endSelection = EmulatorController.getEndSelection(id, col);

      const flag = "field";
      // const flag = 'list';
      if (flag === "list") {
        const selectionStart =
          EmulatorController.getIndexByRowCol(startSelection.row, 0) + 1;
        const selectionEnd =
          EmulatorController.getIndexByRowCol(endSelection.row, col) + 2;

        EmulatorController.setSelectionRange(id, selectionStart, selectionEnd);
      }
    })
    .catch(response => {
      // handle error
      console.log(`response: ${response}`);
    });
};

class FieldsMappingPage extends Component {
  constructor(props) {
    super(props);

    this.smRef = React.createRef();
  }

  render() {
    return (
      <div>
        <FieldsMapping
          id={id}
          ref={this.smRef}
          row={row}
          col={col}
          text={text}
          style={style}
          cursor={cursor}
          highlight={highlightList}
          onDoubleClick={onDblClickHandler}
          onMouseUp={onMouseUpHandler}
        />

        <button
          onClick={() => {
            console.log(this.smRef.current.getFieldHighlight());
          }}
        >
          get field marker
        </button>
        <button
          onClick={() => {
            this.smRef.current.clearFieldHighlight();
          }}
        >
          clear field marker
        </button>
      </div>
    );
  }
}
export default FieldsMappingPage;

List Mapping

field-mapping

List Mapping extend มาจาก Emulator comonent

Properties

NameDefaultTypeDesc
highlightList{}objectjson object ของการ highlight screen
markType-Stringคือ type ของ highlight ประกอบด้วย "mark-1", "mark-2", "mark-3" โดยแต่ละ  type จะมีสีที่แตกต่างกัน
markList-objectlist json data ของข้อมูลที่ต้องการการ highlight
highlight-objectjson data ของข้อมูลที่ต้องการการ highlight
lastSelection-objectjson data ของข้อมูลที่ถูกเลือกครั้งล่าสุด

Method

NameReturnDesc
getListHighlight()markDataเป็น function สำหรับดึงค่าข้อมูล List ที่ถูก Highlight
setListHighlight(highlight)-เป็น function สำหรับ highlight List ที่เลือก
clearListHighlight()-เป็น function สำหรับ clear Highlight List
getFieldHighlight()markListเป็น function สำหรับดึงค่า field ข้อมูลที่ถูก Highlight
setFieldHighlight(highlight)-เป็น function สำหรับ highlight field ที่เลือก
clearFieldHighlight()-เป็น function สำหรับ clear highlight field
getLastSelection()lastSelectionเป็น function สำหรับดึงค่าของข้อมูลที่ถูกเลือกครั้งล่าสุด

Example

import React, { Component } from "react";
import Axios from "axios";

import { ListMapping, EmulatorController } from "ssq-emulator";

// import {
//   setAs400Screen,
//   setAs400Style,
//   getAS400Cursor,
//   setAS400Cursor,
//   getIndexByRowCol,
//   setSelectionRange,
//   getStartSelection,
//   getEndSelection
// } from "../../components/Emulator/controller";

const data = {
  HEADER: {
    tokenId: "EWI112233445566",
    requestId: "ABC123456789",
    deviceId: "UUID9988776655"
  },
  DATA: {
    screen: { row: 24, col: 80 },
    Text:
      "                                   Sign On                                      \n                                               System  . . . . . :   S101CD3M   \n                                               Subsystem . . . . :   QINTER     \n                                               Display . . . . . :   QPADEV003R \n                                                                                \n                User  . . . . . . . . . . . . . .                               \n                Password  . . . . . . . . . . . .                               \n                Program/procedure . . . . . . . .                               \n                Menu  . . . . . . . . . . . . . .                               \n                Current library . . . . . . . . .                               \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                                                                \n                                        (C) COPYRIGHT IBM CORP. 1980, 2005.     ",
    Style:
      ".................................RRRRRRRRRRRRR..................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n.........................................................UUUUUUUUUU.............\n.........................................................HHHHHHHHHH.............\n.........................................................UUUUUUUUUU.............\n.........................................................UUUUUUUUUU.............\n.........................................................UUUUUUUUUU.............\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................\n................................................................................",
    Cursor: "5,53"
  }
};

const id = "flow4";
const { row, col } = data.DATA.screen;
const { Text: text, Style: style, Cursor: cursor } = data.DATA;
const highlightList = {
  mark1: { text: "          ", row: 6, col: 58 }
};

const onDblClickHandler = event => {
  // console.log(`| ========== ${event.type} ========== |`);
  let eventKey = event.key;
  if (event.keyCode >= 8 && event.keyCode < 48) {
    eventKey = `[' + ${eventKey.toLowerCase()} + ']`;
  }
  const selected = EmulatorController.getStartSelection(id, col);
  const dataForApi = {
    HEADER: {
      tokenId: "EWI112233445566",
      requestId: "ABC123456789",
      deviceId: "UUID9988776655"
      // requestCount: this.resultCount
    },
    DATA: {
      Event: "SELECTION",
      KeyValue: eventKey,
      Cursor: `${selected.row},${selected.col}`
    }
  };

  Axios({
    method: "post",
    url: "http://localhost:8085/emulator",
    data: JSON.stringify(dataForApi),
    headers: { "Content-Type": "application/json" }
  })
    .then(response => {
      // handle success
      const data = response.data.DATA;

      EmulatorController.setAs400Screen(id, data.Text);
      EmulatorController.setAs400Style(id, data.Text, data.Style);
      EmulatorController.setAS400Cursor(id, data.Cursor);

      // clearAllMarkChackString(id);

      const fields = data.Fields;
      let selection = null;

      const index = EmulatorController.getAS400Cursor(data.Cursor);
      fields.forEach(f => {
        if (Math.abs(f.EndRow - f.StartRow) === 0) {
          if (
            index.col >= f.StartCol &&
            index.col <= f.EndCol &&
            f.StartRow === index.row
          ) {
            selection = f;
          }
        }
      });

      const selectionStart = EmulatorController.getIndexByRowCol(
        selection.StartRow,
        selection.StartCol
      );
      const selectionEnd = EmulatorController.getIndexByRowCol(
        selection.EndRow,
        selection.EndCol
      );

      EmulatorController.setSelectionRange(id, selectionStart, selectionEnd);
    })
    .catch(response => {
      // handle error
      console.log(`response: ${response}`);
    });
};

const onMouseUpHandler = event => {
  // console.log(`| ========== ${event.type} ========== | `);
  if (event.keyCode === 9 || (event.keyCode > 111 && event.keyCode !== 123)) {
    event.preventDefault();
  }

  let eventKey = event.key;
  const selected = EmulatorController.getStartSelection(id, col);
  if (event.keyCode >= 8 && event.keyCode < 48) {
    eventKey = `[' + ${eventKey.toLowerCase()} + ']`;
  }
  const dataForApi = {
    HEADER: {
      tokenId: "EWI112233445566",
      requestId: "ABC123456789",
      deviceId: "UUID9988776655"
      // requestCount: this.resultCount
    },
    DATA: {
      Event: "KEYDOWN",
      KeyValue: eventKey,
      Cursor: `${selected.row},${selected.col}`
    }
  };

  // Axios({
  //   method: "post",
  //   url: "http://localhost:8080/emulator",
  //   data: JSON.stringify(dataForApi),
  //   headers: { "Content-Type": "application/json" }
  // })
  //   .then(response => {
  // console.log(`| ========== ${event.type} ========== | `);
  const startSelection = EmulatorController.getStartSelection(id, col);
  const endSelection = EmulatorController.getEndSelection(id, col);

  const selectionStart =
    EmulatorController.getIndexByRowCol(startSelection.row, 0) + 2;
  const selectionEnd =
    EmulatorController.getIndexByRowCol(endSelection.row, col) + 2;

  EmulatorController.setSelectionRange(id, selectionStart, selectionEnd);
  // })
  // .catch(response => {
  //   // handle error
  //   console.log(`response: ${response}`);
  // });
};

class ListMappingPage extends Component {
  constructor(props) {
    super(props);

    this.smRef = React.createRef();
  }

  render() {
    return (
      <div>
        <ListMapping
          id={id}
          ref={this.smRef}
          row={row}
          col={col}
          text={text}
          style={style}
          cursor={cursor}
          highlight={highlightList}
          onDoubleClick={onDblClickHandler}
          onMouseUp={onMouseUpHandler}
        />

        <button
          onClick={() => {
            console.log(this.smRef.current.getListHighlight());
          }}
        >
          get list marker
        </button>
        <button
          onClick={() => {
            this.smRef.current.clearListHighlight();
          }}
        >
          clear list marker
        </button>
        <button
          onClick={() => {
            console.log(this.smRef.current.getFieldHighlight());
          }}
        >
          get field marker
        </button>
        <button
          onClick={() => {
            this.smRef.current.clearFieldHighlight();
          }}
        >
          clear field marker
        </button>
      </div>
    );
  }
}
export default ListMappingPage;
1.1.1

4 years ago

1.1.0

4 years ago

1.0.55

4 years ago

1.0.54

4 years ago

1.0.52

4 years ago

1.0.51

4 years ago

1.0.50

4 years ago

1.0.49

4 years ago

1.0.48

4 years ago

1.0.47

4 years ago

1.0.46

4 years ago

1.0.44

4 years ago

1.0.45

4 years ago

1.0.43

4 years ago

1.0.41

4 years ago

1.0.39

4 years ago

1.0.40

4 years ago

1.0.38

4 years ago

1.0.37

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.19

4 years ago

1.0.17

4 years ago

1.0.22

4 years ago

1.0.20

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago