PK index fixes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Argiris Deligiannidis 2024-04-15 02:14:55 +03:00
parent 5ce169a3b2
commit e3a25ede59
2 changed files with 21 additions and 17 deletions

View File

@ -59,7 +59,7 @@ export default defineNuxtComponent({
this.apiURL = `${this.apiBaseURL}/locations`; this.apiURL = `${this.apiBaseURL}/locations`;
if (input) { if (input) {
await this.getDatabaseLocations(true); await this.getDatabaseLocations(true);
let idx = 0; var idx = 0;
for (let i = 0; i < this.cmpDatabaseLocations.length; i++) { for (let i = 0; i < this.cmpDatabaseLocations.length; i++) {
if ( if (
this.databaseLocations[i]['name'].includes(input.name) && this.databaseLocations[i]['name'].includes(input.name) &&
@ -88,11 +88,16 @@ export default defineNuxtComponent({
}); });
this.closeModal('add'); this.closeModal('add');
} else { } else {
idx = this.databaseLocations.length + 1; idx = 0;
for (let i = 0; i < this.databaseLocations.length; i++) {
if (this.databaseLocations[i]['id'] > idx) {
idx = this.databaseLocations[i]['id'];
}
}
await $fetch(this.apiURL, { await $fetch(this.apiURL, {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
id: idx, id: idx + 1,
name: input.name, name: input.name,
country: input.country, country: input.country,
longitude: input.longitude, longitude: input.longitude,
@ -100,7 +105,8 @@ export default defineNuxtComponent({
user: this.userId, user: this.userId,
}), }),
}); });
this.fetchWeatherData(false, idx); await this.addNewLocID(idx + 1);
await this.fetchWeatherData(false, idx + 1);
this.displayNotification('add', input); this.displayNotification('add', input);
this.closeModal('add'); this.closeModal('add');
} }

View File

@ -49,19 +49,17 @@ export default defineNuxtComponent({
await this.removeLocID(input); await this.removeLocID(input);
await delete this.weatherData[input]; await delete this.weatherData[input];
if (this.deleteBootstrapData == true) { await fetch(`${this.apiBaseURL}/locations/${input}`, {
await fetch(`${this.apiBaseURL}/locations/${input}`, { method: 'DELETE',
method: 'DELETE', body: JSON.stringify({
body: JSON.stringify({ id: input,
id: input, }),
user: this.userId, })
}), .then((res) => res.json())
}) .then(async (json) => {
.then((res) => res.json()) console.log('Deleted: ' + input);
.then(async (json) => { });
console.log('Deleted: ' + input);
});
}
this.apiURL = ''; this.apiURL = '';
await this.getDatabaseLocations(); await this.getDatabaseLocations();
}, },