src/app/home/home.component.ts

Implements

AfterContentInit

Metadata

Relationships

Used by

Depends on

Index

Properties
Methods

Constructor

constructor(route: Router, router: ActivatedRoute, licenceService: LicenceService, helperService: HelperService, eventService: EventService, sasService: SasService)
Parameters :
Name Type Optional
route Router No
router ActivatedRoute No
licenceService LicenceService No
helperService HelperService No
eventService EventService No
sasService SasService No

Methods

Private clearGlobalsFilter
clearGlobalsFilter()
Returns : void
Public collapseLibraryItems
collapseLibraryItems(libraries: any, libraryToSkip: any)
Parameters :
Name Type Optional
libraries any No
libraryToSkip any No
Returns : void
Public editTable
editTable()
Returns : void
Public getFromGlobals
getFromGlobals()
Returns : void
Private getLibraryTableState
getLibraryTableState()
Returns : void
Public libraryOnClick
libraryOnClick(lib: string, library: any)
Parameters :
Name Type Optional
lib string No
library any No
Returns : void
Public libraryOnFilter
libraryOnFilter()
Returns : void
Public libTabActive
libTabActive(library: string, table: string)
Parameters :
Name Type Optional
library string No
table string No
Returns : boolean
ngAfterContentInit
ngAfterContentInit()
Returns : void
Public onTableClick
onTableClick(libTable: any, library: any)
Parameters :
Name Type Optional
libTable any No
library any No
Returns : void
Public selectLibrary
selectLibrary(libs: any, initial?: boolean, library?: any)
Parameters :
Name Type Optional
libs any No
initial boolean Yes
library any Yes
Returns : void
Public Async selectTable
selectTable(ev: string, initial?: boolean)
Parameters :
Name Type Optional
ev string No
initial boolean Yes
Returns : any
Public treeNodeClicked
treeNodeClicked(event: any, library: any)
Parameters :
Name Type Optional
event any No
library any No
Returns : void
Public treeOnFilter
treeOnFilter(array: any, arrToFilter: string)
Parameters :
Name Type Optional
array any No
arrToFilter string No
Returns : void

Properties

Public encoding
Type : any
Default value : 'UTF-8'
Public lib
Type : any
Default value : ''
Public libds
Type : string | undefined
Public libraries
Type : Array<String> | undefined
Public librariesSearch
Type : string
Default value : ''
Public libsAndTables
Type : Array<any> | undefined
Public libTab
Type : string | undefined
Public licenceState
Type : unknown
Default value : this.licenceService.licenceState
Public loading
Type : boolean
Default value : true
Public table
Type : any
Default value : ''
Public tables
Type : Array<String> | undefined
Public treeNodeLibraries
Type : Array<any> | null
Default value : null
import { Component, AfterContentInit, ViewEncapsulation } from '@angular/core'
import { Router } from '@angular/router'
import { ActivatedRoute } from '@angular/router'
import { globals } from '../_globals'
import { HelperService } from '../services/helper.service'
import { EventService } from '../services/event.service'
import { SasService } from '../services/sas.service'
import { LicenceService } from '../services/licence.service'

@Component({
  selector: 'home-component',
  styleUrls: ['./home.component.scss'],
  templateUrl: './home.component.html',
  host: {
    class: 'content-container'
  },
  encapsulation: ViewEncapsulation.None,
  standalone: false
})
export class HomeComponent implements AfterContentInit {
  public treeNodeLibraries: Array<any> | null = null
  public librariesSearch: string = ''
  public libraries: Array<String> | undefined
  public libsAndTables: Array<any> | undefined
  public tables: Array<String> | undefined
  public lib: any = ''
  public table: any = ''
  public libds: string | undefined
  public libTab: string | undefined

  public encoding: any = 'UTF-8'
  public loading: boolean = true

  public licenceState = this.licenceService.licenceState

  constructor(
    private route: Router,
    private router: ActivatedRoute,
    private licenceService: LicenceService,
    private helperService: HelperService,
    private eventService: EventService,
    private sasService: SasService
  ) {}

  public collapseLibraryItems(libraries: any, libraryToSkip: any) {
    libraries.forEach((library: any) => {
      if (library.LIBRARYID !== libraryToSkip.LIBRARYID) {
        library['expanded'] = false
      }
    })
  }

