From b7f7d68eed6d07d35ef2f8f126dc9a7f1624d085 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Tue, 25 Feb 2020 20:23:27 -0500 Subject: [PATCH] move mitm controls to devices page --- src/_helpers/util.js | 4 +- src/_store/accountPlans.module.js | 2 +- src/_store/apps.module.js | 4 +- src/_store/bills.module.js | 2 +- src/_store/devices.module.js | 2 +- src/_store/domains.module.js | 2 +- src/_store/footprints.module.js | 2 +- src/_store/networks.module.js | 2 +- src/_store/paymentMethods.module.js | 2 +- src/_store/plans.module.js | 2 +- src/_store/users.module.js | 2 +- src/account/AppsPage.vue | 49 ++-------------------- src/account/DevicesPage.vue | 63 ++++++++++++++++++++++++----- 13 files changed, 73 insertions(+), 65 deletions(-) diff --git a/src/_helpers/util.js b/src/_helpers/util.js index 9d7ae8d..1111aad 100644 --- a/src/_helpers/util.js +++ b/src/_helpers/util.js @@ -187,15 +187,17 @@ export const util = { } }, - checkLoading: function(loadingObject) { + checkLoading: function(loadingObject, store) { return function() { for (const key in loadingObject) { if (loadingObject.hasOwnProperty(key)) { if (loadingObject[key] === true) { + // console.log('checkLoading('+store+'): returning true because key='+key+' was true'); return true; } } } + // console.log('checkLoading('+store+'): returning false'); return false; }; }, diff --git a/src/_store/accountPlans.module.js b/src/_store/accountPlans.module.js index 857e77d..1fe4087 100644 --- a/src/_store/accountPlans.module.js +++ b/src/_store/accountPlans.module.js @@ -81,7 +81,7 @@ const mutations = { }; const getters = { - loading: util.checkLoading(state.loading) + loading: util.checkLoading(state.loading, 'accountPlans') }; export const accountPlans = { diff --git a/src/_store/apps.module.js b/src/_store/apps.module.js index ff5ff0b..b8ab467 100644 --- a/src/_store/apps.module.js +++ b/src/_store/apps.module.js @@ -212,10 +212,12 @@ const mutations = { state.loading.getMitmStatus = true; }, getMitmStatusSuccess(state, enabled) { + console.log('getMitmStatusSuccess: enabled='+enabled); state.loading.getMitmStatus = false; state.mitmEnabled = enabled; }, getMitmStatusFailure(state, error) { + console.log('getMitmStatusFailure: error='+error); state.loading.getMitmStatus = false; state.error = error; }, @@ -424,7 +426,7 @@ const mutations = { }; const getters = { - loading: util.checkLoading(state.loading) + loading: util.checkLoading(state.loading, 'apps') }; export const apps = { diff --git a/src/_store/bills.module.js b/src/_store/bills.module.js index 2996d6c..4b160fc 100644 --- a/src/_store/bills.module.js +++ b/src/_store/bills.module.js @@ -55,7 +55,7 @@ const mutations = { }; const getters = { - loading: util.checkLoading(state.loading) + loading: util.checkLoading(state.loading, 'bills') }; export const bills = { diff --git a/src/_store/devices.module.js b/src/_store/devices.module.js index 5ee15a8..d79038a 100644 --- a/src/_store/devices.module.js +++ b/src/_store/devices.module.js @@ -135,7 +135,7 @@ const mutations = { }; const getters = { - loading: util.checkLoading(state.loading) + loading: util.checkLoading(state.loading, 'devices') }; export const devices = { diff --git a/src/_store/domains.module.js b/src/_store/domains.module.js index 7e7c59a..18a456f 100644 --- a/src/_store/domains.module.js +++ b/src/_store/domains.module.js @@ -56,7 +56,7 @@ const mutations = { }; const getters = { - loading: util.checkLoading(state.loading) + loading: util.checkLoading(state.loading, 'domains') }; export const domains = { diff --git a/src/_store/footprints.module.js b/src/_store/footprints.module.js index e3e35b7..b858af3 100644 --- a/src/_store/footprints.module.js +++ b/src/_store/footprints.module.js @@ -54,7 +54,7 @@ const mutations = { }; const getters = { - loading: util.checkLoading(state.loading) + loading: util.checkLoading(state.loading, 'footprints') }; export const footprints = { diff --git a/src/_store/networks.module.js b/src/_store/networks.module.js index f186104..3fc4026 100644 --- a/src/_store/networks.module.js +++ b/src/_store/networks.module.js @@ -263,7 +263,7 @@ const mutations = { }; const getters = { - loading: util.checkLoading(state.loading) + loading: util.checkLoading(state.loading, 'networks') }; export const networks = { diff --git a/src/_store/paymentMethods.module.js b/src/_store/paymentMethods.module.js index 8a66839..ed2e118 100644 --- a/src/_store/paymentMethods.module.js +++ b/src/_store/paymentMethods.module.js @@ -217,7 +217,7 @@ const mutations = { }; const getters = { - loading: util.checkLoading(state.loading) + loading: util.checkLoading(state.loading, 'paymentMethods') }; export const paymentMethods = { diff --git a/src/_store/plans.module.js b/src/_store/plans.module.js index 5433968..b5501b0 100644 --- a/src/_store/plans.module.js +++ b/src/_store/plans.module.js @@ -54,7 +54,7 @@ const mutations = { }; const getters = { - loading: util.checkLoading(state.loading) + loading: util.checkLoading(state.loading, 'plans') }; export const plans = { diff --git a/src/_store/users.module.js b/src/_store/users.module.js index 07d0308..1082029 100644 --- a/src/_store/users.module.js +++ b/src/_store/users.module.js @@ -375,7 +375,7 @@ const mutations = { }; const getters = { - loading: util.checkLoading(state.loading) + loading: util.checkLoading(state.loading, 'users') }; export const users = { diff --git a/src/account/AppsPage.vue b/src/account/AppsPage.vue index 8621bd4..f657bb7 100644 --- a/src/account/AppsPage.vue +++ b/src/account/AppsPage.vue @@ -1,29 +1,11 @@ @@ -83,18 +98,27 @@ export default { data () { return { + user: util.currentUser(), userId: util.currentUser().uuid, submitted: false, deviceName: null, displayVpnConfig: {}, - config: config + config: config, + mitmLoading: true }; }, computed: { + ...mapState('apps', ['mitmEnabled']), ...mapState('devices', ['devices', 'device', 'qrCodeImageBase64', 'vpnConfBase64']), - ...mapState('system', ['messages']) + ...mapState('system', ['messages']), + ...mapGetters('devices', ['loading']) }, created () { + this.getMitmStatus({ + userId: this.userId, + messages: this.messages, + errors: this.errors + }); this.getDevicesByUserId({ userId: this.userId, messages: this.messages, @@ -102,11 +126,11 @@ }); }, methods: { + ...mapActions('apps', ['getMitmStatus', 'enableMitm', 'disableMitm']), ...mapActions('devices', [ 'getDevicesByUserId', 'addDeviceByUserId', 'removeDeviceByUserId', 'getDeviceQRcodeById', 'getDeviceVPNconfById' ]), - ...mapGetters('devices', ['loading']), addDevice () { this.errors.clear(); this.submitted = true; @@ -156,6 +180,24 @@ document.body.appendChild(link); link.click(); document.body.removeChild(link); + }, + mitmOn () { + this.mitmLoading = true; + this.errors.clear(); + this.enableMitm({ + userId: this.user.uuid, + messages: this.messages, + errors: this.errors + }); + }, + mitmOff () { + this.mitmLoading = true; + this.errors.clear(); + this.disableMitm({ + userId: this.user.uuid, + messages: this.messages, + errors: this.errors + }); } }, watch: { @@ -164,6 +206,9 @@ // after device added, clear device name field this.deviceName = null; } + }, + mitmEnabled (m) { + this.mitmLoading = false; } } };