refs #3 add ability to choose file type to load when loading folder
parent
3b0093cd9b
commit
9b8b9aa44c
|
@ -268,7 +268,7 @@ class PageController extends Controller {
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
* @NoCSRFRequired
|
* @NoCSRFRequired
|
||||||
*/
|
*/
|
||||||
public function getfoldergpxs($path) {
|
public function getfoldergpxs($path, $type) {
|
||||||
$userFolder = \OC::$server->getUserFolder();
|
$userFolder = \OC::$server->getUserFolder();
|
||||||
$cleanpath = str_replace(array('../', '..\\'), '', $path);
|
$cleanpath = str_replace(array('../', '..\\'), '', $path);
|
||||||
$gpxs = Array();
|
$gpxs = Array();
|
||||||
|
@ -277,14 +277,26 @@ class PageController extends Controller {
|
||||||
if ($folder->getType() === \OCP\Files\FileInfo::TYPE_FOLDER){
|
if ($folder->getType() === \OCP\Files\FileInfo::TYPE_FOLDER){
|
||||||
foreach ($folder->getDirectoryListing() as $file) {
|
foreach ($folder->getDirectoryListing() as $file) {
|
||||||
if ($file->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
|
if ($file->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
|
||||||
if (endswith($file->getName(), '.GPX') or endswith($file->getName(), '.gpx')){
|
if ( ($type === 'all' or $type === '.gpx')
|
||||||
|
and (endswith($file->getName(), '.GPX') or endswith($file->getName(), '.gpx'))
|
||||||
|
){
|
||||||
$gpxContent = $file->getContent();
|
$gpxContent = $file->getContent();
|
||||||
array_push($gpxs, $gpxContent);
|
array_push($gpxs, $gpxContent);
|
||||||
}
|
}
|
||||||
else if (getProgramPath('gpsbabel') !== null and
|
else if (getProgramPath('gpsbabel') !== null and
|
||||||
(endswith($file->getName(), '.KML') or endswith($file->getName(), '.kml') or
|
(
|
||||||
endswith($file->getName(), '.JPG') or endswith($file->getName(), '.jpg') or
|
( ($type === 'all' or $type === '.kml')
|
||||||
endswith($file->getName(), '.CSV') or endswith($file->getName(), '.csv'))
|
and (endswith($file->getName(), '.KML') or endswith($file->getName(), '.kml'))
|
||||||
|
)
|
||||||
|
or
|
||||||
|
( ($type === 'all' or $type === '.jpg')
|
||||||
|
and (endswith($file->getName(), '.JPG') or endswith($file->getName(), '.jpg'))
|
||||||
|
)
|
||||||
|
or
|
||||||
|
( ($type === 'all' or $type === '.csv')
|
||||||
|
and (endswith($file->getName(), '.CSV') or endswith($file->getName(), '.csv'))
|
||||||
|
)
|
||||||
|
)
|
||||||
){
|
){
|
||||||
$gpxContent = $this->toGpx($file);
|
$gpxContent = $this->toGpx($file);
|
||||||
array_push($gpxs, $gpxContent);
|
array_push($gpxs, $gpxContent);
|
||||||
|
|
|
@ -798,7 +798,19 @@ h2.popupTitle{
|
||||||
#clearButton i{
|
#clearButton i{
|
||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
#saveButton, #loadButton, #loadFolderButton{
|
|
||||||
|
#divloadfolder{
|
||||||
|
width: 80%;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
select#loadtypeselect{
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
#loadFolderButton{
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#saveButton, #loadButton{
|
||||||
display:block;
|
display:block;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
|
|
@ -962,8 +962,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFolder(folder) {
|
function loadFolder(folder) {
|
||||||
|
var type = $('select#loadtypeselect').val();
|
||||||
var req = {
|
var req = {
|
||||||
path: folder
|
path: folder,
|
||||||
|
type: type
|
||||||
};
|
};
|
||||||
var url = OC.generateUrl('/apps/gpxedit/getfoldergpxs');
|
var url = OC.generateUrl('/apps/gpxedit/getfoldergpxs');
|
||||||
$('#loadingpc').text('0');
|
$('#loadingpc').text('0');
|
||||||
|
@ -989,8 +991,6 @@
|
||||||
if ($('#clearbeforeload').is(':checked')) {
|
if ($('#clearbeforeload').is(':checked')) {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
console.log(Object.keys(response));
|
|
||||||
console.log('len : '+response.gpxs.length);
|
|
||||||
if (response.gpxs.length === 0) {
|
if (response.gpxs.length === 0) {
|
||||||
OC.dialogs.alert('The folder does not exist or does not contain any compatible file',
|
OC.dialogs.alert('The folder does not exist or does not contain any compatible file',
|
||||||
'Load folder error');
|
'Load folder error');
|
||||||
|
@ -1514,8 +1514,9 @@
|
||||||
gpxedit.currentAjax.abort();
|
gpxedit.currentAjax.abort();
|
||||||
hideLoadingAnimation();
|
hideLoadingAnimation();
|
||||||
}
|
}
|
||||||
|
var type = $('select#loadtypeselect').val();
|
||||||
OC.dialogs.filepicker(
|
OC.dialogs.filepicker(
|
||||||
t('gpxedit', 'Load folder (all compatible file inside)'),
|
t('gpxedit', 'Load folder ('+type+')'),
|
||||||
function(targetPath) {
|
function(targetPath) {
|
||||||
loadFolderAction(targetPath);
|
loadFolderAction(targetPath);
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,7 +25,17 @@ p($_['gpxedit_version']);
|
||||||
</form>
|
</form>
|
||||||
<hr/>
|
<hr/>
|
||||||
<button id="loadButton"><i class="fa fa-file-o"></i> <?php p($l->t('Load file'));?></button>
|
<button id="loadButton"><i class="fa fa-file-o"></i> <?php p($l->t('Load file'));?></button>
|
||||||
|
<div id="divloadfolder">
|
||||||
<button id="loadFolderButton"><i class="fa fa-folder-open-o"></i> <?php p($l->t('Load directory'));?></button>
|
<button id="loadFolderButton"><i class="fa fa-folder-open-o"></i> <?php p($l->t('Load directory'));?></button>
|
||||||
|
<select id="loadtypeselect">
|
||||||
|
<option value="all">all</option>
|
||||||
|
<option value=".jpg">jpg</option>
|
||||||
|
<option value=".gpx">gpx</option>
|
||||||
|
<option value=".kml">kml</option>
|
||||||
|
<option value=".csv">csv</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div style="clear:both"></div>
|
||||||
<hr/>
|
<hr/>
|
||||||
<h2 id="savetitle"><?php p($l->t('Save'));?></h2>
|
<h2 id="savetitle"><?php p($l->t('Save'));?></h2>
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Reference in New Issue