AutorÃa | Ultima modificación | Ver Log |
{"version":3,"file":"check_result.min.js","sources":["../../src/check/check_result.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\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\n/**\n * Check API result functions\n *\n * @module core/check\n * @author Matthew Hilton <matthewhilton@catalyst-au.net>\n * @copyright Catalyst IT, 2023\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or
later\n */\n\nimport {getCheckResult} from './repository';\nimport {getString} from 'core/str';\nimport * as Templates from 'core/templates';\n\n/**\n * Get the result of a check and replace a given DOM element with the result.\n *\n * @method getAndRender\n * @param {String} domSelector A CSS selector for a dom element to replace the the HTML for.\n * @param {String} adminTreeId Id of the admin_setting that called this webservice. Used to retrieve the check registered to it.\n * @param {String} settingName Name of setting (used to find the parent node in the admin tree)\n * @param {Boolean} includeDetails If true, details will be included in the check.\n * By default only the status and the summary is returned.\n */\nexport async function getAndRender(domSelector, adminTreeId, settingName, includeDetails) {\n const element = document.querySelector(domSelector);\n\n if (!element) {\n window.console.error('Check selector not found');\n return;\n }\n\n try {\n const result = a
wait getCheckResult(adminTreeId, settingName, includeDetails);\n const decoded = new DOMParser().parseFromString(result.html, \"text/html\").documentElement.textContent;\n element.innerHTML = decoded;\n } catch (e) {\n window.console.error(e);\n\n // Render error as a red notification.\n element.innerHTML = await Templates.render('core/notification', {\n iserror: true,\n closebutton: false,\n announce: 0,\n extraclasses: '',\n message: await getString('checkerror', 'core', adminTreeId)\n });\n }\n}\n"],"names":["domSelector","adminTreeId","settingName","includeDetails","element","document","querySelector","window","console","error","result","decoded","DOMParser","parseFromString","html","documentElement","textContent","innerHTML","e","Templates","render","iserror","closebutton","announce","extraclasses","message"],"mappings":";;;;;;;;;eAsCmCA,YAAaC,YAAaC,YAAaC,sBAChEC,QAAUC,SAASC,cAAcN,iBAElCI,oBACDG,OAAOC,
QAAQC,MAAM,sCAKfC,aAAe,8BAAeT,YAAaC,YAAaC,gBACxDQ,SAAU,IAAIC,WAAYC,gBAAgBH,OAAOI,KAAM,aAAaC,gBAAgBC,YAC1FZ,QAAQa,UAAYN,QACtB,MAAOO,GACLX,OAAOC,QAAQC,MAAMS,GAGrBd,QAAQa,gBAAkBE,UAAUC,OAAO,oBAAqB,CAC5DC,SAAS,EACTC,aAAa,EACbC,SAAU,EACVC,aAAc,GACdC,cAAe,kBAAU,aAAc,OAAQxB"}