mirror of
https://github.com/Sheldan/gw2-tools.git
synced 2026-01-01 06:49:06 +00:00
adding handling of exceptions when the request fails (not a nice solution atm, as we do not actively wait for the request failure, but follow up errors)
passing through http codes from backend to frontend fixing path to environments repository in tiltfile
This commit is contained in:
4
Tiltfile
4
Tiltfile
@@ -32,8 +32,8 @@ docker_build(registry + 'gw2-tools-database', 'gw2-tools-backend/database/src/ma
|
||||
|
||||
local('cd tilt/gw2-tools-dev && helm dep up')
|
||||
k8s_yaml(helm('tilt/gw2-tools-dev', values=[
|
||||
'./../drr-environments/argocd/apps/gw2-tools/values/local/values.yaml',
|
||||
'./../drr-environments/argocd/apps/gw2-tools/values/local/values.secrets.yaml'
|
||||
'./../gw2-tools-environments/argocd/apps/gw2-tools/values/local/values.yaml',
|
||||
'secrets://./../gw2-tools-environments/argocd/apps/gw2-tools/values/local/values.secrets.yaml'
|
||||
]))
|
||||
|
||||
k8s_resource('backend', port_forwards='5005:5005', labels=['applications'])
|
||||
|
||||
@@ -8,7 +8,7 @@ backend:
|
||||
pullPolicy: Always
|
||||
image: gw2-tools-backend
|
||||
# Overrides the image tag whose default is the chart appVersion.
|
||||
tag: 0.0.1
|
||||
tag:
|
||||
debug:
|
||||
enabled: true
|
||||
port: 5005
|
||||
@@ -73,7 +73,7 @@ dbDeployment:
|
||||
image:
|
||||
repository: harbor.sheldan.dev/gw2
|
||||
image: gw2-tools-database
|
||||
tag: 0.0.1
|
||||
tag:
|
||||
pullPolicy: Always
|
||||
|
||||
cacheJob:
|
||||
@@ -101,7 +101,7 @@ frontend:
|
||||
pullPolicy: IfNotPresent
|
||||
image: gw2-tools-frontend
|
||||
# Overrides the image tag whose default is the chart appVersion.
|
||||
tag: 0.0.1
|
||||
tag:
|
||||
port: 8080
|
||||
service:
|
||||
type: ClusterIP
|
||||
|
||||
@@ -51,8 +51,8 @@ def get_account_characters():
|
||||
api_key = request.headers.get(api_key_header_name)
|
||||
headers = {'api-key': api_key}
|
||||
logging.info("Loading characters")
|
||||
inventory_response = requests.get(f'{characters_url}', headers=headers)
|
||||
return inventory_response.text
|
||||
characters_response = requests.get(f'{characters_url}', headers=headers)
|
||||
return characters_response.text, characters_response.status_code
|
||||
|
||||
|
||||
@app.route('/inventory/')
|
||||
@@ -62,7 +62,7 @@ def get_account_inventory():
|
||||
headers = {'api-key': api_key}
|
||||
logging.info("Rendering inventory of full account")
|
||||
inventory_response = requests.get(f'{inventory_url}', headers=headers)
|
||||
text = inventory_response.text
|
||||
text = inventory_response.text, inventory_response.status_code
|
||||
return text
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ def get_account_wallet():
|
||||
headers = {'api-key': api_key}
|
||||
logging.info("Rendering wallet of account")
|
||||
wallet_response = requests.get(f'{wallet_url}', headers=headers)
|
||||
return wallet_response.text
|
||||
return wallet_response.text, wallet_response.status_code
|
||||
|
||||
|
||||
@app.route('/bank/')
|
||||
@@ -83,7 +83,7 @@ def get_account_bank():
|
||||
headers = {'api-key': api_key}
|
||||
logging.info("Rendering bank of account")
|
||||
bank_response = requests.get(f'{bank_url}', headers=headers)
|
||||
return bank_response.text
|
||||
return bank_response.text, bank_response.status_code
|
||||
|
||||
|
||||
@app.route('/materials/')
|
||||
@@ -93,7 +93,7 @@ def get_materials():
|
||||
headers = {'api-key': api_key}
|
||||
logging.info("Rendering materials of account")
|
||||
materials_response = requests.get(f'{materials_url}', headers=headers)
|
||||
return materials_response.text
|
||||
return materials_response.text, materials_response.status_code
|
||||
|
||||
|
||||
@app.route('/sharedInventory/')
|
||||
@@ -103,7 +103,7 @@ def get_shared_inventory():
|
||||
headers = {'api-key': api_key}
|
||||
logging.info("Rendering shared inventory of account")
|
||||
shared_inventory_response = requests.get(f'{shared_inventory_url}', headers=headers)
|
||||
return shared_inventory_response.text
|
||||
return shared_inventory_response.text, shared_inventory_response.status_code
|
||||
|
||||
|
||||
@app.route('/submissionTemplates/')
|
||||
@@ -111,14 +111,14 @@ def get_submission_templates():
|
||||
logging.info("Rendering submission templates")
|
||||
parameters_query = request.query_string.decode()
|
||||
submission_templates_response = requests.get(f'{submission_templates_url}?{parameters_query}')
|
||||
return submission_templates_response.text
|
||||
return submission_templates_response.text, submission_templates_response.status_code
|
||||
|
||||
|
||||
@app.route('/itemRates/')
|
||||
def get_item_rates():
|
||||
logging.info("Rendering item rates")
|
||||
item_rates_response = requests.get(f'{itemRates_url}')
|
||||
return item_rates_response.text
|
||||
return item_rates_response.text, item_rates_response.status_code
|
||||
|
||||
|
||||
@app.route('/openings/', methods=['POST'])
|
||||
@@ -128,7 +128,7 @@ def create_opening():
|
||||
headers = {'api-key': api_key, 'Content-Type': 'application/json'}
|
||||
logging.info("Creating opening")
|
||||
openings_response = requests.post(f'{openings_url}', body, headers=headers)
|
||||
return openings_response.text
|
||||
return openings_response.text, openings_response.status_code
|
||||
|
||||
|
||||
@app.route('/openings/', methods=['GET'])
|
||||
@@ -138,7 +138,7 @@ def get_openings():
|
||||
headers = {'api-key': api_key}
|
||||
logging.info("Loading openings")
|
||||
bank_response = requests.get(f'{openings_url}?{parameters_query}', headers=headers)
|
||||
return bank_response.text
|
||||
return bank_response.text, bank_response.status_code
|
||||
|
||||
|
||||
@app.route('/openings/<opening_id>', methods=['DELETE'])
|
||||
@@ -147,7 +147,7 @@ def delete_opening(opening_id):
|
||||
headers = {'api-key': api_key}
|
||||
logging.info(f"Deleting opening {opening_id}")
|
||||
bank_response = requests.delete(f'{openings_url}/{opening_id}', headers=headers)
|
||||
return bank_response.text
|
||||
return bank_response.text, bank_response.status_code
|
||||
|
||||
|
||||
@app.route('/inventory/<character_name>/')
|
||||
@@ -157,7 +157,7 @@ def get_character_inventory(character_name):
|
||||
headers = {'api-key': api_key}
|
||||
logging.info("rendering inventory of individual character.")
|
||||
inventory_response = requests.get(f'{inventory_url}/{character_name}', headers=headers)
|
||||
return inventory_response.text
|
||||
return inventory_response.text, inventory_response.status_code
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -42,19 +42,23 @@ export function Bank() {
|
||||
|
||||
async function reloadBank() {
|
||||
setBankLoading(true)
|
||||
const bankSlots = await fetchBank();
|
||||
if(!config.locked) {
|
||||
const bankState = {
|
||||
slots: bankSlots,
|
||||
addedSlots: [],
|
||||
removedSlots: []
|
||||
try {
|
||||
const bankSlots = await fetchBank();
|
||||
if(!config.locked) {
|
||||
const bankState = {
|
||||
slots: bankSlots,
|
||||
addedSlots: [],
|
||||
removedSlots: []
|
||||
}
|
||||
dispatch(setBank(bankState))
|
||||
} else {
|
||||
const [slotsToAdd, slotsToRemove, slotsToUpdate] = calculateBankDifferences(bank, bankSlots, config.mocking);
|
||||
dispatch(setRemovedBankSlots(slotsToRemove))
|
||||
dispatch(setAddedBankSlots(slotsToAdd))
|
||||
dispatch(updateChangedBankSlots(slotsToUpdate))
|
||||
}
|
||||
dispatch(setBank(bankState))
|
||||
} else {
|
||||
const [slotsToAdd, slotsToRemove, slotsToUpdate] = calculateBankDifferences(bank, bankSlots, config.mocking);
|
||||
dispatch(setRemovedBankSlots(slotsToRemove))
|
||||
dispatch(setAddedBankSlots(slotsToAdd))
|
||||
dispatch(updateChangedBankSlots(slotsToUpdate))
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
setBankLoading(false)
|
||||
}
|
||||
|
||||
@@ -82,8 +82,12 @@ export const CharacterInventory = ({character}) => {
|
||||
|
||||
async function updateCharacter() {
|
||||
setCharacterLoading(true)
|
||||
await reloadCharacterInventory();
|
||||
await reloadWallet();
|
||||
try {
|
||||
await reloadCharacterInventory();
|
||||
await reloadWallet();
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
setCharacterLoading(false)
|
||||
}
|
||||
|
||||
|
||||
@@ -123,11 +123,15 @@ export function ItemDifference() {
|
||||
|
||||
async function fetchInformation() {
|
||||
dispatch(setLoading(true))
|
||||
await updateWallet()
|
||||
await updateBank()
|
||||
await updateMaterials()
|
||||
await updatedSharedInventory()
|
||||
await updateInventoryCharacterSpecific()
|
||||
try {
|
||||
await updateWallet()
|
||||
await updateBank()
|
||||
await updateMaterials()
|
||||
await updatedSharedInventory()
|
||||
await updateInventoryCharacterSpecific()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
dispatch(setLoading(false))
|
||||
}
|
||||
|
||||
|
||||
@@ -48,21 +48,26 @@ export function Materials() {
|
||||
|
||||
async function reloadMaterials() {
|
||||
setMaterialsLoading(true)
|
||||
const materialSlots = await fetchMaterials();
|
||||
if(!config.locked) {
|
||||
const materialsState = {
|
||||
slots: materialSlots,
|
||||
addedSlots: [],
|
||||
removedSlots: []
|
||||
}
|
||||
dispatch(setMaterials(materialsState))
|
||||
} else {
|
||||
const [slotsToAdd, slotsToRemove, slotsToUpdate] = calculateMaterialsDifference(materials, materialSlots, config.mocking);
|
||||
try {
|
||||
const materialSlots = await fetchMaterials();
|
||||
if(!config.locked) {
|
||||
const materialsState = {
|
||||
slots: materialSlots,
|
||||
addedSlots: [],
|
||||
removedSlots: []
|
||||
}
|
||||
dispatch(setMaterials(materialsState))
|
||||
} else {
|
||||
const [slotsToAdd, slotsToRemove, slotsToUpdate] = calculateMaterialsDifference(materials, materialSlots, config.mocking);
|
||||
|
||||
dispatch(setRemovedMaterialSlots(slotsToRemove))
|
||||
dispatch(setAddedMaterialSlots(slotsToAdd))
|
||||
dispatch(updateChangedMaterialSlots(slotsToUpdate))
|
||||
dispatch(setRemovedMaterialSlots(slotsToRemove))
|
||||
dispatch(setAddedMaterialSlots(slotsToAdd))
|
||||
dispatch(updateChangedMaterialSlots(slotsToUpdate))
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
setMaterialsLoading(false)
|
||||
}
|
||||
|
||||
|
||||
@@ -107,12 +107,16 @@ export function OpeningSubmission() {
|
||||
|
||||
async function submitOpening() {
|
||||
dispatch(setLoading(true))
|
||||
const submissionBody = {}
|
||||
submissionBody.items = getChanges();
|
||||
submissionBody.description = openingDescription;
|
||||
await fetcher("openings", {apiKey: apiKey, method: "POST", body: JSON.stringify(submissionBody), headers: {"Content-Type": "application/json"}})
|
||||
setOpeningDescription("")
|
||||
toast('Opening has been submitted.')
|
||||
try {
|
||||
const submissionBody = {}
|
||||
submissionBody.items = getChanges();
|
||||
submissionBody.description = openingDescription;
|
||||
await fetcher("openings", {apiKey: apiKey, method: "POST", body: JSON.stringify(submissionBody), headers: {"Content-Type": "application/json"}})
|
||||
setOpeningDescription("")
|
||||
toast('Opening has been submitted.')
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
dispatch(setLoading(false))
|
||||
}
|
||||
|
||||
|
||||
@@ -72,9 +72,13 @@ export function OpeningOverview() {
|
||||
}
|
||||
|
||||
async function loadOpenings() {
|
||||
setOpeningsLoading(true)
|
||||
const openings = await fetchOpenings();
|
||||
dispatch(setOpenings(openings))
|
||||
try {
|
||||
setOpeningsLoading(true)
|
||||
const openings = await fetchOpenings();
|
||||
dispatch(setOpenings(openings))
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
setOpeningsLoading(false)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user