diff --git a/.env.example b/.env.example index bc61b843..c708e5a2 100644 --- a/.env.example +++ b/.env.example @@ -8,4 +8,6 @@ VUE_APP_ALIAS={} VUE_APP_DEFAULT_LOG_LEVEL="error" VUE_APP_MAPPING_TYPES={"PO": "PO_MAPPING_PREF","RSTINV": "INV_MAPPING_PREF"} VUE_APP_MAPPING_PO={"orderId": { "label": "Order ID", "required": true }, "productSku": { "label": "Shopify product SKU", "required": true },"orderDate": { "label": "Arrival date", "required": true }, "quantity": { "label": "Ordered quantity", "required": true }, "facility": { "label": "Facility ID", "required": true }} -VUE_APP_MAPPING_RSTINV={"productSku": { "label": "Product SKU", "required": true }, "quantity": { "label": "Quantity", "required": true }, "facility": { "label": "Facility ID", "required": true }, "locationSeqId": { "label": "Facility Location", "required": true }} \ No newline at end of file +VUE_APP_MAPPING_RSTINV={"productSku": { "label": "Product SKU", "required": true }, "quantity": { "label": "Quantity", "required": true }, "facility": { "label": "Facility ID", "required": true }, "locationSeqId": { "label": "Facility Location", "required": true }} +VUE_APP_DEFAULT_LOG_LEVEL="error" +VUE_APP_LOGIN_URL="http://launchpad.hotwax.io/login" \ No newline at end of file diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml index 1704e086..6cf9fc9e 100644 --- a/.github/workflows/firebase-hosting-merge.yml +++ b/.github/workflows/firebase-hosting-merge.yml @@ -7,26 +7,10 @@ name: Deploy to Firebase Hosting on merge branches: - main jobs: - build_and_deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Install Dependencies - run: npm install - - name: Generate .env file - run: cp .env.example .env - - name: Build - run: npm run build - - name: Install Firebase - run: npm install -g firebase-tools - - name: Set Firebase project - run: firebase use default --token "$HOTWAX_PUBLIC_SECRET" - env: - HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} - - name: Deploy - run: firebase deploy --token "$HOTWAX_PUBLIC_SECRET" -m "Deploying via GitHub actions" --only hosting:dev - env: - HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} + call-workflow-in-another-repo: + uses: hotwax/dxp-components/.github/workflows/common-firebase-hosting-merge.yml@main + with: + config-path: .github/labeler.yml + secrets: + envPAT: ${{ secrets.envPAT }} + HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} \ No newline at end of file diff --git a/.github/workflows/firebase-hosting-release.yml b/.github/workflows/firebase-hosting-release.yml index 44ba5fe5..95f9c36e 100644 --- a/.github/workflows/firebase-hosting-release.yml +++ b/.github/workflows/firebase-hosting-release.yml @@ -1,32 +1,16 @@ +# This file was auto-generated by the Firebase CLI +# https://github.com/firebase/firebase-tools + name: Deploy to Firebase Hosting on release 'on': push: tags: - '*' # Push events to every tag not containing / Refer https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#patterns-to-match-branches-and-tags jobs: - build_and_deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Checkout to latest release tag - run: | - git checkout $(git describe --tags `git rev-list --tags --max-count=1`) - - name: Install Dependencies - run: npm install - - name: Generate .env file - run: cp .env.example .env - - name: Build - run: npm run build - - name: Install Firebase - run: npm install -g firebase-tools - - name: Set Firebase project - run: firebase use default --token "$HOTWAX_PUBLIC_SECRET" - env: - HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} - - name: Deploy - run: firebase deploy --token "$HOTWAX_PUBLIC_SECRET" -m "Deploying via GitHub actions" --only hosting:uat - env: - HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} + call-workflow-in-another-repo: + uses: hotwax/dxp-components/.github/workflows/common-firebase-hosting-release.yml@main + with: + config-path: .github/labeler.yml + secrets: + envPAT: ${{ secrets.envPAT }} + HOTWAX_PUBLIC_SECRET: ${{ secrets.HOTWAX_PUBLIC_SECRET }} \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e6bacfd9..0dc36964 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -2,32 +2,15 @@ name: Verify build on: push: - branches: [ main ] + branches: [main] pull_request: # The branches below must be a subset of the branches above - branches: [ main ] - + branches: [main] -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [12.x, 14.x, 16.x] - - steps: - - uses: actions/checkout@v2 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - - - name: Install Dependencies - run: npm install - - name: Generate .env file - run: cp .env.example .env - - name: Build - run: npm run build \ No newline at end of file +jobs: + call-workflow-in-another-repo: + uses: hotwax/dxp-components/.github/workflows/common-pull-request.yml@main + with: + config-path: .github/labeler.yml + secrets: + envPAT: ${{ secrets.envPAT }} diff --git a/package-lock.json b/package-lock.json index bd717c46..43783617 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "import", - "version": "2.9.0", + "version": "2.10.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "import", - "version": "2.9.0", + "version": "2.10.0", "dependencies": { "@capacitor/android": "^2.4.7", "@capacitor/core": "^2.4.7", "@hotwax/app-version-info": "^1.0.0", "@hotwax/apps-theme": "^1.1.0", - "@hotwax/dxp-components": "^1.1.1", + "@hotwax/dxp-components": "^1.3.4", "@hotwax/oms-api": "^1.6.0", "@ionic/core": "6.7.5", "@ionic/vue": "6.7.5", @@ -60,29 +60,6 @@ "vue-cli-plugin-i18n": "^1.0.1" } }, - "../../dxp-components": { - "version": "0.0.1", - "extraneous": true, - "license": "Apache-2.0", - "dependencies": { - "@hotwax/oms-api": "^1.8.1", - "pinia": "2.0.36", - "vue": "^3.3.4" - }, - "devDependencies": { - "@babel/cli": "^7.21.5", - "@babel/core": "^7.22.1", - "@babel/plugin-syntax-jsx": "^7.22.5", - "@babel/preset-env": "^7.22.4", - "@babel/preset-typescript": "^7.21.5", - "@vue/babel-plugin-jsx": "^1.1.1", - "@vue/babel-plugin-transform-vue-jsx": "^1.4.0", - "babel-plugin-module-resolver": "^4.1.0", - "babel-preset-vue": "^2.0.2", - "eslint": "^8.16.0", - "typescript": "^5.0.4" - } - }, "node_modules/@achrinza/node-ipc": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/@achrinza/node-ipc/-/node-ipc-9.2.2.tgz", @@ -2203,12 +2180,14 @@ "integrity": "sha512-yokhlpG+eUEao19vaUtCOC5YwcYTb5sf5joGVH17mbb5B1hM4G+P4ZiGiFw2AMmZBKgu94DtHwSyjtdsf4bHug==" }, "node_modules/@hotwax/dxp-components": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.1.1.tgz", - "integrity": "sha512-R98c9NqMH0njlUZJNMWZB2Imy9Vw48c3RutuCsNL9xWG28fdVKJ3dQ9nPAs5HrudJP265uKoDFeeGa6aMq3x5Q==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.3.4.tgz", + "integrity": "sha512-uw0dmxm19lzsgcLWZ2fQBAZem0d7TkxGR0iSq1c7Bj1mkAJZXH5JbP12w0lYhtes7Q1MjhHPlWljCh6624E9XA==", "dependencies": { "@hotwax/oms-api": "^1.8.1", + "luxon": "^3.3.0", "pinia": "2.0.36", + "pinia-plugin-persistedstate": "^3.1.0", "vue": "^3.3.4" } }, @@ -23757,17 +23736,17 @@ } }, "node_modules/luxon": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.2.1.tgz", - "integrity": "sha512-QrwPArQCNLAKGO/C+ZIilgIuDnEnKx5QYODdDtbFaxzsbZcc/a7WFq7MhsVYgRlwawLtvOUESTlfJ+hc/USqPg==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.3.0.tgz", + "integrity": "sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==", "engines": { "node": ">=12" } }, "node_modules/magic-string": { - "version": "0.30.1", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.1.tgz", - "integrity": "sha512-mbVKXPmS0z0G4XqFDCTllmDQ6coZzn94aMlb0o/A4HEHJCKcanlDZwYJgwnkmgD3jyWhUgj9VsPrfd972yPffA==", + "version": "0.30.2", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.2.tgz", + "integrity": "sha512-lNZdu7pewtq/ZvWUp9Wpf/x7WzMTsR26TWV03BRZrXFsv+BI6dy8RAiKgm1uM/kyR0rCfUcqvOlXKG66KhIGug==", "dependencies": { "@jridgewell/sourcemap-codec": "^1.4.15" }, @@ -25470,6 +25449,14 @@ } } }, + "node_modules/pinia-plugin-persistedstate": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.0.tgz", + "integrity": "sha512-tZbNGf2vjAQcIm7alK40sE51Qu/m9oWr+rEgNm/2AWr1huFxj72CjvpQcIQzMknDBJEkQznCLAGtJTIcLKrKdw==", + "peerDependencies": { + "pinia": "^2.0.0" + } + }, "node_modules/pinia/node_modules/vue-demi": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.5.tgz", @@ -34826,12 +34813,14 @@ "integrity": "sha512-yokhlpG+eUEao19vaUtCOC5YwcYTb5sf5joGVH17mbb5B1hM4G+P4ZiGiFw2AMmZBKgu94DtHwSyjtdsf4bHug==" }, "@hotwax/dxp-components": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.1.1.tgz", - "integrity": "sha512-R98c9NqMH0njlUZJNMWZB2Imy9Vw48c3RutuCsNL9xWG28fdVKJ3dQ9nPAs5HrudJP265uKoDFeeGa6aMq3x5Q==", + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/@hotwax/dxp-components/-/dxp-components-1.3.4.tgz", + "integrity": "sha512-uw0dmxm19lzsgcLWZ2fQBAZem0d7TkxGR0iSq1c7Bj1mkAJZXH5JbP12w0lYhtes7Q1MjhHPlWljCh6624E9XA==", "requires": { "@hotwax/oms-api": "^1.8.1", + "luxon": "^3.3.0", "pinia": "2.0.36", + "pinia-plugin-persistedstate": "^3.1.0", "vue": "^3.3.4" } }, @@ -51839,14 +51828,14 @@ } }, "luxon": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.2.1.tgz", - "integrity": "sha512-QrwPArQCNLAKGO/C+ZIilgIuDnEnKx5QYODdDtbFaxzsbZcc/a7WFq7MhsVYgRlwawLtvOUESTlfJ+hc/USqPg==" + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.3.0.tgz", + "integrity": "sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==" }, "magic-string": { - "version": "0.30.1", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.1.tgz", - "integrity": "sha512-mbVKXPmS0z0G4XqFDCTllmDQ6coZzn94aMlb0o/A4HEHJCKcanlDZwYJgwnkmgD3jyWhUgj9VsPrfd972yPffA==", + "version": "0.30.2", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.2.tgz", + "integrity": "sha512-lNZdu7pewtq/ZvWUp9Wpf/x7WzMTsR26TWV03BRZrXFsv+BI6dy8RAiKgm1uM/kyR0rCfUcqvOlXKG66KhIGug==", "requires": { "@jridgewell/sourcemap-codec": "^1.4.15" }, @@ -53217,6 +53206,12 @@ } } }, + "pinia-plugin-persistedstate": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.0.tgz", + "integrity": "sha512-tZbNGf2vjAQcIm7alK40sE51Qu/m9oWr+rEgNm/2AWr1huFxj72CjvpQcIQzMknDBJEkQznCLAGtJTIcLKrKdw==", + "requires": {} + }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", diff --git a/package.json b/package.json index 3451de5e..9baf702c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "import", - "version": "2.9.0", + "version": "2.10.0", "private": true, "description": "Import App", "scripts": { @@ -16,7 +16,7 @@ "@capacitor/core": "^2.4.7", "@hotwax/app-version-info": "^1.0.0", "@hotwax/apps-theme": "^1.1.0", - "@hotwax/dxp-components": "^1.1.1", + "@hotwax/dxp-components": "^1.3.4", "@hotwax/oms-api": "^1.6.0", "@ionic/core": "6.7.5", "@ionic/vue": "6.7.5", diff --git a/src/App.vue b/src/App.vue index 8c41aeb6..c9732936 100644 --- a/src/App.vue +++ b/src/App.vue @@ -82,7 +82,8 @@ export default defineComponent({ }, async unauthorized() { this.store.dispatch("user/logout"); - this.router.push("/login") + const redirectUrl = window.location.origin + '/login'; + window.location.href = `${process.env.VUE_APP_LOGIN_URL}?redirectUrl=${redirectUrl}`; } }, async mounted() { @@ -103,7 +104,7 @@ export default defineComponent({ cacheMaxAge: this.maxAge, events: { unauthorised: this.unauthorized, - responseErrror: () => { + responseError: () => { setTimeout(() => this.dismissLoader(), 100); }, queueTask: (payload: any) => { @@ -139,4 +140,4 @@ export default defineComponent({ } }, }); - \ No newline at end of file + diff --git a/src/locales/en.json b/src/locales/en.json index 90e0e9a9..a7200c71 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -8,6 +8,7 @@ "Are you sure you want to delete this CSV mapping? This action cannot be undone.": "Are you sure you want to delete this CSV mapping? This action cannot be undone.", "Are you sure you want to update this CSV mapping? This action cannot be undone.": "Are you sure you want to update this CSV mapping? This action cannot be undone.", "Arrival date": "Arrival date", + "Authenticating": "Authenticating", "Backorder": "Backorder", "Blank": "Blank", "Buffer days": "Buffer days", @@ -52,6 +53,7 @@ "Changes to the CSV mapping has been saved.": "Changes to the CSV mapping has been saved.", "File upload": "File upload", "File uploaded successfully": "File uploaded successfully", + "Go to Launchpad": "Go to Launchpad", "Go to OMS": "Go to OMS", "here": "here", "items": "items", @@ -68,6 +70,7 @@ "line items": "line items", "Loading": "Loading", "Login": "Login", + "Logging in": "Logging in", "Logout": "Logout", "Mapping": "Mapping", "Mapping details": "Mapping details", diff --git a/src/main.ts b/src/main.ts index 0307ccf4..2dc5d03c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -30,7 +30,8 @@ import store from './store' import { DateTime } from 'luxon'; import logger from './logger'; -import { dxpComponents } from '@hotwax/dxp-components'; +import { dxpComponents } from '@hotwax/dxp-components' +import { login, logout, loader } from './user-utils'; const app = createApp(App) .use(IonicVue, { @@ -43,7 +44,11 @@ const app = createApp(App) .use(i18n) .use(store) .use(dxpComponents, { - defaultImgUrl: require("@/assets/images/defaultImage.png") + defaultImgUrl: require("@/assets/images/defaultImage.png"), + login, + logout, + loader, + appLoginUrl: process.env.VUE_APP_LOGIN_URL as string }); // Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters diff --git a/src/router/index.ts b/src/router/index.ts index 0df67b7b..89b48093 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -4,26 +4,31 @@ import PurchaseOrder from '@/views/PurchaseOrder.vue' import Inventory from '@/views/Inventory.vue' import InventoryReview from '@/views/InventoryReview.vue' import PurchaseOrderReview from '@/views/PurchaseOrderReview.vue'; -import Login from '@/views/Login.vue' import SavedMappings from '@/views/SavedMappings.vue' import Settings from "@/views/Settings.vue" import store from '@/store' import MappingDetail from '@/views/MappingDetail.vue' +import { Login, useAuthStore } from '@hotwax/dxp-components'; +import { loader } from '@/user-utils'; -const authGuard = (to: any, from: any, next: any) => { - if (store.getters['user/isAuthenticated']) { - next() - } else { - next("/login") +const authGuard = async (to: any, from: any, next: any) => { + const authStore = useAuthStore() + if (!authStore.isAuthenticated || !store.getters['user/isAuthenticated']) { + await loader.present('Authenticating') + // TODO use authenticate() when support is there + const redirectUrl = window.location.origin + '/login' + window.location.href = `${process.env.VUE_APP_LOGIN_URL}?redirectUrl=${redirectUrl}` + loader.dismiss() } + next() }; const loginGuard = (to: any, from: any, next: any) => { - if (!store.getters['user/isAuthenticated']) { - next() - } else { - next("/") + const authStore = useAuthStore() + if (authStore.isAuthenticated && !to.query?.token && !to.query?.oms) { + next('/') } + next(); }; const routes: Array = [ diff --git a/src/store/modules/user/actions.ts b/src/store/modules/user/actions.ts index 0e9d6d46..5303eac4 100644 --- a/src/store/modules/user/actions.ts +++ b/src/store/modules/user/actions.ts @@ -7,61 +7,48 @@ import { hasError, showToast } from '@/utils' import { translate } from '@/i18n' import { updateInstanceUrl, updateToken, resetConfig } from '@/adapter' import logger from "@/logger"; +import { useAuthStore } from '@hotwax/dxp-components'; const actions: ActionTree = { /** * Login user and return token */ - async login ({ commit, dispatch }, { username, password }) { + async login ({ commit, dispatch }, payload) { try { - const resp = await UserService.login(username, password) - if (resp.status === 200 && resp.data) { - if (resp.data.token) { - const permissionId = process.env.VUE_APP_PERMISSION_ID; - if (permissionId) { - const checkPermissionResponse = await UserService.checkPermission({ - data: { - permissionId - }, - headers: { - Authorization: 'Bearer ' + resp.data.token, - 'Content-Type': 'application/json' - } - }); - - if (checkPermissionResponse.status === 200 && !hasError(checkPermissionResponse) && checkPermissionResponse.data && checkPermissionResponse.data.hasPermission) { - commit(types.USER_TOKEN_CHANGED, { newToken: resp.data.token }) - updateToken(resp.data.token) - dispatch('getProfile') - dispatch('setPreferredDateTimeFormat', process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy'); - if (resp.data._EVENT_MESSAGE_ && resp.data._EVENT_MESSAGE_.startsWith("Alert:")) { - // TODO Internationalise text - showToast(translate(resp.data._EVENT_MESSAGE_)); - } - return resp.data; - } else { - const permissionError = 'You do not have permission to access the app.'; - showToast(translate(permissionError)); - logger.error("error", permissionError); - return Promise.reject(new Error(permissionError)); + const { token, oms } = payload; + dispatch("setUserInstanceUrl", oms); + + if (token) { + const permissionId = process.env.VUE_APP_PERMISSION_ID; + if (permissionId) { + const checkPermissionResponse = await UserService.checkPermission({ + data: { + permissionId + }, + headers: { + Authorization: 'Bearer ' + token, + 'Content-Type': 'application/json' } - } else { - commit(types.USER_TOKEN_CHANGED, { newToken: resp.data.token }) - updateToken(resp.data.token) - dispatch('getProfile') + }); + + if (checkPermissionResponse.status === 200 && !hasError(checkPermissionResponse) && checkPermissionResponse.data && checkPermissionResponse.data.hasPermission) { + commit(types.USER_TOKEN_CHANGED, { newToken: token }) + updateToken(token) + await dispatch('getProfile') dispatch('setPreferredDateTimeFormat', process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy'); - return resp.data; + } else { + const permissionError = 'You do not have permission to access the app.'; + showToast(translate(permissionError)); + logger.error("error", permissionError); + return Promise.reject(new Error(permissionError)); } - } else if (hasError(resp)) { - showToast(translate('Sorry, your username or password is incorrect. Please try again.')); - logger.error("error", resp.data._ERROR_MESSAGE_); - return Promise.reject(new Error(resp.data._ERROR_MESSAGE_)); + } else { + commit(types.USER_TOKEN_CHANGED, { newToken: token }) + updateToken(token) + await dispatch('getProfile') + dispatch('setPreferredDateTimeFormat', process.env.VUE_APP_DATE_FORMAT ? process.env.VUE_APP_DATE_FORMAT : 'MM/dd/yyyy'); } - } else { - showToast(translate('Something went wrong')); - logger.error("error", resp.data._ERROR_MESSAGE_); - return Promise.reject(new Error(resp.data._ERROR_MESSAGE_)); } } catch (err: any) { showToast(translate('Something went wrong')); @@ -75,6 +62,8 @@ const actions: ActionTree = { * Logout user */ async logout ({ commit }) { + const authStore = useAuthStore() + // TODO add any other tasks if need commit(types.USER_END_SESSION) resetConfig(); @@ -83,6 +72,9 @@ const actions: ActionTree = { // clearing field mappings and current mapping when the user logout commit(types.USER_FIELD_MAPPINGS_UPDATED, {}) commit(types.USER_CURRENT_FIELD_MAPPING_UPDATED, {id: '', mappingType: '', name: '', value: {}}) + + // reset plugin state on logout + authStore.$reset() }, /** diff --git a/src/user-utils/index.ts b/src/user-utils/index.ts new file mode 100644 index 00000000..faf98e48 --- /dev/null +++ b/src/user-utils/index.ts @@ -0,0 +1,34 @@ +import { translate } from '@/i18n' +import store from '@/store' +import { loadingController } from '@ionic/vue' + +const login = async (payload: any) => store.dispatch('user/login', payload); + +const logout = async () => store.dispatch('user/logout'); + +const loader = { + value: null as any, + present: async (message: string) => { + if (!loader.value) { + loader.value = await loadingController + .create({ + message: translate(message), + translucent: false, + backdropDismiss: false + }); + } + loader.value.present(); + }, + dismiss: () => { + if (loader.value) { + loader.value.dismiss(); + loader.value = null as any; + } + } +} + +export { + login, + loader, + logout +} \ No newline at end of file diff --git a/src/views/Login.vue b/src/views/Login.vue deleted file mode 100644 index 86f3fea9..00000000 --- a/src/views/Login.vue +++ /dev/null @@ -1,107 +0,0 @@ - - - - diff --git a/src/views/Settings.vue b/src/views/Settings.vue index a0abb7ba..66848c95 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -14,12 +14,19 @@ - + + {{ userProfile?.userLoginId }} {{ userProfile?.partyName }} - {{ $t("Logout") }} + {{ $t("Logout") }} + + {{ $t("Go to Launchpad") }} + + @@ -190,9 +197,13 @@ export default defineComponent({ }, logout () { this.store.dispatch('user/logout').then(() => { - this.router.push('/login'); + const redirectUrl = window.location.origin + '/login' + window.location.href = `${process.env.VUE_APP_LOGIN_URL}?isLoggedOut=true&redirectUrl=${redirectUrl}` }) }, + goToLaunchpad() { + window.location.href = `${process.env.VUE_APP_LOGIN_URL}` + }, getDateTime(time: any) { return DateTime.fromMillis(time).toLocaleString(DateTime.DATETIME_MED); },