zmena generovania backend.js na JavaScript lebo Vue projekt nie je typescript,

pridany deploy.bat skript pre nasadenie na produkciu,
This commit is contained in:
2026-07-07 23:37:44 +02:00
parent 4a5a3cc13f
commit 1569a0797e
8 changed files with 134 additions and 19 deletions

View File

@ -29,10 +29,10 @@ if (!$loaded) {
}
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
$host = $_SERVER['HTTP_HOST'];
$uri = $_SERVER['REQUEST_URI']; // obsahuje aj query string
$host = $_SERVER['HTTP_HOST'] ?? ($_SERVER['SERVER_NAME'] ?? 'localhost');
$script_name = $_SERVER['SCRIPT_NAME'] ?? '';
define('URL_PREFIX', $protocol.$host.str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']));
define('URL_PREFIX', $protocol.$host.str_replace(basename($script_name), '', $script_name));
define('UPLOAD_DIR_ATTACHMENTS', __DIR__.'/../../data/attachments/');
if (!file_exists(UPLOAD_DIR_ATTACHMENTS)) {

View File

@ -1,19 +1,25 @@
<?php
require __DIR__ . '/../vendor/autoload.php';
$display_errors = ini_get('display_errors');
ini_set('display_errors', '0');
ob_start();
require __DIR__ . '/../vendor/autoload.php';
ob_end_clean();
$backend_api = new TPsoft\BugreportBackend\API('typescript', 'import.meta.env.VITE_BACKENDAPI_URL', 'backend');
ob_start();
$backend_api = new TPsoft\BugreportBackend\API('javascript', 'import.meta.env.VITE_BACKENDAPI_URL', 'backend');
$output = ob_get_contents();
ob_end_clean();
$ts_path = realpath(__DIR__ . '/../../frontend/src').'/backend.js';
$suc = file_put_contents($ts_path, $output);
ini_set('display_errors', $display_errors);
$js_path = realpath(__DIR__ . '/../../frontend/src').'/backend.js';
$suc = file_put_contents($js_path, $output);
if ($suc === false) {
echo "TypeScript store into file failed\n";
echo "JavaScript store into file failed\n";
exit(2);
}
echo "TypeScript backend script created\n";
echo "JavaScript backend script created\n";

View File

@ -2,7 +2,6 @@
require __DIR__ . '/../vendor/autoload.php';
use \Exception;
use \TPsoft\DBmodel\DBmodel;
use \TPsoft\BugreportBackend\Maintenance;

9
deploy.bat Normal file
View File

@ -0,0 +1,9 @@
@echo off
call php d:\www\sftpsync\src\sftpsync.php --host vihorlat.tpsoft.org --user igor ^
--delete-dir /storage/tpsoft.org/bugreport/app ^
--sync d:/www/BugReport/dist/app /storage/tpsoft.org/bugreport/app ^
--skip .git ^
--print-relative
echo ✔️ Done.

2
dev.bat Normal file
View File

@ -0,0 +1,2 @@
@echo off
php -S localhost:8080

View File

@ -1,7 +1,7 @@
{
"name": "bugreport",
"private": true,
"version": "0.0.2",
"version": "0.0.3",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -2,44 +2,143 @@
* Generated by APIlite
* https://gitea.tpsoft.org/TPsoft.org/APIlite
*
* 2025-10-16 01:38:51 */
* 2026-07-07 22:15:38 */
class backend {
endpoint = import.meta.env.VITE_BACKENDAPI_URL;
bearerStorageKey = 'apilite_bearer_token';
responseHandlers = [];
errorHandlers = [];
normalizeBearerToken(token) {
if (typeof token !== 'string') return null;
token = token.trim();
return token === '' ? null : token;
}
getStorage() {
try {
if (typeof window !== 'undefined' && window.localStorage) return window.localStorage;
} catch (error) {
return null;
}
return null;
}
getBearerToken() {
var storage = this.getStorage();
if (storage == null) return null;
return this.normalizeBearerToken(storage.getItem(this.bearerStorageKey));
}
getRequestHeaders(headers = {}) {
var requestHeaders = Object.assign({}, headers);
if (typeof requestHeaders.Authorization === 'undefined') {
var token = this.getBearerToken();
if (token != null) requestHeaders.Authorization = 'Bearer ' + token;
}
return requestHeaders;
}
applyHeaders(xhttp, headers) {
Object.keys(headers).forEach(key => {
var value = headers[key];
if (typeof value === 'undefined' || value === null) return;
xhttp.setRequestHeader(key, value);
});
}
bearerSet(token) {
var storage = this.getStorage();
if (storage == null) return;
token = this.normalizeBearerToken(token);
if (token == null) {
storage.removeItem(this.bearerStorageKey);
return;
}
storage.setItem(this.bearerStorageKey, token);
}
addResponseHandler(handler) {
this.responseHandlers.push(handler);
return () => {
this.responseHandlers = this.responseHandlers.filter(registeredHandler => registeredHandler !== handler);
};
}
addErrorHandler(handler) {
this.errorHandlers.push(handler);
return () => {
this.errorHandlers = this.errorHandlers.filter(registeredHandler => registeredHandler !== handler);
};
}
emitResponseHandlers(response, context) {
this.responseHandlers.forEach(handler => {
try {
handler(response, context);
} catch (error) {
// Response handlers must not change the API request result.
}
});
}
emitErrorHandlers(response, context) {
this.errorHandlers.forEach(handler => {
try {
handler(response, context);
} catch (error) {
// Error handlers must not change the API request result.
}
});
}
emitHandlers(response, context) {
this.emitResponseHandlers(response, context);
if (response.status === 'ERROR') this.emitErrorHandlers(response, context);
}
/* ----------------------------------------------------
* General API call
*/
call(method, data, callback) {
var xhttp = new XMLHttpRequest();
var headers = this.getRequestHeaders();
var api = this;
xhttp.withCredentials = true;
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
if (this.status == 200) {
if (callback != null) callback(JSON.parse(this.responseText));
if (this.readyState === 4) {
var response;
if (this.status === 200) {
response = JSON.parse(this.responseText);
} else {
if (callback != null) callback({'status': 'ERROR', 'message': 'HTTP STATUS ' + this.status});
response = {'status': 'ERROR', 'msg': 'HTTP STATUS ' + this.status};
}
var context = {method: method, data: data, httpStatus: this.status};
api.emitHandlers(response, context);
if (callback != null) callback(response);
}
}
var form_data = new FormData();
Object.keys(data).forEach(key => {
let val = data[key];
if (typeof val === 'undefined') return;
if (typeof val == 'object') val = JSON.stringify(val);
form_data.append(key, val);
});
xhttp.open('POST', this.endpoint + '?action=' + method);
this.applyHeaders(xhttp, headers);
xhttp.send(form_data);
}
callPromise(method, data) {
return new Promise((resolve, reject) => {
this.call(method, data, function(response) {
if (method == '__HELP__') {
if (method === '__HELP__') {
resolve(response);
return;
}
if (response.status == 'OK') {
if (response.status === 'OK') {
resolve(response.data);
} else {
reject(response.msg);

View File

@ -237,7 +237,7 @@ export default {
for (let i = 0; i < for_reorder.length; i++) {
new_ordnums[for_reorder[i].report_id] = i;
}
backend.updateOrdnum(new_ordnums);
backend.updateOrdNum(new_ordnums);
},
},
mounted() {