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

Improved: migrated the brokering job fetching logic to moqui (#299) #302

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ VUE_APP_BASE_URL=
VUE_APP_ORDER_IN_BRKRNG_FILTERS=["orderTypeId: SALES_ORDER", "facilityId: _NA_", "orderStatusId: ORDER_APPROVED", "!orderItemStatusId: ITEM_CANCELLED" ]
VUE_APP_PERMISSION_ID=
VUE_APP_ALIAS=
VUE_APP_CTGRY_AND_BRKRNG_JOB=["JOB_REL_PREODR_CAT", "JOB_BKR_ORD", "JOB_RLS_ORD_DTE"]
VUE_APP_CTGRY_JOB=["JOB_REL_PREODR_CAT", "JOB_RLS_ORD_DTE"]
VUE_APP_BROKERING_JOB="JOB_BKR_ORD"
VUE_APP_DEFAULT_ALIAS=
VUE_APP_DEFAULT_LOG_LEVEL="error"
VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login"
94 changes: 70 additions & 24 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"@casl/ability": "^6.0.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.2.6",
"@hotwax/dxp-components": "1.13.0",
"@hotwax/oms-api": "1.14.0",
"@hotwax/dxp-components": "1.15.2",
"@hotwax/oms-api": "1.15.0",
"@ionic/core": "^7.6.0",
"@ionic/vue": "^7.6.0",
"@ionic/vue-router": "^7.6.0",
Expand Down
104 changes: 103 additions & 1 deletion src/services/JobService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { api } from '@/adapter';
import { api, client } from '@/adapter';
import store from '@/store'
import { DateTime } from 'luxon';

Expand Down Expand Up @@ -153,15 +153,117 @@ const scheduleJob = async (payload: any): Promise<any> => {
});
}

const fetchBrokeringJobId = async (payload: any): Promise<any> => {
return api({
url: "performFind",
method: "get",
params: payload
});
}

const fetchBrokeringJobSchedule = async (routingGroupId: string): Promise<any> => {
const omsRedirectionInfo = store.getters['user/getOmsRedirectionInfo'];

const url = omsRedirectionInfo.url
const baseURL = url.startsWith('http') ? url.includes('/rest/s1/order-routing') ? url : `${url}/rest/s1/order-routing/` : `https://${url}.hotwax.io/rest/s1/order-routing/`;

return client({
url: `groups/${routingGroupId}/schedule`,
method: "GET",
baseURL,
headers: {
"api_key": omsRedirectionInfo.token,
"Content-Type": "application/json"
}
});
}

const fetchBrokeringJobActiveRun = async (jobName: string): Promise<any> => {
const omsRedirectionInfo = store.getters['user/getOmsRedirectionInfo'];

const url = omsRedirectionInfo.url
const baseURL = url.startsWith('http') ? url.includes('/rest/s1/order-routing') ? url : `${url}/rest/s1/order-routing/` : `https://${url}.hotwax.io/rest/s1/order-routing/`;

return client({
url: `serviceJobRuns/${jobName}/activeJobRun`,
method: "GET",
baseURL,
headers: {
"api_key": omsRedirectionInfo.token,
"Content-Type": "application/json"
}
});
}

const scheduleMaargJob = async (payload: any): Promise<any> => {
const omsRedirectionInfo = store.getters['user/getOmsRedirectionInfo'];

const url = omsRedirectionInfo.url
const baseURL = url.startsWith('http') ? url.includes('/rest/s1/order-routing') ? url : `${url}/rest/s1/order-routing/` : `https://${url}.hotwax.io/rest/s1/order-routing/`;

return client({
url: `groups/${payload.routingGroupId}/schedule`,
method: "POST",
baseURL,
data: payload,
headers: {
"api_key": omsRedirectionInfo.token,
"Content-Type": "application/json"
}
});
}


const runMaargJobNow = async (routingGroupId: string): Promise<any> => {
const omsRedirectionInfo = store.getters['user/getOmsRedirectionInfo'];

const url = omsRedirectionInfo.url
const baseURL = url.startsWith('http') ? url.includes('/rest/s1/order-routing') ? url : `${url}/rest/s1/order-routing/` : `https://${url}.hotwax.io/rest/s1/order-routing/`;

return client({
url: `groups/${routingGroupId}/runNow`,
method: "POST",
baseURL,
headers: {
"api_key": omsRedirectionInfo.token,
"Content-Type": "application/json"
}
});
}

const fetchRoutingHistory = async (routingGroupId: string, params: any): Promise<any> => {
const omsRedirectionInfo = store.getters['user/getOmsRedirectionInfo'];

const url = omsRedirectionInfo.url
const baseURL = url.startsWith('http') ? url.includes('/rest/s1/order-routing') ? url : `${url}/rest/s1/order-routing/` : `https://${url}.hotwax.io/rest/s1/order-routing/`;

return client({
url: `groups/${routingGroupId}/routingRuns`,
method: "GET",
params,
baseURL,
headers: {
"api_key": omsRedirectionInfo.token,
"Content-Type": "application/json"
}
});
}

export const JobService = {
cancelJob,
fetchBackgroundJobs,
fetchBrokeringJobActiveRun,
fetchBrokeringJobId,
fetchBrokeringJobSchedule,
fetchJobLogs,
fetchJobs,
fetchJobInformation,
fetchRoutingHistory,
pollJobs,
prepareFetchJobsQuery,
prepareFetchLogsQuery,
scheduleJob,
scheduleMaargJob,
runMaargJobNow,
runJobNow
}
29 changes: 29 additions & 0 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,34 @@ const login = async (username: string, password: string): Promise <any> => {
});
}

const moquiLogin = async (omsRedirectionUrl: string, token: string): Promise <any> => {
const baseURL = omsRedirectionUrl.startsWith('http') ? omsRedirectionUrl.includes('/rest/s1/order-routing') ? omsRedirectionUrl : `${omsRedirectionUrl}/rest/s1/order-routing/` : `https://${omsRedirectionUrl}.hotwax.io/rest/s1/order-routing/`;
let api_key = ""

try {
const resp = await client({
url: "login",
method: "post",
baseURL,
params: {
token
},
headers: {
"Content-Type": "application/json"
}
}) as any;

if(!hasError(resp) && (resp.data.api_key || resp.data.token)) {
api_key = resp.data.api_key || resp.data.token
} else {
throw "Sorry, login failed. Please try again";
}
} catch(err) {
return Promise.resolve("");
}
return Promise.resolve(api_key)
}

const setUserPreference = async (payload: any): Promise<any> => {
return api({
url: "service/setUserPreference",
Expand Down Expand Up @@ -195,5 +223,6 @@ export const UserService = {
getUserProfile,
getUserPermissions,
login,
moquiLogin,
setUserPreference,
}
3 changes: 2 additions & 1 deletion src/store/modules/job/JobState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default interface JobState {
items: any[];
},
polling: boolean,
ctgryAndBrkrngJobs: any
categoryJobs: any,
brokeringJob: any
}
Loading
Loading