Merge pull request #11867 from owncloud/settings-sidebar-admin

introduce sidebar for admin page
This commit is contained in:
Jan-Christoph Borchardt 2014-10-30 17:03:03 +01:00
commit 108cdeb892
5 changed files with 166 additions and 108 deletions

View File

@ -1,5 +1,7 @@
<form id="ldap" action="#" method="post"> <form id="ldap" class="section" action="#" method="post">
<div id="ldapSettings" class="section"> <h2><?php p($l->t('LDAP')); ?></h2>
<div id="ldapSettings">
<ul> <ul>
<?php foreach($_['toc'] as $id => $title) { ?> <?php foreach($_['toc'] as $id => $title) { ?>
<li id="<?php p($id); ?>"><a href="<?php p($id); ?>"><?php p($title); ?></a></li> <li id="<?php p($id); ?>"><a href="<?php p($id); ?>"><?php p($title); ?></a></li>

View File

@ -6,89 +6,117 @@
*/ */
OC_Util::checkAdminUser(); OC_Util::checkAdminUser();
OC_App::setActiveNavigationEntry("admin");
OCP\Util::addStyle('settings', 'settings'); $template = new OC_Template('settings', 'admin', 'user');
OCP\Util::addScript('settings', 'settings'); $htAccessWorking = OC_Util::isHtaccessWorking();
OCP\Util::addScript( "settings", "admin" );
OCP\Util::addScript( "settings", "log" );
OCP\Util::addScript( 'core', 'multiselect' );
OCP\Util::addScript('core', 'select2/select2');
OCP\Util::addStyle('core', 'select2/select2');
OCP\Util::addScript('core', 'setupchecks');
OC_App::setActiveNavigationEntry( "admin" );
$tmpl = new OC_Template( 'settings', 'admin', 'user'); $entries = OC_Log_Owncloud::getEntries(3);
$forms=OC_App::getForms('admin'); $entriesRemaining = count(OC_Log_Owncloud::getEntries(4)) > 3;
$htaccessworking=OC_Util::isHtaccessWorking();
$entries=OC_Log_Owncloud::getEntries(3);
$entriesremain = count(OC_Log_Owncloud::getEntries(4)) > 3;
$config = \OC::$server->getConfig(); $config = \OC::$server->getConfig();
$appConfig = \OC::$server->getAppConfig();
// Should we display sendmail as an option? // Should we display sendmail as an option?
$tmpl->assign('sendmail_is_available', (bool) findBinaryPath('sendmail')); $template->assign('sendmail_is_available', (bool)findBinaryPath('sendmail'));
$tmpl->assign('loglevel', OC_Config::getValue( "loglevel", 2 )); $template->assign('loglevel', $config->getSystemValue("loglevel", 2));
$tmpl->assign('mail_domain', OC_Config::getValue( "mail_domain", '' )); $template->assign('mail_domain', $config->getSystemValue("mail_domain", ''));
$tmpl->assign('mail_from_address', OC_Config::getValue( "mail_from_address", '' )); $template->assign('mail_from_address', $config->getSystemValue("mail_from_address", ''));
$tmpl->assign('mail_smtpmode', OC_Config::getValue( "mail_smtpmode", '' )); $template->assign('mail_smtpmode', $config->getSystemValue("mail_smtpmode", ''));
$tmpl->assign('mail_smtpsecure', OC_Config::getValue( "mail_smtpsecure", '' )); $template->assign('mail_smtpsecure', $config->getSystemValue("mail_smtpsecure", ''));
$tmpl->assign('mail_smtphost', OC_Config::getValue( "mail_smtphost", '' )); $template->assign('mail_smtphost', $config->getSystemValue("mail_smtphost", ''));
$tmpl->assign('mail_smtpport', OC_Config::getValue( "mail_smtpport", '' )); $template->assign('mail_smtpport', $config->getSystemValue("mail_smtpport", ''));
$tmpl->assign('mail_smtpauthtype', OC_Config::getValue( "mail_smtpauthtype", '' )); $template->assign('mail_smtpauthtype', $config->getSystemValue("mail_smtpauthtype", ''));
$tmpl->assign('mail_smtpauth', OC_Config::getValue( "mail_smtpauth", false )); $template->assign('mail_smtpauth', $config->getSystemValue("mail_smtpauth", false));
$tmpl->assign('mail_smtpname', OC_Config::getValue( "mail_smtpname", '' )); $template->assign('mail_smtpname', $config->getSystemValue("mail_smtpname", ''));
$tmpl->assign('mail_smtppassword', OC_Config::getValue( "mail_smtppassword", '' )); $template->assign('mail_smtppassword', $config->getSystemValue("mail_smtppassword", ''));
$tmpl->assign('entries', $entries); $template->assign('entries', $entries);
$tmpl->assign('entriesremain', $entriesremain); $template->assign('entriesremain', $entriesRemaining);
$tmpl->assign('htaccessworking', $htaccessworking); $template->assign('htaccessworking', $htAccessWorking);
$tmpl->assign('isLocaleWorking', OC_Util::isSetLocaleWorking()); $template->assign('isLocaleWorking', OC_Util::isSetLocaleWorking());
$tmpl->assign('isPhpCharSetUtf8', OC_Util::isPhpCharSetUtf8()); $template->assign('isPhpCharSetUtf8', OC_Util::isPhpCharSetUtf8());
$tmpl->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking()); $template->assign('isAnnotationsWorking', OC_Util::isAnnotationsWorking());
$tmpl->assign('has_fileinfo', OC_Util::fileInfoLoaded()); $template->assign('has_fileinfo', OC_Util::fileInfoLoaded());
$tmpl->assign('old_php', OC_Util::isPHPoutdated()); $template->assign('old_php', OC_Util::isPHPoutdated());
$tmpl->assign('backgroundjobs_mode', OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax')); $template->assign('backgroundjobs_mode', $appConfig->getValue('core', 'backgroundjobs_mode', 'ajax'));
$tmpl->assign('cron_log', OC_Config::getValue('cron_log', true)); $template->assign('cron_log', $config->getSystemValue('cron_log', true));
$tmpl->assign('lastcron', OC_Appconfig::getValue('core', 'lastcron', false)); $template->assign('lastcron', $appConfig->getValue('core', 'lastcron', false));
$tmpl->assign('shareAPIEnabled', OC_Appconfig::getValue('core', 'shareapi_enabled', 'yes')); $template->assign('shareAPIEnabled', $appConfig->getValue('core', 'shareapi_enabled', 'yes'));
$tmpl->assign('shareDefaultExpireDateSet', OC_Appconfig::getValue('core', 'shareapi_default_expire_date', 'no')); $template->assign('shareDefaultExpireDateSet', $appConfig->getValue('core', 'shareapi_default_expire_date', 'no'));
$tmpl->assign('shareExpireAfterNDays', OC_Appconfig::getValue('core', 'shareapi_expire_after_n_days', '7')); $template->assign('shareExpireAfterNDays', $appConfig->getValue('core', 'shareapi_expire_after_n_days', '7'));
$tmpl->assign('shareEnforceExpireDate', OC_Appconfig::getValue('core', 'shareapi_enforce_expire_date', 'no')); $template->assign('shareEnforceExpireDate', $appConfig->getValue('core', 'shareapi_enforce_expire_date', 'no'));
$excludeGroups = OC_Appconfig::getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false; $excludeGroups = $appConfig->getValue('core', 'shareapi_exclude_groups', 'no') === 'yes' ? true : false;
$tmpl->assign('shareExcludeGroups', $excludeGroups); $template->assign('shareExcludeGroups', $excludeGroups);
$excludedGroupsList = OC_Appconfig::getValue('core', 'shareapi_exclude_groups_list', ''); $excludedGroupsList = $appConfig->getValue('core', 'shareapi_exclude_groups_list', '');
$excludedGroupsList = explode(',', $excludedGroupsList); // FIXME: this should be JSON! $excludedGroupsList = explode(',', $excludedGroupsList); // FIXME: this should be JSON!
$tmpl->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList)); $template->assign('shareExcludedGroupsList', implode('|', $excludedGroupsList));
// Check if connected using HTTPS // Check if connected using HTTPS
$tmpl->assign('isConnectedViaHTTPS', OC_Request::serverProtocol() === 'https'); $template->assign('isConnectedViaHTTPS', OC_Request::serverProtocol() === 'https');
$tmpl->assign('enforceHTTPSEnabled', OC_Config::getValue( "forcessl", false)); $template->assign('enforceHTTPSEnabled', $config->getSystemValue("forcessl", false));
// If the current webroot is non-empty but the webroot from the config is, // If the current web root is non-empty but the web root from the config is,
// and system cron is used, the URL generator fails to build valid URLs. // and system cron is used, the URL generator fails to build valid URLs.
$shouldSuggestOverwriteWebroot = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' && $shouldSuggestOverwriteWebRoot = $config->getAppValue('core', 'backgroundjobs_mode', 'ajax') === 'cron' &&
\OC::$WEBROOT && \OC::$WEBROOT !== '/' && \OC::$WEBROOT && \OC::$WEBROOT !== '/' &&
!$config->getSystemValue('overwritewebroot', ''); !$config->getSystemValue('overwritewebroot', '');
$tmpl->assign('suggestedOverwriteWebroot', ($shouldSuggestOverwriteWebroot) ? \OC::$WEBROOT : ''); $suggestedOverwriteWebRoot = ($shouldSuggestOverwriteWebRoot) ? \OC::$WEBROOT : '';
$template->assign('suggestedOverwriteWebroot', $suggestedOverwriteWebRoot);
$tmpl->assign('allowLinks', OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes')); $template->assign('allowLinks', $appConfig->getValue('core', 'shareapi_allow_links', 'yes'));
$tmpl->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired()); $template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired());
$tmpl->assign('allowPublicUpload', OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes')); $template->assign('allowPublicUpload', $appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes'));
$tmpl->assign('allowResharing', OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes')); $template->assign('allowResharing', $appConfig->getValue('core', 'shareapi_allow_resharing', 'yes'));
$tmpl->assign('allowMailNotification', OC_Appconfig::getValue('core', 'shareapi_allow_mail_notification', 'no')); $template->assign('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no'));
$tmpl->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly()); $template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly());
$tmpl->assign('forms', array()); $databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false);
foreach($forms as $form) { $template->assign('databaseOverload', $databaseOverload);
$tmpl->append('forms', $form);
// add hardcoded forms from the template
$forms = OC_App::getForms('admin');
$l = OC_L10N::get('settings');
$formsAndMore = array();
if (OC_Request::serverProtocol() !== 'https' || !$htAccessWorking || !OC_Util::isAnnotationsWorking() ||
$suggestedOverwriteWebRoot || !OC_Util::isSetLocaleWorking() || !OC_Util::isPhpCharSetUtf8() ||
OC_Util::isPHPoutdated() || !OC_Util::fileInfoLoaded() || $databaseOverload
) {
$formsAndMore[] = array('anchor' => 'security-warning', 'section-name' => $l->t('Security & Setup Warnings'));
} }
$databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false); $formsMap = array_map(function ($form) {
$tmpl->assign('databaseOverload', $databaseOverload); if (preg_match('%(<h2[^>]*>.*?</h2>)%i', $form, $regs)) {
$sectionName = str_replace('<h2>', '', $regs[0]);
$sectionName = str_replace('</h2>', '', $sectionName);
$anchor = strtolower($sectionName);
$anchor = str_replace(' ', '-', $anchor);
$tmpl->printPage(); return array(
'anchor' => $anchor,
'section-name' => $sectionName,
'form' => $form
);
}
return array(
'form' => $form
);
}, $forms);
$formsAndMore = array_merge($formsAndMore, $formsMap);
// add bottom hardcoded forms from the template
$formsAndMore[] = array('anchor' => 'backgroundjobs', 'section-name' => $l->t('Cron'));
$formsAndMore[] = array('anchor' => 'shareAPI', 'section-name' => $l->t('Sharing'));
$formsAndMore[] = array('anchor' => 'security', 'section-name' => $l->t('Security'));
$formsAndMore[] = array('anchor' => 'mail_general_settings', 'section-name' => $l->t('Email Server'));
$formsAndMore[] = array('anchor' => 'log-section', 'section-name' => $l->t('Log'));
$template->assign('forms', $formsAndMore);
$template->printPage();
/** /**
* Try to find a programm * Try to find a program
* *
* @param string $program * @param string $program
* @return null|string * @return null|string

View File

@ -3,7 +3,8 @@ $(document).ready(function(){
// Hack to add a trusted domain // Hack to add a trusted domain
if (params.trustDomain) { if (params.trustDomain) {
OC.dialogs.confirm(t('core', 'Are you really sure you want add "{domain}" as trusted domain?', {domain: params.trustDomain}), OC.dialogs.confirm(t('core', 'Are you really sure you want add "{domain}" as trusted domain?',
{domain: params.trustDomain}),
t('core', 'Add trusted domain'), function(answer) { t('core', 'Add trusted domain'), function(answer) {
if(answer) { if(answer) {
$.ajax({ $.ajax({
@ -52,14 +53,13 @@ $(document).ready(function(){
}); });
$('#shareAPI input:not(#excludedGroups)').change(function() { $('#shareAPI input:not(#excludedGroups)').change(function() {
var value = $(this).val();
if ($(this).attr('type') === 'checkbox') { if ($(this).attr('type') === 'checkbox') {
if (this.checked) { if (this.checked) {
var value = 'yes'; value = 'yes';
} else { } else {
var value = 'no'; value = 'no';
} }
} else {
var value = $(this).val();
} }
OC.AppConfig.setValue('core', $(this).attr('name'), value); OC.AppConfig.setValue('core', $(this).attr('name'), value);
}); });

View File

@ -5,75 +5,77 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
OC.Log={ /* global formatDate */
reload:function(count){
if(!count){ OC.Log = {
count=OC.Log.loaded; reload: function (count) {
if (!count) {
count = OC.Log.loaded;
} }
OC.Log.loaded=0; OC.Log.loaded = 0;
$('#log tbody').empty(); $('#log tbody').empty();
OC.Log.getMore(count); OC.Log.getMore(count);
}, },
levels:['Debug','Info','Warning','Error','Fatal'], levels: ['Debug', 'Info', 'Warning', 'Error', 'Fatal'],
loaded:3,//are initially loaded loaded: 3,//are initially loaded
getMore:function(count){ getMore: function (count) {
count = count || 10; count = count || 10;
$.get(OC.filePath('settings','ajax','getlog.php'),{offset:OC.Log.loaded,count:count},function(result){ $.get(OC.filePath('settings', 'ajax', 'getlog.php'), {offset: OC.Log.loaded, count: count}, function (result) {
if(result.status === 'success'){ if (result.status === 'success') {
OC.Log.addEntries(result.data); OC.Log.addEntries(result.data);
if(!result.remain){ if (!result.remain) {
$('#moreLog').hide(); $('#moreLog').hide();
} }
$('#lessLog').show(); $('#lessLog').show();
} }
}); });
}, },
showLess:function(count){ showLess: function (count) {
count = count || 10; count = count || 10;
//calculate remaining items - at least 3 //calculate remaining items - at least 3
OC.Log.loaded = Math.max(3,OC.Log.loaded-count); OC.Log.loaded = Math.max(3, OC.Log.loaded - count);
$('#moreLog').show(); $('#moreLog').show();
// remove all non-remaining items // remove all non-remaining items
$('#log tr').slice(OC.Log.loaded).remove(); $('#log tr').slice(OC.Log.loaded).remove();
if(OC.Log.loaded <= 3) { if (OC.Log.loaded <= 3) {
$('#lessLog').hide(); $('#lessLog').hide();
} }
}, },
addEntries:function(entries){ addEntries: function (entries) {
for(var i=0;i<entries.length;i++){ for (var i = 0; i < entries.length; i++) {
var entry=entries[i]; var entry = entries[i];
var row=$('<tr/>'); var row = $('<tr/>');
var levelTd=$('<td/>'); var levelTd = $('<td/>');
levelTd.text(OC.Log.levels[entry.level]); levelTd.text(OC.Log.levels[entry.level]);
row.append(levelTd); row.append(levelTd);
var appTd=$('<td/>'); var appTd = $('<td/>');
appTd.text(entry.app); appTd.text(entry.app);
row.append(appTd); row.append(appTd);
var messageTd=$('<td/>'); var messageTd = $('<td/>');
messageTd.text(entry.message); messageTd.text(entry.message);
row.append(messageTd); row.append(messageTd);
var timeTd=$('<td/>'); var timeTd = $('<td/>');
timeTd.addClass('date'); timeTd.addClass('date');
if(isNaN(entry.time)){ if (isNaN(entry.time)) {
timeTd.text(entry.time); timeTd.text(entry.time);
} else { } else {
timeTd.text(formatDate(entry.time*1000)); timeTd.text(formatDate(entry.time * 1000));
} }
row.append(timeTd); row.append(timeTd);
$('#log').append(row); $('#log').append(row);
} }
OC.Log.loaded += entries.length; OC.Log.loaded += entries.length;
} }
} };
$(document).ready(function(){ $(document).ready(function () {
$('#moreLog').click(function(){ $('#moreLog').click(function () {
OC.Log.getMore(); OC.Log.getMore();
}) });
$('#lessLog').click(function(){ $('#lessLog').click(function () {
OC.Log.showLess(); OC.Log.showLess();
}) });
}); });

