diff --git a/.gitignore b/.gitignore index 9f69cbb8..b28ec4c9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ dist .vscode logs .idea/ +docker-compose-local-MINE.yml diff --git a/index.mjs b/index.mjs index 5c49cfd9..319e5eb3 100644 --- a/index.mjs +++ b/index.mjs @@ -46,7 +46,8 @@ console.log(' -> Database URI ' + hiddenDatabaseURI) let tradenoteDatabase = process.env.TRADENOTE_DATABASE var app = express(); -app.use(express.json()); +app.use(express.json({ limit: '50mb' })); +app.use(express.urlencoded({ limit: '50mb', extended: true })); const port = process.env.TRADENOTE_PORT; const PROXY_PORT = 39482; @@ -339,7 +340,8 @@ const setupApiRoutes = (app) => { - app.use(express.json()); + app.use(express.json({ limit: '50mb' })); +app.use(express.urlencoded({ limit: '50mb', extended: true })); let allUsers const getAllUsers = async () => { @@ -498,7 +500,7 @@ const startIndex = async () => { resolve(); } else { // In production, handle API routes normally - app.use('/api/*', express.json(), (req, res, next) => { + app.use('/api/*', express.json({ limit: '50mb' }), express.urlencoded({ limit: '50mb', extended: true }), (req, res, next) => { //console.log(`Received API request: ${req.method} ${req.url}`); next(); // Pass control to specific API handlers }); diff --git a/patch-timezones.py b/patch-timezones.py new file mode 100644 index 00000000..6f409104 --- /dev/null +++ b/patch-timezones.py @@ -0,0 +1,60 @@ +from pathlib import Path +import re + +file_path = Path("src/stores/globals.js") + +main_timezones = [ + "America/New_York", + "America/Los_Angeles", + "America/Chicago", + "America/Denver", + "America/Phoenix", + "America/Anchorage", + "Pacific/Honolulu", + "America/Toronto", + "America/Vancouver", + "America/Mexico_City", + "America/Sao_Paulo", + "UTC", + "Europe/London", + "Europe/Dublin", + "Europe/Brussels", + "Europe/Paris", + "Europe/Berlin", + "Europe/Madrid", + "Europe/Rome", + "Europe/Amsterdam", + "Europe/Zurich", + "Europe/Stockholm", + "Europe/Warsaw", + "Europe/Moscow", + "Asia/Riyadh", + "Asia/Dubai", + "Asia/Kolkata", + "Asia/Bangkok", + "Asia/Singapore", + "Asia/Shanghai", + "Asia/Hong_Kong", + "Asia/Tokyo", + "Asia/Seoul", + "Australia/Sydney", + "Australia/Melbourne", + "Pacific/Auckland", +] + +s = file_path.read_text() + +new_line = 'export const timeZones = ref(' + repr(main_timezones).replace("'", '"') + ')' + +s2, n = re.subn( + r'export const timeZones = ref\(\[[^\]]*\]\)', + new_line, + s, + count=1, +) + +if n != 1: + raise SystemExit("Could not find timeZones array in src/stores/globals.js") + +file_path.write_text(s2) +print("Updated timeZones in", file_path) diff --git a/src/stores/globals.js b/src/stores/globals.js index b2c3f3f8..438dac5d 100644 --- a/src/stores/globals.js +++ b/src/stores/globals.js @@ -7,7 +7,7 @@ export const registerOff = ref(false) export const parseId = ref() export const pageId = ref() export const currentUser = ref() -export const timeZones = ref(["America/New_York", "Asia/Shanghai", "Europe/Brussels", "Asia/Tokyo", "Asia/Hong_Kong", "Asia/Kolkata", "Europe/London", "Asia/Riyadh"]) +export const timeZones = ref(["America/New_York", "America/Los_Angeles", "America/Chicago", "America/Denver", "America/Phoenix", "America/Anchorage", "Pacific/Honolulu", "America/Toronto", "America/Vancouver", "America/Mexico_City", "America/Sao_Paulo", "UTC", "Europe/London", "Europe/Dublin", "Europe/Brussels", "Europe/Paris", "Europe/Berlin", "Europe/Madrid", "Europe/Rome", "Europe/Amsterdam", "Europe/Zurich", "Europe/Stockholm", "Europe/Warsaw", "Europe/Moscow", "Asia/Riyadh", "Asia/Dubai", "Asia/Kolkata", "Asia/Bangkok", "Asia/Singapore", "Asia/Shanghai", "Asia/Hong_Kong", "Asia/Tokyo", "Asia/Seoul", "Australia/Sydney", "Australia/Melbourne", "Pacific/Auckland"]) export const timeZoneTrade = ref() export const queryLimit = ref(10000000) export const queryLimitExistingTrades = ref(50) diff --git a/src/utils/daily.js b/src/utils/daily.js index 70676857..eb23685f 100644 --- a/src/utils/daily.js +++ b/src/utils/daily.js @@ -542,7 +542,7 @@ export const useUpdateTags = async () => { query.equalTo("tradeId", tradeTagsId.value) } else { //it's the case when changing daily tags, tradeTagsId.value is null (see useTradeTagsChange) - query.equalTo("tradeId", tradeTagsDateUnix.value.toString()) + query.equalTo("tradeId", (tradeTagsDateUnix.value || screenshot.dateUnix || screenshot.dateUnixDay || screenshot.name || Date.now()).toString()) } } const results = await query.first(); @@ -578,12 +578,12 @@ export const useUpdateTags = async () => { } else { if (tradeTagsId.value) { - object.set("dateUnix", tradeTagsDateUnix.value) + object.set("dateUnix", tradeTagsDateUnix.value || screenshot.dateUnix || screenshot.dateUnixDay || Date.now()) object.set("tradeId", tradeTagsId.value) } else { //it's the case when changing daily tags, tradeTagsId.value is null - object.set("dateUnix", tradeTagsDateUnix.value) - object.set("tradeId", tradeTagsDateUnix.value.toString()) + object.set("dateUnix", tradeTagsDateUnix.value || screenshot.dateUnix || screenshot.dateUnixDay || Date.now()) + object.set("tradeId", (tradeTagsDateUnix.value || screenshot.dateUnix || screenshot.dateUnixDay || screenshot.name || Date.now()).toString()) } } diff --git a/src/utils/screenshots.js b/src/utils/screenshots.js index 249c57b4..30a88346 100644 --- a/src/utils/screenshots.js +++ b/src/utils/screenshots.js @@ -182,7 +182,7 @@ async function imgFileReader(param) { }) } -export async function useSetupImageUpload(event, param1, param2, param3) { +export async function useSetupImageUpload(event, param1, param2, param3, tradeId = null) { tradeScreenshotChanged.value = true if (pageId.value == "daily") { saveButton.value = true @@ -191,6 +191,8 @@ export async function useSetupImageUpload(event, param1, param2, param3) { screenshot.dateUnix = param1 screenshot.symbol = param2 screenshot.side = param3 + screenshot.tradeId = tradeId + screenshot.objectId = undefined } const file = event.target.files[0]; @@ -429,7 +431,7 @@ export async function useSaveScreenshot() { //console.log(" -> dateUnix " + screenshot.dateUnix) - screenshot.side ? screenshot.name = "t" + screenshot.dateUnix + "_" + screenshot.symbol + "_" + screenshot.side : screenshot.name = screenshot.dateUnix + "_" + screenshot.symbol + screenshot.tradeId ? screenshot.name = screenshot.tradeId : (screenshot.side ? screenshot.name = "t" + screenshot.dateUnix + "_" + screenshot.symbol + "_" + screenshot.side : screenshot.name = screenshot.dateUnix + "_" + screenshot.symbol) //console.log("name " + screenshot.name) diff --git a/src/views/Daily.vue b/src/views/Daily.vue index a68afab0..3b1195ea 100644 --- a/src/views/Daily.vue +++ b/src/views/Daily.vue @@ -212,19 +212,21 @@ async function clickTradesModal(param1, param2, param3) { await Promise.all([resetExcursion(), useResetTags()]) //For setups I have added setups into filteredTrades. For screenshots and excursions I need to find so I create on each modal page a screenshot and excursion object - let findScreenshot = screenshots.find(obj => obj.name == filteredTradeId) + let findScreenshots = screenshots.filter(obj => obj.name == filteredTradeId) for (let key in screenshot) delete screenshot[key] candlestickChartFailureMessage.value = null // to avoid message when screenshot is present - if (findScreenshot) { + if (findScreenshots.length > 0) { //console.log(" found screenshot") - for (let key in findScreenshot) { - screenshot[key] = findScreenshot[key] + screenshot.multiple = findScreenshots + for (let key in findScreenshots[0]) { + screenshot[key] = findScreenshots[0][key] } } else { //console.log(" did not find any screenshot") screenshot.side = null screenshot.type = null + screenshot.multiple = [] /* GET OHLC / CANDLESTICK CHARTS */ @@ -948,6 +950,9 @@ function getOHLC(date, symbol, type) { Position Entry + Entry Price + Exit + Exit Price P&L/Sec @@ -1002,6 +1007,31 @@ function getOHLC(date, symbol, type) { v-bind:data-bs-title="'Swing trade from ' + useDateCalFormat(trade.entryTime)"> + + {{ + (trade.entryPrice).toFixed(5) + }}{{ + useTwoDecCurrencyFormat(trade.entryPrice) + }} + + + + {{ useTimeFormat(trade.exitTime) }} + + + {{ + (trade.exitPrice).toFixed(5) + }}{{ + useTwoDecCurrencyFormat(trade.exitPrice) + }} +