Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 1 | import {Component, Directive, ElementRef, EventEmitter, Input, Output, OnInit, ChangeDetectorRef} from '@angular/core'; |
| 2 | import {Router} from '@angular/router'; |
Radek Krejci | a133960 | 2017-11-02 13:52:38 +0100 | [diff] [blame] | 3 | |
| 4 | import {Session} from './session'; |
Radek Krejci | ad45e57 | 2018-02-21 10:54:54 +0100 | [diff] [blame] | 5 | import {Schema} from '../inventory/schema'; |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 6 | import {ModificationsService} from './modifications.service'; |
Radek Krejci | a133960 | 2017-11-02 13:52:38 +0100 | [diff] [blame] | 7 | import {SessionsService} from './sessions.service'; |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 8 | import {TreeService} from './tree.service'; |
Radek Krejci | ad45e57 | 2018-02-21 10:54:54 +0100 | [diff] [blame] | 9 | import {SchemasService} from '../yang/schemas.service'; |
Radek Krejci | a133960 | 2017-11-02 13:52:38 +0100 | [diff] [blame] | 10 | |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 11 | @Directive({ |
| 12 | selector: '[treeScrollTo]' |
| 13 | }) |
| 14 | export class TreeScrollTo { |
| 15 | @Input() node; |
| 16 | |
| 17 | constructor(private elRef:ElementRef) {} |
| 18 | ngAfterContentInit() { |
| 19 | if (!('new' in this.node)) { |
Radek Krejci | 7708844 | 2018-01-26 11:32:12 +0100 | [diff] [blame] | 20 | let middle = this.elRef.nativeElement.getBoundingClientRect().top + window.pageYOffset - (window.innerHeight / 2); |
| 21 | window.scrollTo(0, middle); |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 22 | } |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | @Directive({ |
| 27 | selector: '[checkLeafValue]' |
| 28 | }) |
| 29 | export class CheckLeafValue { |
| 30 | @Input() node; |
Radek Krejci | d0ce4cf | 2018-02-09 14:44:34 +0100 | [diff] [blame] | 31 | @Input() trusted = false; |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 32 | @Output() onCheckValue = new EventEmitter(); |
| 33 | |
| 34 | constructor(private elRef:ElementRef) {} |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 35 | |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 36 | ngAfterContentInit() { |
| 37 | console.log(this.node) |
| 38 | let node = this.node; |
Radek Krejci | d0ce4cf | 2018-02-09 14:44:34 +0100 | [diff] [blame] | 39 | let trusted = this.trusted; |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 40 | let element = this.elRef.nativeElement; |
| 41 | element.value = node['value']; |
Radek Krejci | d0ce4cf | 2018-02-09 14:44:34 +0100 | [diff] [blame] | 42 | this.onCheckValue.emit({node, element, trusted}); |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 43 | } |
| 44 | } |
| 45 | |
| 46 | @Component({ |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 47 | selector: 'tree-create', |
| 48 | templateUrl: 'tree-create.html', |
| 49 | styleUrls: ['./tree.component.scss'] |
| 50 | }) |
| 51 | export class TreeCreate implements OnInit { |
| 52 | @Input() node; |
| 53 | @Input() indentation; |
| 54 | activeSession: Session; |
| 55 | |
| 56 | constructor(private modsService: ModificationsService, private sessionsService: SessionsService) {} |
| 57 | |
| 58 | ngOnInit(): void { |
| 59 | this.activeSession = this.sessionsService.getActiveSession(); |
| 60 | } |
| 61 | |
| 62 | closeCreatingDialog(node, reason='abort') { |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 63 | this.modsService.createClose(this.activeSession, node, reason); |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | creatingDialogSelect(node, index, source) { |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 67 | console.log(node) |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 68 | this.modsService.create(this.activeSession, node, index); |
| 69 | this.sessionsService.storeData(); |
Radek Krejci | 5a69fa3 | 2018-02-01 11:03:04 +0100 | [diff] [blame] | 70 | if (('schemaChildren' in node) && node['schemaChildren'].length) { |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 71 | source.selectedIndex = 0; |
| 72 | } |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | @Component({ |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 77 | selector: 'tree-indent', |
| 78 | templateUrl: 'tree-indent.html', |
| 79 | styleUrls: ['./tree.component.scss'] |
| 80 | }) |
| 81 | export class TreeIndent implements OnInit { |
| 82 | @Input() node; |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 83 | @Input() value; |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 84 | @Input() indentation; |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 85 | @Input() type; |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 86 | activeSession: Session; |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 87 | private timeout; |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 88 | |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 89 | constructor(private treeService: TreeService, |
| 90 | private modsService: ModificationsService, |
| 91 | private sessionsService: SessionsService) {} |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 92 | |
| 93 | ngOnInit(): void { |
| 94 | this.activeSession = this.sessionsService.getActiveSession(); |
| 95 | } |
| 96 | |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 97 | getType():string { |
| 98 | if (this.type) { |
| 99 | return this.type; |
| 100 | } else { |
| 101 | if (this.node && ('new' in this.node)) { |
| 102 | return "new"; |
| 103 | } else if (this.node && ('deleted' in this.node)) { |
| 104 | return "deleted"; |
| 105 | } else { |
| 106 | return "current"; |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 111 | showEditMenu(event) { |
Radek Krejci | cb89097 | 2018-01-26 10:12:45 +0100 | [diff] [blame] | 112 | this.timeout = setTimeout(() => { |
| 113 | let menu = event.target.lastElementChild; |
| 114 | menu.style.visibility = "visible"; |
Radek Krejci | 6cdd21a | 2018-01-26 13:13:14 +0100 | [diff] [blame] | 115 | menu.style.top = event.target.getBoundingClientRect().top + 'px'; |
| 116 | menu.style.left = event.target.getBoundingClientRect().left + (event.target.getBoundingClientRect().width / 2) + 'px'; |
Radek Krejci | cb89097 | 2018-01-26 10:12:45 +0100 | [diff] [blame] | 117 | }, 300); |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 118 | } |
Radek Krejci | cb89097 | 2018-01-26 10:12:45 +0100 | [diff] [blame] | 119 | |
Radek Krejci | 08ad0a8 | 2018-01-26 11:25:17 +0100 | [diff] [blame] | 120 | hideEditMenu(menu) { |
Radek Krejci | cb89097 | 2018-01-26 10:12:45 +0100 | [diff] [blame] | 121 | clearTimeout(this.timeout); |
Radek Krejci | 08ad0a8 | 2018-01-26 11:25:17 +0100 | [diff] [blame] | 122 | menu.style.visibility = "hidden"; |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 123 | } |
Radek Krejci | cb89097 | 2018-01-26 10:12:45 +0100 | [diff] [blame] | 124 | |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 125 | deleteSubtree(node) { |
| 126 | let rmlist = []; |
| 127 | if (node['info']['type'] == 8) { |
| 128 | rmlist = this.treeService.nodesToShow(this.activeSession, node); |
| 129 | } else { |
| 130 | rmlist.push(node); |
| 131 | } |
| 132 | for (let item of rmlist) { |
| 133 | this.modsService.delete(this.activeSession, item); |
| 134 | } |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 135 | this.sessionsService.storeData(); |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 136 | } |
Radek Krejci | 499d1ee | 2018-01-30 14:04:54 +0100 | [diff] [blame] | 137 | |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 138 | deleteInstance(node) { |
| 139 | this.modsService.delete(this.activeSession, node); |
| 140 | this.sessionsService.storeData(); |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 141 | } |
| 142 | |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 143 | openCreatingDialog(element, node, parent = false) { |
| 144 | if (parent) { |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 145 | node = this.treeService.nodeParent(this.activeSession, node); |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 146 | } |
| 147 | if (!('creatingChild' in node)) { |
| 148 | this.sessionsService.childrenSchemas(this.activeSession.key, node['info']['path'], node).then(result => { |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 149 | this.modsService.createOpen(this.activeSession, result, node); |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 150 | }); |
| 151 | } else if (element){ |
| 152 | /* scroll to the existing element */ |
| 153 | element.ownerDocument.getElementById(node['path'] + '_createChildDialog').scrollIntoView(false); |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | closeCreatingDialog(node, reason='abort') { |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 158 | this.modsService.createClose(this.activeSession, node, reason); |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 159 | } |
| 160 | |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 161 | cancelModification(node, value = null) { |
| 162 | if (value && node['deleted'].length > 1) { |
| 163 | let i = node['deleted'].indexOf(value); |
| 164 | node['deleted'].splice(i, 1); |
| 165 | } else { |
| 166 | this.modsService.cancelModification(this.activeSession, node, false); |
| 167 | } |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 168 | this.sessionsService.storeData(); |
Radek Krejci | 499d1ee | 2018-01-30 14:04:54 +0100 | [diff] [blame] | 169 | } |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 170 | } |
| 171 | |
Radek Krejci | a133960 | 2017-11-02 13:52:38 +0100 | [diff] [blame] | 172 | @Component({ |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 173 | selector: 'tree-node', |
| 174 | templateUrl: './tree-node.html', |
Radek Krejci | cd1ebe1 | 2018-01-11 11:34:17 +0100 | [diff] [blame] | 175 | styleUrls: ['./tree.component.scss'] |
Radek Krejci | a133960 | 2017-11-02 13:52:38 +0100 | [diff] [blame] | 176 | }) |
| 177 | |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 178 | export class TreeNode { |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 179 | @Input() node; |
Radek Krejci | a133960 | 2017-11-02 13:52:38 +0100 | [diff] [blame] | 180 | @Input() indentation; |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 181 | @Input() activeSession: Session; |
Radek Krejci | 5a69fa3 | 2018-02-01 11:03:04 +0100 | [diff] [blame] | 182 | |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 183 | constructor(private modsService: ModificationsService, |
| 184 | private sessionsService: SessionsService, |
Radek Krejci | 5a69fa3 | 2018-02-01 11:03:04 +0100 | [diff] [blame] | 185 | private treeService: TreeService, |
Radek Krejci | ad45e57 | 2018-02-21 10:54:54 +0100 | [diff] [blame] | 186 | private schemasService: SchemasService, |
| 187 | private changeDetector: ChangeDetectorRef, |
| 188 | private router: Router) {} |
Radek Krejci | a133960 | 2017-11-02 13:52:38 +0100 | [diff] [blame] | 189 | |
Radek Krejci | 77f7720 | 2017-11-03 15:33:50 +0100 | [diff] [blame] | 190 | inheritIndentation(node) { |
| 191 | let newIndent; |
| 192 | if (node['last']) { |
| 193 | newIndent = [true]; |
| 194 | } else { |
| 195 | newIndent = [false]; |
Radek Krejci | a133960 | 2017-11-02 13:52:38 +0100 | [diff] [blame] | 196 | } |
Radek Krejci | 77f7720 | 2017-11-03 15:33:50 +0100 | [diff] [blame] | 197 | |
| 198 | if (!this.indentation) { |
| 199 | return newIndent; |
| 200 | } else { |
| 201 | return this.indentation.concat(newIndent); |
| 202 | } |
Radek Krejci | a133960 | 2017-11-02 13:52:38 +0100 | [diff] [blame] | 203 | } |
| 204 | |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 205 | startEditing(node, target) { |
Radek Krejci | 9b41f5b | 2018-01-31 14:17:50 +0100 | [diff] [blame] | 206 | if ((node['info']['key'] && !node['new']) || node['deleted']) { |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 207 | return; |
| 208 | } |
Radek Krejci | bf449e0 | 2018-02-23 11:39:00 +0100 | [diff] [blame] | 209 | |
| 210 | let container = target.parentElement.parentElement; |
Radek Krejci | 26bf2bc | 2018-01-09 15:00:54 +0100 | [diff] [blame] | 211 | |
Radek Krejci | d0ce4cf | 2018-02-09 14:44:34 +0100 | [diff] [blame] | 212 | this.modsService.setEdit(this.activeSession, node, true) |
Radek Krejci | 26bf2bc | 2018-01-09 15:00:54 +0100 | [diff] [blame] | 213 | this.changeDetector.detectChanges(); |
| 214 | |
Radek Krejci | bf449e0 | 2018-02-23 11:39:00 +0100 | [diff] [blame] | 215 | container.nextElementSibling.lastElementChild.focus(); |
Radek Krejci | 26bf2bc | 2018-01-09 15:00:54 +0100 | [diff] [blame] | 216 | } |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 217 | |
Radek Krejci | d0ce4cf | 2018-02-09 14:44:34 +0100 | [diff] [blame] | 218 | checkValue(node, target, trusted = false) { |
Radek Krejci | 4d3896c | 2018-01-08 17:10:43 +0100 | [diff] [blame] | 219 | let confirm = target.previousElementSibling; |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 220 | let cancel = confirm.previousElementSibling; |
Radek Krejci | d0ce4cf | 2018-02-09 14:44:34 +0100 | [diff] [blame] | 221 | |
| 222 | if (trusted) { |
| 223 | /* value is selected from valid options */ |
| 224 | target.classList.remove("invalid"); |
| 225 | confirm.style.visibility = "visible"; |
| 226 | if ('value' in node) { |
| 227 | cancel.style.visibility = "visible"; |
| 228 | } |
| 229 | return; |
| 230 | } |
| 231 | |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 232 | let path: string; |
| 233 | if ('creatingChild' in node) { |
| 234 | path = node['creatingChild']['path']; |
| 235 | } else { |
| 236 | path = node['info']['path']; |
| 237 | } |
| 238 | this.sessionsService.checkValue(this.activeSession.key, path, target.value).subscribe(result => { |
Radek Krejci | 4d3896c | 2018-01-08 17:10:43 +0100 | [diff] [blame] | 239 | if (result['success']) { |
| 240 | target.classList.remove("invalid"); |
| 241 | confirm.style.visibility = "visible"; |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 242 | if ('value' in node) { |
| 243 | cancel.style.visibility = "visible"; |
| 244 | } |
Radek Krejci | 4d3896c | 2018-01-08 17:10:43 +0100 | [diff] [blame] | 245 | } else { |
| 246 | target.classList.add("invalid"); |
| 247 | confirm.style.visibility = "hidden"; |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 248 | if (!('value' in node)) { |
| 249 | cancel.style.visibility = "hidden"; |
| 250 | } |
Radek Krejci | 4d3896c | 2018-01-08 17:10:43 +0100 | [diff] [blame] | 251 | } |
| 252 | }); |
| 253 | } |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 254 | |
| 255 | changeValueCancel(node) { |
| 256 | if ('value' in node) { |
Radek Krejci | d0ce4cf | 2018-02-09 14:44:34 +0100 | [diff] [blame] | 257 | this.modsService.setEdit(this.activeSession, node, false); |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 258 | } else { |
| 259 | this.modsService.cancelModification(this.activeSession, node, false); |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 260 | } |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 261 | this.sessionsService.storeData(); |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 262 | } |
| 263 | |
Radek Krejci | 26bf2bc | 2018-01-09 15:00:54 +0100 | [diff] [blame] | 264 | changeValue(node, target) { |
| 265 | let input; |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 266 | if (target.classList.contains('value_inline')) { |
Radek Krejci | 26bf2bc | 2018-01-09 15:00:54 +0100 | [diff] [blame] | 267 | if (target.classList.contains('invalid')) { |
| 268 | return; |
| 269 | } |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 270 | input = target; |
Radek Krejci | 26bf2bc | 2018-01-09 15:00:54 +0100 | [diff] [blame] | 271 | } else { |
| 272 | input = target.nextElementSibling; |
| 273 | } |
| 274 | |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 275 | if (node['info']['type'] == 8) { |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 276 | this.modsService.change(this.activeSession, node, input.value); |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 277 | } else { |
| 278 | this.modsService.change(this.activeSession, node, input.value); |
| 279 | } |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 280 | this.sessionsService.storeData(); |
| 281 | } |
| 282 | |
Radek Krejci | 7a244f0 | 2018-02-21 09:46:18 +0100 | [diff] [blame] | 283 | nodeValue(node, index:number = 0): string { |
| 284 | if ('value' in node) { |
| 285 | if (node['info']['type'] == 4) { |
| 286 | return node['value']; |
| 287 | } else if (node['info']['type'] == 8 && node['value'].length > index) { |
| 288 | return node['value'][index]; |
| 289 | } |
| 290 | } |
| 291 | return null; |
| 292 | } |
| 293 | |
Radek Krejci | ad45e57 | 2018-02-21 10:54:54 +0100 | [diff] [blame] | 294 | moduleName(node): string { |
| 295 | let at = node['info']['module'].indexOf('@'); |
| 296 | if (at == -1) { |
| 297 | return node['info']['module']; |
| 298 | } else { |
| 299 | return node['info']['module'].substring(0, at); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | showSchema(node) { |
| 304 | let schema = new Schema; |
| 305 | let at = node['info']['module'].indexOf('@'); |
| 306 | if (at == -1) { |
| 307 | schema.name = node['info']['module']; |
| 308 | } else { |
| 309 | schema.name = node['info']['module'].substring(0, at); |
| 310 | schema.revision = node['info']['module'].substring(at + 1); |
| 311 | } |
| 312 | let key = node['info']['module'] + '.yang'; |
| 313 | |
| 314 | schema.name = this.moduleName(node); |
| 315 | this.schemasService.show(key, schema); |
| 316 | this.schemasService.changeActiveSchemaKey(key); |
| 317 | this.router.navigateByUrl( '/netopeer/yang' ); |
| 318 | } |
| 319 | |
Radek Krejci | 6e772b2 | 2018-01-25 13:28:57 +0100 | [diff] [blame] | 320 | newChildrenToShow(node) { |
| 321 | if ('newChildren' in node) { |
| 322 | return node['newChildren']; |
| 323 | } else { |
| 324 | return []; |
| 325 | } |
| 326 | } |
Radek Krejci | a133960 | 2017-11-02 13:52:38 +0100 | [diff] [blame] | 327 | } |
Radek Krejci | 30ce159 | 2018-03-01 14:44:14 +0100 | [diff] [blame^] | 328 | |
| 329 | @Component({ |
| 330 | selector: 'tree-view', |
| 331 | templateUrl: './tree.component.html', |
| 332 | styleUrls: ['./tree.component.scss'] |
| 333 | }) |
| 334 | |
| 335 | export class TreeView implements OnInit { |
| 336 | @Input() node; |
| 337 | @Input() indentation; |
| 338 | activeSession: Session; |
| 339 | |
| 340 | constructor(private sessionsService: SessionsService, |
| 341 | private treeService: TreeService) {} |
| 342 | |
| 343 | ngOnInit(): void { |
| 344 | this.activeSession = this.sessionsService.getActiveSession(); |
| 345 | } |
| 346 | } |
| 347 | |