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: Miscellaneous page in job-manager(#364ttxy) #214

Merged
merged 13 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
12 changes: 10 additions & 2 deletions src/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
} from "@ionic/vue";
import { defineComponent, ref } from "vue";
import { mapGetters } from "vuex";
import { pulseOutline, calendarNumberOutline, ticketOutline, albumsOutline, shirtOutline, settings, iceCreamOutline } from "ionicons/icons";
import { pulseOutline, calendarNumberOutline, ticketOutline, albumsOutline, shirtOutline, settings, iceCreamOutline, libraryOutline } from "ionicons/icons";
import { useStore } from "@/store";
export default defineComponent({
name: "Menu",
Expand Down Expand Up @@ -140,6 +140,13 @@ export default defineComponent({
mdIcon: shirtOutline,
dependsOnBaseURL: false
},
{
title: "Miscellaneous",
url: "/miscellaneous",
iosIcon: libraryOutline,
mdIcon: libraryOutline,
dependsOnBaseURL: false
},
{
title: "Settings",
url: "/settings",
Expand All @@ -161,7 +168,8 @@ export default defineComponent({
shirtOutline,
settings,
iceCreamOutline,
store
store,
libraryOutline
};
},
});
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
"Last Shopify Order ID": "Last Shopify Order ID",
"Login": "Login",
"Logout": "Logout",
"Miscellaneous": "Miscellaneous",
"Miscellaneous jobs": "Miscellaneous jobs",
"More options": "More options",
"New broker run": "New broker run",
"New orders": "New orders",
Expand Down
7 changes: 7 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import PreOrder from '@/views/PreOrder.vue'
import Orders from '@/views/Orders.vue'
import JobDetails from '@/views/JobDetails.vue'
import InitialLoad from '@/views/InitialLoad.vue'
import Miscellaneous from '@/views/Miscellaneous.vue'
import Login from '@/views/Login.vue'
import Settings from "@/views/Settings.vue"
import store from '@/store'
Expand Down Expand Up @@ -74,6 +75,12 @@ const routes: Array<RouteRecordRaw> = [
component: InitialLoad,
beforeEnter: authGuard
},
{
path: '/miscellaneous',
name: 'Miscellaneous',
component: Miscellaneous,
beforeEnter: authGuard
},
{
path: '/login',
name: 'Login',
Expand Down
6 changes: 5 additions & 1 deletion src/store/modules/job/JobState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ export default interface JobState {
history: {
list: any,
total: 0
},
}
miscellaneous: {
list: any,
total: 0
}
current: any;
temporalExp: any;
enumIds: any;
Expand Down
51 changes: 51 additions & 0 deletions src/store/modules/job/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,57 @@ const actions: ActionTree<JobState, RootState> = {
showToast(translate("Something went wrong"));
})
},
async fetchMiscellaneousJobs({ commit, dispatch, state }, payload){
const params = {
"inputFields": {
"enumTypeId": "MISC_SYS_JOB",
"statusId": ["SERVICE_PENDING", "SERVICE_DRAFT"],
dt2patel marked this conversation as resolved.
Show resolved Hide resolved
"statusId_op": "in",
"systemJobEnumId_op": "not-empty"
} as any,
"fieldList": [ "systemJobEnumId", "runTime", "tempExprId", "parentJobId", "serviceName", "jobId", "jobName", "currentRetryCount", "statusId", "enumName" ],
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
"noConditionFind": "Y",
"viewSize": payload.viewSize,
"viewIndex": payload.viewIndex,
}

if(payload.eComStoreId) {
params.inputFields["productStoreId"] = payload.eComStoreId
} else {
params.inputFields["productStoreId_op"] = "empty"
}

await JobService.fetchJobInformation(params).then((resp) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could assign resp to a variable directly and use, instead of using await and then both

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sir. Fixed it

if (resp.status === 200 && !hasError(resp) && resp.data.docs?.length > 0) {
const total = resp.data.count;
let jobs = resp.data.docs.map((job: any) => {
return {
...job,
'status': job?.statusId
}
})
if(payload.viewIndex && payload.viewIndex > 0){
jobs = state.miscellaneous.list.concat(resp.data.docs);
ymaheshwari1 marked this conversation as resolved.
Show resolved Hide resolved
}
commit(types.JOB_MISCELLANEOUS_UPDATED, { jobs, total });
const tempExprList = [] as any;
const enumIds = [] as any;
resp.data.docs.map((item: any) => {
enumIds.push(item.systemJobEnumId);
tempExprList.push(item.tempExprId);
})
const tempExpr = [...new Set(tempExprList)];
dispatch('fetchTemporalExpression', tempExpr);
dispatch('fetchJobDescription', enumIds);
} else {
commit(types.JOB_MISCELLANEOUS_UPDATED, { jobs: [], total: 0 });
}
}).catch((err) => {
commit(types.JOB_MISCELLANEOUS_UPDATED, { jobs: [], total: 0 });
console.error(err);
showToast(translate("Something went wrong"));
})
},
async fetchTemporalExpression({ state, commit }, tempExprIds){
const tempIds = [] as any;
const cachedTempExprId = Object.keys(state.temporalExp);
Expand Down
8 changes: 7 additions & 1 deletion src/store/modules/job/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ const getters: GetterTree <JobState, RootState> = {
},
getCurrentJob (state) {
return state.current;
}
},
getMiscellaneousJobs (state){
return state.miscellaneous.list;
},
isMiscellaneousJobsScrollable: (state) => {
return state.miscellaneous.list?.length > 0 && state.miscellaneous.list?.length < state.miscellaneous.total
},
}

