Compare commits
1 Commits
4a5a3cc13f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1569a0797e |
@ -29,10 +29,10 @@ if (!$loaded) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
|
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
|
||||||
$host = $_SERVER['HTTP_HOST'];
|
$host = $_SERVER['HTTP_HOST'] ?? ($_SERVER['SERVER_NAME'] ?? 'localhost');
|
||||||
$uri = $_SERVER['REQUEST_URI']; // obsahuje aj query string
|
$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/');
|
define('UPLOAD_DIR_ATTACHMENTS', __DIR__.'/../../data/attachments/');
|
||||||
if (!file_exists(UPLOAD_DIR_ATTACHMENTS)) {
|
if (!file_exists(UPLOAD_DIR_ATTACHMENTS)) {
|
||||||
|
|||||||
@ -1,19 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
$display_errors = ini_get('display_errors');
|
||||||
|
ini_set('display_errors', '0');
|
||||||
|
|
||||||
ob_start();
|
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();
|
$output = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
$ts_path = realpath(__DIR__ . '/../../frontend/src').'/backend.js';
|
ini_set('display_errors', $display_errors);
|
||||||
$suc = file_put_contents($ts_path, $output);
|
|
||||||
|
$js_path = realpath(__DIR__ . '/../../frontend/src').'/backend.js';
|
||||||
|
$suc = file_put_contents($js_path, $output);
|
||||||
if ($suc === false) {
|
if ($suc === false) {
|
||||||
echo "✗ TypeScript store into file failed\n";
|
echo "✗ JavaScript store into file failed\n";
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "✓ TypeScript backend script created\n";
|
echo "✓ JavaScript backend script created\n";
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
require __DIR__ . '/../vendor/autoload.php';
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
use \Exception;
|
|
||||||
use \TPsoft\DBmodel\DBmodel;
|
use \TPsoft\DBmodel\DBmodel;
|
||||||
use \TPsoft\BugreportBackend\Maintenance;
|
use \TPsoft\BugreportBackend\Maintenance;
|
||||||
|
|
||||||
|
|||||||
9
deploy.bat
Normal file
9
deploy.bat
Normal 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.
|
||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "bugreport",
|
"name": "bugreport",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.2",
|
"version": "0.0.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@ -2,44 +2,143 @@
|
|||||||
* Generated by APIlite
|
* Generated by APIlite
|
||||||
* https://gitea.tpsoft.org/TPsoft.org/APIlite
|
* https://gitea.tpsoft.org/TPsoft.org/APIlite
|
||||||
*
|
*
|
||||||
* 2025-10-16 01:38:51 */
|
* 2026-07-07 22:15:38 */
|
||||||
|
|
||||||
class backend {
|
class backend {
|
||||||
endpoint = import.meta.env.VITE_BACKENDAPI_URL;
|
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
|
* General API call
|
||||||
*/
|
*/
|
||||||
call(method, data, callback) {
|
call(method, data, callback) {
|
||||||
var xhttp = new XMLHttpRequest();
|
var xhttp = new XMLHttpRequest();
|
||||||
|
var headers = this.getRequestHeaders();
|
||||||
|
var api = this;
|
||||||
xhttp.withCredentials = true;
|
xhttp.withCredentials = true;
|
||||||
xhttp.onreadystatechange = function() {
|
xhttp.onreadystatechange = function() {
|
||||||
if (this.readyState == 4) {
|
if (this.readyState === 4) {
|
||||||
if (this.status == 200) {
|
var response;
|
||||||
if (callback != null) callback(JSON.parse(this.responseText));
|
if (this.status === 200) {
|
||||||
|
response = JSON.parse(this.responseText);
|
||||||
} else {
|
} 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();
|
var form_data = new FormData();
|
||||||
Object.keys(data).forEach(key => {
|
Object.keys(data).forEach(key => {
|
||||||
let val = data[key];
|
let val = data[key];
|
||||||
|
if (typeof val === 'undefined') return;
|
||||||
if (typeof val == 'object') val = JSON.stringify(val);
|
if (typeof val == 'object') val = JSON.stringify(val);
|
||||||
form_data.append(key, val);
|
form_data.append(key, val);
|
||||||
});
|
});
|
||||||
xhttp.open('POST', this.endpoint + '?action=' + method);
|
xhttp.open('POST', this.endpoint + '?action=' + method);
|
||||||
|
this.applyHeaders(xhttp, headers);
|
||||||
xhttp.send(form_data);
|
xhttp.send(form_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
callPromise(method, data) {
|
callPromise(method, data) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.call(method, data, function(response) {
|
this.call(method, data, function(response) {
|
||||||
if (method == '__HELP__') {
|
if (method === '__HELP__') {
|
||||||
resolve(response);
|
resolve(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (response.status == 'OK') {
|
if (response.status === 'OK') {
|
||||||
resolve(response.data);
|
resolve(response.data);
|
||||||
} else {
|
} else {
|
||||||
reject(response.msg);
|
reject(response.msg);
|
||||||
|
|||||||
@ -237,7 +237,7 @@ export default {
|
|||||||
for (let i = 0; i < for_reorder.length; i++) {
|
for (let i = 0; i < for_reorder.length; i++) {
|
||||||
new_ordnums[for_reorder[i].report_id] = i;
|
new_ordnums[for_reorder[i].report_id] = i;
|
||||||
}
|
}
|
||||||
backend.updateOrdnum(new_ordnums);
|
backend.updateOrdNum(new_ordnums);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|||||||
Reference in New Issue
Block a user