All files / output zcl_abapgit_html_viewer_web.clas.mjs

5.04% Statements 6/119
66.66% Branches 2/3
25% Functions 1/4
5.04% Lines 6/119

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 1191x 1x                                                                                                                                                                                                                                   1x 1x 1x 1x
const {cx_root} = await import("./cx_root.clas.mjs");
// zcl_abapgit_html_viewer_web.clas.abap
class zcl_abapgit_html_viewer_web {
  static INTERNAL_TYPE = 'CLAS';
  static INTERNAL_NAME = 'ZCL_ABAPGIT_HTML_VIEWER_WEB';
  static IMPLEMENTED_INTERFACES = ["ZIF_ABAPGIT_HTML_VIEWER"];
  static ATTRIBUTES = {"MV_HTML": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MV_CSS": {"type": () => {return new abap.types.String({qualifiedName: "STRING"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MI_REQUEST": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_REQUEST", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_REQUEST"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "MI_RESPONSE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_RESPONSE"});}, "visibility": "I", "is_constant": " ", "is_class": " "},
  "ZIF_ABAPGIT_HTML_VIEWER~C_ID_SAPEVENT": {"type": () => {return new abap.types.Integer({qualifiedName: "I"});}, "visibility": "U", "is_constant": "X", "is_class": "X"}};
  static METHODS = {"CONSTRUCTOR": {"visibility": "U", "parameters": {"II_REQUEST": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_REQUEST", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_REQUEST"});}, "is_optional": " "}, "II_RESPONSE": {"type": () => {return new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_RESPONSE"});}, "is_optional": " "}}}};
  #mv_html;
  #mv_css;
  #mi_request;
  #mi_response;
  constructor() {
    this.me = new abap.types.ABAPObject();
    this.me.set(this);
    this.INTERNAL_ID = abap.internalIdCounter++;
    this.FRIENDS_ACCESS_INSTANCE = {
    };
    this.#mv_html = new abap.types.String({qualifiedName: "STRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_html"] = this.#mv_html;
    this.#mv_css = new abap.types.String({qualifiedName: "STRING"});
    this.FRIENDS_ACCESS_INSTANCE["mv_css"] = this.#mv_css;
    this.#mi_request = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_REQUEST", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_REQUEST"});
    this.FRIENDS_ACCESS_INSTANCE["mi_request"] = this.#mi_request;
    this.#mi_response = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_RESPONSE"});
    this.FRIENDS_ACCESS_INSTANCE["mi_response"] = this.#mi_response;
    this.zif_abapgit_html_viewer$c_id_sapevent = abap.Classes['ZIF_ABAPGIT_HTML_VIEWER'].zif_abapgit_html_viewer$c_id_sapevent;
    this.zif_abapgit_html_viewer$sapevent = {"EVENT_NAME": "SAPEVENT", "EVENT_CLASS": "ZIF_ABAPGIT_HTML_VIEWER"};
  }
  async constructor_(INPUT) {
    let ii_request = INPUT?.ii_request;
    if (ii_request?.getQualifiedName === undefined || ii_request.getQualifiedName() !== "ZIF_ABAPGIT_WEB_REQUEST") { ii_request = undefined; }
    if (ii_request === undefined) { ii_request = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_REQUEST", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_REQUEST"}).set(INPUT.ii_request); }
    let ii_response = INPUT?.ii_response;
    if (ii_response?.getQualifiedName === undefined || ii_response.getQualifiedName() !== "ZIF_ABAPGIT_WEB_RESPONSE") { ii_response = undefined; }
    if (ii_response === undefined) { ii_response = new abap.types.ABAPObject({qualifiedName: "ZIF_ABAPGIT_WEB_RESPONSE", RTTIName: "\\INTERFACE=ZIF_ABAPGIT_WEB_RESPONSE"}).set(INPUT.ii_response); }
    this.#mi_request.set(ii_request);
    this.#mi_response.set(ii_response);
    return this;
  }
  async zif_abapgit_html_viewer$back() {
    return;
  }
  async zif_abapgit_html_viewer$close_document() {
    return;
  }
  async zif_abapgit_html_viewer$free() {
    return;
  }
  async zif_abapgit_html_viewer$set_focus() {
    return;
  }
  async zif_abapgit_html_viewer$get_url() {
    let rv_url = new abap.types.String({qualifiedName: "STRING"});
    return rv_url;
    return rv_url;
  }
  async zif_abapgit_html_viewer$load_data(INPUT) {
    let iv_url = new abap.types.String({qualifiedName: "STRING"});
    if (INPUT && INPUT.iv_url) {iv_url.set(INPUT.iv_url);}
    let iv_type = INPUT?.iv_type || new abap.types.Character();
    if (INPUT === undefined || INPUT.iv_type === undefined) {iv_type = abap.CharacterFactory.get(4, 'text');}
    let iv_subtype = INPUT?.iv_subtype || new abap.types.Character();
    if (INPUT === undefined || INPUT.iv_subtype === undefined) {iv_subtype = abap.CharacterFactory.get(4, 'html');}
    let iv_size = new abap.types.Integer({qualifiedName: "I"});
    if (INPUT && INPUT.iv_size) {iv_size.set(INPUT.iv_size);}
    if (INPUT === undefined || INPUT.iv_size === undefined) {iv_size = abap.IntegerFactory.get(0);}
    let ev_assigned_url = INPUT?.ev_assigned_url || new abap.types.String({qualifiedName: "STRING"});
    let ct_data_table = abap.types.TableFactory.construct(new abap.types.Character(4), {"withHeader":false,"keyType":"DEFAULT"});
    if (INPUT && INPUT.ct_data_table) {ct_data_table = INPUT.ct_data_table;}
    if (abap.compare.eq(iv_url, abap.CharacterFactory.get(14, 'css/bundle.css'))) {
      abap.statements.concatenate({source: [ct_data_table], target: this.#mv_css, lines: true, respectingBlanks: true});
    } else if (abap.compare.eq(iv_url, abap.CharacterFactory.get(1, ''))) {
      abap.statements.concatenate({source: [ct_data_table], target: this.#mv_html, lines: true, respectingBlanks: true});
    }
  }
  async zif_abapgit_html_viewer$set_registered_events(INPUT) {
    let it_events = INPUT?.it_events;
    if (it_events?.getQualifiedName === undefined || it_events.getQualifiedName() !== "CNTL_SIMPLE_EVENTS") { it_events = undefined; }
    if (it_events === undefined) { it_events = abap.types.TableFactory.construct(new abap.types.Structure({
    "eventid": new abap.types.Integer({qualifiedName: "EVENTID"}),
    "appl_event": new abap.types.Character(1, {"qualifiedName":"appl_event"})}, "cntl_simple_event", undefined, {}, {}), {"withHeader":false,"keyType":"DEFAULT","primaryKey":{"name":"primary_key","type":"STANDARD","isUnique":false,"keyFields":[]},"secondary":[]}, "cntl_simple_events").set(INPUT.it_events); }
    return;
  }
  async zif_abapgit_html_viewer$set_visiblity(INPUT) {
    let iv_visible = INPUT?.iv_visible;
    if (iv_visible?.getQualifiedName === undefined || iv_visible.getQualifiedName() !== "ABAP_BOOL") { iv_visible = undefined; }
    if (iv_visible === undefined) { iv_visible = new abap.types.Character(1, {"qualifiedName":"ABAP_BOOL","ddicName":"ABAP_BOOL"}).set(INPUT.iv_visible); }
    return;
  }
  async zif_abapgit_html_viewer$show_url(INPUT) {
    let iv_url = INPUT?.iv_url;
    if (iv_url?.getQualifiedName === undefined || iv_url.getQualifiedName() !== "STRING") { iv_url = undefined; }
    if (iv_url === undefined) { iv_url = new abap.types.String({qualifiedName: "STRING"}).set(INPUT.iv_url); }
    let lv_path = new abap.types.String({qualifiedName: "STRING"});
    let lv_js = new abap.types.String({qualifiedName: "STRING"});
    lv_path.set((await abap.Classes['CL_HTTP_UTILITY'].if_http_utility$unescape_url({escaped: (await this.#mi_request.get().zif_abapgit_web_request$get_header_field({iv_name: abap.CharacterFactory.get(5, '~path')}))})));
    lv_js.set(abap.operators.concat(new abap.types.String().set(`<script>                                     \n`),abap.operators.concat(new abap.types.String().set(`function registerLinks() \{                        \n`),abap.operators.concat(new abap.types.String().set(`  const links = document.getElementsByTagName("a");\n`),abap.operators.concat(new abap.types.String().set(`  for (let i = 0; i < links.length; i++) \{        \n`),abap.operators.concat(new abap.types.String().set(`    if (links[i].href.startsWith("sapevent:")) \{  \n`),abap.operators.concat(new abap.types.String().set(`      links[i].href = "./" + links[i].href;        \n`),abap.operators.concat(new abap.types.String().set(`    \}                                             \n`),abap.operators.concat(new abap.types.String().set(`  \}                                               \n`),abap.operators.concat(new abap.types.String().set(`\}                                                 \n`),abap.operators.concat(new abap.types.String().set(`registerLinks();                                   \n`),abap.operators.concat(new abap.types.String().set(`                                                   \n`),abap.operators.concat(new abap.types.String().set(`function registerForms() \{                              \n`),abap.operators.concat(new abap.types.String().set(`  const forms = document.getElementsByTagName("form");   \n`),abap.operators.concat(new abap.types.String().set(`  for (let i = 0; i < forms.length; i++) \{              \n`),abap.operators.concat(new abap.types.String().set(`    forms[i].action = "./" + forms[i].action;            \n`),abap.operators.concat(new abap.types.String().set(`  \}                                                     \n`),abap.operators.concat(new abap.types.String().set(`  const inputs = document.getElementsByTagName("input"); \n`),abap.operators.concat(new abap.types.String().set(`  for (let i = 0; i < inputs.length; i++) \{             \n`),abap.operators.concat(new abap.types.String().set(`    if (inputs[i].type === "submit"                          \n`),abap.operators.concat(new abap.types.String().set(`        && inputs[i].formAction.startsWith("sapevent:")) \{  \n`),abap.operators.concat(new abap.types.String().set(`      inputs[i].formAction = "./" + inputs[i].formAction;    \n`),abap.operators.concat(new abap.types.String().set(`    \}                                                       \n`),abap.operators.concat(new abap.types.String().set(`  \}                                                     \n`),abap.operators.concat(new abap.types.String().set(`\}                                                       \n`),abap.operators.concat(new abap.types.String().set(`registerForms();                                         \n`),new abap.types.String().set(`</script></body>\n`)))))))))))))))))))))))))));
    if (abap.compare.eq(lv_path, abap.CharacterFactory.get(28, '/sap/zabapgit/css/bundle.css'))) {
      await this.#mi_response.get().zif_abapgit_web_response$set_content_type({iv_type: abap.CharacterFactory.get(8, 'text/css')});
      await this.#mi_response.get().zif_abapgit_web_response$set_cdata({iv_data: this.#mv_css});
    } else if (abap.compare.eq(lv_path, abap.CharacterFactory.get(14, '/sap/zabapgit/')) || abap.compare.cp(lv_path, new abap.types.String().set(`/sap/zabapgit/sapevent:+*`))) {
      abap.statements.replace({target: this.#mv_html, all: false, with: lv_js, of: new abap.types.String().set(`</body>`)});
      await this.#mi_response.get().zif_abapgit_web_response$set_content_type({iv_type: abap.CharacterFactory.get(9, 'text/html')});
      await this.#mi_response.get().zif_abapgit_web_response$set_cdata({iv_data: this.#mv_html});
    } else {
      await this.#mi_response.get().zif_abapgit_web_response$set_content_type({iv_type: abap.CharacterFactory.get(9, 'text/html')});
      await this.#mi_response.get().zif_abapgit_web_response$set_cdata({iv_data: new abap.types.String().set(`show_url, unknown path ${abap.templateFormatting(lv_path)}`)});
    }
  }
}
abap.Classes['ZCL_ABAPGIT_HTML_VIEWER_WEB'] = zcl_abapgit_html_viewer_web;
zcl_abapgit_html_viewer_web.zif_abapgit_html_viewer$c_id_sapevent = new abap.types.Integer({qualifiedName: "I"});
zcl_abapgit_html_viewer_web.zif_abapgit_html_viewer$c_id_sapevent.set(1);
export {zcl_abapgit_html_viewer_web};