-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated ui to show sample block code
- Loading branch information
Showing
7 changed files
with
111 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { | ||
AfterViewInit, | ||
Component, | ||
ElementRef, | ||
Input, | ||
OnInit, | ||
Output, | ||
ViewChild, | ||
ViewEncapsulation, | ||
} from "@angular/core"; | ||
import { ModalLabels } from "@c8y/ngx-components"; | ||
import { Subject } from "rxjs"; | ||
|
||
@Component({ | ||
selector: "name-extension-modal", | ||
styleUrls: ["./editor-stepper.component.css"], | ||
template: `<c8y-modal | ||
title="Show source code {{ monitor }}" | ||
(onClose)="onSave($event)" | ||
[labels]="labels" | ||
[headerClasses]="'modal-header dialog-header'" | ||
> | ||
<pre id="sourceEditor" #sourceEditor> | ||
{{ source }} | ||
</pre> | ||
</c8y-modal>`, | ||
encapsulation: ViewEncapsulation.None, | ||
|
||
}) | ||
export class EditorModalComponent implements OnInit, AfterViewInit { | ||
@Input() source: string; | ||
@Input() monitor: string; | ||
@Output() closeSubject: Subject<any> = new Subject(); | ||
labels: ModalLabels = { ok: "Close" }; | ||
@ViewChild("sourceEditor", { static: false }) | ||
sourceEditor: ElementRef; | ||
|
||
ngOnInit(): void {} | ||
|
||
onSave(event) { | ||
console.log("Save"); | ||
this.closeSubject.next(true); | ||
} | ||
|
||
ngAfterViewInit(): void { | ||
this.addLineClass(); | ||
} | ||
|
||
public addLineClass() { | ||
const ne = this.sourceEditor.nativeElement; | ||
const lines = ne.innerText.split("\n"); // can use innerHTML also | ||
while (ne.childNodes.length > 0) { | ||
this.sourceEditor.nativeElement.removeChild(ne.childNodes[0]); | ||
} | ||
for (var i = 0; i < lines.length; i++) { | ||
var span = document.createElement("span"); | ||
span.className = "line"; | ||
span.innerText = lines[i]; // can use innerHTML also | ||
ne.appendChild(span); | ||
ne.appendChild(document.createTextNode("\n")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters