Newsroom finalization & integration tests.

This commit is contained in:
Denis Flaven
2018-12-06 15:38:29 +01:00
parent 35752a8041
commit 540bc3a54b
8 changed files with 227 additions and 8 deletions

View File

@@ -835,6 +835,7 @@ EOF
'fetch_url' => $oProvider->GetFetchURL(),
'view_all_url' => $oProvider->GetViewAllURL(),
'mark_all_as_read_url' => $oProvider->GetMarkAllAsReadURL(),
'placeholders' => $oProvider->GetPlaceholders(),
'ttl' => $oProvider->GetTTL(),
);
}
@@ -842,7 +843,7 @@ EOF
if (count($aProviderParams) > 0)
{
$sImageUrl= '../images/newsroom_menu.png';
$sPlaceholderImageUrl= '../images/news-32x32.png';
$sPlaceholderImageUrl= '../images/newsroom-message.svg';
$aParams = array(
'image_url' => $sImageUrl,
'placeholder_image_url' => $sPlaceholderImageUrl,

View File

@@ -65,6 +65,13 @@ interface iNewsroomProvider
*/
public function GetPreferencesUrl();
/**
* Return an array key => value to be replaced in URL of the messages
* Example: '%itop_root%' => utils::GetAbsoluteUrlAppRoot();
* @return string[]
*/
public function GetPlaceholders();
/**
* The duration between to refreshes of the cache (in seconds)
* @return int
@@ -136,6 +143,15 @@ abstract class NewsroomProviderBase implements iNewsroomProvider
return false;
}
/**
* {@inheritDoc}
* @see iNewsroomProvider::GetPlaceholders()
*/
public function GetPlaceholders()
{
return array(); // By default, empty set of placeholders
}
public function GetTTL()
{
return 10*60; // Refresh every 10 minutes

View File

@@ -3075,6 +3075,7 @@ input:checked + .slider:before {
font-size: 8pt;
background-color: #1c94c4;
color: #fff;
cursor: pointer;
}
.newsroom_extra_messages_counter {
display: inline-block !important;
@@ -3144,3 +3145,31 @@ input:checked + .slider:before {
height: 1em;
width: 3em;
}
#newsroom_no_new_message p {
text-align: center !important;
cursor: default !important;
font-style: italic;
}
#newsroom_no_new_message {
color: #444 !important;
}
#newsroom_no_new_message:hover {
cursor: default !important;
color: #444 !important;
background-color: #fff !important;
}
#newsroom_menu h1 {
font-weight: 700;
font-size: 16px;
margin-bottom: 0.5em;
}
#newsroom_menu h2 {
font-weight: 700;
font-size: 14px;
margin-bottom: 0.5em;
}
#newsroom_menu h3, #newsroom_menu h4, #newsroom_menu h5 {
font-weight: 700;
font-size: 12px;
margin-bottom: 0.5em;
}

View File

@@ -3562,6 +3562,7 @@ input:checked + .slider:before {
font-size: 8pt;
background-color:$complement-color;
color: $white;
cursor: pointer;
}
.newsroom_extra_messages_counter {
display:inline-block !important;
@@ -3631,3 +3632,31 @@ input:checked + .slider:before {
height: 1em;
width: 3em;
}
#newsroom_no_new_message p {
text-align: center !important;
cursor: default !important;
font-style: italic;
}
#newsroom_no_new_message {
color: $gray-dark !important;
}
#newsroom_no_new_message:hover {
cursor: default !important;
color: $gray-dark !important;
background-color: $white !important;
}
#newsroom_menu h1 {
font-weight: 700;
font-size: 16px;
margin-bottom: 0.5em;
}
#newsroom_menu h2 {
font-weight: 700;
font-size: 14px;
margin-bottom: 0.5em;
}
#newsroom_menu h3, #newsroom_menu h4, #newsroom_menu h5 {
font-weight: 700;
font-size: 12px;
margin-bottom: 0.5em;
}

View File

