WebUI autocomplete scripts
This commit is contained in:
parent
ef44b06bfb
commit
2e983ffed2
2 changed files with 15 additions and 3 deletions
|
@ -1,12 +1,15 @@
|
||||||
from flask_wtf import Form
|
from flask_wtf import Form
|
||||||
from wtforms import StringField, validators, SubmitField, ValidationError
|
from wtforms import StringField, validators, SubmitField, ValidationError
|
||||||
|
|
||||||
|
from larigira.formutils import AutocompleteStringField
|
||||||
|
|
||||||
class ScriptAudioForm(Form):
|
class ScriptAudioForm(Form):
|
||||||
nick = StringField('Audio nick', validators=[validators.required()],
|
nick = StringField('Audio nick', validators=[validators.required()],
|
||||||
description='A simple name to recognize this audio')
|
description='A simple name to recognize this audio')
|
||||||
name = StringField('Name', validators=[validators.required()],
|
name = AutocompleteStringField(
|
||||||
description='filename (NOT path) of the script')
|
'dl-suggested-scripts',
|
||||||
|
'Name', validators=[validators.required()],
|
||||||
|
description='filename (NOT path) of the script')
|
||||||
args = StringField('Arguments',
|
args = StringField('Arguments',
|
||||||
description='arguments, separated by ";"')
|
description='arguments, separated by ";"')
|
||||||
submit = SubmitField('Submit')
|
submit = SubmitField('Submit')
|
||||||
|
|
|
@ -56,6 +56,13 @@ def get_suggested_dirs():
|
||||||
return list(dirset)
|
return list(dirset)
|
||||||
|
|
||||||
|
|
||||||
|
def get_suggested_scripts():
|
||||||
|
base = get_conf()['SCRIPTS_PATH']
|
||||||
|
fnames = [f for f in os.listdir(base)
|
||||||
|
if os.access(os.path.join(base, f), os.R_OK | os.X_OK)]
|
||||||
|
return fnames
|
||||||
|
|
||||||
|
|
||||||
def get_suggestions():
|
def get_suggestions():
|
||||||
files = get_suggested_files()
|
files = get_suggested_files()
|
||||||
if len(files) > 200:
|
if len(files) > 200:
|
||||||
|
@ -63,7 +70,9 @@ def get_suggestions():
|
||||||
files = files[:200]
|
files = files[:200]
|
||||||
return dict(
|
return dict(
|
||||||
files=files,
|
files=files,
|
||||||
dirs=get_suggested_dirs())
|
dirs=get_suggested_dirs(),
|
||||||
|
scripts=get_suggested_scripts(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@db.route('/')
|
@db.route('/')
|
||||||
|
|
Loading…
Reference in a new issue