url not hardcoded

This commit is contained in:
Sam Hadow 2024-01-29 23:35:20 +01:00
parent c19fac2dc5
commit e7a6dc5cd8
3 changed files with 15 additions and 5 deletions

View File

@ -1,8 +1,8 @@
podman build --tag alipricetrack:1.0.0 -f ./Dockerfile podman build --tag alipricetrack:1.0.0 -f ./Dockerfile
podman pod create --name aliexpress -p 8080:8080 podman pod create --name aliexpress -p 8086:8080
podman run -d --pod=aliexpress -e POSTGRES_DB="aliexpress" -e POSTGRES_USER="postgres" -e POSTGRES_PASSWORD="postgres" -v /home/fire/Downloads/db:/var/lib/postgresql/data --name ali-db docker.io/postgres podman run -d --pod=aliexpress -e POSTGRES_DB="aliexpress" -e POSTGRES_USER="postgres" -e POSTGRES_PASSWORD="postgres" -v /home/data/podman/aliexpress/db:/var/lib/postgresql/data:Z --name ali-db docker.io/postgres
podman run -d --pod=aliexpress -e POSTGRES_DB="aliexpress" -e POSTGRES_USER="postgres" -e POSTGRES_PASSWORD="postgres" --name ali-app alipricetrack:1.0.0 podman run -d --pod=aliexpress -e POSTGRES_DB="aliexpress" -e POSTGRES_USER="postgres" -e POSTGRES_PASSWORD="postgres" --name ali-app alipricetrack:1.0.0

View File

@ -7,4 +7,10 @@
<!-- Create a div where the graphs will take place --> <!-- Create a div where the graphs will take place -->
<div id="graphs"></div> <div id="graphs"></div>
<script src="http://127.0.0.1/app.js"></script> <!-- <script src="http://127.0.0.1/app.js"></script> -->
<script>
let currenturl = (window.location);
var s = document.createElement( 'script' );
s.setAttribute( 'src', `${currenturl}/app.js` );
document.body.appendChild( s );
</script>

View File

@ -11,6 +11,10 @@ const margin = {
// get window width // get window width
const width = window.innerWidth - margin.right - margin.left -10; const width = window.innerWidth - margin.right - margin.left -10;
// url
const currentUrl = window.location.href;
console.log(currentUrl);
// reload page when window is resized // reload page when window is resized
// (resizes every elements) // (resizes every elements)
@ -18,7 +22,7 @@ window.onresize = function(){ location.reload(); }
async function fetch_history() { async function fetch_history() {
try { try {
const response = await fetch('http://127.0.0.1:8080/datahistory'); const response = await fetch(`${currentUrl}/datahistory`);
const rawData = await response.json(); const rawData = await response.json();
// SELECT uuid, quantity, discount_percentage, price, currency, h_timestamp // SELECT uuid, quantity, discount_percentage, price, currency, h_timestamp
let historyData = rawData.map(d => ({ let historyData = rawData.map(d => ({
@ -37,7 +41,7 @@ async function fetch_history() {
async function fetch_item() { async function fetch_item() {
try { try {
// SELECT uuid, itemid, skuid, choice, attributes, image // SELECT uuid, itemid, skuid, choice, attributes, image
const response = await fetch('http://127.0.0.1:8080/dataitem'); const response = await fetch(`${currentUrl}/dataitem`);
const rawData = await response.json(); const rawData = await response.json();
const items = rawData.reduce((item, row) => { const items = rawData.reduce((item, row) => {
const uuid = row[0]; const uuid = row[0];