admin settings design

merge-requests/1/head
Julien Veyssier 2016-12-13 11:53:39 +01:00
parent bac51dc7cc
commit 2ef87ce9f8
5 changed files with 26 additions and 42 deletions

View File

@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] ## [Unreleased]
### TODO
- check if name is valid in admin settings
- explain things in admin settings
- compat jpg
### Added ### Added
- file description field - file description field
- 'destination' readonly field indicating full save path - 'destination' readonly field indicating full save path

View File

@ -153,7 +153,6 @@ class UtilsController extends Controller {
Http::STATUS_UNPROCESSABLE_ENTITY Http::STATUS_UNPROCESSABLE_ENTITY
); );
} }
$name = '';
if(!empty($newSymbol)) { if(!empty($newSymbol)) {
$filepath = $this->config->getSystemValue('datadirectory').'/gpxedit/symbols/'.$filename.'.png'; $filepath = $this->config->getSystemValue('datadirectory').'/gpxedit/symbols/'.$filename.'.png';
$content = file_get_contents($newSymbol['tmp_name']); $content = file_get_contents($newSymbol['tmp_name']);

View File

@ -2,6 +2,9 @@ button#addExtraSymbol{
width: 33px; width: 33px;
height: 33px; height: 33px;
} }
table#extraSymbolsTable td{
text-align: center !important;
}
.extraSymbol img{ .extraSymbol img{
width: 25px; width: 25px;
height: 25px; height: 25px;

View File

@ -2,42 +2,15 @@
if (!OCA.GpxEdit) { if (!OCA.GpxEdit) {
OCA.GpxEdit = {}; OCA.GpxEdit = {};
} }
OCA.GpxEdit.Admin = {
initialize: function() {
$('#submitMaxUpload').on('click', _.bind(this._onClickSubmitMaxUpload, this));
},
_onClickSubmitMaxUpload: function () {
OC.msg.startSaving('#maxUploadSizeSettingsMsg');
var request = $.ajax({
url: OC.generateUrl('/apps/files/settings/maxUpload'),
type: 'POST',
data: {
maxUploadSize: $('#maxUploadSize').val()
}
});
request.done(function (data) {
$('#maxUploadSize').val(data.maxUploadSize);
OC.msg.finishedSuccess('#maxUploadSizeSettingsMsg', 'Saved');
});
request.fail(function () {
OC.msg.finishedError('#maxUploadSizeSettingsMsg', 'Error');
});
}
}
})(); })();
function addLogoLine(name){ function addLogoLine(name){
var url = OC.generateUrl('/apps/gpxedit/getExtraSymbol?'); var url = OC.generateUrl('/apps/gpxedit/getExtraSymbol?');
var fullurl = url+'name='+encodeURI(name); var fullurl = url+'name='+encodeURI(name);
var nameWe = name.replace(/\.png$/, ''); var nameWe = name.replace(/\.png$/, '');
$('div#extraSymbols').append('<p class="extraSymbol" id="'+nameWe+'">'+ $('div#extraSymbols table').append('<tr class="extraSymbol" id="'+nameWe+'">'+
'<img src="'+fullurl+'"><label> '+nameWe+' </label>'+ '<td><img src="'+fullurl+'"></td><td><label> '+nameWe+' </label></td>'+
'<button class="delExtraSymbol icon-delete icon" name="'+name+'" title="Remove"></button></p>'); '<td><button class="delExtraSymbol icon-delete icon" name="'+name+'" title="Remove"></button></td></tr>');
} }
function deleteLogo(button){ function deleteLogo(button){
@ -48,7 +21,7 @@ function deleteLogo(button){
} }
var url = OC.generateUrl('/apps/gpxedit/deleteExtraSymbol'); var url = OC.generateUrl('/apps/gpxedit/deleteExtraSymbol');
$.post(url, req).done(function (response) { $.post(url, req).done(function (response) {
button.parent().remove(); button.parent().parent().remove();
OC.msg.finishedSuccess('#extraSymbolsSettingsMsg', response.data.message); OC.msg.finishedSuccess('#extraSymbolsSettingsMsg', response.data.message);
}).fail(function(){ }).fail(function(){
OC.msg.finishedError('#extraSymbolsSettingsMsg', 'Failed'); OC.msg.finishedError('#extraSymbolsSettingsMsg', 'Failed');
@ -57,9 +30,8 @@ function deleteLogo(button){
} }
$(document).ready(function() { $(document).ready(function() {
OCA.GpxEdit.Admin.initialize();
var url = OC.generateUrl('/apps/gpxedit/getExtraSymbol?'); var url = OC.generateUrl('/apps/gpxedit/getExtraSymbol?');
$('p.extraSymbol img').each(function(){ $('tr.extraSymbol img').each(function(){
var filename = $(this).attr('src'); var filename = $(this).attr('src');
var fullurl = url+'name='+encodeURI(filename); var fullurl = url+'name='+encodeURI(filename);
$(this).attr('src', fullurl); $(this).attr('src', fullurl);
@ -70,6 +42,7 @@ $(document).ready(function() {
dropZone: null, dropZone: null,
done: function (e, response) { done: function (e, response) {
//preview('logoMime', response.result.data.name); //preview('logoMime', response.result.data.name);
//alert('success '+response.result.data.name);
addLogoLine(response.result.data.name); addLogoLine(response.result.data.name);
OC.msg.finishedSaving('#extraSymbolsSettingsMsg', response.result); OC.msg.finishedSaving('#extraSymbolsSettingsMsg', response.result);
$('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small'); $('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small');
@ -77,9 +50,12 @@ $(document).ready(function() {
submit: function(e, response) { submit: function(e, response) {
OC.msg.startSaving('#extraSymbolsSettingsMsg'); OC.msg.startSaving('#extraSymbolsSettingsMsg');
$('label#uploadsymbol').removeClass('icon-upload').addClass('icon-loading-small'); $('label#uploadsymbol').removeClass('icon-upload').addClass('icon-loading-small');
//alert(Object.keys(e.target));
//alert('submit '+e.target);
}, },
fail: function (e, response){ fail: function (e, response){
OC.msg.finishedError('#extraSymbolsSettingsMsg', response.data.message); //alert('fail '+Object.keys(response));
OC.msg.finishedError('#extraSymbolsSettingsMsg', 'failed');
$('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small'); $('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small');
} }
}; };

View File

@ -6,26 +6,27 @@ OCP\Util::addstyle('gpxedit', 'admin');
<div class="section" id="gpxedit"> <div class="section" id="gpxedit">
<h2><?php p($l->t('GpxEdit additional settings')); ?></h2> <h2><?php p($l->t('GpxEdit additional settings')); ?></h2>
<label><?php p($l->t( 'Extra symbols' )); ?> </label> <label><?php p($l->t( 'Extra symbols' )); ?> </label>
<span id="extraSymbolsSettingsMsg" class="msg"></span>
<br /> <br />
<div id="extraSymbols"> <div id="extraSymbols">
<table id="extraSymbolsTable">
<?php <?php
foreach($_['extraSymbolList'] as $symbol){ foreach($_['extraSymbolList'] as $symbol){
echo '<p class="extraSymbol" id="'; echo '<tr class="extraSymbol" id="';
p($symbol['smallname']); p($symbol['smallname']);
echo '">'; echo '"><td>';
echo '<img src="'; echo '<img src="';
p($symbol['name']); p($symbol['name']);
echo '"/>'; echo '"/></td><td>';
echo '<label> '; echo '<label> ';
p($symbol['smallname']); p($symbol['smallname']);
echo ' </label>'; echo ' </label></td><td>';
echo '<button class="delExtraSymbol icon-delete icon" name="'; echo '<button class="delExtraSymbol icon-delete icon" name="';
p($symbol['name']); p($symbol['name']);
echo '" title="Remove"></button>'; echo '" title="Remove"></button>';
echo '</p>'; echo '</td></tr>';
} }
?> ?>
</table>
</div> </div>
<!--button id="addExtraSymbol" class="inlineblock button icon-upload" title="Upload new symbol image"></button--> <!--button id="addExtraSymbol" class="inlineblock button icon-upload" title="Upload new symbol image"></button-->
@ -33,7 +34,8 @@ OCP\Util::addstyle('gpxedit', 'admin');
<label for="addExtraSymbolName">New symbol name :</label> <label for="addExtraSymbolName">New symbol name :</label>
<input type="text" name="addExtraSymbolName" id="addExtraSymbolName"></input> <input type="text" name="addExtraSymbolName" id="addExtraSymbolName"></input>
<input id="uploadsymbol" class="upload-symbol-field" name="uploadsymbol" type="file"> <input id="uploadsymbol" class="upload-symbol-field" name="uploadsymbol" type="file"></input>
<label for="uploadsymbol" class="button icon-upload svg" id="uploadsymbol" title="<?php p($l->t('Upload new symbol image')) ?>"></label> <label for="uploadsymbol" class="button icon-upload svg" id="uploadsymbol" title="<?php p($l->t('Upload new symbol image')) ?>"></label>
<span id="extraSymbolsSettingsMsg" class="msg"></span>
</form> </form>
</div> </div>