@@ -52,6 +52,18 @@ class HubNewsroomProvider extends NewsroomProviderBase
{
return $sBaseUrl = $this->oConfig->GetModuleSetting('itop-hub-connector', 'url').MetaModel::GetModuleSetting('itop-hub-connector', 'route_view_all_messages');
}
/**
* {@inheritDoc}
* @see iNewsroomProvider::GetPlaceholders()
*/
public function GetPlaceholders()
{
return array(
'%connect_to_itop_hub%' => utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'launch.php', array('target' => 'view_dashboard')),
);
}
/**
* {@inheritDoc}
* @see NewsroomProviderBase::GetPreferencesUrl()

View File

@@ -1553,7 +1553,7 @@ Dict::Add('EN US', 'English', 'English', array(
//
Dict::Add('EN US', 'English', 'English', array(
'UI:Newsroom:NoNewMessage' => 'No new message',
'UI:Newsroom:MarkAllAsRead' => 'Mark all as messages read',
'UI:Newsroom:MarkAllAsRead' => 'Mark all messages as read',
'UI:Newsroom:ViewAllMessages' => 'View all messages',
'UI:Newsroom:Preferences' => 'Newsroom preferences',
'UI:Newsroom:ConfigurationLink' => 'Configuration',

102
images/newsroom-message.svg Executable file
View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="143.92165mm"
height="143.92165mm"
viewBox="0 0 143.92165 143.92165"
version="1.1"
id="svg8"
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
sodipodi:docname="newsroom-message.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="327.16772"
inkscape:cy="203.50251"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1005"
inkscape:window-x="1911"
inkscape:window-y="-9"
inkscape:window-maximized="1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-40.487099,-26.129204)">
<circle
style="opacity:1;fill:#ea7d1e;fill-opacity:1;stroke:none;stroke-width:10.02023888;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path4514"
cx="112.44792"
cy="98.090027"
r="71.960823"
inkscape:export-xdpi="5.6475177"
inkscape:export-ydpi="5.6475177" />
<g
id="g4519"
transform="matrix(0.88767549,0,0,0.88076684,12.630661,11.695584)"
inkscape:export-xdpi="5.6475177"
inkscape:export-ydpi="5.6475177">
<rect
ry="10.000007"
rx="10.000007"
y="65.111603"
x="66.712799"
height="65.956848"
width="91.470238"
id="rect4508"
style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:7;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
inkscape:export-xdpi="5.6475177"
inkscape:export-ydpi="5.6475177" />
<path
sodipodi:nodetypes="czc"
inkscape:connector-curvature="0"
id="path4510"
d="m 70.492558,70.403272 c 0,0 25.469056,36.944678 42.445432,36.599868 16.97638,-0.34481 41.46528,-37.355819 41.46528,-37.355819"
style="fill:none;stroke:#ffffff;stroke-width:7;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:export-xdpi="5.6475177"
inkscape:export-ydpi="5.6475177" />
<path
sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0"
id="path4512"
d="M 70.114582,128.23363 100.73065,100.1689 m 23.24553,-0.188992 30.42709,28.631692"
style="fill:none;stroke:#ffffff;stroke-width:7;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
inkscape:export-xdpi="5.6475177"
inkscape:export-ydpi="5.6475177" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -118,12 +118,23 @@ $(function()
_onAllMessagesFetched: function()
{
var aAllMessages = [];
for(k in this.aMessageByProvider)
for(var k in this.aMessageByProvider)
{
for(j in this.aMessageByProvider[k])
for(var j in this.aMessageByProvider[k])
{
var oMsg = this.aMessageByProvider[k][j];
oMsg.id = ''+oMsg.id; // Stringify
// Process the provider specific placeholders, if any
if (this.options.providers[k].placeholders !== undefined)
{
for(var sSearch in this.options.providers[k].placeholders)
{
var sReplace = this.options.providers[k].placeholders[sSearch];
var sResult = oMsg.url.replace(sSearch, sReplace);
oMsg.url = sResult;
}
}
oMsg.provider = k;
aAllMessages.push(oMsg);
}
@@ -160,24 +171,28 @@ $(function()
aUnreadMessagesByProvider[oMessage.provider]++;
if (iCount < this.options.display_limit)
{
if (oMessage.image !== undefined)
if ((oMessage.image !== undefined) && (oMessage.image !== null))
{
sImageUrl = oMessage.image;
}
else
{
sImageUrl = this.options.placeholder_image_url;
}
}
var div = document.createElement("div");
div.textContent = oMessage.text;
var sDescription = div.innerHTML; // Escape HTML entities for XSS prevention
var converter = new showdown.Converter();
var converter = new showdown.Converter({noHeaderId: true});
var sRichDescription = converter.makeHtml(sDescription);
sRichDescription += '<span class="newsroom_menu_item_date">'+this.options.providers[oMessage.provider].label+' - '+moment(oMessage.start_date).fromNow()+'</span>';
sHtml += '<li class="newsroom_menu_item" data-msg-id="'+oMessage.id+'" data-provider-id="'+oMessage.provider+'" data-url="'+oMessage.url+'" id="newsroom_menu_item_'+oMessage.id+'"><div><img src="'+sImageUrl+'"><p>'+sRichDescription+'</p><div style="clear:both"></div></div></li>';
}
iCount++;
}
if (iCount == 0)
{
sHtml += '<li class="newsroom_menu_item" id="newsroom_no_new_message"><div><p>'+this.options.labels.no_message+'</p><div style="clear:both"></div></div></li>';
}
if (this.options.providers.length == 1)
{
sHtml += '<li class="newsroom_menu_item" id="newsroom_menu_show_all">'+this.options.labels.view_all+'</li>';
@@ -202,6 +217,7 @@ $(function()
$(this.element).html(sHtml);
var me = this;
$('#newsroom_menu > ul').popupmenu();
$('#newsroom_menu_counter').on('click', function() {setTimeout(function(){ $('#newsroom_menu_icon').trigger('click') }, 10);});
$('.newsroom_menu_item[data-msg-id]').on('click', function(ev) { me._handleClick(this); });
$('#newsroom_menu_dismiss_all').on('click', function(ev) { me._markAllAsRead(); });
if (this.options.providers.length == 1)
@@ -216,7 +232,21 @@ $(function()
}
else
{
$('#top-left-newsroom-cell > img').css({opacity: 0.4}).attr('title', this.options.labels.no_message);
sHtml += '</ul></li></ul></span><div id="newsroom_menu_counter_container"><span id="newsroom_menu_counter" style="visibility:hidden"></span></div></span>';
$(this.element).html(sHtml);
$('#newsroom_menu_dismiss_all').remove();
var me = this;
$('#newsroom_menu > ul').popupmenu();
$('#top-left-newsroom-cell > img').attr('title', this.options.labels.no_message);
if (this.options.providers.length == 1)
{
$('#newsroom_menu_show_all').on('click', function(ev) { window.open(me.options.providers[0].view_all_url, '_blank'); });
}
else
{
$('#newsroom_show_all_submenu > ul').popupmenu();
$('.newsroom_sub_menu_item').on('click', function() { var idx = parseInt($(this).attr('data-provider-id'), 10); window.open(me.options.providers[idx].view_all_url, '_blank');});
}
}
},