Files: Filter files can enter Discover.
This commit is contained in:
@@ -83,7 +83,13 @@ export default defineStore('allMapDataStore', {
|
||||
async getAllMapData() {
|
||||
let logId = this.logId;
|
||||
let tempFilterId = this.tempFilterId;
|
||||
let api = tempFilterId != null ? `/api/temp-filters/${tempFilterId}/discover` : `/api/logs/${logId}/discover`;
|
||||
let filterId = this.createFilterId
|
||||
let api = '';
|
||||
|
||||
// 先判斷暫存 再判斷 filter 最後 log
|
||||
if(tempFilterId != null) api = `/api/temp-filters/${tempFilterId}/discover`;
|
||||
else if(filterId!= null) api = `/api/filters/${filterId}/discover`;
|
||||
else api = `/api/logs/${logId}/discover`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.get(api);
|
||||
@@ -230,6 +236,7 @@ export default defineStore('allMapDataStore', {
|
||||
const response = await this.$axios.post(api, createFilterObj)
|
||||
this.createFilterId = response.data.id;
|
||||
this.tempFilterId = null;
|
||||
console.log('this.createFilterId', this.createFilterId);
|
||||
}catch(error) {
|
||||
this.httpStatus = error.request.status;
|
||||
await delay();
|
||||
|
||||
@@ -43,9 +43,7 @@ export default defineStore('filesStore', {
|
||||
allFiles: state => {
|
||||
let result = [
|
||||
...state.allEventLog,
|
||||
...state.allFilter.map(itemFilter => {
|
||||
return { ...itemFilter, parentLog: itemFilter.log.name }
|
||||
})
|
||||
...state.allFilter
|
||||
];
|
||||
let data = state.switchFilesTagData;
|
||||
let filesTag = state.filesTag;
|
||||
@@ -101,6 +99,7 @@ export default defineStore('filesStore', {
|
||||
this.allFilter = response.data;
|
||||
this.allFilter.map(o => {
|
||||
o.icon = 'tornado';
|
||||
o.parentLog = o.log.name;
|
||||
o.fileType = "Filter";
|
||||
o.ownerName = o.owner.name;
|
||||
o.updated_at = moment(o.updated_at).utcOffset('+08:00').format('YYYY-MM-DD HH:MM');
|
||||
|
||||
@@ -72,7 +72,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import filesStore from '@/stores/files.js';
|
||||
import AllMapDataStore from '@/stores/allMapData.js';
|
||||
import IconDataFormat from '@/components/icons/IconDataFormat.vue';
|
||||
import IconRule from '@/components/icons/IconRule.vue';
|
||||
import IconsFilter from '@/components/icons/IconsFilter.vue';
|
||||
@@ -85,15 +87,14 @@
|
||||
data() {
|
||||
return {
|
||||
switchListOrGrid: false,
|
||||
filesTag: 'all',
|
||||
}
|
||||
},
|
||||
setup() {
|
||||
const store = filesStore();
|
||||
const allMapDataStore = AllMapDataStore();
|
||||
const { createFilterId } = storeToRefs(allMapDataStore);
|
||||
|
||||
return {
|
||||
store,
|
||||
}
|
||||
return { store, allMapDataStore, createFilterId }
|
||||
},
|
||||
components: {
|
||||
IconDataFormat,
|
||||
@@ -131,7 +132,13 @@
|
||||
* @param {object} file
|
||||
*/
|
||||
enterDiscover(file){
|
||||
this.$router.push({ name: 'Discover', params: { logId: file.id }});
|
||||
let logId;
|
||||
if(file.fileType === 'Log') logId = file.id;
|
||||
else if(file.fileType === 'Filter') {
|
||||
this.createFilterId = file.id;
|
||||
logId = file.log.id;
|
||||
}
|
||||
this.$router.push({ name: 'Discover', params: { logId: logId }});
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
|
||||
Reference in New Issue
Block a user