admin settings text, check if png

merge-requests/1/head
Julien Veyssier 2016-12-13 12:56:46 +01:00
parent 2ef87ce9f8
commit bbf0df0bf6
5 changed files with 27 additions and 10 deletions

View File

@ -6,12 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] ## [Unreleased]
### TODO ### TODO
- check if name is valid in admin settings
- explain things in admin settings
- compat jpg - compat jpg
### Added ### Added
- file description field - file description field
- 'destination' readonly field indicating full save path - 'destination' readonly field indicating full save path
- admin setting section to add extra symbols
### Changed ### Changed
- keep time information in loaded tracks/routes/waypoints, written in saved files - keep time information in loaded tracks/routes/waypoints, written in saved files

View File

@ -143,6 +143,18 @@ class UtilsController extends Controller {
public function uploadExtraSymbol($addExtraSymbolName) { public function uploadExtraSymbol($addExtraSymbolName) {
$newSymbol = $this->request->getUploadedFile('uploadsymbol'); $newSymbol = $this->request->getUploadedFile('uploadsymbol');
$filename = str_replace(array('../', '..\\', '/'), '', $addExtraSymbolName); $filename = str_replace(array('../', '..\\', '/'), '', $addExtraSymbolName);
if (!endswith($newSymbol['name'], '.png')){
return new DataResponse(
[
'data' =>
[
'message' => 'File has to be a png'
],
'status' => 'fail'
],
Http::STATUS_UNPROCESSABLE_ENTITY
);
}
if (empty($newSymbol)) { if (empty($newSymbol)) {
return new DataResponse( return new DataResponse(
[ [

View File

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

View File

@ -41,8 +41,6 @@ $(document).ready(function() {
pasteZone: null, pasteZone: null,
dropZone: null, dropZone: null,
done: function (e, response) { done: function (e, response) {
//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');
@ -50,12 +48,14 @@ $(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)); if ($('input#addExtraSymbolName').val() === ''){
//alert('submit '+e.target); OC.msg.finishedError('#extraSymbolsSettingsMsg', 'Empty symbol name');
e.preventDefault();
$('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small');
}
}, },
fail: function (e, response){ fail: function (e, response){
//alert('fail '+Object.keys(response)); OC.msg.finishedError('#extraSymbolsSettingsMsg', response._response.jqXHR.responseJSON.data.message);
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

@ -5,7 +5,9 @@ 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> <h3><?php p($l->t('Extra symbols')); ?> </h3>
<label><?php p($l->t('Those symbols will be available in GpxEdit.')); ?></label><br/>
<label><?php p($l->t('Keep in mind that only symbol names are saved in the gpx files. Other programs will display default symbol if they do not know a symbol name.')); ?></label><br/>
<br /> <br />
<div id="extraSymbols"> <div id="extraSymbols">
<table id="extraSymbolsTable"> <table id="extraSymbolsTable">
@ -28,8 +30,9 @@ OCP\Util::addstyle('gpxedit', 'admin');
?> ?>
</table> </table>
</div> </div>
<!--button id="addExtraSymbol" class="inlineblock button icon-upload" title="Upload new symbol image"></button-->
<label><?php p($l->t('Recommended image ratio : 1:1')); ?></label><br/>
<label><?php p($l->t('Recommended image resolution : between 24x24 and 50x50')); ?></label><br/>
<form class="uploadButton" method="post" action="<?php p($_['uploadPath']) ?>"> <form class="uploadButton" method="post" action="<?php p($_['uploadPath']) ?>">
<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>