mirror of
https://github.com/nextcloud/nextcloudpi.git
synced 2026-01-10 15:12:01 -03:30
ncp-web: file type and case insensitive search
This commit is contained in:
parent
bda1fc468d
commit
1a056212f1
@ -36,7 +36,7 @@ HTML;
|
||||
|
||||
$class = '';
|
||||
if (array_key_exists('type', $param) && ($param['type'] == 'directory' || $param['type'] == 'file'))
|
||||
$class = 'path';
|
||||
$class = $param['type'];
|
||||
|
||||
$ret .= "<td>
|
||||
<input type=\"text\"
|
||||
@ -54,9 +54,19 @@ HTML;
|
||||
if (array_key_exists('type', $param) && $param['type'] == 'directory')
|
||||
{
|
||||
if (file_exists($param['value']))
|
||||
$ret .= " <span class=\"ok-field\">directory exists</span>";
|
||||
$ret .= " <span class=\"ok-field\">path exists</span>";
|
||||
else
|
||||
$ret .= " <span class=\"error-field\">directory doesn't exist</span>";
|
||||
$ret .= " <span class=\"error-field\">path doesn't exist</span>";
|
||||
}
|
||||
|
||||
if (array_key_exists('type', $param) && $param['type'] == 'file')
|
||||
{
|
||||
error_log($param['value']);
|
||||
error_log(dirname($param['value']));
|
||||
if (file_exists(dirname($param['value'])))
|
||||
$ret .= " <span class=\"ok-field\">path exists</span>";
|
||||
else
|
||||
$ret .= " <span class=\"error-field\">path doesn't exist</span>";
|
||||
}
|
||||
|
||||
$ret .= "</td>";
|
||||
|
||||
@ -152,7 +152,8 @@ function filter_apps(e)
|
||||
{
|
||||
if (e && e.key === 'Enter')
|
||||
{
|
||||
var match = ncp_app_list.find(function(app) { if (app.id.indexOf(search_box.value) !== -1) return app; });
|
||||
if (search_box.value.length == 0 ) return;
|
||||
var match = ncp_app_list.find(function(app) { if (app.id.toLowerCase().indexOf(search_box.value.toLowerCase()) !== -1) return app; });
|
||||
if (!match) return;
|
||||
app_clicked($('#' + match.id));
|
||||
ncp_app_list.show();
|
||||
@ -167,7 +168,7 @@ function filter_apps(e)
|
||||
|
||||
ncp_app_list.hide();
|
||||
ncp_app_list.each( function(app){
|
||||
if (app.id.indexOf(search_box.value) !== -1)
|
||||
if (app.id.toLowerCase().indexOf(search_box.value.toLowerCase()) !== -1)
|
||||
app.style.display = 'block';
|
||||
}
|
||||
);
|
||||
@ -303,12 +304,46 @@ $(function()
|
||||
);
|
||||
|
||||
// Path fields
|
||||
$( '.path' ).on('change', function(e)
|
||||
$('.directory').on('change', function(e)
|
||||
{
|
||||
var span = this.up().select('span', true);
|
||||
var path = this.get('.value');
|
||||
|
||||
// request
|
||||
$.request('post', 'ncp-launcher.php', { action:'path-exists',
|
||||
value: this.get('.value'),
|
||||
value: path,
|
||||
csrf_token: $('#csrf-token-cfg').get('.value') }).then(
|
||||
function success( result )
|
||||
{
|
||||
var ret = $.parseJSON( result );
|
||||
if ( ret.token )
|
||||
$('#csrf-token-cfg').set( { value: ret.token } );
|
||||
if ( ret.ret && ret.ret == '0' ) // means that the process was launched
|
||||
{
|
||||
span.fill("path exists")
|
||||
span.set('-error-field');
|
||||
span.set('+ok-field');
|
||||
}
|
||||
else
|
||||
{
|
||||
span.fill("path doesn't exist")
|
||||
span.set('-ok-field');
|
||||
span.set('+error-field');
|
||||
}
|
||||
}
|
||||
).error( errorMsg )
|
||||
} );
|
||||
$('.file').on('change', function(e)
|
||||
{
|
||||
function dirname(path) { return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, ''); }
|
||||
|
||||
var span = this.up().select('span', true);
|
||||
console.log(span);
|
||||
var path = dirname(this.get('.value'));
|
||||
|
||||
// request
|
||||
$.request('post', 'ncp-launcher.php', { action:'path-exists',
|
||||
value: path,
|
||||
csrf_token: $('#csrf-token-cfg').get('.value') }).then(
|
||||
function success( result )
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user