export default getters;
4 changes: 4 additions & 0 deletions src/store/modules/job/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const jobModule: Module<JobState, RootState> = {
list: [],
total: 0
},
miscellaneous: {
list: [],
total: 0
},
temporalExp: [],
enumIds: {},
current: {},
Expand Down
3 changes: 2 additions & 1 deletion src/store/modules/job/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export const JOB_TEMPORAL_EXPRESSION_UPDATED = SN_JOB + '/TEMPORAL_EXPRESSION_UP
export const JOB_DESCRIPTION_UPDATED = SN_JOB + '/DESCRIPTION_UPDATED'
export const JOB_HISTORY_UPDATED = SN_JOB + '/HISTORY_UPDATED'
export const JOB_RUNNING_UPDATED = SN_JOB + '/RUNNING_UPDATED'
export const JOB_CURRENT_UPDATED = SN_JOB + '/CURRENT_UPDATED'
export const JOB_CURRENT_UPDATED = SN_JOB + '/CURRENT_UPDATED'
export const JOB_MISCELLANEOUS_UPDATED = SN_JOB + '/MISCELLANEOUS_UPDATED'
4 changes: 4 additions & 0 deletions src/store/modules/job/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const mutations: MutationTree <JobState> = {
},
[types.JOB_CURRENT_UPDATED] (state, payload){
state.current = payload
},
[types.JOB_MISCELLANEOUS_UPDATED] (state, payload){
state.miscellaneous.list = payload.jobs;
state.miscellaneous.total = payload.total;
}
}
export default mutations;
148 changes: 148 additions & 0 deletions src/views/Miscellaneous.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<template>
<ion-page>
<ion-header :translucent="true">
<ion-toolbar>
<ion-menu-button slot="start" />
<ion-title>{{ $t("Miscellaneous") }}</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<main>
<section>
<ion-list>
<ion-list-header>{{ $t("Miscellaneous jobs") }}</ion-list-header>
<ion-item v-for="job in miscellaneousJobs" :key="job.jobId" @click="viewJobConfiguration(job)">
<ion-label>{{ job.jobName }}</ion-label>
<ion-badge v-if="job.runTime" color="light">{{ timeFromNow(job.runTime)}}</ion-badge>
dt2patel marked this conversation as resolved.
Show resolved Hide resolved
<ion-icon slot="end" :icon="chevronForwardOutline" />
dt2patel marked this conversation as resolved.
Show resolved Hide resolved
</ion-item>
</ion-list>

