[Web] add app hide option
This commit is contained in:
parent
226bdfac72
commit
41a087630b
|
@ -104,12 +104,14 @@ function customize($_action, $_item, $_data = null) {
|
|||
$apps = (array)$_data['app'];
|
||||
$links = (array)$_data['href'];
|
||||
$user_links = (array)$_data['user_href'];
|
||||
$hide = (array)$_data['hide'];
|
||||
$out = array();
|
||||
if (count($apps) == count($links) && count($apps) == count($user_links)) {
|
||||
if (count($apps) == count($links) && count($apps) == count($user_links) && count($apps) == count($hide)) {
|
||||
for ($i = 0; $i < count($apps); $i++) {
|
||||
$out[] = array($apps[$i] => array(
|
||||
'link' => $links[$i],
|
||||
'user_link' => $user_links[$i]
|
||||
'user_link' => $user_links[$i],
|
||||
'hide' => ($hide[$i] === '0' || $hide[$i] === 0) ? false : true
|
||||
));
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -31,11 +31,29 @@ if(!file_exists($CSSPath)) {
|
|||
}
|
||||
|
||||
$mailcow_apps_processed = $MAILCOW_APPS;
|
||||
$app_links = customize('get', 'app_links');
|
||||
$app_links_processed = $app_links;
|
||||
$hide_mailcow_apps = true;
|
||||
for ($i = 0; $i < count($mailcow_apps_processed); $i++) {
|
||||
if ($hide_mailcow_apps && !$mailcow_apps_processed[$i]['hide']){
|
||||
$hide_mailcow_apps = false;
|
||||
}
|
||||
if (!empty($_SESSION['mailcow_cc_username'])){
|
||||
$mailcow_apps_processed[$i]['user_link'] = str_replace('%u', $_SESSION['mailcow_cc_username'], $mailcow_apps_processed[$i]['user_link']);
|
||||
}
|
||||
}
|
||||
if ($app_links_processed){
|
||||
for ($i = 0; $i < count($app_links_processed); $i++) {
|
||||
$key = array_key_first($app_links_processed[$i]);
|
||||
if ($hide_mailcow_apps && !$app_links_processed[$i][$key]['hide']){
|
||||
$hide_mailcow_apps = false;
|
||||
}
|
||||
if (!empty($_SESSION['mailcow_cc_username'])){
|
||||
$app_links_processed[$i][$key]['user_link'] = str_replace('%u', $_SESSION['mailcow_cc_username'], $app_links_processed[$i][$key]['user_link']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$globalVariables = [
|
||||
|
@ -52,9 +70,11 @@ $globalVariables = [
|
|||
'lang' => $lang,
|
||||
'skip_sogo' => (getenv('SKIP_SOGO') == 'y'),
|
||||
'allow_admin_email_login' => (getenv('ALLOW_ADMIN_EMAIL_LOGIN') == 'n'),
|
||||
'mailcow_apps_processed' => $mailcow_apps_processed,
|
||||
'hide_mailcow_apps' => $hide_mailcow_apps,
|
||||
'mailcow_apps' => $MAILCOW_APPS,
|
||||
'app_links' => customize('get', 'app_links'),
|
||||
'mailcow_apps_processed' => $mailcow_apps_processed,
|
||||
'app_links' => $app_links,
|
||||
'app_links_processed' => $app_links_processed,
|
||||
'is_root_uri' => (parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) == '/'),
|
||||
'uri' => $_SERVER['REQUEST_URI'],
|
||||
'last_login' => last_login('get', $_SESSION['mailcow_cc_username'], 7, 0)['ui']['time']
|
||||
|
|
|
@ -119,7 +119,9 @@ $SHOW_DKIM_PRIV_KEYS = false;
|
|||
$MAILCOW_APPS = array(
|
||||
array(
|
||||
'name' => 'Webmail',
|
||||
'link' => '/SOGo/',
|
||||
'link' => '/SOGo/so/',
|
||||
'user_link' => '/sogo-auth.php?login=%u',
|
||||
'hide' => true
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -706,20 +706,34 @@ jQuery(function($){
|
|||
}
|
||||
})
|
||||
// App links
|
||||
// setup eventlistener
|
||||
setAppHideEvent();
|
||||
function setAppHideEvent(){
|
||||
$('.app_hide').off('change');
|
||||
$('.app_hide').on('change', function (e) {
|
||||
var value = $(this).is(':checked') ? '1' : '0';
|
||||
console.log(value)
|
||||
$(this).parent().children(':first-child').val(value);
|
||||
})
|
||||
}
|
||||
function add_table_row(table_id, type) {
|
||||
var row = $('<tr />');
|
||||
if (type == "app_link") {
|
||||
cols = '<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="app" required></td>';
|
||||
cols += '<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="href" required></td>';
|
||||
cols += '<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="user_href" required></td>';
|
||||
cols += '<td><div class="d-flex align-items-center justify-content-center" style="height: 33.5px"><input data-id="app_links" type="hidden" name="hide" value="0"><input class="form-check-input app_hide" type="checkbox" value="1"></div></td>';
|
||||
cols += '<td><a href="#" role="button" class="btn btn-sm btn-xs-lg btn-secondary h-100 w-100" type="button">' + lang.remove_row + '</a></td>';
|
||||
} else if (type == "f2b_regex") {
|
||||
cols = '<td><input style="text-align:center" class="input-sm input-xs-lg form-control" data-id="f2b_regex" type="text" value="+" disabled></td>';
|
||||
cols += '<td><input class="input-sm input-xs-lg form-control regex-input" data-id="f2b_regex" type="text" name="regex" required></td>';
|
||||
cols += '<td><a href="#" role="button" class="btn btn-sm btn-xs-lg btn-secondary h-100 w-100" type="button">' + lang.remove_row + '</a></td>';
|
||||
}
|
||||
|
||||
row.append(cols);
|
||||
table_id.append(row);
|
||||
if (type == "app_link")
|
||||
setAppHideEvent();
|
||||
}
|
||||
$('#app_link_table').on('click', 'tr a', function (e) {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
<th>{{ lang.admin.app_name }}</th>
|
||||
<th>{{ lang.admin.link }}</th>
|
||||
<th>{{ lang.admin.user_link }}</th>
|
||||
<th>{{ lang.admin.app_hide }}</th>
|
||||
<th style="width:100px;"> </th>
|
||||
</tr>
|
||||
{% for row in app_links %}
|
||||
|
@ -63,6 +64,12 @@
|
|||
<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="app" required value="{{ key }}"></td>
|
||||
<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="href" required value="{{ val.link }}"></td>
|
||||
<td><input class="input-sm input-xs-lg form-control" data-id="app_links" type="text" name="user_href" required value="{{ val.user_link }}"></td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center justify-content-center" style="height: 33.5px">
|
||||
<input data-id="app_links" type="hidden" name="hide" {% if val.hide %}value="1"{% else %}value="0"{% endif %}>
|
||||
<input class="form-check-input app_hide" type="checkbox" value="1" {% if val.hide %}checked{% endif %}>
|
||||
</div>
|
||||
</td>
|
||||
<td><a href="#" role="button" class="btn btn-sm btn-xs-lg btn-secondary h-100 w-100" type="button">{{ lang.admin.remove_row }}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -72,6 +79,11 @@
|
|||
<td><input class="input-sm input-xs-lg form-control" value="{{ app.name }}" disabled></td>
|
||||
<td><input class="input-sm input-xs-lg form-control" value="{{ app.link }}" disabled></td>
|
||||
<td><input class="input-sm input-xs-lg form-control" value="{{ app.user_link }}" disabled></td>
|
||||
<td>
|
||||
<div class="d-flex align-items-center justify-content-center" style="height: 33.5px">
|
||||
<input class="form-check-input" data-id="app_links" type="checkbox" name="hide" value="1" disabled {% if app.hide %}checked{% endif %}>
|
||||
</div>
|
||||
</td>
|
||||
<td><a href="#" role="button" class="btn btn-sm btn-xs-lg btn-secondary h-100 w-100 disabled" type="button">{{ lang.admin.remove_row }}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -67,21 +67,25 @@
|
|||
<p><div class="my-4 alert alert-info">{{ lang.login.delayed|format(login_delay) }}</b></div></p>
|
||||
{% endif %}
|
||||
<div class="my-4" id="fido2-alerts"></div>
|
||||
{% if not oauth2_request and (mailcow_apps or app_links) %}
|
||||
{% if not oauth2_request and (mailcow_apps or app_links) and not hide_mailcow_apps %}
|
||||
<legend><i class="bi bi-link-45deg"></i> {{ ui_texts.apps_name|raw }}</legend><hr />
|
||||
<div class="my-2 d-flex flex-wrap apps">
|
||||
{% for app in mailcow_apps %}
|
||||
{% if not skip_sogo or not is_uri('SOGo', app.link) %}
|
||||
<div class="m-2">
|
||||
<a href="{{ app.link }}" role="button" {% if app.description %}title="{{ app.description }}"{% endif %} class="btn btn-primary btn-block">{{ app.name }}</a>
|
||||
</div>
|
||||
{% if not app.hide %}
|
||||
{% if not skip_sogo or not is_uri('SOGo', app.link) %}
|
||||
<div class="m-2">
|
||||
<a href="{{ app.link }}" role="button" {% if app.description %}title="{{ app.description }}"{% endif %} class="btn btn-primary btn-block">{{ app.name }}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% for row in app_links %}
|
||||
{% for key, val in row %}
|
||||
{% if not val.hide %}
|
||||
<div class="m-2">
|
||||
<a href="{{ val.link }}" role="button" class="btn btn-primary btn-block">{{ key }}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue