Skip to content

Commit 4dba04b

Browse files
committed
Login services progress - vuex state holder
1 parent 2fdddc4 commit 4dba04b

File tree

6 files changed

+34
-8
lines changed

6 files changed

+34
-8
lines changed

scripts-definitions/base-module-example.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"base-module-example": {
3-
"version": "0.1.8",
3+
"version": "0.1.9",
44
"icon": "mdi-powershell",
55
"displayName": {
66
"default": "Base commands",
@@ -497,7 +497,7 @@
497497
{
498498
"name": "Test",
499499
"description": "Test PowerShell Module",
500-
"commandBlock": "Connect-AzAccount"
500+
"commandBlock": "Get-Location"
501501
}
502502
],
503503
"parameters": [

src/components/CommandDialog.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
<q-btn
4848
v-for="object in currentCommandMaster.login"
4949
:key="object.name"
50-
:label="$t(onlineCredentials.name ? 'loginDone' : 'loginRequired', { name: object.name })"
51-
:icon="onlineCredentials.name ? 'mdi-account-check' : 'mdi-login-variant'"
52-
:color="onlineCredentials.name ? 'green' : 'red'"
50+
:label="$t(loggedInServices[object.name] ? 'loginDone' : 'loginRequired', { name: object.name })"
51+
:icon="loggedInServices[object.name] ? 'mdi-account-check' : 'mdi-login-variant'"
52+
:color="loggedInServices[object.name] ? 'green' : 'red'"
5353
@click="showLoginCommand(object)"
5454
class="full-width q-my-sm"
5555
no-wrap
@@ -194,7 +194,6 @@ export default {
194194
},
195195
data () {
196196
return {
197-
onlineCredentials: {},
198197
returnParamsPaginate: 1, // In multiple selection workflows allows parameters for each selection
199198
paramType: { // Table translating PowerShell variable types to Quasar components names and options
200199
'String': ['q-input', 'text'],
@@ -208,7 +207,7 @@ export default {
208207
}
209208
},
210209
computed: {
211-
...mapGetters('lazystore', ['getCommandMaximized', 'getDenseInput']),
210+
...mapGetters('lazystore', ['getCommandMaximized', 'getDenseInput', 'getLoggedinServices']),
212211
commandDialogMaximized: {
213212
get () {
214213
return this.getCommandMaximized
@@ -220,6 +219,14 @@ export default {
220219
denseInput: function () {
221220
return this.getDenseInput
222221
},
222+
loggedInServices: {
223+
get () {
224+
return this.getLoggedinServices
225+
},
226+
set (val) {
227+
this.$store.dispatch('lazystore/setLoggedinServices', val)
228+
}
229+
},
223230
localValue: {
224231
get () {
225232
return this.value
@@ -254,6 +261,11 @@ export default {
254261
// Should open external window with login object
255262
this.$pwsh.shell.addCommand(object.commandBlock)
256263
this.$pwsh.shell.invoke().then(o => {
264+
// Set service as logged in
265+
// TODO: Move logic to vuex, actions, add clear on powershell restart and application restart
266+
let temp = {}
267+
temp[object.name] = true
268+
this.loggedInServices = Object.assign({}, this.loggedInServices, temp)
257269
console.log(`Login command for ${object.name} executed succesfully.`)
258270
this.$q.notify({
259271
timeout: 2000,

src/store/lazystore/actions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,8 @@ export async function setCredentialsSaved ({ commit }, saved) {
122122
export async function setDisplayProgress ({ commit }, showProgress) {
123123
commit('SET_DISPLAYPROGRESS', showProgress)
124124
}
125+
126+
// Commit mutation to set object of logged in services - Accessed in ScriptsPage.vue
127+
export async function setLoggedinServices ({ commit }, loggedInServices) {
128+
commit('SET_LOGGEDINSERVICES', loggedInServices)
129+
}

src/store/lazystore/getters.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ export function getDisplayProgress (state) {
8282
return state.display_progress
8383
}
8484

85+
export function getLoggedinServices (state) {
86+
return state.loggedin_services
87+
}
88+
8589
// Dynamically build array of scripts to display in ScriptsPage.vue page
8690
export function getScriptsArray (state) {
8791
try {

src/store/lazystore/mutations.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,7 @@ export const SET_CREDENTIALSSAVED = (state, value) => {
9191
export const SET_DISPLAYPROGRESS = (state, value) => {
9292
state.display_progress = value
9393
}
94+
95+
export const SET_LOGGEDINSERVICES = (state, value) => {
96+
state.loggedin_services = value
97+
}

src/store/lazystore/state.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default function () {
2222
dense_table: true, // Should tables be dense or not
2323
login_skipped: false, // Was login skipped or not
2424
credentials_saved: false, // Are Login credentials saved or not
25-
display_progress: false // Is progress dialog displayed or not
25+
display_progress: false, // Is progress dialog displayed or not
26+
loggedin_services: {} // Holds names of logged in services for current PowerShell session
2627
}
2728
}

0 commit comments

Comments
 (0)