  public treeNodeClicked(event: any, library: any) {
    if (event.target.title === 'Collapse') {
      this.collapseLibraryItems(this.libraries, library)
    }
  }

  public libraryOnClick(lib: string, library: any) {
    library['expanded'] = !library['expanded']

    if (library['expanded'] && !this.table) {
      this.selectLibrary(lib, false, library)
    }

    this.collapseLibraryItems(this.libraries, library)
  }

  public selectLibrary(libs: any, initial?: boolean, library?: any) {
    library['loadingTables'] = true

    let newarray: Array<any>
    let dups: Array<any> = []
    if (this.libsAndTables) {
      newarray = this.libsAndTables[libs]
      this.table = undefined
      if (libs !== 'Please select library') {
        let arr = newarray.filter(function (el) {
          if (dups.indexOf(el) === -1) {
            dups.push(el)
            return true
          }
          return false
        })

        this.tables = arr
        globals.editor.libraries = this.libraries
      }
    }
    globals.editor.library = libs
    if (!initial) {
      this.clearGlobalsFilter()
    }

    library['loadingTables'] = false
    library['expanded'] = true
  }

  public async selectTable(ev: string, initial?: boolean) {
    let libTab = this.lib + '.' + this.table
    this.libTab = libTab
    let sasjsConfig = this.sasService.getSasjsConfig()
    let storage = sasjsConfig.serverUrl
    let metaData = sasjsConfig.appLoc
    let path =
      sasjsConfig.serverType === 'SAS9'
        ? sasjsConfig.pathSAS9
        : sasjsConfig.pathSASViya

    globals.editor.table = ev
    if (!initial) {
      this.clearGlobalsFilter()
    }
  }

  private clearGlobalsFilter() {
    globals.editor.filter.libds = ''
    globals.editor.filter.whereClause = ''
    globals.editor.filter.groupLogic = ''
    globals.editor.filter.clauses = []
    globals.editor.filter.vals = []
    globals.editor.filter.cols = []
  }

  public libTabActive(library: string, table: string) {
    if (!this.lib || !this.table) {
      return false
    }

    return library === this.lib && table === this.table
  }

  public treeOnFilter(array: any, arrToFilter: string) {
    this.helperService.treeOnFilter(array, arrToFilter)
  }

  public libraryOnFilter() {
    this.helperService.libraryOnFilter(
      this.treeNodeLibraries,
      this.librariesSearch,
      'LIBRARYREF'
    )

    globals.lineage.librariesSearch = this.librariesSearch
  }

  public onTableClick(libTable: any, library: any) {
    this.table = libTable
    this.lib = library.LIBRARYREF
    this.selectTable(libTable)
    this.editTable()
  }

  public editTable() {
    let libMem: string = this.lib + '.' + this.table
    this.route.navigateByUrl('/editor/' + libMem)
  }

  private getLibraryTableState() {
    if (globals.editor.treeNodeLibraries !== null) {
      this.treeNodeLibraries = globals.editor.treeNodeLibraries
    }

    if (globals.editor.library !== '') {
      this.lib = globals.editor.library

      let treeNodeLibrary = null
      if (this.treeNodeLibraries) {
        treeNodeLibrary = this.treeNodeLibraries.find(
          (lib: any) => lib.LIBRARYREF === this.lib
        )
      }

      this.selectLibrary(globals.editor.library, true, treeNodeLibrary)
    }
  }

  public getFromGlobals() {
    this.libsAndTables = globals.editor.libsAndTables
    this.libraries = globals.editor.libraries

    this.getLibraryTableState()

    this.loading = false
  }

