src/app/home/home.component.ts
| encapsulation | ViewEncapsulation.None |
| host | { |
| selector | home-component |
| styleUrls | ./home.component.scss |
| templateUrl | ./home.component.html |
Properties |
|
Methods |
|
constructor(route: Router, router: ActivatedRoute, licenceService: LicenceService, helperService: HelperService, eventService: EventService, sasService: SasService)
|
|||||||||||||||||||||
|
Defined in src/app/home/home.component.ts:39
|
|||||||||||||||||||||
|
Parameters :
|
| Private clearGlobalsFilter |
clearGlobalsFilter()
|
|
Defined in src/app/home/home.component.ts:121
|
|
Returns :
void
|
| Public collapseLibraryItems |
collapseLibraryItems(libraries: any, libraryToSkip: any)
|
|
Defined in src/app/home/home.component.ts:50
|
|
Returns :
void
|
| Public editTable |
editTable()
|
|
Defined in src/app/home/home.component.ts:159
|
|
Returns :
void
|
| Public getFromGlobals |
getFromGlobals()
|
|
Defined in src/app/home/home.component.ts:183
|
|
Returns :
void
|
| Private getLibraryTableState |
getLibraryTableState()
|
|
Defined in src/app/home/home.component.ts:164
|
|
Returns :
void
|
| Public libraryOnClick |
libraryOnClick(lib: string, library: any)
|
|
Defined in src/app/home/home.component.ts:64
|
|
Returns :
void
|
| Public libraryOnFilter |
libraryOnFilter()
|
|
Defined in src/app/home/home.component.ts:142
|
|
Returns :
void
|
| Public libTabActive |
libTabActive(library: string, table: string)
|
|
Defined in src/app/home/home.component.ts:130
|
|
Returns :
boolean
|
| ngAfterContentInit |
ngAfterContentInit()
|
|
Defined in src/app/home/home.component.ts:192
|
|
Returns :
void
|
| Public onTableClick |
onTableClick(libTable: any, library: any)
|
|
Defined in src/app/home/home.component.ts:152
|
|
Returns :
void
|
| Public selectLibrary |
selectLibrary(libs: any, initial?: boolean, library?: any)
|
|
Defined in src/app/home/home.component.ts:74
|
|
Returns :
void
|
| Public Async selectTable |
selectTable(ev: string, initial?: boolean)
|
|
Defined in src/app/home/home.component.ts:104
|
|
Returns :
any
|
| Public treeNodeClicked |
treeNodeClicked(event: any, library: any)
|
|
Defined in src/app/home/home.component.ts:58
|
|
Returns :
void
|
| Public treeOnFilter |
treeOnFilter(array: any, arrToFilter: string)
|
|
Defined in src/app/home/home.component.ts:138
|
|
Returns :
void
|
| Public encoding |
Type : any
|
Default value : 'UTF-8'
|
|
Defined in src/app/home/home.component.ts:36
|
| Public lib |
Type : any
|
Default value : ''
|
|
Defined in src/app/home/home.component.ts:31
|
| Public libds |
Type : string | undefined
|
|
Defined in src/app/home/home.component.ts:33
|
| Public libraries |
Type : Array<String> | undefined
|
|
Defined in src/app/home/home.component.ts:28
|
| Public librariesSearch |
Type : string
|
Default value : ''
|
|
Defined in src/app/home/home.component.ts:27
|
| Public libsAndTables |
Type : Array<any> | undefined
|
|
Defined in src/app/home/home.component.ts:29
|
| Public libTab |
Type : string | undefined
|
|
Defined in src/app/home/home.component.ts:34
|
| Public licenceState |
Type : unknown
|
Default value : this.licenceService.licenceState
|
|
Defined in src/app/home/home.component.ts:39
|
| Public loading |
Type : boolean
|
Default value : true
|
|
Defined in src/app/home/home.component.ts:37
|
| Public table |
Type : any
|
Default value : ''
|
|
Defined in src/app/home/home.component.ts:32
|
| Public tables |
Type : Array<String> | undefined
|
|
Defined in src/app/home/home.component.ts:30
|
| Public treeNodeLibraries |
Type : Array<any> | null
|
Default value : null
|
|
Defined in src/app/home/home.component.ts:26
|
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@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