diff options
author | Simon Rettberg | 2016-08-12 17:23:07 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-08-12 17:23:07 +0200 |
commit | 3e54a5b830c9ef9dcd77407b5064de00bd4621fd (patch) | |
tree | 2a69ff8b60ca91cfdd6d01fd39ec2a37e79b9944 /modules-available/dozmod | |
parent | Fix minor issues in exams install hook, taskmanager callback logic (diff) | |
download | slx-admin-3e54a5b830c9ef9dcd77407b5064de00bd4621fd.tar.gz slx-admin-3e54a5b830c9ef9dcd77407b5064de00bd4621fd.tar.xz slx-admin-3e54a5b830c9ef9dcd77407b5064de00bd4621fd.zip |
[dozmod] Improve layout, texts etc.
Diffstat (limited to 'modules-available/dozmod')
-rw-r--r-- | modules-available/dozmod/inc/pagemailtemplates.inc.php | 72 | ||||
-rw-r--r-- | modules-available/dozmod/page.inc.php | 2 | ||||
-rw-r--r-- | modules-available/dozmod/style.css | 51 | ||||
-rw-r--r-- | modules-available/dozmod/templates/mailconfig.html | 2 | ||||
-rw-r--r-- | modules-available/dozmod/templates/runtimeconfig.html | 93 | ||||
-rw-r--r-- | modules-available/dozmod/templates/templates.html | 95 |
6 files changed, 167 insertions, 148 deletions
diff --git a/modules-available/dozmod/inc/pagemailtemplates.inc.php b/modules-available/dozmod/inc/pagemailtemplates.inc.php index fedb13c8..73ce0ade 100644 --- a/modules-available/dozmod/inc/pagemailtemplates.inc.php +++ b/modules-available/dozmod/inc/pagemailtemplates.inc.php @@ -14,12 +14,16 @@ class Page_mail_templates extends Page Util::redirect('?do=Main'); } - $action = Request::get('action', 'show', 'string'); - + $action = Request::post('action', 'show', 'string'); if ($action === 'show') { $this->fetchTemplates(); } elseif ($action === 'save') { $this->handleSave(); + } elseif ($action === 'reset') { + $this->handleReset(); + } else { + Message::addError('main.invalid-action', $action); + Util::redirect('?do=dozmod§ion=templates'); } } @@ -54,32 +58,41 @@ class Page_mail_templates extends Page } protected function doRender() { - //echo '<pre>'; - //var_dump($this->templates); - //echo '</pre>'; - //die(); $this->enrichHtml(); Render::addTemplate('templates', ['templates' => $this->templates]); } private function handleSave() { - $data = []; - $data['templates'] = Request::post('templates'); - $data = $this->cleanTemplateArray($data); - if ($data!= NULL) { - $data = json_encode($data, JSON_PRETTY_PRINT); - //echo '<pre>'; - //print_r($data); - //echo '</pre>'; - //die(); + $data = Request::post('templates'); + if (is_array($data)) { + $this->fetchTemplates(); + foreach ($this->templates as &$template) { + if (isset($data[$template['name']])) { + $template['template'] = $data[$template['name']]['template']; + } + } + unset($template); + $data = json_encode(array('templates' => $this->templates)); Database::exec("UPDATE sat.configuration SET value = :value WHERE parameter = 'templates'", array('value' => $data)); Message::addSuccess('templates-saved'); - Util::redirect('?do=dozmod§ion=templates&action=show'); } else { - die('error while encoding'); + Message::addError('nothing-submitted'); } + Util::redirect('?do=dozmod§ion=templates'); + } + private function handleReset() + { + $result = Download::asStringPost('http://127.0.0.1:9080/do/reset-mail-templates', array(), 10, $code); + if ($code == 999) { + Message::addError('timeout'); + } elseif ($code != 200) { + Message::addError('dozmod-error', $code); + } else { + Message::addSuccess('all-templates-reset', $result); + } + Util::redirect('?do=dozmod§ion=templates'); } private function fetchTemplates() { @@ -87,33 +100,12 @@ class Page_mail_templates extends Page if ($templates != null) { $templates = @json_decode($templates['value'], true); if (is_array($templates)) { + $names = array_map(function ($e) { return $e['name']; }, $templates['templates']); + array_multisort($names, SORT_ASC, $templates['templates']); $this->templates = $templates['templates']; } } } - private function cleanTemplateArray($in) { - $out = []; - foreach ($in['templates'] as $t) { - $tcopy = $t; - $tcopy['mandatory_variables'] = $this->toArray($t['mandatory_variables']); - $tcopy['optional_variables'] = $this->toArray($t['optional_variables']); - $tcopy['description'] = $t['description']; - $tcopy['name'] = $t['name']; - - $out['templates'][] = $tcopy; - } - return $out; - } - - private function toArray($value) { - if (empty($value)) { - return []; - } else if(is_array($value)) { - return $value; - } else { - return array($value); - } - } } diff --git a/modules-available/dozmod/page.inc.php b/modules-available/dozmod/page.inc.php index 31d4cce2..7e8db7c4 100644 --- a/modules-available/dozmod/page.inc.php +++ b/modules-available/dozmod/page.inc.php @@ -234,6 +234,8 @@ class Page_DozMod extends Page 'value' => $data )); Message::addSuccess('mail-config-saved'); + } else { + Message::addError('main.invalid-action', $do); } Util::redirect('?do=DozMod§ion=mailconfig'); } diff --git a/modules-available/dozmod/style.css b/modules-available/dozmod/style.css index c6975d3e..8cc5548d 100644 --- a/modules-available/dozmod/style.css +++ b/modules-available/dozmod/style.css @@ -1,9 +1,3 @@ - - -input[type=checkbox] { - border: 2px solid green !important; -} - /* this is based on https://github.com/flatlogic/awesome-bootstrap-checkbox */ .checkbox { @@ -47,6 +41,7 @@ input[type=checkbox] { .checkbox input[type="radio"] { opacity: 0; z-index: 1; + top: -6px; } @@ -58,18 +53,44 @@ input[type=checkbox] { } .checkbox input[type="checkbox"]:checked + label::after, .checkbox input[type="radio"]:checked + label::after { - font-family: "FontAwesome"; - content: "\f00c"; + font-family: "Glyphicons Halflings"; + content: "\E013"; +} + +.witherror { + border: 1px solid red; +} + +/* +.table-input-group tr:first-child { + background: #EEEEEE url("./style/bg.png"); + border-style: solid none solid solid; + border-radius: 4px 0px 0px 4px; + border-color: #CCCCCC #555555 #CCCCCC #CCCCCC; + border-width: 1px 0px 1px 1px; + color: #555555; } +*/ +.table-input-group { + border-collapse: separate; +} -input[type="checkbox"].styled:checked + label:after { - font-family: 'FontAwesome'; - content: "\f00c"; +.table-input-group tr.input-group { + display: table-row; + width: auto; + border-collapse: separate; } -input[type="checkbox"] .styled:checked + label::before { - color: #fff; + +.table-input-group tr.input-group td.input-group-addon { + text-align: left; + border-collapse: separate; } -input[type="checkbox"] .styled:checked + label::after { - color: #fff; + +.table-input-group tr.input-group input.form-control { + width: auto; +} + +.table-input-group tr.input-group td:last-child input { + border-radius: 0px 4px 4px 0px; } diff --git a/modules-available/dozmod/templates/mailconfig.html b/modules-available/dozmod/templates/mailconfig.html index 56850637..69622796 100644 --- a/modules-available/dozmod/templates/mailconfig.html +++ b/modules-available/dozmod/templates/mailconfig.html @@ -6,8 +6,6 @@ </div> <div class="panel-body"> <p>{{lang_mailDescription}}</p> - <p>[BETA] Diese Funktionalität ist neu. Wir bitten um Nachsicht, falls es Situationen gibt, in denen zu viele - oder zu wenige Nachrichten verschickt werden.</p> <form action="?do=DozMod" method="post" id="mailconf"> <input type="text" name="prevent_autofill" id="prevent_autofill" value="" style="position:absolute;top:-200px" tabindex="-1"> <input type="password" name="password_fake" id="password_fake" value="" style="position:absolute;top:-200px" tabindex="-1"> diff --git a/modules-available/dozmod/templates/runtimeconfig.html b/modules-available/dozmod/templates/runtimeconfig.html index eced5784..011fcac4 100644 --- a/modules-available/dozmod/templates/runtimeconfig.html +++ b/modules-available/dozmod/templates/runtimeconfig.html @@ -5,90 +5,97 @@ {{lang_runtimeConfig}} </div> <div class="panel-body"> - <p> {{lang_descriptionRuntimeConfig}}</p> + <h3>{{lang_defaultPermissions}}</h3> + <p><i>{{lang_descriptionPermissionConfig}}</i></p> <form action="?do=DozMod" method="post" id="runtimeconf" role="form"> <input type="text" name="prevent_autofill" id="prevent_autofill" value="" style="position:absolute;top:-200px" tabindex="-1"> <input type="password" name="password_fake" id="password_fake" value="" style="position:absolute;top:-200px" tabindex="-1"> <fieldset class="form-group"> - <h4>{{lang_defaultLecturePermissions}}</h4> + <legend>{{lang_defaultLecturePermissions}}</legend> - <input type="hidden" name="defaultLecturePermissions[edit]" value="0"/> - <input type="hidden" name="defaultLecturePermissions[admin]" value="0"/> + <input type="hidden" name="defaultLecturePermissions[edit]" value="0"/> + <input type="hidden" name="defaultLecturePermissions[admin]" value="0"/> - <div class="checkbox"> - <input type="checkbox" name="defaultLecturePermissions[edit]" value="1" {{defaultLecturePermissions.edit}} id ="lecture_edit" class="form-control"/> - <label> - {{lang_lecturePermissionEdit}}* - </label> - </div> <div class="checkbox"> - <input type="checkbox" name="defaultLecturePermissions[admin]" value="1" {{defaultLecturePermissions.admin}} id ="lecture_admin" class="form-control"/> - <label> - {{lang_lecturePermissionAdmin}}* + <input type="checkbox" name="defaultLecturePermissions[admin]" value="1" {{defaultLecturePermissions.admin}} id ="lecture_admin" class="form-control"> + <label> + {{lang_lecturePermissionAdmin}} + </label> + </div> + <div class="checkbox"> + <input type="checkbox" name="defaultLecturePermissions[edit]" value="1" {{defaultLecturePermissions.edit}} id ="lecture_edit" class="form-control"> + <label> + {{lang_lecturePermissionEdit}} </label> </div> </fieldset> - <fieldset class="xform-group"> - <h4>{{lang_defaultImagePermissions}}</h4> + <fieldset class="form-group"> + <legend>{{lang_defaultImagePermissions}}</legend> <input type="hidden" name="defaultImagePermissions[edit]" value="0"/> <input type="hidden" name="defaultImagePermissions[admin]" value="0"/> <input type="hidden" name="defaultImagePermissions[download]" value="0"/> <input type="hidden" name="defaultImagePermissions[link]" value="0"/> <div class="checkbox"> - <input type="checkbox" name="defaultImagePermissions[edit]" value="1" {{defaultImagePermissions.edit}} id ="image_edit" class="form-control"/> - <label> - {{lang_defaultImagePermissionEdit}} * + <input type="checkbox" name="defaultImagePermissions[admin]" value="1" {{defaultImagePermissions.admin}} id ="image_admin" class="form-control"> + <label class="" for="image_admin"> + {{lang_defaultImagePermissionAdmin}} </label> </div> <div class="checkbox"> - <input type="checkbox" name="defaultImagePermissions[admin]" value="1" {{defaultImagePermissions.admin}} id ="image_admin" class="form-control"/ > - <label class="" for="image_admin"> - {{lang_defaultImagePermissionAdmin}} * + <input type="checkbox" name="defaultImagePermissions[edit]" value="1" {{defaultImagePermissions.edit}} id ="image_edit" class="form-control"> + <label> + {{lang_defaultImagePermissionEdit}} </label> </div> - <div class="checkbox"> - <input type="checkbox" name="defaultImagePermissions[download]" value="1" {{defaultImagePermissions.download}} id ="image_download" class="form-control"/ > + <input type="checkbox" name="defaultImagePermissions[download]" value="1" {{defaultImagePermissions.download}} id ="image_download" class="form-control"> <label> - {{lang_defaultImagePermissionDownload}} * + {{lang_defaultImagePermissionDownload}} </label> </div> <div class="checkbox"> - <input type="checkbox" name="defaultImagePermissions[link]" value="1" {{defaultImagePermissions.link}} id ="image_link" class="form-control"/ > + <input type="checkbox" name="defaultImagePermissions[link]" value="1" {{defaultImagePermissions.link}} id ="image_link" class="form-control"> <label> - {{lang_defaultImagePermissionLink}} * + {{lang_defaultImagePermissionLink}} </label> </div> - - </fieldset> - <fieldset> - <h4>{{lang_runtimeConfigLimits}}</h4> - <div class="input-group"> - <label class="input-group-addon slx-ga2" for="max_image_validity">{{lang_maxImageValidity}} *</label> - <input name="maxImageValidityDays" id ="max_image_validity" class="form-control" type="number" value="{{maxImageValidityDays}}"></input> - </div> - <div class="input-group"> - <label class="input-group-addon slx-ga2" for="max_lecture_validity">{{lang_maxLectureVisibility}} *</label> - <input name="maxLectureValidityDays" id ="max_lecture_validity" class="form-control" type="number" value="{{maxLectureValidityDays}}"></input> - </div> - <div class="input-group"> - <label class="input-group-addon slx-ga2" for="max_transfers">{{lang_maxTransfers}} *</label> - <input name="maxTransfers" id ="max_transfers" class="form-control" type="number" value="{{maxTransfers}}"></input> - </div> + <fieldset> + <h3>{{lang_runtimeConfigLimits}}</h3> + <p><i>{{lang_descriptionRuntimeLimits}}</i></p> + <table class="table-input-group"> + <tr class="input-group"> + <td class="input-group-addon" for="max_image_validity">{{lang_maxImageValidity}}</td> + <td> + <input name="maxImageValidityDays" id="max_image_validity" class="form-control" type="number" value="{{maxImageValidityDays}}" min="7" max="999" pattern="^\d+$"> + </td> + </tr> + <tr class="input-group"> + <td class="input-group-addon" for="max_lecture_validity">{{lang_maxLectureVisibility}}</td> + <td> + <input name="maxLectureValidityDays" id="max_lecture_validity" class="form-control" type="number" value="{{maxLectureValidityDays}}" min="1" max="999" pattern="^\d+$"> + </td> + </tr> + <tr class="input-group"> + <td class="input-group-addon" for="max_transfers">{{lang_maxTransfers}}</td> + <td> + <input name="maxTransfers" id="max_transfers" class="form-control" type="number" value="{{maxTransfers}}" min="1" max="10" pattern="^\d+$"> + </td> + </tr> + </table> </fieldset> <br> <input type="hidden" name="token" value="{{token}}"> <input type="hidden" name="action" value="runtime"> - <button class="btn btn-primary btn-sm" type="submit" name="button" value="save">{{lang_save}}</button> + <button class="btn btn-primary" type="submit" name="button" value="save">{{lang_save}}</button> </form> </div> </div> diff --git a/modules-available/dozmod/templates/templates.html b/modules-available/dozmod/templates/templates.html index e8e3f592..3b2a003f 100644 --- a/modules-available/dozmod/templates/templates.html +++ b/modules-available/dozmod/templates/templates.html @@ -1,15 +1,18 @@ -<h1> Templates</h1> +<h1>{{lang_mailTemplates}}</h1> -<form id="templateForm" role="form" method="POST" action="?do=dozmod§ion=templates&action=save"> +<p><i>{{lang_templatePageDescription}}</i></p> + +<form id="templateForm" role="form" method="POST" action="?do=dozmod&section=templates"> <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="save"> <div class="panel-group" id="accordion"> {{#templates}} - <div class="panel panel-default"> - <div id="heading_{{name}}" class="panel-heading"> + <div id="frame_{{name}}" class="panel panel-default"> + <div class="panel-heading"> <div class="panel-title"> <h4> <a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#panel_{{name}}"> @@ -24,21 +27,26 @@ <div class="panel-body"> <div id="msgbox_{{name}}"> </div> + <!-- <label for="n_{{name}}">{{lang_name}}</label> - <input name="templates[{{name}}][name]" value="{{name}}" class="form-control"/> - - <label for="n_{{description}}">{{lang_description}}</label> - <input name="templates[{{name}}][description]" value="{{description}}" class="form-control"/> - + <div class="form-group"> + <input id="n_{{name}}" name="templates[{{name}}][name]" value="{{name}}" class="form-control"/> + </div> + <label for="d_{{name}}">{{lang_description}}</label> + <div class="form-group"> + <input id="d_{{name}}" name="templates[{{name}}][description]" value="{{description}}" class="form-control"/> + </div> + --> <label for="ta_{{name}}">{{lang_template}}</label> - <br/> - <textarea data-mandatory="{{list_mandatoryVariables}}" name="templates[{{name}}][template]" data-setting="{{name}}" id="ta_{{name}}" - class="form-control templateEditor" style="min-height:200px" - >{{template}}</textarea> + <div class="form-group"> + <textarea data-mandatory="{{list_mandatoryVariables}}" name="templates[{{name}}][template]" + data-setting="{{name}}" id="ta_{{name}}" + class="form-control templateEditor" style="min-height:200px">{{template}}</textarea> + </div> - <h3>{{lang_placeholders}}</h3> + <h4>{{lang_placeholders}}</h4> <select name="templates[{{name}}][mandatory_variables]" multiple="multiple" class="hidden"> {{{html_mandatoryVariables}}} </select> @@ -56,16 +64,25 @@ {{/templates}} </div> - <div class="btn-group"> - <button type="button" onclick="sendForm()" class="btn btn-primary">{{lang_save}}</button> + <div class="pull-left"> + <button type="submit" onclick="return validateForm()" class="btn btn-primary">{{lang_save}}</button> </div> </form> +<form method="POST" action="?do=dozmod&section=templates"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" name="action" value="reset"> + <div> + <button type="submit" onclick="return confirm('{{lang_reallyResetTemplates}}')" class="btn btn-danger">{{lang_loadDefaults}}</button> + </div> +</form> +<div class="clearfix"></div> <script type="application/javascript"><!-- /* check that all necessary placeholders are used */ function validateForm() { var ok = true; + var $toppest = false; $('.templateEditor').each(function (i, editor) { @@ -76,7 +93,7 @@ function validateForm() { /* ? */ - if (mandatory.length == 1 && mandatory[0] == "") { + if (mandatory.length === 1 && mandatory[0] === "") { mandatory = []; } @@ -87,54 +104,36 @@ function validateForm() { missing.push(v); } }); - console.log("missing are"); - console.log(missing); var $msgBox = $("#msgbox_" + setting); - var $panel = $("#panel_" + setting); - var $header = $("#heading_" + setting); - + var $frame = $("#frame_" + setting); if (missing.length > 0) { /* add errors */ var missingL = missing.join(", "); - var msg="<strong>Fehler:</strong> Folgende wichtige Platzhalter wurden nicht verwendet: " +missingL; - console.log("msg box has " + $msgBox.size()); + var msg="<strong>{{lang_error}}:</strong> {{lang_followingPlaceholdersUnused}}: " +missingL; $msgBox.html('<div class="alert alert-danger">' + msg + '</div>'); - $panel.addClass('witherror'); - $header.addClass('witherror'); + $frame.addClass('witherror'); + if ($toppest === false || $toppest.offset().top > $frame.offset().top) { + $toppest = $frame; + } /* overall result */ ok = false; } else { $msgBox.html(""); - $panel.removeClass('witherror'); - $header.removeClass('witherror'); + $frame.removeClass('witherror'); } }); - return ok; -} - -function submitForm() { - console.log('sending form'); - $('#templateForm').submit(); -} - - -function sendForm() { - var ok = validateForm(); - if (ok) { - console.log("is ok"); - submitForm(); - } else { - console.log("form is not ok"); + if ($toppest !== false) { + $toppest[0].scrollIntoView(); } + return ok; } document.addEventListener("DOMContentLoaded", function () { - - - + validateForm(); // Do once in case invalid templates are in DB }); -</script> + +//--></script> |