Skip to content

Commit

Permalink
Pass image url via data attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
takai committed Feb 14, 2017
1 parent 2bbb957 commit 7ecc693
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
9 changes: 3 additions & 6 deletions app/assets/javascripts/kuroko2/job_instances.js
Expand Up @@ -3,16 +3,13 @@

jQuery(function ($) {
var logIntervalId;
var notifyIfNeeded = function (status, name) {
var notifyIfNeeded = function (status, name, image) {
if (!('Notification' in window)) {
return;
}

if (Notification.permission === 'granted' && Cookies.get('notification') === 'on') {
var notification = new Notification(
"[" + status + "] " + name,
{"icon": window.location.origin + "/assets/kuroko2/kuroko-logo-" + status.toLowerCase() + ".png"}
);
var notification = new Notification("[" + status + "] " + name, {"icon": image[status.toLowerCase()]});
notification.onclick = function () {
notification.close();
window.focus();
Expand All @@ -24,7 +21,7 @@ jQuery(function ($) {

$.get(instancePath, function (data) {
$('#instance').replaceWith(data);
notifyIfNeeded($('#instance-status').text(), $('#definition-name').text());
notifyIfNeeded($('#instance-status').text(), $('#definition-name').text(), $('#notification').data());
});
};
var updateLogs = function () {
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/kuroko2/application.html.slim
Expand Up @@ -31,7 +31,7 @@ html
img.img-circle src='#{current_user.image}' alt="#{current_user.name}"
.pull-left.info
p Hello, #{current_user.name}
p#notification
p#notification data-success='#{asset_url('kuroko2/kuroko-logo-success.png')}' data-error='#{asset_url('kuroko2/kuroko-logo-error.png')}'
i.fa.fa-volume-off
| Turn on notification
ul.sidebar-menu
Expand Down
2 changes: 2 additions & 0 deletions lib/kuroko2/engine.rb
Expand Up @@ -50,6 +50,8 @@ class Engine < ::Rails::Engine
config.action_mailer.smtp_settings =
Kuroko2.config.action_mailer.smtp_settings.to_h.symbolize_keys || {}

app.config.assets.precompile += %w(kuroko2/kuroko-logo-success.png kuroko2/kuroko-logo-error.png)

if Kuroko2.config.extentions && Kuroko2.config.extentions.controller
Kuroko2.config.extentions.controller.each do |extention|
Kuroko2::ApplicationController.include(Module.const_get(extention, false))
Expand Down

0 comments on commit 7ecc693

Please sign in to comment.