Compare commits
3 Commits
4750d43c55
...
c3adc7123b
Author | SHA1 | Date |
---|---|---|
Jean-Christian Paul Denis | c3adc7123b | |
Jean-Christian Paul Denis | 182aa2d4c9 | |
Jean-Christian Paul Denis | 2441981717 |
|
@ -1,3 +1,10 @@
|
||||||
|
DotclearWatch 0.7 - 2023.08.12
|
||||||
|
===========================================================
|
||||||
|
* require dotclear 2.27
|
||||||
|
* require php 7.4
|
||||||
|
* Use asynchronous report sending
|
||||||
|
* Use HttpClient first to send report
|
||||||
|
|
||||||
DotclearWatch 0.6 - 2023.08.09
|
DotclearWatch 0.6 - 2023.08.09
|
||||||
===========================================================
|
===========================================================
|
||||||
* require dotclear 2.27
|
* require dotclear 2.27
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-0.6-a2cbe9.svg)](https://git.dotclear.watch/dw/DotclearWatch/releases)
|
[![Release](https://img.shields.io/badge/release-0.7-a2cbe9.svg)](https://git.dotclear.watch/dw/DotclearWatch/releases)
|
||||||
[![Date](https://img.shields.io/badge/date-2023.08.09-c44d58.svg)](https://git.dotclear.watch/dw/DotclearWatch/releases)
|
[![Date](https://img.shields.io/badge/date-2023.08.12-c44d58.svg)](https://git.dotclear.watch/dw/DotclearWatch/releases)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/DotclearWatch)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/DotclearWatch)
|
||||||
[![License](https://img.shields.io/github/license/JcDenis/DotclearWatch)](https://git.dotclear.watch/dw/DotclearWatch/blob/master/LICENSE)
|
[![License](https://img.shields.io/github/license/JcDenis/DotclearWatch)](https://git.dotclear.watch/dw/DotclearWatch/blob/master/LICENSE)
|
||||||
|
|
|
@ -14,7 +14,7 @@ $this->registerModule(
|
||||||
'Dotclear Watch',
|
'Dotclear Watch',
|
||||||
'Send report about your Dotclear',
|
'Send report about your Dotclear',
|
||||||
'Jean-Christian Denis and contributors',
|
'Jean-Christian Denis and contributors',
|
||||||
'0.6',
|
'0.7',
|
||||||
[
|
[
|
||||||
'requires' => [
|
'requires' => [
|
||||||
['php', '7.4'],
|
['php', '7.4'],
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="DotclearWatch">
|
<module id="DotclearWatch">
|
||||||
<name>Dotclear Watch</name>
|
<name>Dotclear Watch</name>
|
||||||
<version>0.6</version>
|
<version>0.7</version>
|
||||||
<author>Jean-Christian Denis and contributors</author>
|
<author>Jean-Christian Denis and contributors</author>
|
||||||
<desc>Send report about your Dotclear</desc>
|
<desc>Send report about your Dotclear</desc>
|
||||||
<file>https://git.dotclear.watch/dw/DotclearWatch/releases/download/v0.6/plugin-DotclearWatch.zip</file>
|
<file>https://git.dotclear.watch/dw/DotclearWatch/releases/download/v0.7/plugin-DotclearWatch.zip</file>
|
||||||
<da:dcmin>2.27</da:dcmin>
|
<da:dcmin>2.27</da:dcmin>
|
||||||
<da:details>http://plugins.dotaddict.org/dc2/details/DotclearWatch</da:details>
|
<da:details>https://git.dotclear.watch/dw/DotclearWatch/src/branch/master/README.md</da:details>
|
||||||
<da:support>https://git.dotclear.watch/dw/DotclearWatch/issues</da:support>
|
<da:support>https://git.dotclear.watch/dw/DotclearWatch/issues</da:support>
|
||||||
</module>
|
</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
|
@ -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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//My::addBackendMenuItem();
|
|
||||||
|
|
||||||
dcCore::app()->addBehaviors([
|
dcCore::app()->addBehaviors([
|
||||||
'adminDashboardHeaders' => [Utils::class, 'sendReport'],
|
'adminDashboardHeaders' => function (): string {
|
||||||
|
return My::jsLoad('service', dcCore::app()->getVersion(My::id()));
|
||||||
|
},
|
||||||
'adminPageFooterV2' => [Utils::class, 'addMark'],
|
'adminPageFooterV2' => [Utils::class, 'addMark'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
dcCore::app()->rest->addFunction(
|
||||||
|
'adminDotclearWatchSendReport',
|
||||||
|
function (): array {
|
||||||
|
Utils::sendReport();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'ret' => true,
|
||||||
|
'msg' => 'report sent',
|
||||||
|
];
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,20 +192,9 @@ class Utils
|
||||||
$status = 500;
|
$status = 500;
|
||||||
$response = '';
|
$response = '';
|
||||||
$url = sprintf(self::url(), 'report');
|
$url = sprintf(self::url(), 'report');
|
||||||
|
$path = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (function_exists('curl_init')) {
|
|
||||||
if (false !== ($client = curl_init($url))) {
|
|
||||||
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($client, CURLOPT_POST, true);
|
|
||||||
curl_setopt($client, CURLOPT_POSTFIELDS, ['key' => self::key(), 'report' => $contents]);
|
|
||||||
|
|
||||||
if (false !== ($response = curl_exec($client))) {
|
|
||||||
$status = (int) curl_getinfo($client, CURLINFO_HTTP_CODE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$path = '';
|
|
||||||
if (false !== ($client = HttpClient::initClient($url, $path))) {
|
if (false !== ($client = HttpClient::initClient($url, $path))) {
|
||||||
$client->setUserAgent('Dotclear.watch ' . My::id() . '/' . self::DISTANT_API_VERSION);
|
$client->setUserAgent('Dotclear.watch ' . My::id() . '/' . self::DISTANT_API_VERSION);
|
||||||
$client->useGzip(false);
|
$client->useGzip(false);
|
||||||
|
@ -214,6 +203,15 @@ class Utils
|
||||||
|
|
||||||
$status = (int) $client->getStatus();
|
$status = (int) $client->getStatus();
|
||||||
$response = $client->getContent();
|
$response = $client->getContent();
|
||||||
|
} elseif (function_exists('curl_init')) {
|
||||||
|
if (false !== ($client = curl_init($url))) {
|
||||||
|
curl_setopt($client, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($client, CURLOPT_POST, true);
|
||||||
|
curl_setopt($client, CURLOPT_POSTFIELDS, ['key' => self::key(), 'report' => $contents]);
|
||||||
|
|
||||||
|
if (false !== ($response = curl_exec($client))) {
|
||||||
|
$status = (int) curl_getinfo($client, CURLINFO_HTTP_CODE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue