diff --git a/src/app/app.module.ts b/src/app/app.module.ts index f891077f..e7a9b69f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -107,6 +107,10 @@ import { ScenarioWizardComponent } from './scenario/scenario-wizard/scenario-wiz import { ScenarioDetailComponent } from './scenario/scenario-detail/scenario-detail.component'; import { StepsScenarioComponent } from './scenario/steps-scenario/steps-scenario.component'; import { DashboardDetailsComponent } from './dashboards/dashboard-details/dashboard-details.component'; +import { TaskComponent } from './scenario/task/task.component'; +import { TaskFormComponent } from './scenario/task-form/task-form.component'; +import { SingleTaskVerificationMarkdownComponent } from './step/single-task-verification-markdown/single-task-verification-markdown.component'; + import '@cds/core/icon/register.js'; import { ClarityIcons, @@ -146,8 +150,10 @@ import { timesIcon, buildingIcon, numberListIcon, + syncIcon, downloadIcon, } from '@cds/core/icon'; +import { ReadonlyTaskComponent } from './scenario/task/readonly-task/readonly-task.component'; ClarityIcons.addIcons( plusIcon, @@ -186,6 +192,7 @@ ClarityIcons.addIcons( timesIcon, buildingIcon, numberListIcon, + syncIcon, downloadIcon ); @@ -281,6 +288,10 @@ export function jwtOptionsFactory(): JwtConfig { ScenarioDetailComponent, StepsScenarioComponent, DashboardDetailsComponent, + TaskComponent, + TaskFormComponent, + ReadonlyTaskComponent, + SingleTaskVerificationMarkdownComponent, ], imports: [ BrowserModule, @@ -306,7 +317,10 @@ export function jwtOptionsFactory(): JwtConfig { sanitize: false, convertHTMLEntities: false, }, - globalParsers: [{ component: CtrComponent }], + globalParsers: [ + { component: CtrComponent }, + { component: SingleTaskVerificationMarkdownComponent }, + ], }), BrowserAnimationsModule, DragulaModule.forRoot(), diff --git a/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.html b/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.html index 7281db8f..bd457f7e 100644 --- a/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.html +++ b/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.html @@ -1,5 +1,5 @@
- - +
\ No newline at end of file diff --git a/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.scss b/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.scss index a70bbb84..49b17685 100644 --- a/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.scss +++ b/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.scss @@ -19,14 +19,14 @@ top: 0px; left: 0px; width: 100%; - height: 100%; + height: auto; padding: 10px; margin: 0; font-size: inherit; font-family: inherit; line-height: inherit; border: none; - overflow: hidden + overflow: hidden; } .code-editor textarea:focus { diff --git a/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.ts b/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.ts index 56f05d5c..0f7fccf9 100644 --- a/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.ts +++ b/src/app/configuration/code-with-syntax-highlighting/code-with-syntax-highlighting.component.ts @@ -1,24 +1,73 @@ -import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnDestroy, Output, SimpleChanges, ViewChild } from '@angular/core'; -import 'prismjs' -import 'prismjs/components/prism-yaml' +import { + AfterViewInit, + Component, + ElementRef, + EventEmitter, + Input, + OnDestroy, + Output, + SimpleChanges, + ViewChild, +} from '@angular/core'; +import 'prismjs'; +import 'prismjs/components/prism-yaml'; +import 'prismjs/components/prism-bash'; +import 'prismjs/components/prism-regex'; declare var Prism: any; +export enum supportedLanguages { //To allow for more Languages the prism Components have to be imported also. For a list of all Supported Languages see: https://prismjs.com/#supported-languages + YAML = 'language-yaml', + BASH = 'language-bash', + REGEX = 'language-regex', +} + @Component({ selector: 'app-code-with-syntax-highlighting', templateUrl: './code-with-syntax-highlighting.component.html', - styleUrls: ['./code-with-syntax-highlighting.component.scss'] + styleUrls: ['./code-with-syntax-highlighting.component.scss'], }) -export class CodeWithSyntaxHighlightingComponent implements AfterViewInit, OnDestroy { +export class CodeWithSyntaxHighlightingComponent + implements AfterViewInit, OnDestroy +{ + @Input('textValue') set textValue(value: string) { + this._textValue = value; + this.count++ + if (!this.resizeable) { + this.previousScrollHeight = 0; + this.setStyleValues(); + } + } + + count: number = 0 + + _textValue: string = ''; + + @Input() + height: string = '500px'; @Input() - textValue: string; + width: string = '100%'; + + @Input() + resizeable: boolean = false; + + @Input() + readonly: boolean = false; + + @Input() + outline: string = 'solid 1px'; + + @Input() + language: supportedLanguages = supportedLanguages.YAML; + + private lang: string = 'yaml'; @Output() - textChanged: EventEmitter = new EventEmitter() + textChanged: EventEmitter = new EventEmitter(); @ViewChild('codeEditor') - codeEditor: ElementRef + codeEditor: ElementRef; @ViewChild('code') codeBlock: ElementRef; @@ -28,43 +77,83 @@ export class CodeWithSyntaxHighlightingComponent implements AfterViewInit, OnDes public highlightedText: string; - private observer = new MutationObserver(() => this.resize()) + private observer = new MutationObserver(() => { + this.resize(); + }); + private previousScrollHeight = 0; + + private initialized: boolean = false; // Prevent Errors when Parent sets the text before initialization, i.e. in a clarity accordeon element. ngAfterViewInit() { - this.setHighlightedText(this.textValue) - this.observer.observe(this.textarea.nativeElement, {attributes: true}) + this.initialized = true + this.setStyleValues(); + this.lang = this.language.split('-')[1]; + this.setHighlightedText(this._textValue); + this.observer.observe(this.textarea.nativeElement, { attributes: true }); + } + + setStyleValues() { + if (!!this.initialized) { + this.codeEditor.nativeElement.style.outline = this.outline; + this.codeEditor.nativeElement.style.height = this.height; + this.codeEditor.nativeElement.style.width = this.width; + this.codeEditor.nativeElement.style.maxWidth = this.width; + this.codeBlock.nativeElement.style.height = this.height; + this.textarea.nativeElement.style.height = this.height; + this.textarea.nativeElement.style.resize = this.resizeable + ? 'vertical' + : 'none'; + } } setHighlightedText(textValue) { - this.highlightedText = Prism.highlight(textValue, Prism.languages.yaml, 'yaml') + this.highlightedText = Prism.highlight( + textValue, + Prism.languages[this.lang], + this.lang + ); } ngOnChanges(changes: SimpleChanges) { - this.textValue = changes.textValue.currentValue - this.setHighlightedText(changes.textValue.currentValue) - + if (!!changes.textValue) { + this._textValue = changes.textValue.currentValue; + this.setHighlightedText(changes.textValue.currentValue); + } } onValueChange(event) { - let newText: string = event.target.value - this.textChanged.emit(newText) + this.count++ + let newText: string = event.target.value; + this.textChanged.emit(newText); + } + + manualResizeEvent(event) { + if (this.previousScrollHeight > event.height) { + this.previousScrollHeight = event.height; + } + this.resizeEvent(event); } resizeEvent(event) { - this.codeEditor.nativeElement.style.height = event.height + 'px' - this.codeBlock.nativeElement.style.height = event.height + 'px' + let newHeight = event.height + 'px'; + this.codeEditor.nativeElement.style.height = newHeight; + this.codeBlock.nativeElement.style.height = newHeight; + this.textarea.nativeElement.style.height = newHeight; } resize() { - const scrollHeight = this.textarea.nativeElement.scrollHeight - if (scrollHeight > 0) { - this.resizeEvent({height: scrollHeight}) + const scrollHeight = this.textarea.nativeElement.scrollHeight; + if (scrollHeight > 0 && scrollHeight > this.previousScrollHeight) { + this.previousScrollHeight = scrollHeight; + if (!this.resizeable) { + this.textarea.nativeElement.style.height = 0; + } + this.resizeEvent({ height: scrollHeight, isResize: true }); } } ngOnDestroy() { - this.observer.disconnect() + this._textValue = null; + this.observer.disconnect(); } -} - - +} \ No newline at end of file diff --git a/src/app/configuration/vmtemplates/edit-vmtemplate/vmtemplate-service-form/vmtemplate-service-form.component.html b/src/app/configuration/vmtemplates/edit-vmtemplate/vmtemplate-service-form/vmtemplate-service-form.component.html index 48291561..cde79a9a 100644 --- a/src/app/configuration/vmtemplates/edit-vmtemplate/vmtemplate-service-form/vmtemplate-service-form.component.html +++ b/src/app/configuration/vmtemplates/edit-vmtemplate/vmtemplate-service-form/vmtemplate-service-form.component.html @@ -249,6 +249,7 @@