feat: Conformance Save Log Done.
This commit is contained in:
@@ -10,6 +10,8 @@ export default defineStore('conformanceStore', {
|
||||
conformanceFilterId: null, // filter 檔
|
||||
conformanceLogTempCheckId: null, // log 檔存檔前的 check Id
|
||||
conformanceFilterTempCheckId: null, // Filter 檔存檔前的 check Id
|
||||
conformanceLogCreateCheckId: null, // log 檔存檔後的 check Id
|
||||
conformanceFilterCreateCheckId: null, // Filter 檔存檔後的 check Id
|
||||
allConformanceTask: [],
|
||||
allCfmSeqStart: [],
|
||||
allCfmSeqEnd: [],
|
||||
@@ -32,6 +34,9 @@ export default defineStore('conformanceStore', {
|
||||
infinite404: null,
|
||||
isStartSelected: null, // start & end 連動先選擇 start
|
||||
isEndSelected: null, // start & end 連動先選擇 end
|
||||
conformanceRuleData: null, // create checkId's data to save
|
||||
isUpdataConformance: false, // 成功儲存後要跳 Modal
|
||||
conformanceFileName: null, // 儲存成功的 Modal 用
|
||||
}),
|
||||
getters: {
|
||||
conformanceAllTasks: state => {
|
||||
@@ -225,11 +230,15 @@ export default defineStore('conformanceStore', {
|
||||
async getConformanceReport() {
|
||||
let logTempCheckId = this.conformanceLogTempCheckId;
|
||||
let filterTempCheckId = this.conformanceFilterTempCheckId;
|
||||
let logCreateCheckId = this.conformanceLogCreateCheckId;
|
||||
let filterCreateCheckId = this.conformanceFilterCreateCheckId;
|
||||
let api = '';
|
||||
|
||||
// 先判斷 filter 檔,再判斷 log 檔。
|
||||
// 先判斷 Temp 再判斷原 ID;先判斷 filter 檔,再判斷 log 檔。
|
||||
if(filterTempCheckId !== null) api = `/api/temp-filter-checks/${filterTempCheckId}`;
|
||||
else api = `/api/temp-log-checks/${logTempCheckId}`;
|
||||
else if(logTempCheckId !== null) api = `/api/temp-log-checks/${logTempCheckId}`;
|
||||
else if(filterCreateCheckId !== null) api = `/api/filter-checks/${filterCreateCheckId}`;
|
||||
else if(logCreateCheckId !== null) api = `/api/log-checks/${logCreateCheckId}`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.get(api);
|
||||
@@ -243,12 +252,16 @@ export default defineStore('conformanceStore', {
|
||||
*/
|
||||
async getConformanceIssue(issueNo) {
|
||||
let logTempCheckId = this.conformanceLogTempCheckId;
|
||||
let filterTempCheckId = this.conformanceFilterTempCheckId
|
||||
let filterTempCheckId = this.conformanceFilterTempCheckId;
|
||||
let logCreateCheckId = this.conformanceLogCreateCheckId;
|
||||
let filterCreateCheckId = this.conformanceFilterCreateCheckId;
|
||||
let api = '';
|
||||
|
||||
// 先判斷 filter 檔,再判斷 log 檔。
|
||||
if(filterTempCheckId !== null) api = `/api/temp-filter-checks/${filterTempCheckId}/issues/${issueNo}`;
|
||||
else api = `/api/temp-log-checks/${logTempCheckId}/issues/${issueNo}`;
|
||||
else if(logTempCheckId !== null) api = `/api/temp-log-checks/${logTempCheckId}/issues/${issueNo}`;
|
||||
else if(filterCreateCheckId !== null) api = `/api/filter-checks/${filterCreateCheckId}/issues/${issueNo}`;
|
||||
else if(logCreateCheckId !== null) api = `/api/log-checks/${logCreateCheckId}/issues/${issueNo}`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.get(api);
|
||||
@@ -262,12 +275,16 @@ export default defineStore('conformanceStore', {
|
||||
*/
|
||||
async getConformanceTraceDetail(issueNo, traceId, start) {
|
||||
let logTempCheckId = this.conformanceLogTempCheckId;
|
||||
let filterTempCheckId = this.conformanceFilterTempCheckId
|
||||
let filterTempCheckId = this.conformanceFilterTempCheckId;
|
||||
let logCreateCheckId = this.conformanceLogCreateCheckId;
|
||||
let filterCreateCheckId = this.conformanceFilterCreateCheckId;
|
||||
let api = '';
|
||||
|
||||
// 先判斷 filter 檔,再判斷 log 檔。
|
||||
if(filterTempCheckId !== null) api = `/api/temp-filter-checks/${filterTempCheckId}/issues/${issueNo}/traces/${traceId}?start=${start}&page_size=20`;
|
||||
else api = `/api/temp-log-checks/${logTempCheckId}/issues/${issueNo}/traces/${traceId}?start=${start}&page_size=20`;
|
||||
else if(logTempCheckId !== null) api = `/api/temp-log-checks/${logTempCheckId}/issues/${issueNo}/traces/${traceId}?start=${start}&page_size=20`;
|
||||
else if(filterCreateCheckId !== null) api = `/api/filter-checks/${filterCreateCheckId}/issues/${issueNo}/traces/${traceId}?start=${start}&page_size=20`;
|
||||
else if(logCreateCheckId !== null) api = `/api/log-checks/${logCreateCheckId}/issues/${issueNo}/traces/${traceId}?start=${start}&page_size=20`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.get(api);
|
||||
@@ -284,12 +301,16 @@ export default defineStore('conformanceStore', {
|
||||
*/
|
||||
async getConformanceLoop(loopNo) {
|
||||
let logTempCheckId = this.conformanceLogTempCheckId;
|
||||
let filterTempCheckId = this.conformanceFilterTempCheckId
|
||||
let filterTempCheckId = this.conformanceFilterTempCheckId;
|
||||
let logCreateCheckId = this.conformanceLogCreateCheckId;
|
||||
let filterCreateCheckId = this.conformanceFilterCreateCheckId;
|
||||
let api = '';
|
||||
|
||||
// 先判斷 filter 檔,再判斷 log 檔。
|
||||
if(filterTempCheckId !== null) api = `/api/temp-filter-checks/${filterTempCheckId}/loops/${loopNo}`;
|
||||
else api = `/api/temp-log-checks/${logTempCheckId}/loops/${loopNo}`;
|
||||
else if(logTempCheckId !== null) api = `/api/temp-log-checks/${logTempCheckId}/loops/${loopNo}`;
|
||||
else if(filterCreateCheckId !== null) api = `/api/filter-checks/${filterCreateCheckId}/loops/${loopNo}`;
|
||||
else if(logCreateCheckId !== null) api = `/api/log-checks/${logCreateCheckId}/loops/${loopNo}`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.get(api);
|
||||
@@ -303,12 +324,16 @@ export default defineStore('conformanceStore', {
|
||||
*/
|
||||
async getConformanceLoopsTraceDetail(loopNo, traceId, start) {
|
||||
let logTempCheckId = this.conformanceLogTempCheckId;
|
||||
let filterTempCheckId = this.conformanceFilterTempCheckId
|
||||
let filterTempCheckId = this.conformanceFilterTempCheckId;
|
||||
let logCreateCheckId = this.conformanceLogCreateCheckId;
|
||||
let filterCreateCheckId = this.conformanceFilterCreateCheckId;
|
||||
let api = '';
|
||||
|
||||
// 先判斷 filter 檔,再判斷 log 檔。
|
||||
if(filterTempCheckId !== null) api = `/api/temp-filter-checks/${filterTempCheckId}/loops/${loopNo}/traces/${traceId}?start=${start}&page_size=20`;
|
||||
else api = `/api/temp-log-checks/${logTempCheckId}/loops/${loopNo}/traces/${traceId}?start=${start}&page_size=20`;
|
||||
else if(logTempCheckId !== null) api = `/api/temp-log-checks/${logTempCheckId}/loops/${loopNo}/traces/${traceId}?start=${start}&page_size=20`;
|
||||
else if(filterCreateCheckId !== null) api = `/api/filter-checks/${filterCreateCheckId}/loops/${loopNo}/traces/${traceId}?start=${start}&page_size=20`;
|
||||
else if(logCreateCheckId !== null) api = `/api/log-checks/${logCreateCheckId}/loops/${loopNo}/traces/${traceId}?start=${start}&page_size=20`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.get(api);
|
||||
@@ -320,5 +345,57 @@ export default defineStore('conformanceStore', {
|
||||
apiError(error, 'Failed to Get the detail of a temporary log conformance loop.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Add a New Log Conformance Check, Save the log file.
|
||||
*/
|
||||
async addConformanceCreateCheckId(value) {
|
||||
let logId = this.conformanceLogId;
|
||||
let filterId = this.conformanceFilterId;
|
||||
let api = '';
|
||||
let data = {
|
||||
name: value,
|
||||
rule: this.conformanceRuleData
|
||||
};
|
||||
|
||||
// 先判斷 filter 檔,再判斷 log 檔。
|
||||
if(filterId !== null) api = `/api/filter-checks?filter_id=${filterId}`;
|
||||
else api = `/api/log-checks?log_id=${logId}`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.post(api, data);
|
||||
if(filterId !== null) {
|
||||
this.conformanceFilterCreateCheckId = response.data.id;
|
||||
this.conformanceFilterTempCheckId = null;
|
||||
}
|
||||
else {
|
||||
this.conformanceLogCreateCheckId = response.data.id;
|
||||
this.conformanceLogTempCheckId= null;
|
||||
}
|
||||
}catch(error) {
|
||||
apiError(error, 'Failed to add the Conformance Check for a file.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Updata an Existing Conformance Check, log and filter
|
||||
*/
|
||||
async updataConformance() {
|
||||
let logCreateCheckId = this.conformanceLogCreateCheckId;
|
||||
let filterCreateCheckId = this.conformanceFilterCreateCheckId;
|
||||
let api = '';
|
||||
const data = this.conformanceRuleData;
|
||||
|
||||
// 先判斷有無 Temp ID,再判斷原始檔 ID
|
||||
if(filterCreateCheckId !== null) api = `/api/filter-checks/${filterCreateCheckId}`;
|
||||
else if(logCreateCheckId !== null) api = `/api/log-checks/${logCreateCheckId}`;
|
||||
|
||||
try {
|
||||
const response = await this.$axios.put(api, data);
|
||||
this.isUpdataConformance = response.status === 200;
|
||||
this.conformanceLogTempCheckId = null;
|
||||
this.conformanceFilterTempCheckId = null;
|
||||
}catch(error) {
|
||||
apiError(error, 'Failed to updata an Existing Conformance.');
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -16,6 +16,20 @@ export default defineStore('filesStore', {
|
||||
ownerName: '',
|
||||
}
|
||||
],
|
||||
allConformanceLog: [
|
||||
{
|
||||
log: {},
|
||||
fileType: '',
|
||||
ownerName: '',
|
||||
}
|
||||
],
|
||||
allConformanceFilter: [
|
||||
{
|
||||
filter: {},
|
||||
fileType: '',
|
||||
ownerName: '',
|
||||
}
|
||||
],
|
||||
allEventLog: [
|
||||
{
|
||||
parentLog: '',
|
||||
@@ -39,7 +53,9 @@ export default defineStore('filesStore', {
|
||||
allFiles: state => {
|
||||
let result = [
|
||||
...state.allEventLog,
|
||||
...state.allFilter
|
||||
...state.allFilter,
|
||||
...state.allConformanceLog,
|
||||
...state.allConformanceFilter
|
||||
];
|
||||
let data = state.switchFilesTagData;
|
||||
let filesTag = state.filesTag;
|
||||
@@ -101,6 +117,56 @@ export default defineStore('filesStore', {
|
||||
apiError(error, 'Failed to load the filters.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Fetch Conformance Log api
|
||||
*/
|
||||
async fetchConformanceLog() {
|
||||
const api = '/api/log-checks';
|
||||
|
||||
try {
|
||||
const response = await axios.get(api);
|
||||
|
||||
this.allConformanceLog = response.data;
|
||||
this.allConformanceLog.map(o => {
|
||||
o.icon = 'local_police';
|
||||
o.parentLog = o.log.name;
|
||||
o.fileType = "Rule";
|
||||
o.ownerName = o.owner.name;
|
||||
o.updated_base = o.updated_at;
|
||||
o.accessed_base = o.accessed_at;
|
||||
o.updated_at = moment(o.updated_at).utcOffset('+08:00').format('YYYY-MM-DD HH:mm');
|
||||
o.accessed_at = o.accessed_at ? moment(o.accessed_at).utcOffset('+08:00').format('YYYY-MM-DD HH:mm') : null;
|
||||
});
|
||||
if(this.httpStatus < 300) loading.isLoading = false;
|
||||
} catch(error) {
|
||||
apiError(error, 'Failed to load the filters.');
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Fetch Conformance Filter api
|
||||
*/
|
||||
async fetchConformanceFilter() {
|
||||
const api = '/api/filter-checks';
|
||||
|
||||
try {
|
||||
const response = await axios.get(api);
|
||||
|
||||
this.allConformancefilter = response.data;
|
||||
this.allConformancefilter.map(o => {
|
||||
o.icon = 'local_police';
|
||||
o.parentLog = o.filter.name;
|
||||
o.fileType = "Rule";
|
||||
o.ownerName = o.owner.name;
|
||||
o.updated_base = o.updated_at;
|
||||
o.accessed_base = o.accessed_at;
|
||||
o.updated_at = moment(o.updated_at).utcOffset('+08:00').format('YYYY-MM-DD HH:mm');
|
||||
o.accessed_at = o.accessed_at ? moment(o.accessed_at).utcOffset('+08:00').format('YYYY-MM-DD HH:mm') : null;
|
||||
});
|
||||
if(this.httpStatus < 300) loading.isLoading = false;
|
||||
} catch(error) {
|
||||
apiError(error, 'Failed to load the filters.');
|
||||
};
|
||||
},
|
||||
// fetchRule(){o.icon = local_police}
|
||||
// fetchDesign(){o.icon = shape_line}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user