feat: Compare SidebarStates API done.

This commit is contained in:
chiayin
2024-02-20 17:40:19 +08:00
parent 1eadcdd506
commit a6a007abd2
5 changed files with 167 additions and 127 deletions

View File

@@ -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.');
};
},
/**

View File

@@ -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.");
}
}
},
})