  ngAfterContentInit(): void {
    if (globals.editor.startupSet) {
      this.getFromGlobals()
    } else {
      this.eventService.onStartupDataLoaded.subscribe(() => {
        this.getFromGlobals()
      })
    }
  }
}
<app-sidebar>
  <clr-tree>
    @if (treeNodeLibraries?.length! > 0) {
      <clr-tree-node class="search-node">
        <div class="tree-search-wrapper">
          <input
            clrInput
            appStealFocus
            #searchLibTreeInput
            placeholder="Libraries"
            name="input"
            [(ngModel)]="librariesSearch"
            (keyup)="libraryOnFilter()"
            autocomplete="off"
          />
          @if (searchLibTreeInput.value.length < 1) {
            <clr-icon shape="search" aria-hidden="true"></clr-icon>
          }
          @if (searchLibTreeInput.value.length > 0) {
            <clr-icon
              (click)="librariesSearch = ''; libraryOnFilter()"
              shape="times"
              aria-label="Clear libraries search"
            ></clr-icon>
          }
        </div>
      </clr-tree-node>
    }

    @for (library of treeNodeLibraries; track library) {
      @if (!library['hidden']) {
        <clr-tree-node
          (click)="treeNodeClicked($event, library); lib = library.LIBRARYREF"
          [(clrExpanded)]="library['expanded']"
          [clrLoading]="library['loadingTables'] && !library.tables"
          [class.clr-expanded]="library['expanded']"
        >
          <p
            (click)="
              lib = library.LIBRARYREF;
              libraryOnClick(library.LIBRARYREF, library)
            "
            class="m-0 cursor-pointer"
          >
            <clr-icon shape="rack-server" aria-hidden="true"></clr-icon>
            {{ library.LIBRARYREF }}
          </p>
          @if (library['tables']) {
            <clr-tree-node class="search-node">
              <div class="tree-search-wrapper">
                <input
                  appStealFocus
                  clrInput
                  #searchTreeInput
                  placeholder="Tables"
                  name="input"
                  [(ngModel)]="library['searchString']"
                  (keyup)="treeOnFilter(library, 'tables')"
                  autocomplete="off"
                />
                @if (searchTreeInput.value.length < 1) {
                  <clr-icon shape="search" aria-hidden="true"></clr-icon>
                }
                @if (searchTreeInput.value.length > 0) {
                  <clr-icon
                    (click)="
                      searchTreeInput.value = '';
                      library['searchString'] = '';
                      treeOnFilter(library, 'tables')
                    "
                    shape="times"
                    aria-label="Clear tables search"
                  ></clr-icon>
                }
              </div>
            </clr-tree-node>
          }
          @for (
            libTable of library['tables'];
            track libTable;
            let index = $index
          ) {
            <clr-tree-node>
              <clr-tooltip
                *ngVar="
                  index + 1 >
                  licenceState.value.tables_in_library_limit as tableLocked
                "
              >
                <button
                  clrTooltipTrigger
                  (click)="!tableLocked ? onTableClick(libTable, library) : ''"
                  class="clr-treenode-link"
                  [class.dc-locked-control]="tableLocked"
                  [class.active]="libTabActive(library.LIBRARYREF, libTable)"
                >
                  @switch (libTable.includes('-FC')) {
                    @case (true) {
                      <clr-icon shape="bolt" aria-hidden="true"></clr-icon>
                    }
                    @case (false) {
                      <clr-icon shape="table" aria-hidden="true"></clr-icon>
                    }
                  }
                  {{ libTable.replace('-FC', '') }}
                </button>
                @if (tableLocked) {
                  <clr-tooltip-content
                    clrPosition="bottom-right"
                    clrSize="lg"
                    *clrIfOpen
                  >
                    <span>
                      To unlock all tables, contact
                      support&#64;datacontroller.io
                    </span>
                  </clr-tooltip-content>
                }
              </clr-tooltip>
            </clr-tree-node>
          }
        </clr-tree-node>
      }
    }
  </clr-tree>
</app-sidebar>

<main class="content-area">
  <div class="card-block">
    @if (loading) {
      <div class="spinner-wrapper-fullpage">
        <div class="loadingSpinner">
          <span class="spinner"> Loading... </span>
        </div>
      </div>
    }

    @if (!loading) {
      <div class="no-table-selected">
        <img
          src="images/select-table.png"
          class="select-table-icon"
          alt="select table icon"
        />
        @if (treeNodeLibraries?.length! > 0) {
          <p class="text-center color-gray mt-10" cds-text="section">
            Please select a table
          </p>
        }
        @if (treeNodeLibraries?.length! < 1) {
          <p class="text-center color-gray mt-10" cds-text="section">
            No Editable Tables Configured
          </p>
        }
      </div>
    }
  </div>
</main>

./home.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""