View File

@ -8,6 +8,16 @@
* @var array $_ * @var array $_
* @var \OCP\IL10N $l * @var \OCP\IL10N $l
*/ */
style('settings', 'settings');
script('settings', 'settings');
script( "settings", "admin" );
script( "settings", "log" );
script( 'core', 'multiselect' );
script('core', 'select2/select2');
style('core', 'select2/select2');
script('core', 'setupchecks');
$levels = array('Debug', 'Info', 'Warning', 'Error', 'Fatal'); $levels = array('Debug', 'Info', 'Warning', 'Error', 'Fatal');
$levelLabels = array( $levelLabels = array(
$l->t( 'Everything (fatal issues, errors, warnings, info, debug)' ), $l->t( 'Everything (fatal issues, errors, warnings, info, debug)' ),
@ -40,9 +50,23 @@ if ($_['sendmail_is_available']) {
if ($_['mail_smtpmode'] == 'qmail') { if ($_['mail_smtpmode'] == 'qmail') {
$mail_smtpmode[] = 'qmail'; $mail_smtpmode[] = 'qmail';
} }
?> ?>
<div id="app-navigation">
<ul>
<?php foreach($_['forms'] as $form) {
if (isset($form['anchor'])) {
$anchor = '#' . $form['anchor'];
$sectionName = $form['section-name'];
print_unescaped(sprintf("<li><a href='%s'>%s</a></li>", OC_Util::sanitizeHTML($anchor), OC_Util::sanitizeHTML($sectionName)));
}
}?>
</ul>
</div>
<div id="app-content">
<div id="security-warning">
<?php <?php
// is ssl working ? // is ssl working ?
@ -72,7 +96,6 @@ if (!$_['htaccessworking']) {
</div> </div>
<?php <?php
} }
// Are doc blocks accessible? // Are doc blocks accessible?
if (!$_['isAnnotationsWorking']) { if (!$_['isAnnotationsWorking']) {
?> ?>
@ -193,10 +216,12 @@ if ($_['suggestedOverwriteWebroot']) {
?></span> ?></span>
</div> </div>
</div> </div>
<?php foreach ($_['forms'] as $form) { </div>
print_unescaped($form); <?php foreach($_['forms'] as $form) {
} if (isset($form['form'])) {?>
;?> <div id="<?php isset($form['anchor']) ? p($form['anchor']) : p('');?>"><?php print_unescaped($form['form']);?></div>
<?php }
};?>
<div class="section" id="backgroundjobs"> <div class="section" id="backgroundjobs">
<h2 class="inlineblock"><?php p($l->t('Cron'));?></h2> <h2 class="inlineblock"><?php p($l->t('Cron'));?></h2>
@ -419,7 +444,7 @@ if ($_['suggestedOverwriteWebroot']) {
<span id="sendtestmail_msg" class="msg"></span> <span id="sendtestmail_msg" class="msg"></span>
</div> </div>
<div class="section"> <div class="section" id="log-section">
<h2><?php p($l->t('Log'));?></h2> <h2><?php p($l->t('Log'));?></h2>
<?php p($l->t('Log level'));?> <select name='loglevel' id='loglevel'> <?php p($l->t('Log level'));?> <select name='loglevel' id='loglevel'>
<?php for ($i = 0; $i < 5; $i++): <?php for ($i = 0; $i < 5; $i++):
@ -472,3 +497,4 @@ if ($_['suggestedOverwriteWebroot']) {
<div class="section credits-footer"> <div class="section credits-footer">
<p><?php print_unescaped($theme->getShortFooter()); ?></p> <p><?php print_unescaped($theme->getShortFooter()); ?></p>
</div> </div>
</div>