Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow users to display html with inline styles #31 #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,9 @@ class AjaxCtrl extends MetricsPanelCtrl {
case RenderMode.html:
txt = '<div ng-bind-html="response"></div>';
break;
case RenderMode.trustedHtml:
txt = this.$scope.response;
break;
case RenderMode.text:
txt = '{{ response }}';
break;
Expand All @@ -449,7 +452,9 @@ class AjaxCtrl extends MetricsPanelCtrl {
//console.log('UPDATE template', this.panel, txt);

this.ngtemplate.html(txt);
this.$compile(this.ngtemplate.contents())(this.$scope);
if (this.panel.mode != RenderMode.trustedHtml) {
this.$compile(this.ngtemplate.contents())(this.$scope);
}
if (this.$scope.response) {
this.render();
}
Expand Down Expand Up @@ -551,7 +556,7 @@ class AjaxCtrl extends MetricsPanelCtrl {
}

// JSON Node needs to force refresh
if (this.panel.mode == RenderMode.json) {
if (this.panel.mode == RenderMode.json || this.panel.mode == RenderMode.trustedHtml) {
this.updateTemplate();
}
}
Expand Down
1 change: 1 addition & 0 deletions src/partials/editor.display.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h5 class="section-heading">Display</h5>
<option value="pre">Preformatted Text</option>
<option value="json">JSON Tree</option>
<option value="template">Angular Template</option>
<option value="trustedHtml">Trusted HTML</option>
</select>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ export class DSInfo {
// <option value="image">Image</option>
// <option value="json">JSON Tree</option>
// <option value="template">Angular Template</option>
// <option value="trustedHtml">Trusted HTML</option>
export enum RenderMode {
html = 'html',
text = 'text',
pre = 'pre',
image = 'image',
json = 'json',
template = 'template',
trustedHtml = 'trustedHtml'
}