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
vNext
**New features or improvements**
-
Allow
[
[..
]
] filter notation in all text panels (markdown/html/text) (Issue #511)
**Changes**
**Changes**
-
Use unix epoch for Graphite from/to for absolute time ranges (Closes #536)
-
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()"
>
<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>-->
<p
ng-bind-html-unsafe=
"content"
>
<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>
</p>
</div>
</div>
src/app/panels/text/module.js
View file @
91b48258
...
@@ -23,7 +23,7 @@ function (angular, app, _, require) {
...
@@ -23,7 +23,7 @@ function (angular, app, _, require) {
var
module
=
angular
.
module
(
'kibana.panels.text'
,
[]);
var
module
=
angular
.
module
(
'kibana.panels.text'
,
[]);
app
.
useModule
(
module
);
app
.
useModule
(
module
);
module
.
controller
(
'text'
,
function
(
$scope
)
{
module
.
controller
(
'text'
,
function
(
$scope
,
filterSrv
)
{
$scope
.
panelMeta
=
{
$scope
.
panelMeta
=
{
description
:
"A static text panel that can use plain text, markdown, or (sanitized) HTML"
description
:
"A static text panel that can use plain text, markdown, or (sanitized) HTML"
...
@@ -40,84 +40,58 @@ function (angular, app, _, require) {
...
@@ -40,84 +40,58 @@ function (angular, app, _, require) {
$scope
.
init
=
function
()
{
$scope
.
init
=
function
()
{
$scope
.
initBaseController
(
this
,
$scope
);
$scope
.
initBaseController
(
this
,
$scope
);
$scope
.
ready
=
false
;
$scope
.
ready
=
false
;
$scope
.
$on
(
'refresh'
,
$scope
.
render
);
$scope
.
render
();
};
};
$scope
.
render
=
function
()
{
$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
.
renderText
=
function
(
content
)
{
//$scope.$emit('open-modal','paneleditor');
content
=
content
console
.
log
(
'scope id'
,
$scope
.
$id
);
.
replace
(
/&/g
,
'&'
)
};
.
replace
(
/>/g
,
'>'
)
.
replace
(
/</g
,
'<'
)
.
replace
(
/
\n
/g
,
'<br/>'
);
});
$scope
.
updateContent
(
content
);
};
module
.
directive
(
'markdown'
,
function
()
{
$scope
.
renderMarkdown
=
function
(
content
)
{
return
{
require
([
'./lib/showdown'
],
function
(
Showdown
)
{
restrict
:
'E'
,
var
converter
=
new
Showdown
.
converter
();
link
:
function
(
scope
,
element
)
{
var
text
=
content
scope
.
$on
(
'render'
,
function
()
{
.
replace
(
/&/g
,
'&'
)
render_panel
();
.
replace
(
/>/g
,
'>'
)
});
.
replace
(
/</g
,
'<'
);
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
();
}
});
}
render_panel
(
);
$scope
.
updateContent
(
converter
.
makeHtml
(
text
)
);
}
}
);
};
};
});
module
.
filter
(
'newlines'
,
function
()
{
$scope
.
updateContent
=
function
(
html
)
{
return
function
(
input
)
{
try
{
return
input
.
replace
(
/
\n
/g
,
'<br/>'
);
$scope
.
content
=
filterSrv
.
applyTemplateToTarget
(
html
);
};
});
module
.
filter
(
'striphtml'
,
function
()
{
if
(
!
$scope
.
$$phase
)
{
return
function
(
text
)
{
$scope
.
$apply
();
return
text
}
.
replace
(
/&/g
,
'&'
)
}
catch
(
e
)
{
.
replace
(
/>/g
,
'>'
)
}
.
replace
(
/</g
,
'<'
);
};
};
});
module
.
filter
(
'applytemplate'
,
function
(
filterSrv
)
{
$scope
.
openEditor
=
function
()
{
return
function
(
input
)
{
return
filterSrv
.
applyTemplateToTarget
(
input
);
};
};
});
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