Now browser notifications are disabled by default. Issue #156.

This commit is contained in:
Dmitry Khomutov 2018-04-29 12:08:44 +07:00
parent ddc5cd6a25
commit 84b2fefd19
No known key found for this signature in database
GPG key ID: EC19426474B37AAC
6 changed files with 50 additions and 25 deletions

View file

@ -39,6 +39,8 @@ php-censor:
log: log:
rotate: true rotate: true
max_files: 10 max_files: 10
notifications:
enabled: false # notify.js notifications to browser
ssh: ssh:
strength: 4096 # SSH keys strength (default: 2048) strength: 4096 # SSH keys strength (default: 2048)
comment: admin@php-censor.info # SSH keys comment (default: admin@php-censor) comment: admin@php-censor.info # SSH keys comment (default: admin@php-censor)

View file

@ -164,6 +164,7 @@ var PHPCensor = {
error: PHPCensor.handleFailedAjax error: PHPCensor.handleFailedAjax
}); });
if (NOTIFICATIONS) {
$.ajax({ $.ajax({
url: APP_URL + 'web-notifications/builds-updated', url: APP_URL + 'web-notifications/builds-updated',
success: function (data) { success: function (data) {
@ -171,6 +172,7 @@ var PHPCensor = {
}, },
error: PHPCensor.handleFailedAjax error: PHPCensor.handleFailedAjax
}); });
}
}, },
getProjectBuilds: function () { getProjectBuilds: function () {

View file

@ -34,6 +34,7 @@ PHPCensor.widgets.allProjects = {
error: PHPCensor.handleFailedAjax error: PHPCensor.handleFailedAjax
}); });
if (NOTIFICATIONS) {
$.ajax({ $.ajax({
url: APP_URL + url: APP_URL +
'web-notifications/widgets-all-projects-update/' + 'web-notifications/widgets-all-projects-update/' +
@ -43,6 +44,7 @@ PHPCensor.widgets.allProjects = {
}, },
error: PHPCensor.handleFailedAjax error: PHPCensor.handleFailedAjax
}); });
}
}); });
} }
}; };

View file

@ -258,6 +258,9 @@ class InstallCommand extends Command
'rotate' => false, 'rotate' => false,
'max_files' => 0, 'max_files' => 0,
], ],
'notifications' => [
'enabled' => false,
],
'email_settings' => [ 'email_settings' => [
'from_address' => 'PHP Censor <no-reply@php-censor.local>', 'from_address' => 'PHP Censor <no-reply@php-censor.local>',
'smtp_address' => null, 'smtp_address' => null,

View file

@ -2,8 +2,20 @@
use PHPCensor\Helper\Lang; use PHPCensor\Helper\Lang;
/**
* @var \PHPCensor\Model\User $user
*/
$user = $this->getUser(); $user = $this->getUser();
/**
* @var string $title
* @var string $subtitle
* @var string $version
* @var string $content
* @var string $skin
* @var bool $notifications
*/
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
@ -36,6 +48,7 @@ $user = $this->getUser();
<script> <script>
var APP_URL = '<?= APP_URL; ?>'; var APP_URL = '<?= APP_URL; ?>';
var NOTIFICATIONS = <?= ($notifications ? 'true' : 'false'); ?>;
var LANGUAGE = '<?= Lang::getLanguage(); ?>'; var LANGUAGE = '<?= Lang::getLanguage(); ?>';
<?php if (defined('JSON_UNESCAPED_UNICODE')): ?> <?php if (defined('JSON_UNESCAPED_UNICODE')): ?>

View file

@ -48,9 +48,12 @@ abstract class WebController extends Controller
if (!empty($this->layoutName)) { if (!empty($this->layoutName)) {
$this->layout = new View($this->layoutName); $this->layout = new View($this->layoutName);
$notifications = (bool)Config::getInstance()->get('php-censor.notifications.enabled', false);
$this->layout->title = 'PHP Censor'; $this->layout->title = 'PHP Censor';
$this->layout->breadcrumb = []; $this->layout->breadcrumb = [];
$this->layout->version = trim(file_get_contents(ROOT_DIR . 'VERSION.md')); $this->layout->version = trim(file_get_contents(ROOT_DIR . 'VERSION.md'));
$this->layout->notifications = $notifications;
$groups = []; $groups = [];
$groupStore = Factory::getStore('ProjectGroup'); $groupStore = Factory::getStore('ProjectGroup');