Skip to content

Commit

Permalink
Merge pull request #357 from amansinghbais/#356
Browse files Browse the repository at this point in the history
Implemented: functionality to the Publish segment of the Inventory channels page (#356)
  • Loading branch information
ravilodhi authored Jul 26, 2024
2 parents c5c867e + 842320c commit 244c9a7
Show file tree
Hide file tree
Showing 18 changed files with 995 additions and 45 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@casl/vue": "^2.2.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.2.6",
"@hotwax/dxp-components": "^1.13.0",
"@hotwax/dxp-components": "1.14.1",
"@hotwax/oms-api": "^1.14.0",
"@ionic/core": "7.6.0",
"@ionic/vue": "7.6.0",
Expand Down
15 changes: 13 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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"];
Expand Down Expand Up @@ -77,6 +79,8 @@ const axiosCache = setupCache({
* @return {Promise} Response from API as returned by Axios
*/
const api = async (customConfig: any) => {
apiConfig = customConfig

Check warning on line 82 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'apiConfig' is assigned a value but never used

Check warning on line 82 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / build_and_deploy

'apiConfig' is assigned a value but never used

Check warning on line 82 in src/api/index.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'apiConfig' is assigned a value but never used

// Prepare configuration
const config: any = {
url: customConfig.url,
Expand All @@ -87,7 +91,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 All @@ -108,7 +119,7 @@ const api = async (customConfig: any) => {
* @return {Promise} Response from API as returned by Axios
*/
const client = (config: any) => {
return axios.request(config);
return axios.create().request(config);
}

export { api as default, client, axios };
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 "@hotwax/dxp-components";
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 '@hotwax/dxp-components';
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

0 comments on commit 244c9a7

Please sign in to comment.