Add maintenance banner on UI (#797)

* fix bug on email separator

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>

* allow group name change

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>

* add maintenance banner on UI

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>

* removes unnecessary comments

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>

---------

Signed-off-by: Denis barbaron <denis.barbaron@orange.com>
This commit is contained in:
Denis Barbaron
2024-07-19 10:33:52 +02:00
committed by GitHub
parent cf56911e9f
commit 489ba0427e
17 changed files with 446 additions and 16 deletions

View File

@@ -0,0 +1,41 @@
/**
* Copyright © 2024 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
module.exports = function AlertMessageCtrl(
$scope
, SettingsService
) {
$scope.defaultAlertMessage = {
data: '*** This site is currently under maintenance, please wait ***'
, activation: 'False'
, level: 'Critical'
}
SettingsService.bind($scope, {
target: 'alertMessage'
, source: 'alertMessage'
, defaultValue: $scope.defaultAlertMessage
})
$scope.alertMessageActivationOptions = ['True', 'False']
$scope.alertMessageLevelOptions = ['Information', 'Warning', 'Critical']
$scope.$watch(
function() {
return SettingsService.get('alertMessage')
}
, function(newvalue) {
if (typeof newvalue === 'undefined') {
SettingsService.set('alertMessage', $scope.defaultAlertMessage)
}
}
)
$scope.$on('user.menu.users.updated', function(event, message) {
if (message.user.privilege === 'admin') {
$scope.alertMessage = message.user.settings.alertMessage
}
})
}

View File

@@ -0,0 +1,34 @@
//
Copyright © 2024 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//
.widget-container.fluid-height(ng-controller='AlertMessageCtrl')
.heading
i.fa.fa-exclamation-triangle
span(translate) Alert Message
.widget-content.padded
.form-horizontal
.form-group.general-item
.input-group
.input-group-addon.input-sm
i.fa.fa-exclamation-triangle(
uib-tooltip="{{'Define your own alert message' | translate}}" tooltip-placement='auto top-right' tooltip-popup-delay='500')
input.form-control.input-sm(size='20' type='text' placeholder='' ng-model='alertMessage.data')
.form-group.general-item
label.general-label(
translate
uib-tooltip="{{'Alert message activation' | translate}}"
tooltip-placement='auto top-right'
tooltip-popup-delay='500') Activation
select(
ng-model='alertMessage.activation'
ng-options='option for option in alertMessageActivationOptions')
.form-group.general-item
label.general-label(
translate
uib-tooltip="{{'Alert message level' | translate}}"
tooltip-placement='auto top-right'
tooltip-popup-delay='500') Level
select(
ng-model='alertMessage.level'
ng-options='option for option in alertMessageLevelOptions')

View File

@@ -0,0 +1,14 @@
/**
* Copyright © 2024 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
module.exports = angular.module('stf.settings.general.alert-message', [
require('stf/settings').name
])
.run(['$templateCache', function($templateCache) {
$templateCache.put(
'settings/general/alert-message/alert-message.pug'
, require('./alert-message.pug')
)
}])
.controller('AlertMessageCtrl', require('./alert-message-controller'))

View File

@@ -1,3 +1,9 @@
module.exports = function GeneralCtrl() {
/**
* Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
module.exports = function GeneralCtrl($scope, AppState) {
$scope.isAdmin = function() {
return AppState.user.privilege === 'admin'
}
}

View File

@@ -1,3 +1,16 @@
/*
Copyright © 2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
*/
.stf-general {
}
}
.stf-general .general-item {
margin: 0px 10px 15px 0px;
}
.stf-general .general-label {
font-weight: bold;
margin-right: 10px;
}

View File

@@ -1,8 +1,9 @@
//
Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
//
.row
.div(ng-controller='GeneralCtrl')
.row.stf-general
.col-md-3
div(ng-include='"settings/general/local/local-settings.pug"')
.col-md-3
@@ -11,3 +12,6 @@
div(ng-include='"settings/general/date-format/date-format.pug"')
.col-md-3
div(ng-include='"settings/general/email-address-separator/email-address-separator.pug"')
.row.stf-general(ng-if='isAdmin()')
.col-md-12
div(ng-include='"settings/general/alert-message/alert-message.pug"')

View File

@@ -1,5 +1,5 @@
/**
* Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
* Copyright © 2019-2024 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
**/
require('./general.css')
@@ -8,7 +8,9 @@ module.exports = angular.module('stf.settings.general', [
require('./language').name,
require('./local').name,
require('./email-address-separator').name,
require('./date-format').name
require('./date-format').name,
require('stf/app-state').name,
require('./alert-message').name
])
.run(['$templateCache', function($templateCache) {
$templateCache.put(