This commit is contained in:
Jun Pataleta 2025-02-04 10:05:58 +08:00
commit 458b35a7bb
4 changed files with 11 additions and 11 deletions

View file

@ -5,6 +5,6 @@ define("core_ai/aiprovider_action_management_table",["exports","core_admin/plugi
* @module core_ai/aiprovider_action_management_table
* @copyright 2024 Matt Porritt <matt.porritt@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/class _default extends _plugin_management_table.default{constructor(providerid){super(),this.providerid=providerid}static init(providerid){watching||(watching=!0,new this(providerid))}setPluginState(methodname,pluginaction,state){const providerid=this.providerid;return(0,_ajax.call)([{methodname:methodname,args:{pluginaction:pluginaction,state:state,providerid:providerid}}])[0]}}return _exports.default=_default,_exports.default}));
*/class _default extends _plugin_management_table.default{constructor(providerid){super(),this.providerid=providerid}static init(providerid){watching||(watching=!0,new this(providerid))}setPluginState(methodname,plugin,state){const providerid=this.providerid;return(0,_ajax.call)([{methodname:methodname,args:{plugin:plugin,state:state,providerid:providerid}}])[0]}}return _exports.default=_default,_exports.default}));
//# sourceMappingURL=aiprovider_action_management_table.min.js.map

View file

@ -1 +1 @@
{"version":3,"file":"aiprovider_action_management_table.min.js","sources":["../src/aiprovider_action_management_table.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/ //\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\nimport PluginManagementTable from 'core_admin/plugin_management_table';\nimport {call as fetchMany} from 'core/ajax';\n\nlet watching = false;\n\n/**\n * Handles setting plugin state for the AI provider management table.\n *\n * @module core_ai/aiprovider_action_management_table\n * @copyright 2024 Matt Porritt <matt.porritt@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default class extends PluginManagementTable {\n\n /**\n * Constructor for the class.\n *\n * @param {int} providerid The provider id.\n */\n constructor(providerid) {\n super(); // Call the parent constructor, so inherited properties and methods initialize properly.\n this.providerid = providerid; // Store provider id as an instance field.\n }\n\n /**\n * Initialise an instance of the class.\n *\n * @param {int} providerid The provider id.\n */\n static init(providerid) {\n if (watching) {\n return;\n }\n watching = true;\n new this(providerid);\n }\n\n /**\n * Set the plugin state (enabled or disabled).\n *\n * @param {string} methodname The web service to call.\n * @param {string} pluginaction The name of the plugin and action to set the state for.\n * @param {number} state The state to set.\n * @returns {Promise}\n */\n setPluginState(methodname, pluginaction, state) {\n const providerid = this.providerid;\n return fetchMany([{\n methodname,\n args: {\n pluginaction,\n state,\n providerid,\n },\n }])[0];\n }\n\n}\n"],"names":["watching","PluginManagementTable","constructor","providerid","this","setPluginState","methodname","pluginaction","state","args"],"mappings":"0VAiBIA,UAAW;;;;;;;4BAScC,iCAOzBC,YAAYC,yBAEHA,WAAaA,uBAQVA,YACJH,WAGJA,UAAW,MACPI,KAAKD,aAWbE,eAAeC,WAAYC,aAAcC,aAC/BL,WAAaC,KAAKD,kBACjB,cAAU,CAAC,CACdG,WAAAA,WACAG,KAAM,CACFF,aAAAA,aACAC,MAAAA,MACAL,WAAAA,eAEJ"}
{"version":3,"file":"aiprovider_action_management_table.min.js","sources":["../src/aiprovider_action_management_table.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/ //\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\nimport PluginManagementTable from 'core_admin/plugin_management_table';\nimport {call as fetchMany} from 'core/ajax';\n\nlet watching = false;\n\n/**\n * Handles setting plugin state for the AI provider management table.\n *\n * @module core_ai/aiprovider_action_management_table\n * @copyright 2024 Matt Porritt <matt.porritt@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default class extends PluginManagementTable {\n\n /**\n * Constructor for the class.\n *\n * @param {int} providerid The provider id.\n */\n constructor(providerid) {\n super(); // Call the parent constructor, so inherited properties and methods initialize properly.\n this.providerid = providerid; // Store provider id as an instance field.\n }\n\n /**\n * Initialise an instance of the class.\n *\n * @param {int} providerid The provider id.\n */\n static init(providerid) {\n if (watching) {\n return;\n }\n watching = true;\n new this(providerid);\n }\n\n /**\n * Set the plugin state (enabled or disabled).\n *\n * @param {string} methodname The web service to call.\n * @param {string} plugin The name of the plugin and action to set the state for.\n * @param {number} state The state to set.\n * @returns {Promise}\n */\n setPluginState(methodname, plugin, state) {\n const providerid = this.providerid;\n return fetchMany([{\n methodname,\n args: {\n plugin,\n state,\n providerid,\n },\n }])[0];\n }\n\n}\n"],"names":["watching","PluginManagementTable","constructor","providerid","this","setPluginState","methodname","plugin","state","args"],"mappings":"0VAiBIA,UAAW;;;;;;;4BAScC,iCAOzBC,YAAYC,yBAEHA,WAAaA,uBAQVA,YACJH,WAGJA,UAAW,MACPI,KAAKD,aAWbE,eAAeC,WAAYC,OAAQC,aACzBL,WAAaC,KAAKD,kBACjB,cAAU,CAAC,CACdG,WAAAA,WACAG,KAAM,CACFF,OAAAA,OACAC,MAAAA,MACAL,WAAAA,eAEJ"}

View file

@ -53,16 +53,16 @@ export default class extends PluginManagementTable {
* Set the plugin state (enabled or disabled).
*
* @param {string} methodname The web service to call.
* @param {string} pluginaction The name of the plugin and action to set the state for.
* @param {string} plugin The name of the plugin and action to set the state for.
* @param {number} state The state to set.
* @returns {Promise}
*/
setPluginState(methodname, pluginaction, state) {
setPluginState(methodname, plugin, state) {
const providerid = this.providerid;
return fetchMany([{
methodname,
args: {
pluginaction,
plugin,
state,
providerid,
},

View file

@ -37,7 +37,7 @@ class set_action extends external_api {
*/
public static function execute_parameters(): external_function_parameters {
return new external_function_parameters([
'pluginaction' => new external_value(
'plugin' => new external_value(
PARAM_TEXT,
'The name of the plugin and the action to change state for',
VALUE_REQUIRED,
@ -59,23 +59,23 @@ class set_action extends external_api {
/**
* Set the providers action state.
*
* @param string $pluginaction The name of the plugin and the action to change state for.
* @param string $plugin The name of the plugin and the action to change state for.
* @param int $state The target state.
* @param int $providerid The provider id.
* @return array
*/
public static function execute(
string $pluginaction,
string $plugin,
int $state,
int $providerid = 0
): array {
// Parameter validation.
[
'pluginaction' => $pluginaction,
'plugin' => $plugin,
'state' => $state,
'providerid' => $providerid,
] = self::validate_parameters(self::execute_parameters(), [
'pluginaction' => $pluginaction,
'plugin' => $plugin,
'state' => $state,
'providerid' => $providerid,
]);
@ -84,7 +84,7 @@ class set_action extends external_api {
self::validate_context($context);
require_capability('moodle/site:config', $context);
[$plugin, $action] = explode('-', $pluginaction);
[$plugin, $action] = explode('-', $plugin);
$actionname = get_string("action_$action", 'core_ai');
if (!empty($state)) {