fully working api
This commit is contained in:
parent
5fba1a4300
commit
d88db002f1
@ -22,7 +22,7 @@ jQuery(document).ready(function ($) {
|
|||||||
$('.modal-variable-edit input:visible:eq(0)').focus().select();
|
$('.modal-variable-edit input:visible:eq(0)').focus().select();
|
||||||
$('#variable-edit-name').val(variable.name);
|
$('#variable-edit-name').val(variable.name);
|
||||||
$('#variable-edit-description').html(variable.description);
|
$('#variable-edit-description').html(variable.description);
|
||||||
$('#variable-edit-description-edition').html(variable.description_edition).toggleClass('hidden', variable.description_edition === '');
|
$('#variable-edit-description-edition').html(variable.description_edition).toggleClass('hidden', variable.description_edition === '' || variable.description_edition === null);
|
||||||
$('#variable-edit-value').val(variable.value);
|
$('#variable-edit-value').val(variable.value);
|
||||||
$('#variable-edit-id').val(variable.id);
|
$('#variable-edit-id').val(variable.id);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,6 +20,9 @@ class CoreApi(ObPlugin):
|
|||||||
def use_description(self):
|
def use_description(self):
|
||||||
return self.translate('plugin_description')
|
return self.translate('plugin_description')
|
||||||
|
|
||||||
|
def use_help_on_activation(self):
|
||||||
|
return self.translate('plugin_help_on_activation')
|
||||||
|
|
||||||
def use_variables(self) -> List[Variable]:
|
def use_variables(self) -> List[Variable]:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"plugin_title": "Core API",
|
"plugin_title": "Core API",
|
||||||
"plugin_description": "Adds api feature wrapping core features"
|
"plugin_description": "Adds api feature wrapping core features",
|
||||||
|
"plugin_help_on_activation": "Documentation will be available on the /api page"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"plugin_title": "Core API",
|
"plugin_title": "Core API",
|
||||||
"plugin_description": "Agrega características de API que envuelven las características principales"
|
"plugin_description": "Agrega características de API que envuelven las características principales",
|
||||||
|
"plugin_help_on_activation": "La documentación estará disponible en la página /api"
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"plugin_title": "Core API",
|
"plugin_title": "Core API",
|
||||||
"plugin_description": "Ajoute des fonctionnalités d'API englobant les fonctionnalités principales"
|
"plugin_description": "Ajoute des fonctionnalités d'API englobant les fonctionnalités principales",
|
||||||
|
"plugin_help_on_activation": "La documentation sera disponible sur la page /api"
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"plugin_title": "Core API",
|
"plugin_title": "Core API",
|
||||||
"plugin_description": "Aggiunge funzionalità API che racchiudono le funzionalità di base"
|
"plugin_description": "Aggiunge funzionalità API che racchiudono le funzionalità di base",
|
||||||
|
"plugin_help_on_activation": "La documentazione sarà disponibile nella pagina /api"
|
||||||
}
|
}
|
||||||
@ -22,6 +22,9 @@ class GitUpdater(ObPlugin):
|
|||||||
def use_description(self):
|
def use_description(self):
|
||||||
return self.translate('plugin_description')
|
return self.translate('plugin_description')
|
||||||
|
|
||||||
|
def use_help_on_activation(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def use_variables(self) -> List[Variable]:
|
def use_variables(self) -> List[Variable]:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,9 @@ class Dashboard(ObPlugin):
|
|||||||
def use_description(self):
|
def use_description(self):
|
||||||
return self.translate('plugin_description')
|
return self.translate('plugin_description')
|
||||||
|
|
||||||
|
def use_help_on_activation(self):
|
||||||
|
return None
|
||||||
|
|
||||||
def use_variables(self) -> List[Variable]:
|
def use_variables(self) -> List[Variable]:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|||||||
@ -38,6 +38,10 @@ class ObPlugin(abc.ABC):
|
|||||||
def use_description(self) -> str:
|
def use_description(self) -> str:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abc.abstractmethod
|
||||||
|
def use_help_on_activation(self) -> Optional[str]:
|
||||||
|
pass
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def use_variables(self) -> List[Variable]:
|
def use_variables(self) -> List[Variable]:
|
||||||
pass
|
pass
|
||||||
@ -86,7 +90,10 @@ class ObPlugin(abc.ABC):
|
|||||||
def add_functional_hook_registration(self, hook: HookType, priority: int = 0, function=None) -> FunctionalHookRegistration:
|
def add_functional_hook_registration(self, hook: HookType, priority: int = 0, function=None) -> FunctionalHookRegistration:
|
||||||
return FunctionalHookRegistration(plugin=self, hook=hook, priority=priority, function=function)
|
return FunctionalHookRegistration(plugin=self, hook=hook, priority=priority, function=function)
|
||||||
|
|
||||||
def translate(self, token, resolve=False) -> Union[Dict, str]:
|
def translate(self, token, resolve=True) -> Union[Dict, str]:
|
||||||
|
if not token:
|
||||||
|
token = '<UNKNOWN>'
|
||||||
|
|
||||||
token = token if token.startswith(self.use_id()) else "{}_{}".format(self.use_id(), token)
|
token = token if token.startswith(self.use_id()) else "{}_{}".format(self.use_id(), token)
|
||||||
return self._model_store.lang().translate(token) if resolve else token
|
return self._model_store.lang().translate(token) if resolve else token
|
||||||
|
|
||||||
|
|||||||
@ -120,6 +120,10 @@ class PluginStore:
|
|||||||
self._hooks[hook_type] = sorted(self._hooks[hook_type], key=lambda hook_reg: hook_reg.priority, reverse=True)
|
self._hooks[hook_type] = sorted(self._hooks[hook_type], key=lambda hook_reg: hook_reg.priority, reverse=True)
|
||||||
|
|
||||||
def setup_plugin(self, plugin: ObPlugin) -> None:
|
def setup_plugin(self, plugin: ObPlugin) -> None:
|
||||||
|
# LANGS
|
||||||
|
self._model_store.lang().load(directory=plugin.get_directory(), prefix=plugin.use_id())
|
||||||
|
self._model_store.variable().reload()
|
||||||
|
|
||||||
# VARIABLES
|
# VARIABLES
|
||||||
variables = plugin.use_variables() + [
|
variables = plugin.use_variables() + [
|
||||||
plugin.add_variable(
|
plugin.add_variable(
|
||||||
@ -127,7 +131,8 @@ class PluginStore:
|
|||||||
value=False,
|
value=False,
|
||||||
type=VariableType.BOOL,
|
type=VariableType.BOOL,
|
||||||
editable=True,
|
editable=True,
|
||||||
description=self._model_store.lang().translate("common_enable_plugin")
|
description=self._model_store.lang().translate("common_enable_plugin"),
|
||||||
|
description_edition=plugin.use_help_on_activation()
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -135,10 +140,6 @@ class PluginStore:
|
|||||||
if variable.name in self._dead_variables_candidates:
|
if variable.name in self._dead_variables_candidates:
|
||||||
del self._dead_variables_candidates[variable.name]
|
del self._dead_variables_candidates[variable.name]
|
||||||
|
|
||||||
# LANGS
|
|
||||||
self._model_store.lang().load(directory=plugin.get_directory(), prefix=plugin.use_id())
|
|
||||||
self._model_store.variable().reload()
|
|
||||||
|
|
||||||
if not self.is_plugin_enabled(plugin):
|
if not self.is_plugin_enabled(plugin):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,6 @@ def camel_to_snake(camel: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def str_datetime_to_cron(datetime_str: str) -> str:
|
def str_datetime_to_cron(datetime_str: str) -> str:
|
||||||
print(datetime_str)
|
|
||||||
datetime_obj = datetime.strptime(datetime_str, '%Y-%m-%d %H:%M')
|
datetime_obj = datetime.strptime(datetime_str, '%Y-%m-%d %H:%M')
|
||||||
return "{} {} {} {} * {}".format(
|
return "{} {} {} {} * {}".format(
|
||||||
datetime_obj.minute,
|
datetime_obj.minute,
|
||||||
|
|||||||
@ -13,9 +13,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="variable-edit-description-edition" class="alert alert-danger">
|
<div id="variable-edit-description-edition" class="alert alert-danger"></div>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="variable-edit-value" id="variable-edit-description"></label>
|
<label for="variable-edit-value" id="variable-edit-description"></label>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user