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

Implemented: functionality to the Publish segment of the Inventory channels page (#356) #357

Merged
merged 20 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
62ed045
Implemented: logic to fetch shopify shop jobs for publish section (#356)
amansinghbais Jun 28, 2024
da5ab40
Implemented: logic for shopifyShop job history modal,and job copy to …
amansinghbais Jul 1, 2024
0d5c3cc
Improved: logic for frequencyOptions generation and selection (#356)
amansinghbais Jul 1, 2024
2ee63e6
Implemented: logic for custom runTime selection (#356)
amansinghbais Jul 2, 2024
5e6d7ed
Improved: added logic to disable job (#356)
amansinghbais Jul 3, 2024
d8c2cce
Improved: logic to save job changes (#356)
amansinghbais Jul 3, 2024
834b904
Implemented: action and service for updating the job (#356)
amansinghbais Jul 3, 2024
b3ee387
Improved: logic to schedule job and logic to runTime validation (#356)
amansinghbais Jul 3, 2024
6522410
Implemented: functionality to the runNow action in shopActions popove…
amansinghbais Jul 3, 2024
3bab42d
Improved: optimized logic for publish segment, syntax and structure o…
amansinghbais Jul 3, 2024
cc32973
Improved: logic for saveChanges functionality (#356)
amansinghbais Jul 4, 2024
3476118
Improved: using currentJob from prop instead of passing in arguement …
amansinghbais Jul 4, 2024
8b406a7
Improved: migrated the logic to schedule and update job in the compon…
amansinghbais Jul 4, 2024
bb9d535
Improved: added viewSize while fetching draft job and reverted env en…
amansinghbais Jul 9, 2024
1ada9be
Reverted: unused job parameter 'SinceId' and unused commit argument i…
amansinghbais Jul 10, 2024
c423171
Merge branch 'main' of https://github.com/hotwax/threshold-management…
amansinghbais Jul 19, 2024
bff7ffc
Merge branch 'main' of https://github.com/hotwax/threshold-management…
amansinghbais Jul 26, 2024
6764174
Improved: version of the dxp-component dependency (#356)
amansinghbais Jul 26, 2024
baa2ab0
Improved: ofbiz api calling logic (#356)
amansinghbais Jul 26, 2024
842320c
Improved: endpoint for fetching shopifyShops using moqui instead of u…
amansinghbais Jul 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ VUE_APP_ALIAS={}
VUE_APP_DEFAULT_ALIAS=""
VUE_APP_DEFAULT_LOG_LEVEL="error"
VUE_APP_CRON_EXPRESSIONS={"Every 5 minutes":"0 */5 * ? * *","Every 15 minutes":"0 */15 * ? * *","Every 30 minutes":"0 */30 * ? * *","Hourly":"0 0 * ? * *","Every six hours":"0 0 */6 ? * *","Every day at midnight":"0 0 0 * * ?"}
VUE_APP_SHOPIFY_JOBS_FREQUENCY_OPTIONS=[{"id": "HOURLY","description":"Hourly"},{"id": "EVERY_6_HOUR","description":"Every 6 hours"},{"id":"EVERYDAY","description":"Every day"},{"id":"CUSTOM","description":"Custom"}]
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
VUE_APP_LOGIN_URL="https://launchpad.hotwax.io/login"
21 changes: 19 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ import emitter from "@/event-bus"
import store from "@/store";
import { StatusCodes } from "http-status-codes";

let apiConfig = {} as any

axios.interceptors.request.use((config: any) => {
// TODO: pass csrf token
const token = store.getters["user/getUserToken"];
if (token) {
if (token && !apiConfig.useOmsRedirection) {
config.headers["api_key"] = token;
config.headers["Content-Type"] = "application/json";
}

const omsRedirectionInfo = store.getters["user/getOmsRedirectionInfo"]
if (apiConfig.useOmsRedirection && omsRedirectionInfo.token) {
config.headers["Authorization"] = `Bearer ${omsRedirectionInfo.token}`;
config.headers["Content-Type"] = "application/json";
}

return config;
});

Expand Down Expand Up @@ -77,6 +85,8 @@ const axiosCache = setupCache({
* @return {Promise} Response from API as returned by Axios
*/
const api = async (customConfig: any) => {
apiConfig = customConfig

// Prepare configuration
const config: any = {
url: customConfig.url,
Expand All @@ -87,7 +97,14 @@ const api = async (customConfig: any) => {
}

const baseURL = store.getters["user/getInstanceUrl"];
if (baseURL) config.baseURL = baseURL.startsWith('http') ? baseURL.includes('/rest/s1/available-to-promise') ? baseURL : `${baseURL}/rest/s1/available-to-promise/` : `https://${baseURL}.hotwax.io/rest/s1/available-to-promise/`;
const omsRedirectionInfo = store.getters["user/getOmsRedirectionInfo"]

if(customConfig.useOmsRedirection) {
config.baseURL = omsRedirectionInfo.url.startsWith('http') ? omsRedirectionInfo.url.includes('/api') ? omsRedirectionInfo.url : `${omsRedirectionInfo.url}/api/` : `https://${omsRedirectionInfo.url}.hotwax.io/api/`;
} else if (baseURL) {
config.baseURL = baseURL.startsWith('http') ? baseURL.includes('/rest/s1/available-to-promise') ? baseURL : `${baseURL}/rest/s1/available-to-promise/` : `https://${baseURL}.hotwax.io/rest/s1/available-to-promise/`;
}

if(customConfig.cache) config.adapter = axiosCache.adapter;
const networkStatus = await OfflineHelper.getNetworkStatus();
if (customConfig.queue && !networkStatus.connected) {
Expand Down
62 changes: 62 additions & 0 deletions src/components/CustomFrequencyModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-button @click="closeModal">
<ion-icon :icon="closeOutline" slot="icon-only" />
</ion-button>
</ion-buttons>
<ion-title>{{ translate("Custom frequency") }}</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<div v-if="customFrequencies.length">
<ion-list>
<ion-radio-group v-model="frequencyId">
<ion-item :key="customFrequency.tempExprId" v-for="customFrequency in customFrequencies">
<ion-radio :value="customFrequency.tempExprId">{{ customFrequency.description }}</ion-radio>
</ion-item>
</ion-radio-group>
</ion-list>
</div>
<div class="empty-state" v-else>
<p>{{ translate("No frequency found.")}}</p>
</div>
</ion-content>

<ion-fab vertical="bottom" horizontal="end" slot="fixed">
<ion-fab-button :disabled="!frequencyId" @click="setFrequency()">
<ion-icon :icon="saveOutline" />
</ion-fab-button>
</ion-fab>
</template>

<script setup lang="ts">
import { IonButton, IonButtons, IonContent, IonFab, IonFabButton, IonHeader, IonIcon, IonItem, IonList, IonRadio, IonRadioGroup, IonTitle, IonToolbar, modalController } from "@ionic/vue";
import { onMounted, ref } from "vue";
import { closeOutline, saveOutline } from "ionicons/icons";
import { translate } from "@/i18n";
import { useStore } from "vuex";

const store = useStore();

const customFrequencies = ref([]) as any;
const frequencyId = ref("");

onMounted(() => {
findFrequencies();
})

function closeModal() {
modalController.dismiss({ dismissed: true });
}

async function findFrequencies() {
customFrequencies.value = await store.dispatch("channel/findTemporalExpression");
}

async function setFrequency() {
modalController.dismiss({ dismissed: true, frequencyId: frequencyId.value });
}
</script>
84 changes: 84 additions & 0 deletions src/components/JobHistoryModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<template>
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-button @click="closeModal">
<ion-icon slot="icon-only" :icon="closeOutline" />
</ion-button>
</ion-buttons>
<ion-title>{{ currentJob?.enumName }}</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<div v-if="jobHistory?.length">
<ion-list>
<ion-item v-for="(job, index) in jobHistory" :key="index">
<ion-label>
{{ job.runTime ? getTime(job.runTime) : "-" }}
<p v-if="job.runTime">{{ getDate(job.runTime) }}</p>
</ion-label>
<ion-badge v-if="job.statusId" :color="job.statusId === 'SERVICE_FINISHED' ? 'success' : 'danger'">{{ getStatusDesc(job.statusId) }}</ion-badge>
</ion-item>
</ion-list>
</div>

<div v-else>
<p class="ion-text-center">{{ translate("No available history for this job.")}}</p>
</div>
</ion-content>
</template>

<script setup lang="ts">
import { IonBadge, IonButton, IonButtons, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonList, IonTitle, IonToolbar, modalController } from '@ionic/vue';
import { translate } from '@/i18n';
import { closeOutline } from 'ionicons/icons';
import { computed, defineProps, onMounted, ref } from "vue";
import { DateTime } from 'luxon';
import { ChannelService } from '@/services/ChannelService';
import { useStore } from "vuex";

const store = useStore();
const props = defineProps(["currentJob"]);

const jobHistory = ref([]) as any;

const getStatusDesc = computed(() => store.getters["channel/getStatusDesc"])

onMounted(async () => {
await store.dispatch("channel/getServiceStatusDesc");
fetchJobHistory();
})

function closeModal() {
modalController.dismiss({ dismissed: true });
}

function getDate(runTime: any) {
return DateTime.fromMillis(runTime).toLocaleString(DateTime.DATE_MED);
}

function getTime(runTime: any) {
return DateTime.fromMillis(runTime).toLocaleString(DateTime.TIME_SIMPLE);
}

async function fetchJobHistory() {
jobHistory.value = await ChannelService.fetchJobInformation({
"inputFields": {
"productStoreId": props.currentJob.productStoreId,
"statusId": ["SERVICE_CANCELLED", "SERVICE_CRASHED", "SERVICE_FAILED", "SERVICE_FINISHED"],
"statusId_op": "in",
"systemJobEnumId": props.currentJob.systemJobEnumId,
"shopId_fld0_value": props.currentJob.shopId,
"shopId_fld0_grp": "1",
"shopId_fld0_op": "equals",
"shopId_fld1_grp": "2",
"shopId_fld1_op": "empty"
},
"fieldList": ["runTime", "statusId"],
"noConditionFind": "Y",
"viewSize": process.env.VUE_APP_VIEW_SIZE,
"orderBy": "runTime DESC"
})
}
</script>
4 changes: 2 additions & 2 deletions src/components/ScheduleActionsPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ async function runNow() {
try {
const resp = await RuleService.runNow(ruleGroup.value.ruleGroupId)
if(!hasError(resp) && resp.data.jobRunId) {
showToast(translate("Service has been scheduled"))
showToast(translate("Service has been scheduled."))
await store.dispatch('rule/fetchRules', { groupTypeEnumId: ruleGroup.value.groupTypeEnumId, pageSize: 50 })
popoverController.dismiss();
} else {
throw resp.data
}
} catch(err) {
showToast(translate("Failed to schedule service"))
showToast(translate("Failed to schedule service."))
logger.error(err)
}
emitter.emit("dismissLoader");
Expand Down
4 changes: 2 additions & 2 deletions src/components/ScheduleRuleItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ async function saveSchedule() {
try {
const resp = await RuleService.scheduleRuleGroup(payload)
if(!hasError(resp)) {
showToast(translate("Service has been scheduled"))
showToast(translate("Service has been scheduled."))
await store.dispatch('rule/fetchRules', { groupTypeEnumId: ruleGroup.value.groupTypeEnumId, pageSize: 50 })
} else {
throw resp.data
}
} catch(err) {
showToast(translate("Failed to schedule service"))
showToast(translate("Failed to schedule service."))
logger.error(err)
}
emitter.emit("dismissLoader");
Expand Down
Loading
Loading