From 7982c1e60e1333ccbd313819f9275bda6ec3ede8 Mon Sep 17 00:00:00 2001 From: volodymyr Date: Mon, 23 Dec 2024 16:10:44 +0200 Subject: [PATCH 1/5] feature: deadlines done, sla and APIs mock refactored [WTEL-5799](https://webitel.atlassian.net/browse/WTEL-5799) --- src/app/locale/en/en.js | 2 + src/app/locale/ru/ru.js | 2 + src/app/locale/ua/ua.js | 2 + src/modules/cases/api/CasesAPI.js | 154 +++++++++--------- .../cases/components/opened-case-general.vue | 4 + .../case-info/components/editable-field.vue | 9 +- .../deadlines/components/case-deadline.vue | 96 +++++++++++ .../deadlines/components/case-deadlines.vue | 73 +++++++++ .../cases/modules/sla/api/SLAConditionsAPI.js | 2 +- .../cases/modules/sla/components/case-sla.vue | 96 +++++++---- 10 files changed, 320 insertions(+), 120 deletions(-) create mode 100644 src/modules/cases/modules/deadlines/components/case-deadline.vue create mode 100644 src/modules/cases/modules/deadlines/components/case-deadlines.vue diff --git a/src/app/locale/en/en.js b/src/app/locale/en/en.js index 170ec8ec..68e0626e 100644 --- a/src/app/locale/en/en.js +++ b/src/app/locale/en/en.js @@ -155,6 +155,8 @@ export default { rating: 'Rating', persons: 'Persons', selectAService: 'Select a service', + deadlines: 'Deadlines', + createdAt: 'Created at', caseInfo: { caseInfo: 'Case info', contactInfo: 'Contact info', diff --git a/src/app/locale/ru/ru.js b/src/app/locale/ru/ru.js index 5b2d7292..adf996b0 100644 --- a/src/app/locale/ru/ru.js +++ b/src/app/locale/ru/ru.js @@ -154,6 +154,8 @@ export default { rating: 'Оценка', persons: 'Персоны', selectAService: 'Выберите сервис', + deadlines: 'Сроки', + createdAt: 'Создано', caseInfo: { caseInfo: 'Информация', contactInfo: 'Контактная информация', diff --git a/src/app/locale/ua/ua.js b/src/app/locale/ua/ua.js index 90f43f4f..e1850cfd 100644 --- a/src/app/locale/ua/ua.js +++ b/src/app/locale/ua/ua.js @@ -155,6 +155,8 @@ export default { rating: 'Оцінка', persons: 'Особи', selectAService: 'Виберіть сервіс', + deadlines: 'Терміни', + createdAt: 'Створено', caseInfo: { caseInfo: 'Інформація', contactInfo: 'Контактна інформація', diff --git a/src/modules/cases/api/CasesAPI.js b/src/modules/cases/api/CasesAPI.js index 8a95e1e7..17472e9f 100644 --- a/src/modules/cases/api/CasesAPI.js +++ b/src/modules/cases/api/CasesAPI.js @@ -20,7 +20,7 @@ const data = { id: "u1", name: "User One" }, - createdAt: "2024-11-01T10:00:00Z", + createdAt: "1734950841253", updatedBy: { id: "u2", name: "User Two" @@ -30,8 +30,8 @@ const data = { subject: "Network Issue", description: "The network is experiencing downtime.", contactInfo: "contact1@example.com", - plannedReactionAt: "2024-11-01T12:00:00Z", - plannedResolveAt: "2024-11-03T12:00:00Z", + plannedReactionAt: "1734961322138", + plannedResolveAt: "1734961322138", status: { id: "s1", name: "Open" @@ -84,42 +84,40 @@ const data = { ratingComment: "Issue resolved promptly." }, timing: { - resolvedAt: "2024-11-03T10:00:00Z", - reactedAt: "2024-11-01T10:30:00Z", - differenceInReaction: "30m", - differenceInResolve: "2d" - }, - slaCondition: [ - { - id: "sla1", - name: "Critical SLA", - priorities: [ - { - id: "p1", - name: "High" - } - ], - reactionTime: { - hours: 1, - minutes: 0 - }, - resolutionTime: { - hours: 48, - minutes: 0 - }, - slaId: "slaId1", - createdAt: "2024-10-01T10:00:00Z", - updatedAt: "2024-10-01T12:00:00Z", - createdBy: { - id: "u5", - name: "SLA Manager" - }, - updatedBy: { - id: "u6", - name: "SLA Admin" + resolvedAt: "1734961389622", + reactedAt: "1734950841253", + differenceInReaction: "1800", + differenceInResolve: "-172800000" + }, + slaCondition: { + id: "sla1", + name: "Critical SLA", + priorities: [ + { + id: "p1", + name: "High" } + ], + reactionTime: { + hours: 1, + minutes: 0 + }, + resolutionTime: { + hours: 48, + minutes: 0 + }, + slaId: "slaId1", + createdAt: "2024-10-01T10:00:00Z", + updatedAt: "2024-10-01T12:00:00Z", + createdBy: { + id: "u5", + name: "SLA Manager" + }, + updatedBy: { + id: "u6", + name: "SLA Admin" } - ], + }, service: { id: "subservice2", name: "Network Support" @@ -224,8 +222,8 @@ const data = { subject: "Login Issue", description: "Users are unable to log in to the system.", contactInfo: "contact2@example.com", - plannedReactionAt: "2024-11-05T12:00:00Z", - plannedResolveAt: "2024-11-07T12:00:00Z", + plannedReactionAt: "1734961322138", + plannedResolveAt: "1734961322138", status: { id: "s2", name: "In Progress" @@ -278,42 +276,40 @@ const data = { ratingComment: "Issue is being addressed." }, timing: { - resolvedAt: "2024-11-07T10:00:00Z", - reactedAt: "2024-11-05T11:30:00Z", - differenceInReaction: "30m", - differenceInResolve: "2d" - }, - slaCondition: [ - { - id: "sla2", - name: "Standard SLA", - priorities: [ - { - id: "p2", - name: "Medium" - } - ], - reactionTime: { - hours: 2, - minutes: 0 - }, - resolutionTime: { - hours: 72, - minutes: 0 - }, - slaId: "slaId2", - createdAt: "2024-10-05T10:00:00Z", - updatedAt: "2024-10-05T12:00:00Z", - createdBy: { - id: "u5", - name: "SLA Manager" - }, - updatedBy: { - id: "u6", - name: "SLA Admin" + resolvedAt: "1734950841253", + reactedAt: "1734950841253", + differenceInReaction: "1800", + differenceInResolve: "172800000" + }, + slaCondition: { + id: "sla2", + name: "Standard SLA", + priorities: [ + { + id: "p2", + name: "Medium" } + ], + reactionTime: { + hours: 2, + minutes: 0 + }, + resolutionTime: { + hours: 72, + minutes: 0 + }, + slaId: "slaId2", + createdAt: "2024-10-05T10:00:00Z", + updatedAt: "2024-10-05T12:00:00Z", + createdBy: { + id: "u5", + name: "SLA Manager" + }, + updatedBy: { + id: "u6", + name: "SLA Admin" } - ], + }, service: { id: "srv2", name: "Login Support" @@ -405,11 +401,11 @@ const fieldsToSend = [ 'name', 'subject', 'description', - 'contact_info', - 'planned_reaction_at', - 'planned_resolve_at', + 'contactInfo', + 'plannedReactionAt', + 'plannedResolveAt', 'status_lookup', - 'close_reason_lookup', + 'closeReasonLookup', 'author', 'assignee', 'reporter', @@ -421,13 +417,13 @@ const fieldsToSend = [ 'close', 'rate', 'timing', - 'sla_condition', + 'slaCondition', 'sla', 'service', 'comments', 'related', 'links', - 'status_condition' + 'statusCondition' ]; diff --git a/src/modules/cases/components/opened-case-general.vue b/src/modules/cases/components/opened-case-general.vue index 1a07c02a..df8bf9e5 100644 --- a/src/modules/cases/components/opened-case-general.vue +++ b/src/modules/cases/components/opened-case-general.vue @@ -6,6 +6,9 @@ + @@ -19,6 +22,7 @@ + + diff --git a/src/modules/cases/modules/deadlines/components/case-deadlines.vue b/src/modules/cases/modules/deadlines/components/case-deadlines.vue new file mode 100644 index 00000000..99c5b78d --- /dev/null +++ b/src/modules/cases/modules/deadlines/components/case-deadlines.vue @@ -0,0 +1,73 @@ + + + + diff --git a/src/modules/cases/modules/sla/api/SLAConditionsAPI.js b/src/modules/cases/modules/sla/api/SLAConditionsAPI.js index 74526161..3fddada8 100644 --- a/src/modules/cases/modules/sla/api/SLAConditionsAPI.js +++ b/src/modules/cases/modules/sla/api/SLAConditionsAPI.js @@ -15,7 +15,7 @@ const mockData = { name: "Critical SLA Condition", priorities: [ { - id: "priority1", + id: "p1", name: "High", }, ], diff --git a/src/modules/cases/modules/sla/components/case-sla.vue b/src/modules/cases/modules/sla/components/case-sla.vue index 09bcfc76..099ad2f2 100644 --- a/src/modules/cases/modules/sla/components/case-sla.vue +++ b/src/modules/cases/modules/sla/components/case-sla.vue @@ -8,19 +8,19 @@
{{ itemInstance?.sla?.name }}
-
- - - {{ condition.name }} - -
+ @@ -59,47 +59,71 @@ const { } = useCardComponent({ id, itemInstance, - ...restStore + ...restStore, }); const { t } = useI18n(); -const store = useStore(); +const store = useStore(); const serviceSLA = computed(() => store.getters[`${props.namespace}/service/SLA`]); + +const updateSlaCondition = async (slaId, priorityId) => { + if (!slaId || !priorityId) { + await resetSlaCondition(); + return; + } + + try { + const response = await slaConditionsAPI.getList({ slaId }); + const matchingCondition = response.items.find(condition => + condition.priorities.some(priority => priority.id === priorityId), + ); + + await setItemProp({ path: 'slaCondition', value: matchingCondition }); + } catch (err) { + await resetSlaCondition(); + throw err; + } +}; + +const resetSlaCondition = async () => { + await setItemProp({ path: 'slaCondition', value: null }); +}; + +const resetSla = async () => { + await setItemProp({ path: 'sla', value: null }); +}; + watch( () => serviceSLA.value?.id, async (newSlaId) => { - if (!newSlaId) return; + if (!newSlaId) { + await resetSla(); + return; + } try { - const slaConditionResponse = await slaConditionsAPI.getList({ slaId: newSlaId }); - - await setItemProp({ - path: 'sla', - value: serviceSLA.value, - }); - - await setItemProp({ - path: 'slaCondition', - value: slaConditionResponse.items, - }); + await setItemProp({ path: 'sla', value: serviceSLA.value }); + await updateSlaCondition(newSlaId, itemInstance.value.priority?.id); } catch (err) { - await setItemProp({ - path: 'sla', - value: null, - }); - - await setItemProp({ - path: 'slaCondition', - value: [], - }); throw err; } }, ); +watch( + () => itemInstance.value.priority?.id, + async (newPriorityId) => { + try { + await updateSlaCondition(serviceSLA.value?.id, newPriorityId); + } catch (err) { + throw err; + } + }, +); +initialize();