Sha256: ae28887db26b1c1db8d5bb74a4e151ee50b9cac0aebe5b4ff1cc6e4f3e270a5f

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 KB

Contents

import { Component, ViewChild, AfterViewInit, OnDestroy } from '@angular/core';
import {CdkPortal, DomPortalOutlet} from '@angular/cdk/portal';
import { OpenC3Api } from "@openc3/js-common/services";

@Component({
  selector: 'openc3-tool-<%= tool_name %>-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
export class AppComponent implements  AfterViewInit, OnDestroy {
  @ViewChild(CdkPortal)
  private portal: CdkPortal | undefined;
  private host: DomPortalOutlet | undefined;

  clickHandler = function() {
    let api = new OpenC3Api();
    api.cmd("INST", "COLLECT", { TYPE: "NORMAL" }).then((response: any) => {
      alert("Command Sent!");
    });
  }
  getMenuElement() {
    let elem = document.getElementById("openc3-menu")
    if (elem) {
      return elem
    } else {
      return document.createElement('span')
    }
  }
  ngAfterViewInit(): void {
    this.host = new DomPortalOutlet(
      this.getMenuElement()
    );
    this.host.attach(this.portal);
    document.title = "<%= tool_name_display %>";
    let tool = document.querySelector('#openc3-tool');
    if (tool == null) {
      tool = document.createElement('div')
    }
    let overlay = document.querySelector('.cdk-overlay-container');
    if (overlay == null) {
      overlay = document.createElement('div')
      overlay.classList.add('cdk-overlay-container');
    }
    // Move stuff
    tool.append(overlay);
  }
  ngOnDestroy(): void {
    if (this.host) {
      this.host.detach();
    }
  }
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
openc3-6.2.1 templates/tool_angular/src/app/app.component.ts
openc3-6.2.0 templates/tool_angular/src/app/app.component.ts
openc3-6.1.0 templates/tool_angular/src/app/app.component.ts
openc3-6.0.2 templates/tool_angular/src/app/app.component.ts
openc3-6.0.1 templates/tool_angular/src/app/app.component.ts
openc3-6.0.0 templates/tool_angular/src/app/app.component.ts