From bbf0df0bf6c0ea0557ed34278afc74f7269499e5 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Tue, 13 Dec 2016 12:56:46 +0100 Subject: [PATCH] admin settings text, check if png --- CHANGELOG.md | 3 +-- controller/utilscontroller.php | 12 ++++++++++++ css/admin.css | 3 +++ js/admin.js | 12 ++++++------ templates/admin.php | 7 +++++-- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95931f7..8f0e938 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### TODO -- check if name is valid in admin settings -- explain things in admin settings - compat jpg ### Added - file description field - 'destination' readonly field indicating full save path +- admin setting section to add extra symbols ### Changed - keep time information in loaded tracks/routes/waypoints, written in saved files diff --git a/controller/utilscontroller.php b/controller/utilscontroller.php index fc86461..29178b7 100644 --- a/controller/utilscontroller.php +++ b/controller/utilscontroller.php @@ -143,6 +143,18 @@ class UtilsController extends Controller { public function uploadExtraSymbol($addExtraSymbolName) { $newSymbol = $this->request->getUploadedFile('uploadsymbol'); $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)) { return new DataResponse( [ diff --git a/css/admin.css b/css/admin.css index 40d4f44..d05c5f0 100644 --- a/css/admin.css +++ b/css/admin.css @@ -2,6 +2,9 @@ button#addExtraSymbol{ width: 33px; height: 33px; } +table#extraSymbolsTable{ + width: 330px; +} table#extraSymbolsTable td{ text-align: center !important; } diff --git a/js/admin.js b/js/admin.js index 9cf933f..8a6702c 100644 --- a/js/admin.js +++ b/js/admin.js @@ -41,8 +41,6 @@ $(document).ready(function() { pasteZone: null, dropZone: null, done: function (e, response) { - //preview('logoMime', response.result.data.name); - //alert('success '+response.result.data.name); addLogoLine(response.result.data.name); OC.msg.finishedSaving('#extraSymbolsSettingsMsg', response.result); $('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small'); @@ -50,12 +48,14 @@ $(document).ready(function() { submit: function(e, response) { OC.msg.startSaving('#extraSymbolsSettingsMsg'); $('label#uploadsymbol').removeClass('icon-upload').addClass('icon-loading-small'); - //alert(Object.keys(e.target)); - //alert('submit '+e.target); + if ($('input#addExtraSymbolName').val() === ''){ + OC.msg.finishedError('#extraSymbolsSettingsMsg', 'Empty symbol name'); + e.preventDefault(); + $('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small'); + } }, fail: function (e, response){ - //alert('fail '+Object.keys(response)); - OC.msg.finishedError('#extraSymbolsSettingsMsg', 'failed'); + OC.msg.finishedError('#extraSymbolsSettingsMsg', response._response.jqXHR.responseJSON.data.message); $('label#uploadsymbol').addClass('icon-upload').removeClass('icon-loading-small'); } }; diff --git a/templates/admin.php b/templates/admin.php index 6f7775b..ab419f9 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -5,7 +5,9 @@ OCP\Util::addstyle('gpxedit', 'admin');

t('GpxEdit additional settings')); ?>

- +

t('Extra symbols')); ?>

+
+

@@ -28,8 +30,9 @@ OCP\Util::addstyle('gpxedit', 'admin'); ?>
- +
+