<ion-infinite-scroll @ionInfinite="loadMoreMiscellaneousJobs($event)" threshold="100px" :disabled="!isMiscellaneousJobsScrollable">
<ion-infinite-scroll-content loading-spinner="crescent" :loading-text="$t('Loading')"/>
</ion-infinite-scroll>
</section>

<aside class="desktop-only" v-if="isDesktop" v-show="currentJob && Object.keys(currentJob).length">
<JobConfiguration :title="title" :status="currentJobStatus" :key="currentJob"/>
</aside>
</main>
</ion-content>
</ion-page>
</template>

<script lang="ts">
import { DateTime } from 'luxon';
import {
IonBadge,
IonContent,
IonHeader,
IonIcon,
IonInfiniteScroll,
IonInfiniteScrollContent,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonMenuButton,
IonPage,
IonTitle,
IonToolbar,
isPlatform,
} from '@ionic/vue';
import { defineComponent } from 'vue';
import { useRouter } from 'vue-router'
import { mapGetters, useStore } from 'vuex'
import emitter from '@/event-bus';
import JobConfiguration from '@/components/JobConfiguration.vue';
import { chevronForwardOutline } from "ionicons/icons";

export default defineComponent({
name: 'Miscellaneous',
components: {
IonBadge,
IonContent,
IonHeader,
IonIcon,
IonInfiniteScroll,
IonInfiniteScrollContent,
IonItem,
IonLabel,
IonList,
IonListHeader,
IonMenuButton,
IonPage,
IonTitle,
IonToolbar,
JobConfiguration
},
mounted() {
this.getMiscellaneousJobs();
},
data() {
return {
title: '',
currentJobStatus: '',
isJobDetailAnimationCompleted: false,
isDesktop: isPlatform('desktop')
}
},
computed: {
...mapGetters({
miscellaneousJobs: 'job/getMiscellaneousJobs',
getCurrentEComStore:'user/getCurrentEComStore',
currentJob: 'job/getCurrentJob',
isMiscellaneousJobsScrollable: 'job/isMiscellaneousJobsScrollable'
})
},
methods: {
async viewJobConfiguration(job: any) {
this.title = job.jobName
this.currentJobStatus = job.tempExprId

await this.store.dispatch('job/updateCurrentJob', { job });
if(!this.isDesktop && job?.jobId) {
this.router.push({name: 'JobDetails', params: { title: this.title, jobId: job?.jobId, category: "miscellaneous"}});
return;
}

if (job && !this.isJobDetailAnimationCompleted) {
emitter.emit('playAnimation');
this.isJobDetailAnimationCompleted = true;
}
},
async getMiscellaneousJobs(viewSize = process.env.VUE_APP_VIEW_SIZE, viewIndex = '0') {
await this.store.dispatch('job/fetchMiscellaneousJobs', {eComStoreId: this.getCurrentEComStore.productStoreId, viewSize, viewIndex});
},
async loadMoreMiscellaneousJobs (event: any) {
this.getMiscellaneousJobs(
undefined,
Math.ceil(this.miscellaneousJobs.length / (process.env.VUE_APP_VIEW_SIZE as any)).toString()
).then(() => {
event.target.complete();
})
},
timeFromNow (time: any) {
const timeDiff = DateTime.fromMillis(time).diff(DateTime.local());
return DateTime.local().plus(timeDiff).toRelative();
},
},
setup() {
const store = useStore();
const router = useRouter();

return {
chevronForwardOutline,
router,
store,
};
},
})
</script>

<style scoped>
main > section {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation.

Also is this css not global? I don't think we need to re-add this for this page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually sir, that global css was getting applied but was not visible, then I discussed with Azkya ma'am and decided to override it with local css.
Fixed indetation.

width: 423px;
}
</style>