Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
91b48258
Commit
91b48258
authored
Jun 30, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring PR #511, Allow filter notation [[..]] in text panels
parent
2ac7b9da
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
70 deletions
+42
-70
CHANGELOG.md
+3
-0
src/app/panels/text/module.html
+1
-6
src/app/panels/text/module.js
+38
-64
No files found.
CHANGELOG.md
View file @
91b48258
vNext
**New features or improvements**
-
Allow
[
[..
]
] filter notation in all text panels (markdown/html/text) (Issue #511)
**Changes**
-
Use unix epoch for Graphite from/to for absolute time ranges (Closes #536)
...
...
src/app/panels/text/module.html
View file @
91b48258
<div
ng-controller=
'text'
ng-init=
"init()"
style=
"min-height:{{panel.height || row.height}}"
ng-dblclick=
"openEditor()"
>
<!--<p ng-style="panel.style" ng-bind-html-unsafe="panel.content | striphtml | newlines"></p>-->
<markdown
ng-show=
"ready && panel.mode == 'markdown'"
ng-bind-html-unsafe=
"panel.content | applymarkdown | applytemplate"
>
</markdown>
<p
ng-show=
"panel.mode == 'text'"
ng-style=
'panel.style'
ng-bind-html-unsafe=
"panel.content | striphtml | newlines | applytemplate"
>
</p>
<p
ng-show=
"panel.mode == 'html'"
ng-bind-html-unsafe=
"panel.content | applytemplate"
>
<p
ng-bind-html-unsafe=
"content"
>
</p>
</div>
src/app/panels/text/module.js
View file @
91b48258
...
...
@@ -23,7 +23,7 @@ function (angular, app, _, require) {
var
module
=
angular
.
module
(
'kibana.panels.text'
,
[]);
app
.
useModule
(
module
);
module
.
controller
(
'text'
,
function
(
$scope
)
{
module
.
controller
(
'text'
,
function
(
$scope
,
filterSrv
)
{
$scope
.
panelMeta
=
{
description
:
"A static text panel that can use plain text, markdown, or (sanitized) HTML"
...
...
@@ -40,84 +40,58 @@ function (angular, app, _, require) {
$scope
.
init
=
function
()
{
$scope
.
initBaseController
(
this
,
$scope
);
$scope
.
ready
=
false
;
$scope
.
$on
(
'refresh'
,
$scope
.
render
);
$scope
.
render
();
};
$scope
.
render
=
function
()
{
$scope
.
$emit
(
'render'
);
if
(
$scope
.
panel
.
mode
===
'markdown'
)
{
$scope
.
renderMarkdown
(
$scope
.
panel
.
content
);
}
else
if
(
$scope
.
panel
.
mode
===
'html'
)
{
$scope
.
updateContent
(
$scope
.
panel
.
content
);
}
else
if
(
$scope
.
panel
.
mode
===
'text'
)
{
$scope
.
renderText
(
$scope
.
panel
.
content
);
}
};
$scope
.
openEditor
=
function
()
{
//$scope.$emit('open-modal','paneleditor');
console
.
log
(
'scope id'
,
$scope
.
$id
);
};
$scope
.
renderText
=
function
(
content
)
{
content
=
content
.
replace
(
/&/g
,
'&'
)
.
replace
(
/>/g
,
'>'
)
.
replace
(
/</g
,
'<'
)
.
replace
(
/
\n
/g
,
'<br/>'
);
});
$scope
.
updateContent
(
content
);
};
module
.
directive
(
'markdown'
,
function
()
{
return
{
restrict
:
'E'
,
link
:
function
(
scope
,
element
)
{
scope
.
$on
(
'render'
,
function
()
{
render_panel
();
});
function
render_panel
()
{
require
([
'./lib/showdown'
],
function
(
Showdown
)
{
scope
.
ready
=
true
;
var
converter
=
new
Showdown
.
converter
();
var
text
=
scope
.
panel
.
content
.
replace
(
/&/g
,
'&'
)
.
replace
(
/>/g
,
'>'
)
.
replace
(
/</g
,
'<'
);
var
htmlText
=
converter
.
makeHtml
(
text
);
element
.
html
(
htmlText
);
// For whatever reason, this fixes chrome. I don't like it, I think
// it makes things slow?
if
(
!
scope
.
$$phase
)
{
scope
.
$apply
();
}
});
}
$scope
.
renderMarkdown
=
function
(
content
)
{
require
([
'./lib/showdown'
],
function
(
Showdown
)
{
var
converter
=
new
Showdown
.
converter
();
var
text
=
content
.
replace
(
/&/g
,
'&'
)
.
replace
(
/>/g
,
'>'
)
.
replace
(
/</g
,
'<'
);
render_panel
(
);
}
$scope
.
updateContent
(
converter
.
makeHtml
(
text
)
);
}
);
};
});
module
.
filter
(
'newlines'
,
function
()
{
return
function
(
input
)
{
return
input
.
replace
(
/
\n
/g
,
'<br/>'
);
};
});
$scope
.
updateContent
=
function
(
html
)
{
try
{
$scope
.
content
=
filterSrv
.
applyTemplateToTarget
(
html
);
module
.
filter
(
'striphtml'
,
function
()
{
return
function
(
text
)
{
return
text
.
replace
(
/&/g
,
'&'
)
.
replace
(
/>/g
,
'>'
)
.
replace
(
/</g
,
'<'
);
if
(
!
$scope
.
$$phase
)
{
$scope
.
$apply
();
}
}
catch
(
e
)
{
}
};
});
module
.
filter
(
'applytemplate'
,
function
(
filterSrv
)
{
return
function
(
input
)
{
return
filterSrv
.
applyTemplateToTarget
(
input
);
$scope
.
openEditor
=
function
()
{
};
});
module
.
filter
(
'applymarkdown'
,
function
()
{
return
function
(
input
)
{
if
(
require
.
defined
(
'./lib/showdown'
))
{
var
Showdown
=
require
(
'./lib/showdown'
);
var
converter
=
new
Showdown
.
converter
();
var
text
=
input
.
replace
(
/&/g
,
'&'
)
.
replace
(
/>/g
,
'>'
)
.
replace
(
/</g
,
'<'
);
return
converter
.
makeHtml
(
text
);
}
else
{
return
input
;
}
};
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment