use asynchronous report sending, fix #1
This commit is contained in:
parent
2441981717
commit
182aa2d4c9
2 changed files with 45 additions and 4 deletions
29
js/service.js
Normal file
29
js/service.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*global $, dotclear */
|
||||
'use strict';
|
||||
|
||||
dotclear.adminDotclearWatchSendReport = () => {
|
||||
dotclear.services(
|
||||
'adminDotclearWatchSendReport',
|
||||
(data) => {
|
||||
try {
|
||||
const response = JSON.parse(data);
|
||||
if (response?.success) {
|
||||
} else {
|
||||
console.log(dotclear.debug && response?.message ? response.message : 'Dotclear REST server error');
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
console.log(error);
|
||||
},
|
||||
true, // Use GET method
|
||||
{ json: 1 },
|
||||
);
|
||||
};
|
||||
|
||||
$(() => {
|
||||
dotclear.adminDotclearWatchSendReport();
|
||||
});
|
|
@ -30,13 +30,25 @@ class Backend extends Process
|
|||
return false;
|
||||
}
|
||||
|
||||
//My::addBackendMenuItem();
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'adminDashboardHeaders' => [Utils::class, 'sendReport'],
|
||||
'adminPageFooterV2' => [Utils::class, 'addMark'],
|
||||
'adminDashboardHeaders' => function (): string {
|
||||
return My::jsLoad('service', dcCore::app()->getVersion(My::id()));
|
||||
},
|
||||
'adminPageFooterV2' => [Utils::class, 'addMark'],
|
||||
]);
|
||||
|
||||
dcCore::app()->rest->addFunction(
|
||||
'adminDotclearWatchSendReport',
|
||||
function (): array {
|
||||
Utils::sendReport();
|
||||
|
||||
return [
|
||||
'ret' => true,
|
||||
'msg' => 'report sent',
|
||||
];
|
||||
},
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue