diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php index e3af7e131..a98f89068 100644 --- a/application/itopwebpage.class.inc.php +++ b/application/itopwebpage.class.inc.php @@ -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, diff --git a/application/newsroomprovider.class.inc.php b/application/newsroomprovider.class.inc.php index dca4bc022..bee402b88 100644 --- a/application/newsroomprovider.class.inc.php +++ b/application/newsroomprovider.class.inc.php @@ -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 diff --git a/css/light-grey.css b/css/light-grey.css index 0dd9c0601..2cb668716 100644 --- a/css/light-grey.css +++ b/css/light-grey.css @@ -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; +} diff --git a/css/light-grey.scss b/css/light-grey.scss index 553f0f8db..edfbafda2 100644 --- a/css/light-grey.scss +++ b/css/light-grey.scss @@ -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; +} diff --git a/datamodels/2.x/itop-hub-connector/hubnewsroomprovider.class.inc.php b/datamodels/2.x/itop-hub-connector/hubnewsroomprovider.class.inc.php index ebb17cb04..21322ff9d 100644 --- a/datamodels/2.x/itop-hub-connector/hubnewsroomprovider.class.inc.php +++ b/datamodels/2.x/itop-hub-connector/hubnewsroomprovider.class.inc.php @@ -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() diff --git a/dictionaries/en.dictionary.itop.ui.php b/dictionaries/en.dictionary.itop.ui.php index 8450085de..fbadf3a73 100644 --- a/dictionaries/en.dictionary.itop.ui.php +++ b/dictionaries/en.dictionary.itop.ui.php @@ -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', diff --git a/images/newsroom-message.svg b/images/newsroom-message.svg new file mode 100755 index 000000000..ed20e23ad --- /dev/null +++ b/images/newsroom-message.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/js/newsroom_menu.js b/js/newsroom_menu.js index dd4597642..dd1d4bc79 100644 --- a/js/newsroom_menu.js +++ b/js/newsroom_menu.js @@ -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 += ''+this.options.providers[oMessage.provider].label+' - '+moment(oMessage.start_date).fromNow()+''; sHtml += '
  • '+sRichDescription+'

  • '; } iCount++; } + if (iCount == 0) + { + sHtml += '
  • '+this.options.labels.no_message+'

  • '; + } if (this.options.providers.length == 1) { sHtml += '
  • '+this.options.labels.view_all+'
  • '; @@ -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 += '
    '; + $(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');}); + } } },