Apply repository-wide ESLint auto-fix formatting pass

Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
2026-03-08 12:11:57 +08:00
parent 7c48faaa3d
commit 847904c49b
172 changed files with 13629 additions and 9154 deletions

View File

@@ -13,8 +13,8 @@
import { defineStore } from "pinia";
import moment from "moment";
import apiClient from "@/api/client.js";
import apiError from '@/module/apiError.js';
import { Decimal } from 'decimal.js';
import apiError from "@/module/apiError.js";
import { Decimal } from "decimal.js";
/**
* Returns the API base path for the current map data source,
@@ -30,7 +30,7 @@ function getMapApiBase(state) {
}
/** Pinia store for Discover Map page data and filter management. */
export const useAllMapDataStore = defineStore('allMapDataStore', {
export const useAllMapDataStore = defineStore("allMapDataStore", {
state: () => ({
baseLogId: null,
logId: null,
@@ -68,73 +68,85 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
baseInfiniteStart: 0, // Starting index for base infinite scroll cases
}),
getters: {
processMap: state => {
processMap: (state) => {
return state.allProcessMap;
},
bpmn: state => {
bpmn: (state) => {
return state.allBpmn;
},
stats: state => {
stats: (state) => {
return state.allStats;
},
insights: state => {
insights: (state) => {
return state.allInsights;
},
traces: state => {
traces: (state) => {
return state.allTrace.sort((x, y) => x.id - y.id);
},
baseTraces: state => {
baseTraces: (state) => {
return state.allBaseTrace.sort((x, y) => x.id - y.id);
},
cases: state => {
cases: (state) => {
return state.allCase;
},
baseCases: state => {
baseCases: (state) => {
return state.allBaseCase;
},
infiniteFirstCases: state => {
if(state.infiniteStart === 0) return state.allCase;
infiniteFirstCases: (state) => {
if (state.infiniteStart === 0) return state.allCase;
},
BaseInfiniteFirstCases: state => {
if(state.baseInfiniteStart === 0) return state.allBaseCase;
BaseInfiniteFirstCases: (state) => {
if (state.baseInfiniteStart === 0) return state.allBaseCase;
},
traceTaskSeq: state => {
traceTaskSeq: (state) => {
return state.allTraceTaskSeq;
},
baseTraceTaskSeq: state => {
baseTraceTaskSeq: (state) => {
return state.allBaseTraceTaskSeq;
},
// All tasks
filterTasks: state => {
filterTasks: (state) => {
return state.allFilterTask;
},
// form start to end tasks
filterStartToEnd: state => {
filterStartToEnd: (state) => {
return state.allFilterStartToEnd;
},
// form end to start tasks
filterEndToStart: state => {
filterEndToStart: (state) => {
return state.allFilterEndToStart;
},
filterTimeframe: state => {
filterTimeframe: (state) => {
return state.allFilterTimeframe;
},
filterTrace: state => {
filterTrace: (state) => {
return state.allFilterTrace;
},
filterAttrs: state => {
if(state.allFilterAttrs !== null){
return state.allFilterAttrs.map(att => {
filterAttrs: (state) => {
if (state.allFilterAttrs !== null) {
return state.allFilterAttrs.map((att) => {
const copy = { ...att };
switch (copy.type) {
case 'date':
copy.min = copy.min !== null ? moment(copy.min).format('YYYY/MM/DD HH:mm') : null;
copy.max = copy.max !== null ? moment(copy.max).format('YYYY/MM/DD HH:mm') : null;
case "date":
copy.min =
copy.min !== null
? moment(copy.min).format("YYYY/MM/DD HH:mm")
: null;
copy.max =
copy.max !== null
? moment(copy.max).format("YYYY/MM/DD HH:mm")
: null;
break;
case "float":
copy.min =
copy.min !== null
? Number(new Decimal(copy.min).toFixed(2, 1))
: null;
copy.max =
copy.max !== null
? Number(new Decimal(copy.max).toFixed(2, 0))
: null;
break;
case 'float':
copy.min = copy.min !== null ? Number(new Decimal(copy.min).toFixed(2, 1)) : null;
copy.max = copy.max !== null ? Number(new Decimal(copy.max).toFixed(2, 0)) : null;
break
default:
break;
}
@@ -142,7 +154,7 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
});
}
},
allFunnels: state => {
allFunnels: (state) => {
return state.allFunnelData;
},
},
@@ -158,9 +170,9 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
this.allBpmn = response.data.bpmn;
this.allStats = response.data.stats;
this.allInsights = response.data.insights;
} catch(error) {
apiError(error, 'Failed to load the Map.');
};
} catch (error) {
apiError(error, "Failed to load the Map.");
}
},
/**
* fetch trace api.
@@ -173,12 +185,12 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
let baseResponse;
const response = await apiClient.get(api);
this.allTrace = response.data;
if(baseLogId) {
if (baseLogId) {
baseResponse = await apiClient.get(baseApi);
this.allBaseTrace = baseResponse.data;
}
} catch(error) {
apiError(error, 'Failed to load the Trace.');
} catch (error) {
apiError(error, "Failed to load the Trace.");
}
},
/**
@@ -192,30 +204,36 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
const response = await apiClient.get(api);
this.allTraceTaskSeq = response.data.task_seq;
this.allCase = response.data.cases;
this.allCase.forEach(c => {
c.started_at = moment(c.started_at).format('YYYY/MM/DD HH:mm');
c.completed_at = moment(c.completed_at).format('YYYY/MM/DD HH:mm');
c.attributes.forEach(att => {
this.allCase.forEach((c) => {
c.started_at = moment(c.started_at).format("YYYY/MM/DD HH:mm");
c.completed_at = moment(c.completed_at).format("YYYY/MM/DD HH:mm");
c.attributes.forEach((att) => {
switch (att.type) {
case 'date':
att.value = att.value !== null ? moment(att.value).format('YYYY/MM/DD HH:mm') : null;
case "date":
att.value =
att.value !== null
? moment(att.value).format("YYYY/MM/DD HH:mm")
: null;
break;
case 'float':
att.value = att.value !== null ? Number(new Decimal(att.value).toFixed(2)) : null;
case "float":
att.value =
att.value !== null
? Number(new Decimal(att.value).toFixed(2))
: null;
break;
default:
break;
}
})
});
});
return this.allCase;
} catch(error) {
if(error.response?.status === 404) {
} catch (error) {
if (error.response?.status === 404) {
this.infinite404 = 404;
return;
}
apiError(error, 'Failed to load the Trace Detail.');
};
apiError(error, "Failed to load the Trace Detail.");
}
},
/**
* fetch base log trace detail api.
@@ -230,30 +248,36 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
const response = await apiClient.get(api);
this.allBaseTraceTaskSeq = response.data.task_seq;
this.allBaseCase = response.data.cases;
this.allBaseCase.forEach(c => {
c.started_at = moment(c.started_at).format('YYYY/MM/DD HH:mm');
c.completed_at = moment(c.completed_at).format('YYYY/MM/DD HH:mm');
c.attributes.forEach(att => {
this.allBaseCase.forEach((c) => {
c.started_at = moment(c.started_at).format("YYYY/MM/DD HH:mm");
c.completed_at = moment(c.completed_at).format("YYYY/MM/DD HH:mm");
c.attributes.forEach((att) => {
switch (att.type) {
case 'date':
att.value = att.value !== null ? moment(att.value).format('YYYY/MM/DD HH:mm') : null;
case "date":
att.value =
att.value !== null
? moment(att.value).format("YYYY/MM/DD HH:mm")
: null;
break;
case 'float':
att.value = att.value !== null ? Number(new Decimal(att.value).toFixed(2)) : null;
case "float":
att.value =
att.value !== null
? Number(new Decimal(att.value).toFixed(2))
: null;
break;
default:
break;
}
})
});
});
return this.allBaseCase;
} catch(error) {
if(error.response?.status === 404) {
} catch (error) {
if (error.response?.status === 404) {
this.infinite404 = 404;
return;
}
apiError(error, 'Failed to load the Base Trace Detail.');
};
apiError(error, "Failed to load the Base Trace Detail.");
}
},
/**
* fetch Filter Parameters api.
@@ -277,11 +301,13 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
this.allFilterTimeframe.x_axis.min_base = min;
this.allFilterTimeframe.x_axis.max_base = max;
// Convert to a time format without seconds
this.allFilterTimeframe.x_axis.min = min !== null ? moment(min).format('YYYY/MM/DD HH:mm') : null;
this.allFilterTimeframe.x_axis.max = max !== null ? moment(max).format('YYYY/MM/DD HH:mm') : null;
} catch(error) {
apiError(error, 'Failed to load the Filter Parameters.');
};
this.allFilterTimeframe.x_axis.min =
min !== null ? moment(min).format("YYYY/MM/DD HH:mm") : null;
this.allFilterTimeframe.x_axis.max =
max !== null ? moment(max).format("YYYY/MM/DD HH:mm") : null;
} catch (error) {
apiError(error, "Failed to load the Filter Parameters.");
}
},
/**
* Test if the Filter Rules Result in Any Data
@@ -291,11 +317,11 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
const api = `/api/filters/has-result?log_id=${logId}`;
try {
const response = await apiClient.post(api, this.postRuleData)
const response = await apiClient.post(api, this.postRuleData);
this.hasResultRule = response.data.result;
} catch(error) {
apiError(error, 'Failed to load the Has Result.');
};
} catch (error) {
apiError(error, "Failed to load the Has Result.");
}
},
/**
* Add a New Temporary Filter
@@ -305,11 +331,11 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
const api = `/api/temp-filters?log_id=${logId}`;
try {
const response = await apiClient.post(api, this.postRuleData)
const response = await apiClient.post(api, this.postRuleData);
this.tempFilterId = response.data.id;
} catch(error) {
apiError(error, 'Failed to add the Temporary Filters.');
};
} catch (error) {
apiError(error, "Failed to add the Temporary Filters.");
}
},
/**
* Add a New Filter
@@ -320,16 +346,16 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
const api = `/api/filters?log_id=${logId}`;
const createFilterObj = {
name: value,
rules: this.postRuleData
rules: this.postRuleData,
};
try {
const response = await apiClient.post(api, createFilterObj);
this.createFilterId = response.data.id;
this.tempFilterId = null;
}catch(error) {
apiError(error, 'Failed to load the Filters.');
};
} catch (error) {
apiError(error, "Failed to load the Filters.");
}
},
/**
* Get Filter Detail
@@ -338,15 +364,15 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
async fetchFunnel(createFilterId) {
const api = `/api/filters/${createFilterId}`;
if(createFilterId){
if (createFilterId) {
try {
const response = await apiClient.get(api);
this.temporaryData = response.data.rules;
this.logId = response.data.log.id;
this.filterName = response.data.name;
this.baseLogId = response.data.log.id;
}catch(error) {
apiError(error, 'Failed to get Filter Detail.');
} catch (error) {
apiError(error, "Failed to get Filter Detail.");
}
}
},
@@ -354,7 +380,7 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
* Update an Existing Filter
*/
async updateFilter() {
const createFilterId = this.createFilterId
const createFilterId = this.createFilterId;
const api = `/api/filters/${createFilterId}`;
const data = this.postRuleData;
@@ -362,9 +388,9 @@ export const useAllMapDataStore = defineStore('allMapDataStore', {
const response = await apiClient.put(api, data);
this.isUpdateFilter = response.status === 200;
this.tempFilterId = null;
}catch(error) {
apiError(error, 'Failed to update an Existing Filter.');
} catch (error) {
apiError(error, "Failed to update an Existing Filter.");
}
},
},
})
});

View File

@@ -11,15 +11,15 @@
import { defineStore } from "pinia";
import apiClient from "@/api/client.js";
import apiError from '@/module/apiError.js';
import apiError from "@/module/apiError.js";
/** Pinia store for the Compare Dashboard page data. */
export const useCompareStore = defineStore('compareStore', {
export const useCompareStore = defineStore("compareStore", {
state: () => ({
allCompareDashboardData: null,
}),
getters: {
compareDashboardData: state => {
compareDashboardData: (state) => {
return state.allCompareDashboardData;
},
},
@@ -36,8 +36,8 @@ export const useCompareStore = defineStore('compareStore', {
try {
const response = await apiClient.get(api);
this.allCompareDashboardData = response.data;
} catch(error) {
apiError(error, 'Failed to load the Compare.');
} catch (error) {
apiError(error, "Failed to load the Compare.");
}
},
/**
@@ -46,38 +46,38 @@ export const useCompareStore = defineStore('compareStore', {
* @param {number} id log or filter ID
*/
async getStateData(type, id) {
let api = '';
let api = "";
switch (type) {
case 'log':
case "log":
api = `/api/logs/${id}/discover`;
break;
case 'filter':
api = `/api/filters/${id}/discover`
case "filter":
api = `/api/filters/${id}/discover`;
break;
}
try {
const response = await apiClient.get(api);
return response.data.stats;
} catch(error) {
} catch (error) {
apiError(error, "Failed to load the Compare's States.");
};
}
},
/**
* Get file's name
* @param {number} id log or filter ID
*/
async getFileName(id) {
id = Number(id)
id = Number(id);
try {
const response = await apiClient.get('/api/files');
const file = response.data.find(i => i.id === id);
const response = await apiClient.get("/api/files");
const file = response.data.find((i) => i.id === id);
if(file) return file.name;
} catch(error) {
if (file) return file.name;
} catch (error) {
apiError(error, "Failed to load the Compare's file name.");
}
}
},
},
})
});

View File

@@ -11,10 +11,10 @@
import { defineStore } from "pinia";
import moment from "moment";
import { Decimal } from 'decimal.js';
import abbreviateNumber from '@/module/abbreviateNumber.js';
import { Decimal } from "decimal.js";
import abbreviateNumber from "@/module/abbreviateNumber.js";
import apiClient from "@/api/client.js";
import apiError from '@/module/apiError.js';
import apiError from "@/module/apiError.js";
/**
* Returns the API base path for the current conformance check,
@@ -23,13 +23,21 @@ import apiError from '@/module/apiError.js';
* @returns {string} The API base path.
*/
function getCheckApiBase(state) {
const { conformanceFilterTempCheckId, conformanceLogTempCheckId,
conformanceFilterCreateCheckId, conformanceLogCreateCheckId } = state;
if (conformanceFilterTempCheckId !== null) return `/api/temp-filter-checks/${conformanceFilterTempCheckId}`;
if (conformanceLogTempCheckId !== null) return `/api/temp-log-checks/${conformanceLogTempCheckId}`;
if (conformanceFilterCreateCheckId !== null) return `/api/filter-checks/${conformanceFilterCreateCheckId}`;
if (conformanceLogCreateCheckId !== null) return `/api/log-checks/${conformanceLogCreateCheckId}`;
return '';
const {
conformanceFilterTempCheckId,
conformanceLogTempCheckId,
conformanceFilterCreateCheckId,
conformanceLogCreateCheckId,
} = state;
if (conformanceFilterTempCheckId !== null)
return `/api/temp-filter-checks/${conformanceFilterTempCheckId}`;
if (conformanceLogTempCheckId !== null)
return `/api/temp-log-checks/${conformanceLogTempCheckId}`;
if (conformanceFilterCreateCheckId !== null)
return `/api/filter-checks/${conformanceFilterCreateCheckId}`;
if (conformanceLogCreateCheckId !== null)
return `/api/log-checks/${conformanceLogCreateCheckId}`;
return "";
}
/**
@@ -41,13 +49,13 @@ function getCheckApiBase(state) {
function getFileTypeApi(state) {
const { conformanceFilterId, conformanceLogId } = state;
if (conformanceFilterId !== null) {
return { prefix: 'filter', idParam: `filter_id=${conformanceFilterId}` };
return { prefix: "filter", idParam: `filter_id=${conformanceFilterId}` };
}
return { prefix: 'log', idParam: `log_id=${conformanceLogId}` };
return { prefix: "log", idParam: `log_id=${conformanceLogId}` };
}
/** Pinia store for conformance checking and rule management. */
export const useConformanceStore = defineStore('conformanceStore', {
export const useConformanceStore = defineStore("conformanceStore", {
state: () => ({
conformanceLogId: null, // Log file
conformanceFilterId: null, // Filter file
@@ -69,12 +77,12 @@ export const useConformanceStore = defineStore('conformanceStore', {
allLoopTraces: null,
allLoopTaskSeq: null,
allLoopCases: null,
selectedRuleType: 'Have activity', // radio
selectedActivitySequence: 'Start & End', // radio
selectedMode: 'Directly follows', // radio
selectedProcessScope: 'End to end', // radio
selectedActSeqMore: 'All', // radio
selectedActSeqFromTo: 'From', // radio
selectedRuleType: "Have activity", // radio
selectedActivitySequence: "Start & End", // radio
selectedMode: "Directly follows", // radio
selectedProcessScope: "End to end", // radio
selectedActSeqMore: "All", // radio
selectedActSeqFromTo: "From", // radio
infinite404: null,
isStartSelected: null, // Whether start is selected in linked start & end selection
isEndSelected: null, // Whether end is selected in linked start & end selection
@@ -83,109 +91,119 @@ export const useConformanceStore = defineStore('conformanceStore', {
conformanceFileName: null, // File name displayed in the save success modal
}),
getters: {
conformanceAllTasks: state => {
conformanceAllTasks: (state) => {
return state.allConformanceTask;
},
conformanceTask: state => {
return state.allConformanceTask.map(i => i.label);
conformanceTask: (state) => {
return state.allConformanceTask.map((i) => i.label);
},
cfmSeqStart: state => {
cfmSeqStart: (state) => {
return state.allCfmSeqStart;
},
cfmSeqEnd: state => {
cfmSeqEnd: (state) => {
return state.allCfmSeqEnd;
},
cfmPtEteWhole: state => {
cfmPtEteWhole: (state) => {
return state.allProcessingTime.end_to_end.whole;
},
cfmPtEteStart: state => {
cfmPtEteStart: (state) => {
return state.allProcessingTime.end_to_end.starts_with;
},
cfmPtEteEnd: state => {
cfmPtEteEnd: (state) => {
return state.allProcessingTime.end_to_end.ends_with;
},
cfmPtEteSE: state => {
cfmPtEteSE: (state) => {
return state.allProcessingTime.end_to_end.start_end;
},
cfmPtPStart: state => {
cfmPtPStart: (state) => {
return state.allProcessingTime.partial.starts_with;
},
cfmPtPEnd: state => {
cfmPtPEnd: (state) => {
return state.allProcessingTime.partial.ends_with;
},
cfmPtPSE: state => {
cfmPtPSE: (state) => {
return state.allProcessingTime.partial.start_end;
},
cfmWtEteWhole: state => {
cfmWtEteWhole: (state) => {
return state.allWaitingTime.end_to_end.whole;
},
cfmWtEteStart: state => {
cfmWtEteStart: (state) => {
return state.allWaitingTime.end_to_end.starts_with;
},
cfmWtEteEnd: state => {
cfmWtEteEnd: (state) => {
return state.allWaitingTime.end_to_end.ends_with;
},
cfmWtEteSE: state => {
cfmWtEteSE: (state) => {
return state.allWaitingTime.end_to_end.start_end;
},
cfmWtPStart: state => {
cfmWtPStart: (state) => {
return state.allWaitingTime.partial.starts_with;
},
cfmWtPEnd: state => {
cfmWtPEnd: (state) => {
return state.allWaitingTime.partial.ends_with;
},
cfmWtPSE: state => {
cfmWtPSE: (state) => {
return state.allWaitingTime.partial.start_end;
},
cfmCtEteWhole: state => {
cfmCtEteWhole: (state) => {
return state.allCycleTime.end_to_end.whole;
},
cfmCtEteStart: state => {
cfmCtEteStart: (state) => {
return state.allCycleTime.end_to_end.starts_with;
},
cfmCtEteEnd: state => {
cfmCtEteEnd: (state) => {
return state.allCycleTime.end_to_end.ends_with;
},
cfmCtEteSE: state => {
cfmCtEteSE: (state) => {
return state.allCycleTime.end_to_end.start_end;
},
conformanceTempReportData: state => {
conformanceTempReportData: (state) => {
return state.allConformanceTempReportData;
},
routeFile: state => {
routeFile: (state) => {
return state.allRouteFile;
},
issueTraces: state => {
issueTraces: (state) => {
return state.allIssueTraces;
},
taskSeq: state => {
taskSeq: (state) => {
return state.allTaskSeq;
},
cases: state => {
if(state.allCases !== null){
return state.allCases.map(c => {
const facets = c.facets.map(fac => {
cases: (state) => {
if (state.allCases !== null) {
return state.allCases.map((c) => {
const facets = c.facets.map((fac) => {
const copy = { ...fac };
switch(copy.type) {
case 'dummy': //sonar-qube
case 'duration-list':
copy.value = copy.value.map(v => v !== null ? abbreviateNumber(new Decimal(v.toFixed(2))) : null);
copy.value = (copy.value).map(v => v.trim()).join(', ');
switch (copy.type) {
case "dummy": //sonar-qube
case "duration-list":
copy.value = copy.value.map((v) =>
v !== null
? abbreviateNumber(new Decimal(v.toFixed(2)))
: null,
);
copy.value = copy.value.map((v) => v.trim()).join(", ");
break;
default:
break;
};
}
return copy;
});
const attributes = c.attributes.map(att => {
const attributes = c.attributes.map((att) => {
const copy = { ...att };
switch (copy.type) {
case 'date':
copy.value = copy.value !== null ? moment(copy.value).format('YYYY/MM/DD HH:mm:ss') : null;
case "date":
copy.value =
copy.value !== null
? moment(copy.value).format("YYYY/MM/DD HH:mm:ss")
: null;
break;
case "float":
copy.value =
copy.value !== null
? new Decimal(copy.value).toFixed(2)
: null;
break;
case 'float':
copy.value = copy.value !== null ? new Decimal(copy.value).toFixed(2) : null;
break
default:
break;
}
@@ -193,32 +211,38 @@ export const useConformanceStore = defineStore('conformanceStore', {
});
return {
...c,
started_at: moment(c.started_at).format('YYYY/MM/DD HH:mm'),
completed_at: moment(c.completed_at).format('YYYY/MM/DD HH:mm'),
started_at: moment(c.started_at).format("YYYY/MM/DD HH:mm"),
completed_at: moment(c.completed_at).format("YYYY/MM/DD HH:mm"),
facets,
attributes,
};
});
};
}
},
loopTraces: state => {
loopTraces: (state) => {
return state.allLoopTraces;
},
loopTaskSeq: state => {
loopTaskSeq: (state) => {
return state.allLoopTaskSeq;
},
loopCases: state => {
if(state.allLoopCases !== null){
return state.allLoopCases.map(c => {
const attributes = c.attributes.map(att => {
loopCases: (state) => {
if (state.allLoopCases !== null) {
return state.allLoopCases.map((c) => {
const attributes = c.attributes.map((att) => {
const copy = { ...att };
switch (copy.type) {
case 'date':
copy.value = copy.value !== null ? moment(copy.value).format('YYYY/MM/DD HH:mm:ss') : null;
case "date":
copy.value =
copy.value !== null
? moment(copy.value).format("YYYY/MM/DD HH:mm:ss")
: null;
break;
case "float":
copy.value =
copy.value !== null
? new Decimal(copy.value).toFixed(2)
: null;
break;
case 'float':
copy.value = copy.value !== null ? new Decimal(copy.value).toFixed(2) : null;
break
default:
break;
}
@@ -226,12 +250,12 @@ export const useConformanceStore = defineStore('conformanceStore', {
});
return {
...c,
started_at: moment(c.started_at).format('YYYY/MM/DD HH:mm'),
completed_at: moment(c.completed_at).format('YYYY/MM/DD HH:mm'),
started_at: moment(c.started_at).format("YYYY/MM/DD HH:mm"),
completed_at: moment(c.completed_at).format("YYYY/MM/DD HH:mm"),
attributes,
};
});
};
}
},
},
actions: {
@@ -249,8 +273,8 @@ export const useConformanceStore = defineStore('conformanceStore', {
this.allProcessingTime = response.data.processing_time;
this.allWaitingTime = response.data.waiting_time;
this.allCycleTime = response.data.cycle_time;
} catch(error) {
apiError(error, 'Failed to load the Conformance Parameters.');
} catch (error) {
apiError(error, "Failed to load the Conformance Parameters.");
}
},
/**
@@ -263,13 +287,13 @@ export const useConformanceStore = defineStore('conformanceStore', {
try {
const response = await apiClient.post(api, data);
if (prefix === 'filter') {
if (prefix === "filter") {
this.conformanceFilterTempCheckId = response.data.id;
} else {
this.conformanceLogTempCheckId = response.data.id;
}
} catch(error) {
apiError(error, 'Failed to add the Temporary Check for a file.');
} catch (error) {
apiError(error, "Failed to add the Temporary Check for a file.");
}
},
/**
@@ -280,13 +304,13 @@ export const useConformanceStore = defineStore('conformanceStore', {
const api = getCheckApiBase(this);
try {
const response = await apiClient.get(api);
if(!getRouteFile) {
this.allConformanceTempReportData = response.data
if (!getRouteFile) {
this.allConformanceTempReportData = response.data;
} else {
this.allRouteFile = response.data.file;
}
} catch(error) {
apiError(error, 'Failed to Get the Temporary Log Conformance Report.');
} catch (error) {
apiError(error, "Failed to Get the Temporary Log Conformance Report.");
}
},
/**
@@ -298,9 +322,12 @@ export const useConformanceStore = defineStore('conformanceStore', {
try {
const response = await apiClient.get(api);
this.allIssueTraces = response.data.traces;
} catch(error) {
apiError(error, 'Failed to Get the detail of a temporary log conformance issue.');
};
} catch (error) {
apiError(
error,
"Failed to Get the detail of a temporary log conformance issue.",
);
}
},
/**
* Get the Trace Details of a Temporary Log Conformance lssue.
@@ -315,13 +342,16 @@ export const useConformanceStore = defineStore('conformanceStore', {
this.allTaskSeq = response.data.task_seq;
this.allCases = response.data.cases;
return response.data.cases;
} catch(error) {
if(error.response?.status === 404) {
} catch (error) {
if (error.response?.status === 404) {
this.infinite404 = 404;
return;
}
apiError(error, 'Failed to Get the detail of a temporary log conformance issue.');
};
apiError(
error,
"Failed to Get the detail of a temporary log conformance issue.",
);
}
},
/**
* Get the Details of a Temporary Log Conformance Loop.
@@ -332,9 +362,12 @@ export const useConformanceStore = defineStore('conformanceStore', {
try {
const response = await apiClient.get(api);
this.allLoopTraces = response.data.traces;
} catch(error) {
apiError(error, 'Failed to Get the detail of a temporary log conformance loop.');
};
} catch (error) {
apiError(
error,
"Failed to Get the detail of a temporary log conformance loop.",
);
}
},
/**
* Get the Trace Details of a Temporary Log Conformance Loops.
@@ -349,13 +382,16 @@ export const useConformanceStore = defineStore('conformanceStore', {
this.allLoopTaskSeq = response.data.task_seq;
this.allLoopCases = response.data.cases;
return response.data.cases;
} catch(error) {
if(error.response?.status === 404) {
} catch (error) {
if (error.response?.status === 404) {
this.infinite404 = 404;
return;
}
apiError(error, 'Failed to Get the detail of a temporary log conformance loop.');
};
apiError(
error,
"Failed to Get the detail of a temporary log conformance loop.",
);
}
},
/**
* Add a New Log Conformance Check, Save the log file.
@@ -366,21 +402,21 @@ export const useConformanceStore = defineStore('conformanceStore', {
const api = `/api/${prefix}-checks?${idParam}`;
const data = {
name: value,
rule: this.conformanceRuleData
rule: this.conformanceRuleData,
};
try {
const response = await apiClient.post(api, data);
if (prefix === 'filter') {
if (prefix === "filter") {
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.');
};
} catch (error) {
apiError(error, "Failed to add the Conformance Check for a file.");
}
},
/**
* Update an Existing Conformance Check, log and filter
@@ -394,8 +430,8 @@ export const useConformanceStore = defineStore('conformanceStore', {
this.isUpdateConformance = response.status === 200;
this.conformanceLogTempCheckId = null;
this.conformanceFilterTempCheckId = null;
}catch(error) {
apiError(error, 'Failed to update an Existing Conformance.');
} catch (error) {
apiError(error, "Failed to update an Existing Conformance.");
}
},
/**
@@ -406,4 +442,4 @@ export const useConformanceStore = defineStore('conformanceStore', {
this.conformanceLogCreateCheckId = createCheckID;
},
},
})
});

View File

@@ -12,46 +12,46 @@
*/
import { defineStore } from "pinia";
import moment from 'moment';
import moment from "moment";
/**
* Pinia store for caching user input during conformance rule editing.
*/
export const useConformanceInputStore = defineStore('conformanceInputStore', {
export const useConformanceInputStore = defineStore("conformanceInputStore", {
state: () => ({
inputDataToSave: {
inputStart: null, // TODO: clarify whether "start" means activity start or time start
inputEnd: null,
min: null,
max: null,
type: null,
task: null,
inputStart: null, // TODO: clarify whether "start" means activity start or time start
inputEnd: null,
min: null,
max: null,
type: null,
task: null,
},
activityRadioData: {
category: null,
task: ['', ''],
task: ["", ""],
},
}),
getters: {
},
getters: {},
actions: {
/**
* Sets the activity radio global state for either the start ('From') or end ('To') of a task.
* We arrange in this way because backend needs us to communicate in this way.
* @param {object} actRadioData
* @param {object} actRadioData
* @param {string} fromToStr 'From' or 'To'
*/
setActivityRadioStartEndData(actRadioData, fromToStr){
switch(fromToStr) {
case 'From':
setActivityRadioStartEndData(actRadioData, fromToStr) {
switch (fromToStr) {
case "From":
this.activityRadioData.task[0] = actRadioData;
break;
case 'To':
this.activityRadioData.task[this.activityRadioData.task.length - 1] = actRadioData;
case "To":
this.activityRadioData.task[this.activityRadioData.task.length - 1] =
actRadioData;
break;
default:
break;
}
},
},
})
});

View File

@@ -11,18 +11,24 @@
import { defineStore } from "pinia";
import apiClient from "@/api/client.js";
import moment from 'moment';
import apiError from '@/module/apiError.js';
import Swal from 'sweetalert2';
import { uploadFailedFirst, uploadFailedSecond, uploadloader, uploadSuccess, deleteSuccess } from '@/module/alertModal.js';
import { useLoadingStore } from '@/stores/loading';
import moment from "moment";
import apiError from "@/module/apiError.js";
import Swal from "sweetalert2";
import {
uploadFailedFirst,
uploadFailedSecond,
uploadloader,
uploadSuccess,
deleteSuccess,
} from "@/module/alertModal.js";
import { useLoadingStore } from "@/stores/loading";
/** Map of file type to API path segment. */
const FILE_TYPE_PATHS = {
'log': 'logs',
'filter': 'filters',
'log-check': 'log-checks',
'filter-check': 'filter-checks',
log: "logs",
filter: "filters",
"log-check": "log-checks",
"filter-check": "filter-checks",
};
/**
@@ -36,22 +42,22 @@ function getFileApiBase(type, id) {
}
/** Pinia store for file CRUD operations and upload workflow. */
export const useFilesStore = defineStore('filesStore', {
export const useFilesStore = defineStore("filesStore", {
state: () => ({
allEventFiles: [
{
parentLog: '',
fileType: '',
ownerName: '',
}
parentLog: "",
fileType: "",
ownerName: "",
},
],
switchFilesTagData: {
ALL: ['Log', 'Filter', 'Rule', 'Design'],
DISCOVER: ['Log', 'Filter', 'Rule'],
COMPARE: ['Log','Filter'],
DESIGN: ['Log', 'Design'],
ALL: ["Log", "Filter", "Rule", "Design"],
DISCOVER: ["Log", "Filter", "Rule"],
COMPARE: ["Log", "Filter"],
DESIGN: ["Log", "Design"],
},
filesTag: 'ALL',
filesTag: "ALL",
httpStatus: 200,
uploadId: null,
allUploadDetail: null,
@@ -63,64 +69,64 @@ export const useFilesStore = defineStore('filesStore', {
/**
* Get allFiles and switch files tag
*/
allFiles: state => {
allFiles: (state) => {
let result = state.allEventFiles;
const data = state.switchFilesTagData;
const filesTag = state.filesTag;
result = result.filter(file => data[filesTag].includes(file.fileType));
result = result.filter((file) => data[filesTag].includes(file.fileType));
return result;
},
/**
* Get upload preview
*/
uploadDetail: state => {
uploadDetail: (state) => {
return state.allUploadDetail;
},
/**
* Get dependents of files data
*/
dependentsData: state => {
dependentsData: (state) => {
return state.allDependentsData;
}
},
},
actions: {
/**
* Fetch All Files api
*/
async fetchAllFiles() {
const api = '/api/files';
const api = "/api/files";
try {
const response = await apiClient.get(api);
this.allEventFiles = response.data;
this.allEventFiles.forEach(o => {
let icon = '';
let fileType = '';
this.allEventFiles.forEach((o) => {
let icon = "";
let fileType = "";
let parentLog = o.name;
switch (o.type) {
case 'log':
icon = 'work_history';
fileType = 'Log';
case "log":
icon = "work_history";
fileType = "Log";
parentLog = o.name;
break;
case 'filter':
icon = 'tornado';
fileType = 'Filter';
case "filter":
icon = "tornado";
fileType = "Filter";
parentLog = o.parent.name;
break;
case 'log-check':
case 'filter-check':
icon = 'local_police';
fileType = 'Rule';
case "log-check":
case "filter-check":
icon = "local_police";
fileType = "Rule";
parentLog = o.parent.name;
break;
case 'design':
icon = 'shape_line';
fileType = 'Design';
case "design":
icon = "shape_line";
fileType = "Design";
parentLog = o.name;
break;
}
@@ -130,23 +136,29 @@ export const useFilesStore = defineStore('filesStore', {
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;
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;
});
} catch(error) {
apiError(error, 'Failed to load the files.');
};
} catch (error) {
apiError(error, "Failed to load the files.");
}
},
/**
* Uploads a CSV log file (first stage).
* @param {Object} fromData - The form data to send to the backend.
*/
async upload(fromData) {
const api = '/api/logs/csv-uploads';
const api = "/api/logs/csv-uploads";
const config = {
data: true,
headers: {
'Content-Type': 'multipart/form-data',
"Content-Type": "multipart/form-data",
},
};
@@ -155,10 +167,10 @@ export const useFilesStore = defineStore('filesStore', {
const response = await apiClient.post(api, fromData, config);
this.uploadId = response.data.id;
this.$router.push({name: 'Upload'});
this.$router.push({ name: "Upload" });
Swal.close(); // Close the loading progress bar
} catch(error) {
if(error.response?.status === 422) {
} catch (error) {
if (error.response?.status === 422) {
// msg: 'not in UTF-8' | 'insufficient columns' | 'the csv file is empty' | 'the filename does not ends with .csv'
// type: 'encoding' | 'insufficient_columns' | 'empty' | 'name_suffix'
const detail = error.response.data.detail;
@@ -166,7 +178,7 @@ export const useFilesStore = defineStore('filesStore', {
uploadFailedFirst(detail[0].type, detail[0].msg, detail[0].loc[2]);
} else {
Swal.close(); // Close the loading progress bar
apiError(error, 'Failed to upload the files.');
apiError(error, "Failed to upload the files.");
}
}
},
@@ -180,8 +192,8 @@ export const useFilesStore = defineStore('filesStore', {
try {
const response = await apiClient.get(api);
this.allUploadDetail = response.data.preview;
} catch(error) {
apiError(error, 'Failed to get upload detail.');
} catch (error) {
apiError(error, "Failed to get upload detail.");
}
},
/**
@@ -200,15 +212,15 @@ export const useFilesStore = defineStore('filesStore', {
Swal.close(); // Close the loading progress bar
await this.rename(); // Rename the file
await uploadSuccess();
this.$router.push({name: 'Files'});
} catch(error) {
if(error.response?.status === 422) {
this.$router.push({ name: "Files" });
} catch (error) {
if (error.response?.status === 422) {
const detail = [...error.response.data.detail];
uploadFailedSecond(detail);
} else {
Swal.close(); // Close the loading progress bar
apiError(error, 'Failed to upload the log files.');
apiError(error, "Failed to upload the log files.");
}
}
},
@@ -220,19 +232,19 @@ export const useFilesStore = defineStore('filesStore', {
*/
async rename(type, id, fileName) {
// If uploadLogId exists, set id and type accordingly; then check the file type.
if(this.uploadId && this.uploadFileName) {
type = 'log';
if (this.uploadId && this.uploadFileName) {
type = "log";
id = this.uploadLogId;
fileName = this.uploadFileName;
}
const data = {"name": fileName};
const data = { name: fileName };
try {
await apiClient.put(`${getFileApiBase(type, id)}/name`, data);
this.uploadFileName = null;
await this.fetchAllFiles();
} catch(error) {
apiError(error, 'Failed to rename.');
} catch (error) {
apiError(error, "Failed to rename.");
}
},
/**
@@ -242,10 +254,12 @@ export const useFilesStore = defineStore('filesStore', {
*/
async getDependents(type, id) {
try {
const response = await apiClient.get(`${getFileApiBase(type, id)}/dependents`);
const response = await apiClient.get(
`${getFileApiBase(type, id)}/dependents`,
);
this.allDependentsData = response.data;
} catch(error) {
apiError(error, 'Failed to get Dependents of the files.');
} catch (error) {
apiError(error, "Failed to get Dependents of the files.");
}
},
/**
@@ -254,18 +268,18 @@ export const useFilesStore = defineStore('filesStore', {
* @param {number} id - The file ID.
*/
async deleteFile(type, id) {
if(id === null || id === undefined || isNaN(id)) {
console.error('Delete File API Error: invalid id');
if (id === null || id === undefined || isNaN(id)) {
console.error("Delete File API Error: invalid id");
return;
};
}
const loading = useLoadingStore();
loading.isLoading = true;
try {
await apiClient.delete(getFileApiBase(type, id));
await this.fetchAllFiles();
await deleteSuccess();
} catch(error) {
apiError(error, 'Failed to delete.');
} catch (error) {
apiError(error, "Failed to delete.");
} finally {
loading.isLoading = false;
}
@@ -275,15 +289,15 @@ export const useFilesStore = defineStore('filesStore', {
* @param {number} id - The file ID.
*/
async deletionRecord(id) {
let api = '';
let api = "";
const loading = useLoadingStore();
loading.isLoading = true;
api = `/api/deletion/${id}`;
try {
await apiClient.delete(api);
} catch(error) {
apiError(error, 'Failed to Remove a Deletion Record.')
} catch (error) {
apiError(error, "Failed to Remove a Deletion Record.");
} finally {
loading.isLoading = false;
}
@@ -295,21 +309,21 @@ export const useFilesStore = defineStore('filesStore', {
* @param {string} fileName - The file name.
*/
async downloadFileCSV(type, id, fileName) {
if (type !== 'log' && type !== 'filter') return;
if (type !== "log" && type !== "filter") return;
try {
const response = await apiClient.get(`${getFileApiBase(type, id)}/csv`);
const csvData = response.data;
const blob = new Blob([csvData], { type: 'text/csv' });
const blob = new Blob([csvData], { type: "text/csv" });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
const link = document.createElement("a");
link.href = url;
link.download = `${fileName}.csv`;
link.click();
window.URL.revokeObjectURL(url);
} catch(error) {
apiError(error, 'Failed to download.');
} catch (error) {
apiError(error, "Failed to download.");
}
},
},
})
});

View File

@@ -9,7 +9,7 @@
import { defineStore } from "pinia";
/** Pinia store for managing the global loading spinner visibility. */
export const useLoadingStore = defineStore('loadingStore', {
export const useLoadingStore = defineStore("loadingStore", {
state: () => ({
/** Whether the loading spinner is currently visible. */
isLoading: true,
@@ -21,6 +21,6 @@ export const useLoadingStore = defineStore('loadingStore', {
*/
setIsLoading(isLoadingBoolean) {
this.isLoading = isLoadingBoolean;
}
},
},
});

View File

@@ -10,20 +10,24 @@
*/
import { defineStore } from "pinia";
import axios from 'axios';
import apiClient from '@/api/client.js';
import apiError from '@/module/apiError.js';
import { deleteCookie, setCookie, setCookieWithoutExpiration } from "../utils/cookieUtil";
import axios from "axios";
import apiClient from "@/api/client.js";
import apiError from "@/module/apiError.js";
import {
deleteCookie,
setCookie,
setCookieWithoutExpiration,
} from "../utils/cookieUtil";
/** Pinia store for authentication and user session management. */
export const useLoginStore = defineStore('loginStore', {
export const useLoginStore = defineStore("loginStore", {
// data, methods, computed
// state, actions, getters
state: () => ({
auth: {
grant_type: 'password', // password | refresh_token
username: '',
password: '',
grant_type: "password", // password | refresh_token
username: "",
password: "",
refresh_token: undefined,
},
isInvalid: false,
@@ -36,11 +40,11 @@ export const useLoginStore = defineStore('loginStore', {
* fetch Login For Access Token api
*/
async signIn() {
const api = '/api/oauth/token';
const api = "/api/oauth/token";
const config = {
headers: {
// Default URL-encoded format for HTTP POST, not JSON
'Content-Type':'application/x-www-form-urlencoded',
"Content-Type": "application/x-www-form-urlencoded",
},
};
@@ -52,7 +56,13 @@ export const useLoginStore = defineStore('loginStore', {
setCookieWithoutExpiration("luciaToken", accessToken);
const expiryDate = new Date();
expiryDate.setMonth(expiryDate.getMonth() + 6);
setCookie("luciaRefreshToken", refresh_token, Math.ceil((expiryDate.getTime() - Date.now()) / (24 * 60 * 60 * 1000)));
setCookie(
"luciaRefreshToken",
refresh_token,
Math.ceil(
(expiryDate.getTime() - Date.now()) / (24 * 60 * 60 * 1000),
),
);
this.isLoggedIn = true;
setCookie("isLuciaLoggedIn", "true");
@@ -60,30 +70,30 @@ export const useLoginStore = defineStore('loginStore', {
// By default, redirect to the FILES page.
// However, if the user pasted a URL while not logged in,
// redirect them to the remembered return-to URL after login.
if(this.rememberedReturnToUrl !== "") {
if (this.rememberedReturnToUrl !== "") {
const decodedUrl = atob(this.rememberedReturnToUrl);
// Only allow relative paths to prevent open redirect attacks
if(decodedUrl.startsWith('/') && !decodedUrl.startsWith('//')) {
if (decodedUrl.startsWith("/") && !decodedUrl.startsWith("//")) {
window.location.href = decodedUrl;
} else {
this.$router.push('/files');
this.$router.push("/files");
}
} else {
this.$router.push('/files');
this.$router.push("/files");
}
} catch(error) {
} catch (error) {
this.isInvalid = true;
};
}
},
/**
* Refresh Token
*/
async refreshToken() {
try {
const { refreshTokenAndGetNew } = await import('@/api/auth.js');
const { refreshTokenAndGetNew } = await import("@/api/auth.js");
await refreshTokenAndGetNew();
} catch(error) {
this.$router.push('/login');
} catch (error) {
this.$router.push("/login");
throw error;
}
},
@@ -96,36 +106,36 @@ export const useLoginStore = defineStore('loginStore', {
this.isLoggedIn = false;
deleteCookie("isLuciaLoggedIn");
this.$router.push('/login');
this.$router.push("/login");
},
/**
* get user detail for 'my-account' api
*/
async getUserData() {
const api = '/api/my-account';
const api = "/api/my-account";
try {
const response = await apiClient.get(api);
this.userData = response.data;
} catch(error) {
apiError(error, 'Failed to load user data.');
};
} catch (error) {
apiError(error, "Failed to load user data.");
}
},
/**
* check login for 'my-account' api
*/
async checkLogin() {
const api = '/api/my-account';
const api = "/api/my-account";
try {
await apiClient.get(api);
} catch(error) {
this.$router.push('/login');
};
} catch (error) {
this.$router.push("/login");
}
},
setRememberedReturnToUrl(returnToUrl){
this.rememberedReturnToUrl = returnToUrl
setRememberedReturnToUrl(returnToUrl) {
this.rememberedReturnToUrl = returnToUrl;
},
setIsLoggedIn(boolean) {
this.isLoggedIn = boolean;

View File

@@ -8,8 +8,8 @@
* @module stores/main Pinia store instance with persisted state plugin.
*/
import { createPinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
import { createPinia } from "pinia";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);

View File

@@ -6,11 +6,11 @@
// cindy.chang@dsp.im (Cindy Chang), 2024/5/30
/** @module stores/modal Account management modal state. */
import { defineStore } from 'pinia';
import { MODAL_ACCT_INFO, } from '@/constants/constants.js';
import { defineStore } from "pinia";
import { MODAL_ACCT_INFO } from "@/constants/constants.js";
/** Pinia store for controlling account management modal visibility. */
export const useModalStore = defineStore('modalStore', {
export const useModalStore = defineStore("modalStore", {
state: () => ({
/** Whether a modal is currently open. */
isModalOpen: false,
@@ -27,7 +27,7 @@ export const useModalStore = defineStore('modalStore', {
this.whichModal = whichModal;
},
/** Closes the currently open modal. */
async closeModal(){
async closeModal() {
this.isModalOpen = false;
},
},

View File

@@ -23,56 +23,65 @@ const printPageAdminLog = false;
* page refreshes. Manages pending states for SweetAlert2 modal
* confirmation flows.
*/
export const usePageAdminStore = defineStore('pageAdminStore', {
export const usePageAdminStore = defineStore("pageAdminStore", {
state: () => ({
activePage: 'MAP',
previousPage: 'MAP',
pendingActivePage: 'FILES',
isPagePending: false,
shouldKeepPreviousPage: false, // false -- meaning modal is not pressed as "NO"
activePageComputedByRoute: "MAP",
currentMapFile: '',
activePage: "MAP",
previousPage: "MAP",
pendingActivePage: "FILES",
isPagePending: false,
shouldKeepPreviousPage: false, // false -- meaning modal is not pressed as "NO"
activePageComputedByRoute: "MAP",
currentMapFile: "",
}),
getters: {
},
getters: {},
actions: {
/**
* Sets the active page based on the last matched route record.
* @param {Array} routeMatched - The route.matched array.
*/
setActivePageComputedByRoute(routeMatched){
if (routeMatched.length && routeMatched[routeMatched.length - 1]
&& routeMatched[routeMatched.length - 1].name) {
printPageAdminLog && console.log('setActivePageComputedByRoute()', mapPageNameToCapitalUnifiedName(routeMatched[routeMatched.length - 1].name));
setActivePageComputedByRoute(routeMatched) {
if (
routeMatched.length &&
routeMatched[routeMatched.length - 1] &&
routeMatched[routeMatched.length - 1].name
) {
printPageAdminLog &&
console.log(
"setActivePageComputedByRoute()",
mapPageNameToCapitalUnifiedName(
routeMatched[routeMatched.length - 1].name,
),
);
this.activePageComputedByRoute = mapPageNameToCapitalUnifiedName(
routeMatched[routeMatched.length - 1].name);
routeMatched[routeMatched.length - 1].name,
);
}
},
/**
* Set Active Page; the page which the user is currently visiting
* @param {string} activePage
* @param {string} activePage
*/
setActivePage(activePage) {
printPageAdminLog && console.log("setActivePage", activePage)
printPageAdminLog && console.log("setActivePage", activePage);
this.activePage = mapPageNameToCapitalUnifiedName(activePage);
},
/**
* Specify previous page state value.
* @param {string} prevPage
* @param {string} prevPage
*/
setPreviousPage(prevPage) {
this.previousPage = mapPageNameToCapitalUnifiedName(prevPage);
},
/**
* Set the previous(usually current) pages to the ones we just decide.
*/
* Set the previous(usually current) pages to the ones we just decide.
*/
setPreviousPageUsingActivePage() {
this.previousPage = this.activePage;
},
/**
* Set the boolean value of status of pending state of the pate
* For the control of Swal popup
* @param {boolean} boolVal
* @param {boolean} boolVal
*/
setIsPagePendingBoolean(boolVal) {
this.isPagePending = boolVal;
@@ -81,49 +90,59 @@ export const usePageAdminStore = defineStore('pageAdminStore', {
* Copy(transit) the value of pendingActivePage to activePage
*/
copyPendingPageToActivePage() {
printPageAdminLog && console.log('pinia copying this.pendingActivePage', this.pendingActivePage);
printPageAdminLog &&
console.log(
"pinia copying this.pendingActivePage",
this.pendingActivePage,
);
this.activePage = this.pendingActivePage;
},
},
/**
* Set Pending active Page, meaning we are not sure if user will chang her mind later on.
* Also, start pending state.
* Often, user triggers the modal and the pending state starts.
* Note: String conversion is needed. For Example, CheckMap is converted into MAP
* @param {string} pendingActivePage
* @param {string} pendingActivePage
*/
setPendingActivePage(argPendingActivePage) {
printPageAdminLog && console.log('pinia setting this.pendingActivePage', this.pendingActivePage);
this.pendingActivePage = mapPageNameToCapitalUnifiedName(argPendingActivePage);
printPageAdminLog &&
console.log(
"pinia setting this.pendingActivePage",
this.pendingActivePage,
);
this.pendingActivePage =
mapPageNameToCapitalUnifiedName(argPendingActivePage);
},
/**
* Set Pending active Page to empty string; we call this right after we just decide an active page.
* Also, stop pending state.
*/
clearPendingActivePage(){
this.pendingActivePage = '';
clearPendingActivePage() {
this.pendingActivePage = "";
},
/**
* When user dismiss the popup modal, we don't apply the new page,
* instead, we apply the previous page.
*/
keepPreviousPage() {
printPageAdminLog && console.log('pinia keeping this.previousPage', this.previousPage);
printPageAdminLog &&
console.log("pinia keeping this.previousPage", this.previousPage);
this.activePage = this.previousPage;
this.shouldKeepPreviousPage = true;
},
/**
* Clean up the state of the boolean related to modal showing phase
*/
clearShouldKeepPreviousPageBoolean(){
printPageAdminLog && console.log('clearShouldKeepPreviousPageBoolean()');
clearShouldKeepPreviousPageBoolean() {
printPageAdminLog && console.log("clearShouldKeepPreviousPageBoolean()");
this.shouldKeepPreviousPage = false;
},
/**
* Stores the name of the currently opened map file.
* @param {string} fileName - The file name.
*/
setCurrentMapFile(fileName){
setCurrentMapFile(fileName) {
this.currentMapFile = fileName;
},
},
})
});

View File

@@ -11,10 +11,10 @@
import { defineStore } from "pinia";
import apiClient from "@/api/client.js";
import apiError from '@/module/apiError.js';
import apiError from "@/module/apiError.js";
/** Pinia store for the Discover Performance page data. */
export const usePerformanceStore = defineStore('performanceStore', {
export const usePerformanceStore = defineStore("performanceStore", {
state: () => ({
allPerformanceData: null,
freqChartData: null,
@@ -24,10 +24,10 @@ export const usePerformanceStore = defineStore('performanceStore', {
maxX: null,
xData: null,
content: null,
}
},
}),
getters: {
performanceData: state => {
performanceData: (state) => {
return state.allPerformanceData;
},
},
@@ -38,43 +38,43 @@ export const usePerformanceStore = defineStore('performanceStore', {
* @param {number} id - The file ID.
*/
async getPerformance(type, id) {
let api = '';
let api = "";
switch (type) {
case 'log':
case "log":
api = `/api/logs/${id}/performance`;
break;
case 'filter':
case "filter":
api = `/api/filters/${id}/performance`;
break;
}
try {
const response = await apiClient.get(api);
this.allPerformanceData = response.data;
} catch(error) {
apiError(error, 'Failed to load the Performance.');
} catch (error) {
apiError(error, "Failed to load the Performance.");
}
},
/**
* In PrimeVue format
* @param {object} freqChartData
* @param {object} freqChartData
*/
setFreqChartData(freqChartData){
setFreqChartData(freqChartData) {
this.freqChartData = freqChartData;
},
/**
* In PrimeVue format
* @param {object} freqChartOptions
* @param {object} freqChartOptions
*/
setFreqChartOptions(freqChartOptions){
setFreqChartOptions(freqChartOptions) {
this.freqChartOptions = freqChartOptions;
},
/**
*
* @param {object} freqChartXData
*
* @param {object} freqChartXData
*/
setFreqChartXData(freqChartXData) {
this.freqChartXData = freqChartXData;
}
},
},
})
});