Skip to content

Commit

Permalink
Merge pull request #314 from k2maan/#32j3gu0
Browse files Browse the repository at this point in the history
Implement bulk scheduling (#32j3gu0)
  • Loading branch information
adityasharma7 authored Jan 18, 2023
2 parents f7e2bac + 7b9e69a commit 1197c49
Show file tree
Hide file tree
Showing 14 changed files with 730 additions and 99 deletions.
180 changes: 180 additions & 0 deletions src/components/JobConfigurationForBulkScheduler.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
<template>
<ion-card>
<ion-item lines="none">
<ion-label class="ion-text-wrap">
{{ job.jobName }}
<p>{{ job.description }}</p>
</ion-label>
</ion-item>
<ion-item-divider>
{{ $t("Parameters") }}
</ion-item-divider>
<ion-item>
<ion-label>{{ $t("Store") }}</ion-label>
<ion-note slot="end">{{ eComStoreName }}</ion-note>
</ion-item>
<ion-item>
<ion-label>{{ $t("eCommerce") }}</ion-label>
<ion-badge v-if="selectedShopifyConfigs.length === 0" color="danger">{{ $t("no eCommerce selected") }}</ion-badge>
<ion-note v-else slot="end">{{ shopifyConfigNames }}</ion-note>
</ion-item>
<ion-item>
<ion-label>{{ $t("Run time") }}</ion-label>
<ion-label class="ion-text-wrap" @click="() => isDateTimeModalOpen = true" slot="end">{{ job.runTime ? getTime(job.runTime) : $t('Select run time') }}</ion-label>
<ion-modal class="date-time-modal" :is-open="isDateTimeModalOpen" @didDismiss="() => isDateTimeModalOpen = false">
<ion-content force-overscroll="false">
<ion-datetime
show-default-buttons
hour-cycle="h23"
:value="job.runTime ? getDateTime(job.runTime) : ''"
@ionChange="updateRunTime($event)"
/>
</ion-content>
</ion-modal>
</ion-item>
<ion-item>
<ion-label>{{ $t("Schedule") }}</ion-label>
<ion-select :interface-options="customPopoverOptions" :value="job.frequency" interface="popover" :placeholder='$t("Bulk schedule")' @ionChange='setFrequency($event)'>
<ion-select-option v-for="freq in generateFrequencyOptions(job.freqType)" :key="freq.value" :value="freq.value">{{ $t(freq.label) }}</ion-select-option>
</ion-select>
</ion-item>
<div class="actions">
<ion-button size="small" fill="outline" color="danger" @click="removeJob(job.jobId)">
<ion-icon slot="start" :icon="closeOutline"/>
{{ $t("Remove") }}
</ion-button>
</div>
</ion-card>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import {
IonBadge,
IonButton,
IonCard,
IonContent,
IonDatetime,
IonIcon,
IonItem,
IonItemDivider,
IonLabel,
IonNote,
IonModal,
IonSelect,
IonSelectOption,
} from "@ionic/vue";
import {
calendarClearOutline,
flashOutline,
copyOutline,
timeOutline,
timerOutline,
syncOutline,
personCircleOutline,
pinOutline,
closeOutline
} from "ionicons/icons";
import { mapGetters, useStore } from "vuex";
import { handleDateTimeInput, showToast, generateFrequencyOptions } from "@/utils";
import { DateTime } from 'luxon';
import { translate } from '@/i18n'
export default defineComponent({
name: "JobConfigurationForBulkScheduler",
components: {
IonBadge,
IonButton,
IonCard,
IonContent,
IonDatetime,
IonIcon,
IonItem,
IonItemDivider,
IonLabel,
IonModal,
IonNote,
IonSelect,
IonSelectOption,
},
data() {
return {
isDateTimeModalOpen: false,
}
},
props: ["job", "selectedShopifyConfigs", "selectedEComStoreId"],
computed: {
...mapGetters({
bulkJobs: 'job/getBulkJobs',
userProfile: 'user/getUserProfile',
shopifyConfigs: 'user/getShopifyConfigs',
}),
eComStoreName() {
return this.userProfile.stores.find((store: any) => store.productStoreId === this.selectedEComStoreId).storeName;
},
shopifyConfigNames() {
// find matching shopifyConfig objects and return their names
return this.shopifyConfigs.filter((config: any) => this.selectedShopifyConfigs.includes(config.shopId)).map((config: any) => config.name).join(', ');
},
customPopoverOptions() {
return {
header: (this as any).job.jobName,
showBackdrop: false
}
}
},
methods: {
getDateTime(time: any) {
return DateTime.fromMillis(time).toISO()
},
updateRunTime(ev: CustomEvent) {
const currTime = DateTime.now().toMillis();
const setTime = handleDateTimeInput(ev['detail'].value);
if(setTime > currTime) {
this.store.dispatch('job/setBulkJobRuntime', { runtime: setTime, jobId: this.job.jobId });
} else {
showToast(translate("Provide a future date and time"));
}
},
async setFrequency(ev: CustomEvent) {
const frequency = ev['detail'].value;
await this.store.dispatch('job/setBulkJobFrequency', { frequency: frequency, jobId: this.job.jobId });
},
getTime (time: any) {
return DateTime.fromMillis(time).toLocaleString(DateTime.DATETIME_MED);
},
removeJob(jobId: any) {
this.store.dispatch('job/removeBulkJob', jobId);
},
},
setup() {
const store = useStore();
return {
calendarClearOutline,
copyOutline,
flashOutline,
timeOutline,
timerOutline,
store,
syncOutline,
personCircleOutline,
pinOutline,
closeOutline,
generateFrequencyOptions
};
}
});
</script>
<style scoped>
ion-modal {
--width: 290px;
--height: 440px;
--border-radius: 8px;
}
.actions > ion-button {
margin: var(--spacer-sm);
}
</style>
4 changes: 2 additions & 2 deletions src/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default defineComponent({
mdIcon: libraryOutline,
dependsOnBaseURL: false
},
/* {
{
title: "Bulk editor"
},
{
Expand All @@ -203,7 +203,7 @@ export default defineComponent({
iosIcon: terminalOutline,
mdIcon: terminalOutline,
dependsOnBaseURL: false
}, */
},
{
title: "Settings",
url: "/settings",
Expand Down
4 changes: 2 additions & 2 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const i18n = createI18n({

// TODO Check if this is needed in updated versions
// Currently this method is added to be used in ts files
const translate = (key: string) => {
const translate = (key: string, named?: any) => {
if (!key) {
return '';
}
return i18n.global.t(key);
return i18n.global.t(key, named);
};

export { i18n as default, translate }
14 changes: 12 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"A store repesents a company or a unique catalog of products. If your OMS is connected to multiple eCommerce stores sellling different collections of products, you may have multiple Product Stores set up in HotWax Commerce.": "A store repesents a company or a unique catalog of products. If your OMS is connected to multiple eCommerce stores sellling different collections of products, you may have multiple Product Stores set up in HotWax Commerce.",
"Add": "Add",
"Add jobs": "Add jobs",
"Add shipping dates in Shopify": "Add shipping dates in Shopify",
"Add tags in Shopify": "Add tags in Shopify",
"Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to?",
"Adjustments": "Adjustments",
"Are you sure you want to save these changes?": "Are you sure you want to save these changes?",
"Are you sure you want to schedule these jobs?": "Are you sure you want to schedule these jobs?",
"Auto cancelations": "Auto cancelations",
"Auto cancel days updated": "Auto cancel days updated",
"Import all products from Shopify. Make sure you run this before importing orders in bulk during intial setup.": "Import all products from Shopify. Make sure you run this before importing orders in bulk during intial setup.",
Expand Down Expand Up @@ -57,6 +59,7 @@
"Don't skip": "Don't skip",
"eCommerce": "eCommerce",
"eCommerce stores are directly connected to one Shop Config. If your OMS is connected to multiple eCommerce stores selling the same catalog operating as one Company, you may have multiple Shop Configs for the selected Product Store.": "eCommerce stores are directly connected to one Shop Config. If your OMS is connected to multiple eCommerce stores selling the same catalog operating as one Company, you may have multiple Shop Configs for the selected Product Store.",
"Failed to schedule service(s)": "Failed to schedule {count} service(s)",
"Every day": "Every day",
"Every 6 hours": "Every 6 hours",
"Every 1 minute": "Every 1 minute",
Expand Down Expand Up @@ -100,7 +103,9 @@
"New broker run": "New broker run",
"New orders": "New orders",
"New products": "New products",
"No": "No",
"no eCommerce selected": "no eCommerce selected",
"No jobs found": "No jobs found",
"No jobs have run yet": "No jobs have run yet",
"No previous occurrence": "No previous occurrence",
"Notes": "Notes",
Expand Down Expand Up @@ -140,6 +145,7 @@
"Rejected orders": "Rejected orders",
"Release": "Release",
"Release preorders": "Release preorders",
"Remove": "Remove",
"Remove shipping dates in Shopify": "Remove shipping dates in Shopify",
"Remove tags in Shopify": "Remove tags in Shopify",
"Repeat untill disabled": "Repeat untill disabled",
Expand All @@ -166,7 +172,9 @@
"Schedule product sync": "Schedule product sync",
"Select run time": "Select run time",
"Search jobs": "Search jobs",
"Select jobs": "Select jobs",
"select jobs": "select jobs",
"Services have been scheduled in bulk": "Services have been scheduled in bulk",
"Search time zones": "Search time zones",
"Select time zone": "Select time zone",
"eCom Store": "eCom Store",
Expand All @@ -176,7 +184,6 @@
"Sorry, your username or password is incorrect. Please try again.": "Sorry, your username or password is incorrect. Please try again.",
"Select eCommerce": "Select eCommerce",
"Select store": "Select store",
"Service has been scheduled": "Service has been scheduled",
"Service updated successfully": "Service updated successfully",
"Settings": "Settings",
"Shopify Config": "Shopify Config",
Expand All @@ -185,6 +192,7 @@
"Skip job": "Skip job",
"Skip once": "Skip once",
"Skipping will run this job at the next occurrence based on the temporal expression.": "Skipping will run this job at the next occurrence based on the temporal expression.",
"Some jobs have slow frequency type, hence, feasible frequency will be set automatically": "Some jobs have slow frequency type, hence, feasible frequency will be set automatically",
"Start with Ionic": "Start with Ionic",
"Status": "Status",
"Store": "Store",
Expand All @@ -202,6 +210,7 @@
"This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.": "This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.",
"This job has been skipped": "This job has been skipped",
"This job has been canceled": "This job has been canceled",
"This job has slow frequency type, hence, feasible frequency will be set automatically": "This job has slow frequency type, hence, feasible frequency will be set automatically",
"This job may take several minutes to run. Wait till the job has moved to the pipeline history before checking results.": "This job may take several minutes to run.{ space } Wait till the job has moved to the pipeline history before checking results.",
"This job schedule cannot be skipped": "This job schedule cannot be skipped",
"This job will be scheduled to run as soon as possible. There may not be enough time to revert this action.": "This job will be scheduled to run as soon as possible.{ space } There may not be enough time to revert this action.",
Expand All @@ -227,5 +236,6 @@
"Upload Pending Process": "Upload Pending Process",
"Update shipping dates in Shopify": "Update shipping dates in Shopify",
"When importing historical completed orders, this should be turned off.": "When importing historical completed orders, this should be turned off.",
"When using HotWax BOPIS, Shopify isn't aware of the actual inventory consumed. HotWax will automatically restore inventory automatically reduced by Shopify and deduct inventory from the correct store to maintain inventory accuracy.": "When using HotWax BOPIS, Shopify isn't aware of the actual inventory consumed. HotWax will automatically restore inventory automatically reduced by Shopify and deduct inventory from the correct store to maintain inventory accuracy."
"When using HotWax BOPIS, Shopify isn't aware of the actual inventory consumed. HotWax will automatically restore inventory automatically reduced by Shopify and deduct inventory from the correct store to maintain inventory accuracy.": "When using HotWax BOPIS, Shopify isn't aware of the actual inventory consumed. HotWax will automatically restore inventory automatically reduced by Shopify and deduct inventory from the correct store to maintain inventory accuracy.",
"Yes": "Yes"
}
3 changes: 2 additions & 1 deletion src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ const getShopifyConfig = async (payload: any): Promise <any> => {
return api({
url: "performFind",
method: "get",
params: payload
params: payload,
cache: true
});
}

Expand Down
7 changes: 6 additions & 1 deletion src/store/modules/job/JobState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ export default interface JobState {
status: any,
category: any,
enum: any
}
},
bulk: {
jobs: any,
runtime: any,
frequency: any,
},
}
Loading

0 comments on commit 1197c49

Please sign in to comment.