All files / src/store FlowStoreElement.ts

66.66% Statements 28/42
100% Branches 0/0
0% Functions 0/4
66.66% Lines 28/42

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 4392x   92x 92x 92x 92x 92x 92x       92x 92x 92x 92x 92x 92x 92x               92x       92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x 92x  
import { html, PropertyValueMap, TemplateResult } from 'lit';
import { property } from 'lit/decorators.js';
import { FlowDetails } from '../interfaces';
import { EndpointMonitorElement } from './EndpointMonitorElement';
 
export class FlowStoreElement extends EndpointMonitorElement {
  @property({ type: String })
  flow: string;

  @property({ type: Object, attribute: false })
  data: FlowDetails;
 
  @property({ type: String })
  endpoint = '/api/v2/flows.json?uuid=';
 
  prepareData(data: any) {
    if (data && data.length > 0) {
      data = data[0];
    }
    return data;
  }

  protected updated(
    changes: PropertyValueMap<any> | Map<PropertyKey, unknown>
  ): void {
    super.updated(changes);
    if (changes.has('flow')) {
      if (this.flow) {
        this.url = `${this.endpoint}${this.flow}`;
      } else {
        this.url = null;
      }
    }
  }
 
  public render(): TemplateResult {
    if (!this.data) {
      return;
    }
    return html`<div></div>`;
  }
}