feat: Compare SidebarStates API done.
This commit is contained in:
@@ -142,8 +142,7 @@ export default defineStore('allMapDataStore', {
|
||||
this.allStats = response.data.stats;
|
||||
this.allInsights = response.data.insights;
|
||||
} catch(error) {
|
||||
console.dir(error)
|
||||
// apiError(error, 'Failed to load the Map.');
|
||||
apiError(error, 'Failed to load the Map.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,42 @@ export default defineStore('compareStore', {
|
||||
} catch(error) {
|
||||
apiError(error, 'Failed to load the Compare.');
|
||||
}
|
||||
},
|
||||
/**
|
||||
* fetch discover api, get stats.
|
||||
*/
|
||||
async getStateData(type, id) {
|
||||
let api = '';
|
||||
|
||||
switch (type) {
|
||||
case 'log':
|
||||
api = `/api/logs/${id}/discover`;
|
||||
break;
|
||||
case 'filter':
|
||||
api = `/api/filters/${id}/discover`
|
||||
break;
|
||||
}
|
||||
try {
|
||||
const response = await this.$axios.get(api);
|
||||
|
||||
return response.data.stats;
|
||||
} catch(error) {
|
||||
apiError(error, "Failed to load the Compare's States.");
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Get file's name
|
||||
*/
|
||||
async getFileName(id) {
|
||||
id = Number(id)
|
||||
try {
|
||||
const response = await this.$axios.get('/api/files');
|
||||
const file = response.data.find(i => i.id === id);
|
||||
|
||||
if(file) return file.name;
|
||||
} catch(error) {
|
||||
apiError(error, "Failed to load the Compare's file name.");
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user