Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: apply alert manager v2 #5466

Merged
merged 149 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
77e4aa0
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
skdud4659 Nov 28, 2024
53a0fb8
feat: create alert manager v2 menu (#5110)
skdud4659 Nov 28, 2024
9eeb976
feat: mark-up service main page (#5113)
skdud4659 Nov 29, 2024
b25971c
feat: apply click event at service item card and change card componen…
skdud4659 Nov 29, 2024
67f0601
feat: create header at service detail page (#5118)
skdud4659 Nov 29, 2024
4f3b530
feat: markup for the first step of the service creation page (#5123)
skdud4659 Dec 2, 2024
9d41a7c
refactor: apply componentization for common parts in the service crea…
skdud4659 Dec 3, 2024
cafff0f
feat: markup for step 2 of the service creation page (#5126)
skdud4659 Dec 3, 2024
a48029c
feat: markup for the overview tab of the service detail page (#5130)
skdud4659 Dec 3, 2024
b51d0c2
Merge branch 'master' into feature-project-alert-manager
sulmoJ Dec 4, 2024
2abda5d
feat: markup for step 3-1 of the service creation page (#5127)
skdud4659 Dec 4, 2024
e277d97
feat: markup for the webhook tab of the service detail page (#5134)
skdud4659 Dec 4, 2024
ae0d47e
feat: markup for the notifications tab of the service detail page (#5…
skdud4659 Dec 4, 2024
cc99130
feat: update router for resource manager v2 (#5137)
sulmoJ Dec 4, 2024
fba3ea9
feat: markup for the settings tab of the service detail page (#5136)
skdud4659 Dec 4, 2024
830648f
feat: apply tab switching when the details button in the overview tab…
skdud4659 Dec 5, 2024
6e34ef5
feat: separate assetInventory router (#5146)
sulmoJ Dec 5, 2024
b37d0fe
feat: create webhook / notifications creation page and apply routing …
skdud4659 Dec 5, 2024
0c126b2
fix: fix variable name
sulmoJ Dec 5, 2024
43bbbeb
fix: apply menu list by version at page access (#5148)
skdud4659 Dec 5, 2024
95c4919
feat: create alerts menu and detail/main page (#5149)
skdud4659 Dec 6, 2024
fe079a3
feat: apply webhook/notification create step at webhook creation page…
skdud4659 Dec 6, 2024
6da4518
feat: copy the alert section of the existing project details/main pag…
skdud4659 Dec 6, 2024
e0be394
refactor: refactor code for alert detail page (#5154)
skdud4659 Dec 6, 2024
b80988a
feat: apply v2 at project (#5156)
skdud4659 Dec 6, 2024
33883de
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
skdud4659 Dec 6, 2024
f66e90b
feat: remove routes to CloudServiceDetail (#5155)
sulmoJ Dec 6, 2024
1e2b814
feat: set model, type and constant of user group page
seungyeoneeee Dec 4, 2024
76a5d21
feat: set store of user group page and detail tabs
seungyeoneeee Dec 4, 2024
095c7d9
feat: create user group menu
seungyeoneeee Nov 29, 2024
a3ea4bc
fix: fix user group menu icon
seungyeoneeee Dec 5, 2024
c3847a2
feat: update type, constant and store about modal state
seungyeoneeee Dec 5, 2024
bd4514f
feat: add modal component about editing user group in main page
seungyeoneeee Dec 5, 2024
b651edc
fix: fix labels with updated language pack
seungyeoneeee Dec 5, 2024
4237afe
feat: add detail method (`handleSelectDropdown`, `handleCreateGroup`)
seungyeoneeee Dec 5, 2024
acb1950
feat: add modal component and detail component of it (edit user group)
seungyeoneeee Dec 5, 2024
25acaf5
feat: update language pack
seungyeoneeee Dec 6, 2024
0fb8cc0
Merge pull request #5160 from seungyeoneeee/feature/alert-iam
seungyeoneeee Dec 6, 2024
abf2aa7
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
skdud4659 Dec 6, 2024
cf0fc98
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
sulmoJ Dec 6, 2024
fb2f4f2
refactor: replace store with pinia in user-related components (#5167)
sulmoJ Dec 6, 2024
b57de96
chore: add missing code to the display store (#5171)
skdud4659 Dec 6, 2024
a044e68
feat: markup for the redesigned notification settings modal on the bu…
skdud4659 Dec 9, 2024
d5a0dc5
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
sulmoJ Dec 9, 2024
a0f043a
refactor: rename inventory service directory name (#5189)
sulmoJ Dec 9, 2024
7ab97f5
feat: create api schema (#5192)
skdud4659 Dec 10, 2024
6da7e3d
feat: Update 1st feedback & userGroup markup 1st completed (#5176)
seungyeoneeee Dec 10, 2024
a2f85eb
feat: create schedule-setting-form (#5194)
skdud4659 Dec 10, 2024
8e31e8d
feat: update API call to use inventory V2 (#5196)
sulmoJ Dec 10, 2024
de7a562
feat(inventory-v2): create inventory-v2 namespace & namespaceGroup ap…
piggggggggy Dec 10, 2024
173073d
feat: apply service create API (#5198)
skdud4659 Dec 10, 2024
9805c3d
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
sulmoJ Dec 11, 2024
cda6986
feat: apply service list API (#5202)
skdud4659 Dec 11, 2024
d5707b2
chore: fixed merge bug (#5203)
skdud4659 Dec 11, 2024
61c5247
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
skdud4659 Dec 11, 2024
fedbf05
refactor(router): update import path for asset inventory routes
sulmoJ Dec 11, 2024
8da6a6d
feat: apply service get API (#5205)
skdud4659 Dec 11, 2024
2e317bd
feat(metric-explorer-l-s-b-store): create lsb store to replace using …
piggggggggy Dec 11, 2024
b366de2
refactor(asset-inventory): update region fetch logic for v2 support (…
sulmoJ Dec 11, 2024
efc353b
feat: apply API at service detail header (edit / delete) (#5211)
skdud4659 Dec 11, 2024
243deab
feat: apply API at overview tab (#5212)
skdud4659 Dec 11, 2024
055105e
fix: bug fix for fetch timing (#5213)
skdud4659 Dec 11, 2024
ae2a822
Feat: Add API Connection and update mark-up of User Group (#5206)
seungyeoneeee Dec 11, 2024
7c52e2d
fix: fix admin NavigationRail for no costDataSource (#5208)
sulmoJ Dec 12, 2024
2630d04
feat(metric-explorer-l-s-b): renewal metric lsb (inventory v2) (#5216)
piggggggggy Dec 13, 2024
fb79781
Feat: update about refreshing page after CRUD & mark-up about notific…
seungyeoneeee Dec 16, 2024
47dcd0c
feat: apply filters at alerts main page (#5240)
skdud4659 Dec 17, 2024
bf9bbdf
feat: create alert creation modal (#5241)
skdud4659 Dec 17, 2024
9314a27
feat: apply toolbox function (#5242)
skdud4659 Dec 17, 2024
87f51fb
feat: update user select dropdown (#5246)
skdud4659 Dec 18, 2024
04e0346
feat: apply webhook api at service detail webhook tab (#5249)
skdud4659 Dec 18, 2024
4ebd952
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
skdud4659 Dec 18, 2024
e32eae7
fix: fixed emit value type error and changed minor issue (#5251)
skdud4659 Dec 18, 2024
e25fbb1
feat: apply user select dropdown at service create step1 (#5253)
skdud4659 Dec 18, 2024
45d0d6e
feat: apply webhook create API (#5254)
skdud4659 Dec 18, 2024
71520eb
feat: apply webhook create API (#5255)
skdud4659 Dec 18, 2024
bea085b
feat: apply API at service detail tabs (#5256)
skdud4659 Dec 18, 2024
affc09e
feat: create setting modal (notification policy, auto recovery) (#5257)
skdud4659 Dec 18, 2024
d6bbe65
fix: change service version range(alert v2, inventory v1) (#5262)
sulmoJ Dec 19, 2024
349c0f4
refactor: remove unused favorite store references (#5264)
sulmoJ Dec 19, 2024
8dedae3
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
sulmoJ Dec 19, 2024
f9d7b50
feat: apply API at notification create page (#5266)
skdud4659 Dec 19, 2024
0c69d0b
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
sulmoJ Dec 19, 2024
03b46c2
fix: fix domain-specific access control for Advanced_Service (#5268)
sulmoJ Dec 19, 2024
da3aab4
feat: apply detail (search, escalation policy, style) (#5272)
skdud4659 Dec 19, 2024
7a3d336
chore: fixed minor issue (#5279)
skdud4659 Dec 20, 2024
d8b0e88
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
skdud4659 Dec 20, 2024
de5a4bb
feat: apply detail function at service detail page (#5286)
skdud4659 Dec 21, 2024
3d9ca7f
feat: create escalation policy creation modal (#5297)
skdud4659 Dec 22, 2024
fd2758d
feat: apply escalation policy API (#5304)
skdud4659 Dec 23, 2024
d09da98
feat: apply webhook API (disable, enable, delete, update) (#5310)
skdud4659 Dec 23, 2024
fbdde5d
feat: apply notification API (enable, disable, update, delete) (#5312)
skdud4659 Dec 23, 2024
53fdbee
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
sulmoJ Dec 24, 2024
af7a61f
feat(cloud-service): add unidentified provider handling (#5314)
sulmoJ Dec 24, 2024
29bba11
feat: fix schedule setting bug, update create page (#5318)
skdud4659 Dec 24, 2024
59ad66b
feat: apply alert list API at alert main page (#5319)
skdud4659 Dec 24, 2024
5df2464
feat: apply alert API at alert detail page (#5321)
skdud4659 Dec 24, 2024
91445e3
feat: apply modals API (service member, update alert, delete alert) (…
skdud4659 Dec 24, 2024
5e43edf
feat: update user select dropdown & fix mark-up bugs & update API Con…
seungyeoneeee Dec 25, 2024
fce94da
refactor: refactor schedule setting form and changed minor type issue…
skdud4659 Dec 25, 2024
e93da26
Merge remote-tracking branch 'cloudforet-io/develop' into feature-pro…
skdud4659 Dec 26, 2024
bf7fe74
feat: apply responsive mobile web, error handler, toast alert, notifi…
skdud4659 Dec 26, 2024
8e26d78
feat: apply service to reference store (#5344)
skdud4659 Dec 27, 2024
06f2a73
feat: apply favorite, breadcrumbs (#5345)
skdud4659 Dec 27, 2024
ff2206d
Feat: add ReadWriteAccess of UserGroupPage and update minor revision …
seungyeoneeee Dec 27, 2024
12a8dc9
chore: apply RWD at alert main page, remove topbar/budget notificatio…
skdud4659 Dec 27, 2024
2e4186a
refactor: refactor file name and fixed bug (#5347)
skdud4659 Dec 27, 2024
98f895b
feat: apply read write access (#5348)
skdud4659 Dec 27, 2024
ab17d25
feat: apply create forward channel API, validation check (#5350)
skdud4659 Dec 29, 2024
4aa05c2
feat: apply additional issue at service (#5351)
skdud4659 Dec 29, 2024
42a0a2a
chore: minor changed (#5352)
skdud4659 Dec 29, 2024
56d9e3d
feat: apply excel download function, apply alert note API (#5353)
skdud4659 Dec 29, 2024
f568df3
Feat: update minor changes and UserGroupChannel details (#5349)
seungyeoneeee Dec 30, 2024
117c867
fix: fixed schedule setting form bug (#5356)
skdud4659 Dec 30, 2024
b7c0b80
feat: apply minor issue (#5359)
skdud4659 Dec 30, 2024
562dd91
Fix: fix code according to schedule type change (#5357)
seungyeoneeee Dec 30, 2024
a50570d
chore: apply min-height (#5360)
skdud4659 Dec 30, 2024
9c1eaf8
feat: changed account info to service info at alert detail (#5361)
skdud4659 Dec 30, 2024
423cc78
feat: apply qa issue (#5369)
skdud4659 Dec 31, 2024
d9d2c88
feat: apply qa issue (user group & user) (#5370)
seungyeoneeee Jan 2, 2025
76fb9e7
feat: apply qa (#5375)
skdud4659 Jan 2, 2025
81c8756
feat: apply qa issues (#5381)
skdud4659 Jan 2, 2025
7287016
chore: changed css (#5382)
skdud4659 Jan 2, 2025
273b76b
chore: Add translation (#5380)
JEONG-SEULAH Jan 2, 2025
ed15119
chore: update translations (#5383)
skdud4659 Jan 2, 2025
a7c20f6
feat: apply history (#5388)
skdud4659 Jan 3, 2025
88f1e75
Merge remote-tracking branch 'cloudforet-io/develop' into feature-pro…
skdud4659 Jan 3, 2025
f77d604
feat: apply qa & changed design (#5391)
skdud4659 Jan 3, 2025
231f146
Merge remote-tracking branch 'cloudforet-io/develop' into feature-pro…
skdud4659 Jan 3, 2025
f9933e5
Feat: Alert Manager v2 - IAM QA 2 (#5387)
seungyeoneeee Jan 3, 2025
4751fd0
feat: apply user select dropdown at opsFlow (#5401)
skdud4659 Jan 3, 2025
d545719
feat: apply design qa issue (#5403)
skdud4659 Jan 3, 2025
3a58e87
feat: apply empty data at user select dropdown (#5407)
skdud4659 Jan 3, 2025
2685275
feat: apply drag at escalation policy rule card (#5408)
skdud4659 Jan 3, 2025
4ff73bf
Feat: apply qa issue (#5424)
seungyeoneeee Jan 3, 2025
9e32965
feat: apply changed design (#5425)
skdud4659 Jan 3, 2025
3bb2c22
chore: update translations qa (#5431)
skdud4659 Jan 6, 2025
86f3480
Merge remote-tracking branch 'cloudforet-io/develop' into feature-pro…
skdud4659 Jan 6, 2025
dc51ccc
feat: apply changed design at service alert tab (#5438)
skdud4659 Jan 6, 2025
08e0454
Feat: apply qa issue (#5434)
seungyeoneeee Jan 6, 2025
32536d0
feat: apply qa issue (#5443)
skdud4659 Jan 7, 2025
38edc81
feat: apply qa issue (#5446)
seungyeoneeee Jan 7, 2025
44c7772
Feature/mypage upd (#5459)
seungyeoneeee Jan 8, 2025
e603da2
feat: self qa issue & escalation-policy-reference-store update (#5460)
seungyeoneeee Jan 8, 2025
9be55d3
feat: apply event rule (#5461)
skdud4659 Jan 8, 2025
1fbd08b
chore: update translations (#5462)
skdud4659 Jan 9, 2025
d9ae42a
fix: fixed time display bug (#5464)
skdud4659 Jan 9, 2025
388b256
Merge remote-tracking branch 'cloudforet-io/master' into feature-proj…
skdud4659 Jan 9, 2025
fa0a009
chore: Add translation - from [English] to [Korean/Japanese] (#5465)
JEONG-SEULAH Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<script lang="ts" setup>
import {
computed, reactive, ref, watch,
} from 'vue';
import {
PFieldGroup, PRadioGroup, PRadio,
} from '@cloudforet/mirinae';
import type { MenuItem } from '@cloudforet/mirinae/types/inputs/context-menu/type';
import { i18n } from '@/translations';
import UserSelectDropdown from '@/common/modules/user/UserSelectDropdown.vue';
import { useNotificationChannelCreateFormStore } from '@/services/iam/store/notification-channel-create-form-store';
const notificationChannelCreateFormStore = useNotificationChannelCreateFormStore();
const notificationChannelCreateFormState = notificationChannelCreateFormStore.state;
const USER_MODE = {
ALL_MEMBER: 'ALL_MEMBER',
USER_GROUP: 'USER_GROUP',
USER: 'USER',
};
const SHOW_TYPE = {
USER_LIST: 'userList',
USER_GROUP_LIST: 'userGroupList',
};
const showType = ref<string>();
const selectedIds = ref<any>([]);
const state = reactive({
userMode: computed<MenuItem[]>(() => [{
label: i18n.t('IAM.USER_GROUP.MODAL.CREATE_CHANNEL.DESC.USER_MODE.ALL_MEMBERS'),
name: USER_MODE.ALL_MEMBER,
}, {
label: i18n.t('IAM.USER_GROUP.MODAL.CREATE_CHANNEL.DESC.USER_MODE.USER_GROUP'),
name: USER_MODE.USER_GROUP,
}, {
label: i18n.t('IAM.USER_GROUP.MODAL.CREATE_CHANNEL.DESC.USER_MODE.SPECIFIC_USER'),
name: USER_MODE.USER,
}]),
selectedUserModeIdx: 0,
});
/* Component */
const handleChange = (idx: number) => {
state.selectedUserModeIdx = idx;
};
const handleSelectedIds = (value) => {
selectedIds.value = value;
};
/* Watcher */
watch(() => state.userMode[state.selectedUserModeIdx], (nv_userMode) => {
showType.value = nv_userMode?.name === USER_MODE.USER_GROUP ? SHOW_TYPE.USER_GROUP_LIST : SHOW_TYPE.USER_LIST;
}, { deep: true, immediate: true });
watch(() => state.selectedUserModeIdx, async (nv_selectedIdx, ov_selectedIdx) => {
if (nv_selectedIdx !== ov_selectedIdx) {
selectedIds.value = [];
}
});
watch(() => state.selectedUserModeIdx, (nv_selected_idx) => {
if (nv_selected_idx === 0) {
notificationChannelCreateFormState.userInfo.type = 'ALL_MEMBER';
} else if (nv_selected_idx === 1) {
notificationChannelCreateFormState.userInfo.type = 'USER_GROUP';
} else {
notificationChannelCreateFormState.userInfo.type = 'USER';
}
});
watch([() => notificationChannelCreateFormState.userInfo.type, () => notificationChannelCreateFormState.userInfo.value], () => {
// TODO: Retrieving a list of existing users
// if (nv_user_info_type) {
// if (nv_user_info_type !== 'ALL_MEMBER') {
// state.selectedUserModeIdx = nv_user_info_type === 'USER_GROUP' ? 1 : 2;
//
// selectedIds.value = {
// type: nv_user_info_type,
// value: nv_user_info_value,
// };
// } else {
// state.selectedUserModeIdx = 0;
// }
// }
}, { immediate: true, deep: true });
watch(selectedIds, (nv_selected_ids) => {
const result: string[] = [];
nv_selected_ids.forEach((id) => {
result.push(id.value);
});
notificationChannelCreateFormState.userInfo.value = result;
}, { immediate: true });
</script>

<template>
<p-field-group :label="$t('IAM.USER_GROUP.MODAL.CREATE_CHANNEL.DESC.USER_MODE.TITLE')"
required
>
<p-radio-group>
<p-radio v-for="(mode, idx) in state.userMode"
:key="`${mode.name}-${idx}`"
v-model="state.selectedUserModeIdx"
:value="idx"
@handle="handleChange"
>
{{ mode.label }}
</p-radio>
</p-radio-group>
<user-select-dropdown class="mt-2"
:show-user-list="showType === SHOW_TYPE.USER_LIST"
:show-user-group-list="showType === SHOW_TYPE.USER_GROUP_LIST"
:disabled="state.userMode[state.selectedUserModeIdx].name === USER_MODE.ALL_MEMBER"
appearance-type="stack"
selection-type="multiple"
:selected-ids="selectedIds"
@update:selected-ids="handleSelectedIds"
/>
</p-field-group>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<script lang="ts" setup>
import {
computed, onMounted, reactive, watch,
} from 'vue';
import { range, zipObject } from 'lodash';
import {
PFieldGroup, PRadioGroup, PRadio, PI, PSelectButton, PSelectDropdown,
} from '@cloudforet/mirinae';
import type { SelectDropdownMenuItem } from '@cloudforet/mirinae/types/controls/dropdown/select-dropdown/type';
import type { ServiceChannelScheduleType } from '@/schema/alert-manager/service-channel/type';
import { i18n } from '@/translations';
import { useUserStore } from '@/store/user/user-store';
import type {
ScheduleDayButtonType,
ScheduleRadioType,
DayType,
ScheduleSettingFormType,
ScheduleFormDayType,
} from '@/common/components/schedule-setting-form/schedule-setting-form';
import { blue } from '@/styles/colors';
interface Props {
scheduleForm?: ScheduleSettingFormType;
}
const props = withDefaults(defineProps<Props>(), {
scheduleForm: undefined,
});
const userStore = useUserStore();
const userState = userStore.state;
const emit = defineEmits<{(e: 'update-form', form: ScheduleSettingFormType): void; }>();
const storeState = reactive({
timezone: computed(() => userState.timezone || 'UTC'),
});
const state = reactive({
scheduleTypeList: computed<ScheduleRadioType[]>(() => [
{ name: 'WEEK_DAY', label: i18n.t('COMMON.SCHEDULE_SETTING.WEEKDAYS') },
{ name: 'ALL_DAY', label: i18n.t('COMMON.SCHEDULE_SETTING.EVERYDAY') },
{ name: 'CUSTOM', label: i18n.t('COMMON.SCHEDULE_SETTING.CUSTOM') },
]),
selectedRadioIdx: 0,
days: computed<ScheduleDayButtonType[]>(() => [
{ name: 'MON', label: i18n.t('COMMON.SCHEDULE_SETTING.MON') },
{ name: 'TUE', label: i18n.t('COMMON.SCHEDULE_SETTING.TUE') },
{ name: 'WED', label: i18n.t('COMMON.SCHEDULE_SETTING.WED') },
{ name: 'THU', label: i18n.t('COMMON.SCHEDULE_SETTING.THU') },
{ name: 'FRI', label: i18n.t('COMMON.SCHEDULE_SETTING.FRI') },
{ name: 'SAT', label: i18n.t('COMMON.SCHEDULE_SETTING.SAT') },
{ name: 'SUN', label: i18n.t('COMMON.SCHEDULE_SETTING.SUN') },
]),
selectedDayButton: ['MON', 'TUE', 'WED', 'THU', 'FRI'] as DayType[],
start: 0,
end: 24,
startHourTimeList: computed<SelectDropdownMenuItem[]>(() => range(0, state.end).map((h) => ({
label: `${h.toString().padStart(2, '0')}:00`,
name: h.toString(),
}))),
endHourTimeList: computed<SelectDropdownMenuItem[]>(() => range(Number(state.start) + 1, 25).map((h) => ({
label: `${h.toString().padStart(2, '0')}:00`,
name: h.toString(),
}))),
scheduleDayForm: computed<Record<DayType, ScheduleFormDayType>>(() => {
const refinedDays = state.days.map((day) => ({
is_scheduled: state.selectedDayButton.includes(day.name),
start: state.start,
end: state.end,
}));
return zipObject(state.days.map((i) => i.name), refinedDays) as Record<DayType, ScheduleFormDayType>;
}),
});
const initScheduleForm = () => {
if (!props.scheduleForm) return;
state.selectedRadioIdx = state.scheduleTypeList.findIndex((item) => item.name === props.scheduleForm?.SCHEDULE_TYPE) || 0;
let filteredSchedule: string[] = [];
if (state.selectedRadioIdx === 0) {
filteredSchedule = state.days.slice(0, 5).map((day) => day.name);
} else if (state.selectedRadioIdx === 1) {
filteredSchedule = state.days.map((day) => day.name);
} else {
filteredSchedule = state.days.filter((day) => {
if (!props.scheduleForm) return [];
const schedule = props.scheduleForm[day.name];
return schedule?.is_scheduled;
}).map((i) => i.name);
}
state.selectedDayButton = filteredSchedule;
state.start = props.scheduleForm[filteredSchedule[0]]?.start || 0;
state.end = props.scheduleForm[filteredSchedule[0]]?.end || 24;
};
const handleSelectScheduleType = (type: ServiceChannelScheduleType) => {
if (type === 'WEEK_DAY') {
state.selectedDayButton = state.days.slice(0, 5).map((day) => day.name);
} else if (type === 'ALL_DAY') {
state.selectedDayButton = state.days.map((day) => day.name);
} else {
state.selectedDayButton = [];
}
};
const handleSelectDayButton = (value: DayType[]) => {
state.selectedRadioIdx = 2;
state.selectedDayButton = value;
};
const handleSelectDropdown = (type: 'start' | 'end', value: number) => {
if (type === 'start') {
state.start = value || 0;
} else {
state.end = value || 0;
}
};
watch([() => state.selectedRadioIdx, () => state.selectedDayButton, () => state.start, () => state.end], ([selectedRadioIdx]) => {
emit('update-form', {
SCHEDULE_TYPE: state.scheduleTypeList[selectedRadioIdx].name,
TIMEZONE: storeState.timezone,
...state.scheduleDayForm,
});
}, { immediate: true });
onMounted(() => {
if (props.scheduleForm) {
initScheduleForm();
}
});
</script>

<template>
<div class="schedule-setting-form flex flex-col">
<p-field-group :label="$t('COMMON.SCHEDULE_SETTING.SCHEDULE_SETTING')"
required
>
<p-radio-group direction="horizontal">
<p-radio v-for="(item, index) in state.scheduleTypeList"
:key="`schedule-setting-${index}`"
v-model="state.selectedRadioIdx"
:value="index"
@change="handleSelectScheduleType(item.name)"
>
{{ item.label }}
</p-radio>
</p-radio-group>
<div class="flex gap-1 py-2 px-0.5">
<p-i name="ic_info-circle"
:color="blue[600]"
width="0.875rem"
height="0.875rem"
/>
<p class="text-xs text-blue-600">
{{ $t('COMMON.SCHEDULE_SETTING.INFO') }}
</p>
</div>
<div class="w-full overflow py-4 flex flex-wrap gap-2">
<p-select-button v-for="(item, index) in state.days"
:key="`schedule-days-${index}`"
v-model="state.selectedDayButton"
multi-selectable
:value="item.name"
@change="handleSelectDayButton"
>
{{ item.label }}
</p-select-button>
</div>
<div class="flex items-center gap-2">
<p-select-dropdown :menu="state.startHourTimeList"
:selected="state.start"
:placeholder="state.startHourTimeList[state.start].label"
@select="handleSelectDropdown('start', $event)"
/>
<span>{{ $t('COMMON.SCHEDULE_SETTING.TO') }}</span>
<p-select-dropdown :menu="state.endHourTimeList"
:selected="state.end"
:placeholder="state.endHourTimeList[state.end - state.start - 1].label"
@select="handleSelectDropdown('end', $event)"
/>
</div>
</p-field-group>
</div>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { TranslateResult } from 'vue-i18n';

export type ScheduleType = 'ALL_DAY' | 'WEEK_DAY' | 'WEEKEND' | 'CUSTOM';
export type DayType = 'MON' | 'TUE' | 'WED' | 'THU' | 'FRI' | 'SAT' | 'SUN';

export type ScheduleRadioType = {
name: ScheduleType;
label: TranslateResult;
};
export type ScheduleDayButtonType = {
name: DayType;
label: TranslateResult;
};

type ScheduleFormType = {
SCHEDULE_TYPE: ScheduleType;
};
export type ScheduleFormDayType = {
is_scheduled: boolean;
start: number;
end: number;
};

export type ScheduleSettingFormType = ScheduleFormType & Partial<Record<DayType, ScheduleFormDayType>> & {
TIMEZONE: string;
};
Loading
Loading