Skip to content

Commit

Permalink
Merge pull request #578 from the-hideout/presets-page-fixes
Browse files Browse the repository at this point in the history
fixes for presets page
  • Loading branch information
Razzmatazzz authored Nov 13, 2024
2 parents c9fbd29 + 433d819 commit a6c8fdb
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 70 deletions.
6 changes: 3 additions & 3 deletions src/tarkov-data-manager/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ app.use(maybe((req, res, next) => {
dataType: "json"
}).done(function (data) {
if (!data.success) {
M.toast({text: data.message});
new M.Toast({text: data.message});
} else {
location.reload();
}
Expand Down Expand Up @@ -277,7 +277,7 @@ const getHeader = (req, options) => {
const getFooter = (req) => {
let toastJs = '';
if (req.query.toast) {
toastJs = `M.toast({text: '${decodeToast(req.query.toast)}'});`;
toastJs = `new M.Toast({text: '${decodeToast(req.query.toast)}'});`;
}
return `
</div>
Expand Down Expand Up @@ -2014,7 +2014,7 @@ app.get('/presets/get', async (req, res) => {
});
preset.image_8x_link = items.get(preset.id)?.image_8x_link;
preset.image_512_link = items.get(preset.id)?.image_512_link;
preset.image_link = items.get(preset.id)?.image_link;
preset.image_link = items.get(preset.id)?.image_link ?? null;
preset.base_image_link = items.get(preset.id)?.base_image_link;
preset.grid_image_link = items.get(preset.id)?.grid_image_link;
preset.icon_link = items.get(preset.id)?.icon_link;
Expand Down
59 changes: 50 additions & 9 deletions src/tarkov-data-manager/jobs/update-quests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -728,18 +728,32 @@ class UpdateQuestsJob extends DataJob {
}

getRewardItems = async (reward) => {
if (reward.value > 1) {
reward.items = reward.items.reduce((rewardItems, current, currentIndex) => {
if (currentIndex === 0) {
rewardItems.push(current);
} else if (current.parentId && rewardItems.some(r => r._id === current.parentId)) {
rewardItems.push(current);
}
return rewardItems;
}, []);
}
const rewardData = {
item: reward.items[0]._tpl,
item_name: this.locales.en[`${reward.items[0]._tpl} Name`],
count: 1,
contains: [],
attributes: []
};
if (reward.items[0].upd && reward.items[0].upd.StackObjectsCount) {
if (reward.items[0].upd?.StackObjectsCount) {
rewardData.count = reward.items[0].upd.StackObjectsCount;
}
for (let i = 1; i < reward.items.length; i++) {
const item = reward.items[i];
if (this.items[rewardData.item]._parent === '543be5cb4bdc2deb348b4568') {
// skip ammo pack contents
break;
}
if (this.items[item._tpl]._parent === '65649eb40bf0ed77b8044453') {
// skip built-in armor inserts
continue;
Expand Down Expand Up @@ -1743,6 +1757,29 @@ const skipQuests = [
'66e3e2ee2136472d220bcb36', // Night of the Cult
'66e3e2fcb26de0e0790d3fe6', // The Graven Image
'66e3e3027804a21d860755d6', // Until Dawn
'670404a2ea1caa8f2e0be106', // Don't Believe Your Eyes
'67040b3d10b18d153a08f636', // Dirty Blood
'67040b6c45eaf70db10dbec6', // Burn it Down
'67040ba4578a46e44a05c0a8', // The Root Cause
'67040c22cc1f3752720376e9', // Matter of Technique
'67040c43ce929d6ee506c7c7', // Find the Source
'67040c5b4ac6d9c18c0ade26', // Gloves Off
'67040c78bf4be8a4ef041a65', // Sample IV - A New Hope
'67040c92bf4be8a4ef041a6c', // Darkest Hour Is Just Before Dawn
'6727ef2c6015b7cc540ea754', // Contagious Beast
'67190f6c1b3f4964d90d71e9', // Global Threat
'67190f9c7b0991dc22064766', // Watch the Watcher
'67040cae4ac6d9c18c0ade2c', // Radical Treatment
'67040ccdcc1f3752720376ef', // Forgotten Oaths
'6707e6614e617ec94f0e63dc', // Clear Conscience
'67190febcce4a5fdf605d4f8', // Not a Step Back!
'671910d5dbd4354ac10e9784', // Conservation Area
'6719116460f6f081570d05f7', // Every Man for Himself
'67191048eddf081d340d4c6e', // Pressured by Circumstances
'671911bbcee3738f8502d401', // Reduce the Distance
'6719101deddf081d340d4c60', // Spread the Damage
'67190f157b0991dc22064755', // Foreign Support
'67165d59a9c06627040a9094', // Forces Measure
];

// Secure Folder 0013 appears on multiple maps
Expand All @@ -1760,14 +1797,18 @@ const questStatusMap = {
};

const factionMap = {
'5e381b0286f77420e3417a74': 'USEC',
'5e4d4ac186f774264f758336': 'USEC',
'6179b5eabca27a099552e052': 'USEC',
'639282134ed9512be67647ed': 'USEC',
'5e383a6386f77465910ce1f3': 'BEAR',
'5e4d515e86f77438b2195244': 'BEAR',
'6179b5b06e9dd54ac275e409': 'BEAR',
'639136d68ba6894d155e77cf': 'BEAR',
'5e381b0286f77420e3417a74': 'USEC', // Textile - Part 1
'5e4d4ac186f774264f758336': 'USEC', // Textile - Part 2
'6179b5eabca27a099552e052': 'USEC', // Counteraction
'639282134ed9512be67647ed': 'USEC', // Road Closed
'5e383a6386f77465910ce1f3': 'BEAR', // Textile - Part 1
'5e4d515e86f77438b2195244': 'BEAR', // Textile - Part 2
'6179b5b06e9dd54ac275e409': 'BEAR', // Our Own Land
'639136d68ba6894d155e77cf': 'BEAR', // Green Corridor
'6613f3007f6666d56807c929': 'BEAR', // Drip-Out - Part 1
'66151401efb0539ae10875ae': 'USEC', // Drip-Out - Part 1
'6613f307fca4f2f386029409': 'BEAR', // Drip-Out - Part 2
'6615141bfda04449120269a7': 'USEC', // Drip-Out - Part 2
};

export default UpdateQuestsJob;
2 changes: 1 addition & 1 deletion src/tarkov-data-manager/modules/tarkov-data.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ async function addManualTranslations(lang, langCode) {
return lang;
}
return {
...manualTranslations[langCode],
...lang,
...manualTranslations[langCode],
};
}

Expand Down
14 changes: 11 additions & 3 deletions src/tarkov-data-manager/modules/upload-s3.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const getBucketContents = async (continuationToken = false) => {
Bucket: process.env.S3_BUCKET,
};

if(continuationToken){
if (continuationToken) {
input.ContinuationToken = continuationToken;
}

Expand All @@ -185,9 +185,17 @@ export const getBucketContents = async (continuationToken = false) => {
const response = await s3.send(command);

responseKeys = response.Contents.reduce((all, item) => {
if (!item.Key.startsWith('Applications/') && !item.Key.startsWith('maps/') && !item.Key.startsWith('profile/')) {
all.push(item.Key);
if (item.Key.startsWith('Applications/')) {
return all;
}
if (item.Key.startsWith('maps/') && !item.Key.startsWith('maps/svg/')) {
return all;
}
if (item.Key.startsWith('profile/')) {
return all;
}

all.push(item.Key);
return all;
}, []);

Expand Down
10 changes: 5 additions & 5 deletions src/tarkov-data-manager/public/crons.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ $(document).ready( function () {
let target = $(event.target);
if (target[0].nodeName === 'I') target = target.parent();
target.addClass('disabled');
M.toast({text: `Starting ${target.data('job')} job...`});
new M.Toast({text: `Starting ${target.data('job')} job...`});
$.ajax({
//method: ,
dataType: "json",
url: '/crons/run/'+target.data('job')
}).done(function (data) {
M.toast({text: data.message});
new M.Toast({text: data.message});
if (data.errors.length > 0) {
for (let i = 0; i < data.errors.length; i++) {
M.toast({text: data.errors[i]});
new M.Toast({text: data.errors[i]});
}
return;
}
Expand Down Expand Up @@ -177,10 +177,10 @@ $(document).ready( function () {
data: formData,
dataType: 'json'
}).done(function (data) {
M.toast({text: data.message});
new M.Toast({text: data.message});
if (data.errors.length > 0) {
for (let i = 0; i < data.errors.length; i++) {
M.toast({text: data.errors[i]});
new M.Toast({text: data.errors[i]});
}
return;
}
Expand Down
12 changes: 6 additions & 6 deletions src/tarkov-data-manager/public/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ $(document).ready( async function () {
$(target).addClass('disabled');
fetch(`/items/regenerate-images/${$(target).data('id')}`, {method: 'POST'}).then(response => response.json()).then(data => {
$(target).removeClass('disabled');
M.toast({text: data.message});
new M.Toast({text: data.message});
for (const error of data.errors) {
M.toast({text: error});
new M.Toast({text: error});
}
});
});
Expand All @@ -205,9 +205,9 @@ $(document).ready( async function () {
$(target).addClass('disabled');
fetch(`/items/refresh-images/${$(target).data('id')}`, {method: 'POST'}).then(response => response.json()).then(data => {
$(target).removeClass('disabled');
M.toast({text: data.message});
new M.Toast({text: data.message});
for (const error of data.errors) {
M.toast({text: error});
new M.Toast({text: error});
}
});
});
Expand All @@ -232,10 +232,10 @@ $(document).ready( async function () {
method: 'POST',
body: formData
}).then(response => response.json()).then(data => {
M.toast({text: data.message});
new M.Toast({text: data.message});
if (data.errors.length > 0) {
for (let i = 0; i < data.errors.length; i++) {
M.toast({text: data.errors[i]});
new M.Toast({text: data.errors[i]});
}
}
});
Expand Down
10 changes: 5 additions & 5 deletions src/tarkov-data-manager/public/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ $(document).ready( function () {
dataType: "json",
url: `/json/${dir}/${fileName}`
}).done(function (data) {
M.toast({text: data.message});
new M.Toast({text: data.message});
if (data.errors.length > 0) {
for (let i = 0; i < data.errors.length; i++) {
M.toast({text: data.errors[i]});
new M.Toast({text: data.errors[i]});
}
return;
}
Expand All @@ -110,17 +110,17 @@ $(document).ready( function () {
const form = $('form.json-upload').first();
const formData = new FormData(form[0]);
if (!formData.has('file') || formData.get('file').size === 0) {
M.toast({text: 'You must select a json file to upload'});
new M.Toast({text: 'You must select a json file to upload'});
return;
}
fetch('/json/'+$('input[name="json-dir"]:checked').val(), {
method: 'POST',
body: formData
}).then(response => response.json()).then(data => {
M.toast({text: data.message});
new M.Toast({text: data.message});
if (data.errors.length > 0) {
for (let i = 0; i < data.errors.length; i++) {
M.toast({text: data.errors[i]});
new M.Toast({text: data.errors[i]});
}
}
$('#json-upload').val('');
Expand Down
26 changes: 15 additions & 11 deletions src/tarkov-data-manager/public/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const existingImageElement = (itemId, imageType, url) => {
`;
};

const missingImageElement = (imageType) => {
return `<span class="tooltipped" style="cursor: default" data-tooltip="${imageType} image">🚫</span>`;
};

$(document).ready( function () {
//$('.tooltipped').tooltip();
//$('.modal').modal();
Expand All @@ -22,7 +26,7 @@ $(document).ready( function () {
method: 'get',
dataType: 'json',
url: '/presets/get/game',
}).done(function (data) {
}).done((data) => {
gamePresets = data;
});

Expand Down Expand Up @@ -202,9 +206,9 @@ $(document).ready( function () {
$(target).addClass('disabled');
fetch(`/items/regenerate-images/${$(target).data('id')}`, {method: 'POST'}).then(response => response.json()).then(data => {
$(target).removeClass('disabled');
M.toast({text: data.message});
new M.Toast({text: data.message});
for (const error of data.errors) {
M.toast({text: error});
new M.Toast({text: error});
}
});
});
Expand All @@ -218,9 +222,9 @@ $(document).ready( function () {
$(target).addClass('disabled');
fetch(`/items/refresh-images/${$(target).data('id')}`, {method: 'POST'}).then(response => response.json()).then(data => {
$(target).removeClass('disabled');
M.toast({text: data.message});
new M.Toast({text: data.message});
for (const error of data.errors) {
M.toast({text: error});
new M.Toast({text: error});
}
});
});
Expand All @@ -234,15 +238,15 @@ $(document).ready( function () {
dataType: 'json',
url: `/presets/${presetId}`
}).done(function (data) {
M.toast({text: data.message});
new M.Toast({text: data.message});
$('.delete-preset').each((index, el) => {
if (el.dataset.id === presetId) {
$(el).removeClass('disabled');
}
});
if (data.errors.length > 0) {
for (let i = 0; i < data.errors.length; i++) {
M.toast({text: data.errors[i]});
new M.Toast({text: data.errors[i]});
}
return;
}
Expand All @@ -268,10 +272,10 @@ $(document).ready( function () {
data: formData,
dataType: 'json'
}).done(function (data) {
M.toast({text: data.message});
new M.Toast({text: data.message});
if (data.errors.length > 0) {
for (let i = 0; i < data.errors.length; i++) {
M.toast({text: data.errors[i]});
new M.Toast({text: data.errors[i]});
}
return;
}
Expand All @@ -298,10 +302,10 @@ $(document).ready( function () {
data: {id: targetId},
dataType: 'json'
}).done(function (data) {
M.toast({text: data.message});
new M.Toast({text: data.message});
if (data.errors.length > 0) {
for (let i = 0; i < data.errors.length; i++) {
M.toast({text: data.errors[i]});
new M.Toast({text: data.errors[i]});
}
return;
}
Expand Down
Loading

0 comments on commit a6c8fdb

Please sign in to comment.