diff --git a/Dockerfile b/Dockerfile index 6b1ffcc..7661d87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,13 @@ FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ -RUN npm install +RUN npm install --force COPY . . RUN npm run build # Stage 2: Serve the application with Nginx FROM nginx:1.25-alpine COPY --from=builder /app/dist /usr/share/nginx/html +COPY --from=builder /app/src/public /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/index.html b/index.html index e12ed66..5e9149e 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Brain Training App + Мониторинг инфраструктуры diff --git a/src/app/components/Dashboard.tsx b/src/app/components/Dashboard.tsx index c89f60d..6a29855 100644 --- a/src/app/components/Dashboard.tsx +++ b/src/app/components/Dashboard.tsx @@ -97,7 +97,7 @@ export function Dashboard() { throw new Error('Network response was not ok'); } const result = await response.json(); - setServers([...servers, ...result['result']]); + setServers([...result['result']]); setError(null); } catch (err) { setError(err.message); diff --git a/src/public/.htaccess b/src/public/.htaccess new file mode 100644 index 0000000..47f1fae --- /dev/null +++ b/src/public/.htaccess @@ -0,0 +1,55 @@ +Options -Indexes +ErrorDocument 404 /404.php + + + SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on + + + + php_flag session.use_trans_sid off + #php_flag default_charset UTF-8 + #php_value display_errors 1 + + + + php_flag session.use_trans_sid off + #php_flag default_charset UTF-8 + #php_value display_errors 1 + + + + Options +FollowSymLinks + RewriteEngine On + +RewriteCond %{REQUEST_FILENAME} -f [OR] +RewriteCond %{REQUEST_FILENAME} -l [OR] +RewriteCond %{REQUEST_FILENAME} -d +RewriteCond %{REQUEST_FILENAME} [\xC2-\xDF][\x80-\xBF] [OR] +RewriteCond %{REQUEST_FILENAME} \xE0[\xA0-\xBF][\x80-\xBF] [OR] +RewriteCond %{REQUEST_FILENAME} [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} [OR] +RewriteCond %{REQUEST_FILENAME} \xED[\x80-\x9F][\x80-\xBF] [OR] +RewriteCond %{REQUEST_FILENAME} \xF0[\x90-\xBF][\x80-\xBF]{2} [OR] +RewriteCond %{REQUEST_FILENAME} [\xF1-\xF3][\x80-\xBF]{3} [OR] +RewriteCond %{REQUEST_FILENAME} \xF4[\x80-\x8F][\x80-\xBF]{2} +RewriteCond %{REQUEST_FILENAME} !/bitrix/virtual_file_system.php$ +RewriteRule ^(.*)$ /bitrix/virtual_file_system.php [L] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-l + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$ + RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L] + RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}] + + + + DirectoryIndex index.php index.html + + + + ExpiresActive on + ExpiresByType image/jpeg "access plus 3 day" + ExpiresByType image/gif "access plus 3 day" + ExpiresByType image/png "access plus 3 day" + ExpiresByType text/css "access plus 3 day" + ExpiresByType application/javascript "access plus 3 day" + diff --git a/src/public/local/php_interface/s1/init.php b/src/public/local/php_interface/s1/init.php new file mode 100644 index 0000000..03aba72 --- /dev/null +++ b/src/public/local/php_interface/s1/init.php @@ -0,0 +1,149 @@ + [ + 'js' => '/assets/index-chN5Iirr.js', + 'css' => '/assets/index-IAjJXhKq.css', + 'rel' =>[], + ] +]; + +foreach ($arJsConfig as $nameExt => $arExt) { + \CJSCore::RegisterExt($nameExt, $arExt); +} + +class RestTest +{ + public static function OnRestServiceBuildDescription() + { + return array( + 'iblock' => array( + 'iblock.test' => array( + 'callback' => array(__CLASS__, 'test'), + 'options' => array(), + ), + 'iblock.edocadd' => array( + 'callback' => array(__CLASS__, 'edocadd'), + 'options' => array(), + ), + 'iblock.servers' => array( + 'callback' => array(__CLASS__, 'serverList'), + 'options' => array(), + ), + ) + ); + } + + public static function test($query, $navStart, \CRestServer $server) + { + if ($query['error']) { + throw new \Bitrix\Rest\RestException( + 'Message', + 'ERROR_CODE', + \CRestServer::STATUS_PAYMENT_REQUIRED + ); + } + + return array( + 'query' => $query, + 'files' => $_FILES + ); + } + public static function serverList($query, $navStart, \CRestServer $server) + { + if ($query['error']) { + throw new \Bitrix\Rest\RestException( + 'Message', + 'ERROR_CODE', + \CRestServer::STATUS_PAYMENT_REQUIRED + ); + } + + if (\Bitrix\Main\Loader::includeModule('iblock')) { + $el = new CIBlockElement; + $result = array(); + + $arFilter = array("IBLOCK_ID" => 3, "ACTIVE" => "Y"); + $arOrder = array("SORT" => "ASC"); + + $res = CIBlockElement::GetList($arOrder, $arFilter, false, false); + + while($ob = $res->GetNextElement()) { + $arFields = $ob->GetFields(); + $arFields["PROPERTY"] = $ob->GetProperties(); + $result[] = array( + "id" => $arFields["ID"], + "name"=> $arFields["NAME"], + "url" => $arFields["PROPERTY"]["1"]["VALUE"], + "status"=> $arFields["PROPERTY"]["2"]["VALUE"], + "responseTime"=> $arFields["PROPERTY"]["3"]["VALUE"], + "uptime"=> $arFields["PROPERTY"]["4"]["VALUE"], + "lastCheck"=> $arFields["PROPERTY"]["5"]["VALUE"], + "checkType"=> $arFields["PROPERTY"]["6"]["VALUE"], + ); + } + + return $result; + } + + return array( + 'result' => 'error' + ); + } + //-----------------------------EDOC------------------------------------ + public static function edocadd($query, $navStart, \CRestServer $server) + { + if ($query['error']) { + throw new \Bitrix\Rest\RestException( + 'Message', + 'ERROR_CODE', + \CRestServer::STATUS_PAYMENT_REQUIRED + ); + } + if (\Bitrix\Main\Loader::includeModule('iblock')) { + $el = new CIBlockElement; + + $PROP = array(); + $PROP['TITLE'] = $query['title'] ?? 'Без имени'; + if($_FILES) { + foreach(array_keys($_FILES) as $file_key) { + if(!empty($query['pdf']) && $query['pdf'] == $file_key) $PROP['PDF'] = $_FILES[$file_key]; + else $PROP['ANNEXES'].array_push($_FILES[$file_key]); + } + } + $query['name'] = $query['name'] ?? 'Без имени'; + $code = CUtil::translit($query['name'], "ru", array( + "max_len" => 100, + "change_case" => "L", // L - в нижний регистр, U - в верхний, сниппеты [3, 7] + "replace_space" => "-", // замена пробелов + "replace_other" => "-", // замена спецсимволов + "delete_repeat_replace" => true, // удалять повторяющиеся символы + )); + + $arFields = Array( + "CODE" => $code ?? 'nocode', + "MODIFIED_BY" => $query['user_id'] ?? 1, + "IBLOCK_SECTION_ID" => $query['section'] ?? false, + "IBLOCK_ID" => 5, //НПА + "PROPERTY_VALUES"=> $PROP, + "NAME" => $query['name'], + "ACTIVE" => "Y", + "ACTIVE_FROM" => ConvertTimeStamp(time(), "SHORT"), + "PREVIEW_TEXT" => $query['preview_text'] ?? "", + "DETAIL_TEXT" => $query['detail_text'] ?? "", + ); + + if($NEW_ID = $el->Add($arFields)) + $message = "Создан элемент с ID: ".$NEW_ID; + else + $message = "Ошибка: ".$el->LAST_ERROR; + } + return array( + 'result' => $message + ); + } +} + +AddEventHandler( + 'rest', + 'OnRestServiceBuildDescription', + ['\RestTest','OnRestServiceBuildDescription'] +); \ No newline at end of file diff --git a/src/public/local/rest/index.php b/src/public/local/rest/index.php new file mode 100644 index 0000000..5354401 --- /dev/null +++ b/src/public/local/rest/index.php @@ -0,0 +1,64 @@ + + +
+ +IncludeComponent( + 'bitrix:rest.hook', + '.default', + [ + 'SEF_MODE' => 'Y', + // путь к нашей папке + 'SEF_FOLDER' => '/local/rest/', + 'COMPONENT_TEMPLATE' => '.default', + // шаблоны ЧПУ для компонента + 'SEF_URL_TEMPLATES' => [ + 'list' => '', + 'event_list' => 'event/', + 'event_edit' => 'event/#id#/', + 'ap_list' => 'ap/', + 'ap_edit' => 'ap/#id#/', + ], + ], + false +); ?> +
+ + Добавить вебхук + + +
+ + + \ No newline at end of file diff --git a/src/public/urlrewrite.php b/src/public/urlrewrite.php new file mode 100644 index 0000000..8aa1f16 --- /dev/null +++ b/src/public/urlrewrite.php @@ -0,0 +1,27 @@ + + array ( + 'CONDITION' => '#^/local/rest/#', + 'RULE' => '', + 'ID' => 'bitrix:rest.hook', + 'PATH' => '/local/rest/index.php', + 'SORT' => 100, + ), + 1 => + array ( + 'CONDITION' => '#^/local/rest/#', + 'RULE' => '', + 'ID' => 'bitrix:rest.hook', + 'PATH' => '/local/rest/index.php', + 'SORT' => 100, + ), + 2 => + array ( + 'CONDITION' => '#^/rest/#', + 'RULE' => '', + 'ID' => '', + 'PATH' => '/bitrix/services/rest/index.php', + 'SORT' => 200, + ), +);