Skip to content

Commit 3846dd0

Browse files
authored
Merge pull request #655 from reconness/agents-form-merge
October - Week 3
2 parents 8adaa53 + f9a29f8 commit 3846dd0

16 files changed

+602
-247
lines changed

package-lock.json

Lines changed: 181 additions & 139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
"@vue/cli-plugin-vuex": "4.5.19",
4040
"@vue/cli-service": "4.5.19",
4141
"@vue/compiler-sfc": "3.2.37",
42-
"@vue/eslint-config-standard": "6.1.0",
42+
"@vue/eslint-config-standard": "8.0.1",
4343
"babel-eslint": "10.1.0",
4444
"eslint": "7.32.0",
4545
"eslint-plugin-import": "2.26.0",
4646
"eslint-plugin-node": "11.1.0",
47-
"eslint-plugin-promise": "5.2.0",
47+
"eslint-plugin-promise": "6.1.1",
4848
"eslint-plugin-standard": "4.1.0",
4949
"eslint-plugin-vue": "8.7.1",
5050
"node-sass": "7.0.1",

src/App.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<li @mouseenter="showUserConfigurationMenu" @mouseleave="hideUserConfigurationMenu" class="nav-item dropdown">
5454
<div class="image nav-link cursor-pointer d-flex" data-toggle="dropdown">
5555
<div class="main-bar-user-data d-flex flex-column">
56-
<span class="loged-user-name font-size-16px">{{getLoggedUserDataFirstName}} {{getLoggedUserDataLastName}}</span>
56+
<span class="loged-user-name font-size-16px">{{getLoggedUserDataUserName}}</span>
5757
<span class="font-size-10px font-weight-light">{{getRoleById(getLoggedUserDataRoleId).longName}}</span>
5858
</div>
5959
<div>
@@ -251,6 +251,9 @@ export default {
251251
},
252252
showTopAndLeftBars () {
253253
return this.isUserAlreadyLogged && !this.isUserManagementPage && !(this.isLoginPage || this.isUserManagementPage)
254+
},
255+
isUserRealNameDefined () {
256+
return (this.getLoggedUserDataFirstName && this.getLoggedUserDataLastName)
254257
}
255258
},
256259
watch: {

src/components/Target/AgentExecution.vue

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ import { VAceEditor } from 'vue3-ace-editor'
7979
import MotionPlayOutlineIco from '@/components/Icons/MotionPlayOutlineIco.vue'
8080
import OverlayPanel from 'primevue/overlaypanel'
8181
import CircleProgress from 'vue3-circle-progress'
82-
import { mapMutations, mapState } from 'vuex'
82+
import { mapMutations, mapState, mapActions } from 'vuex'
8383
import { ProgressBarMixin } from '@/mixins/ProgressBarMixin'
84+
import { StatusMessageMixin } from '@/mixins/StatusMessageMixin'
8485
import jQuery from 'jquery'
8586
export default {
8687
name: 'AgentExecution ',
@@ -123,7 +124,7 @@ export default {
123124
minimized: false
124125
}
125126
},
126-
mixins: [ProgressBarMixin],
127+
mixins: [ProgressBarMixin, StatusMessageMixin],
127128
computed: {
128129
...mapState('target', ['agentStatus']),
129130
...mapState('pipelines', ['isAgentInfoOpenedForTerminal']),
@@ -158,8 +159,10 @@ export default {
158159
}
159160
},
160161
methods: {
161-
...mapMutations('target', ['setAgentStatus', 'updateStatusRootDomainAgent', 'updateStatusSubDomainAgent']),
162+
...mapMutations('target', ['setAgentStatus']),
163+
...mapMutations('agent', ['updateStatusRootDomainAgent', 'updateStatusSubDomainAgent']),
162164
...mapMutations('pipelines', ['setIsAgentInfoOpenedForTerminal']),
165+
...mapActions('agent', ['stopRunningAgentToServer']),
163166
toggle (event) {
164167
this.$refs.op.toggle(event)
165168
},
@@ -189,25 +192,53 @@ export default {
189192
},
190193
closeWindow () {
191194
if (this.$route.name !== 'PipelineRunView') {
192-
this.setAgentStatus({ status: this.$entityStatus.FINISHED, id: parseInt(-1) })
195+
this.setAgentStatus({ status: this.$entityStatus.FINISHED, id: '-1' })
193196
if (this.$route.name === 'RootDomainDetails') {
197+
this.stopRootDomainRunningAgent()
198+
} else {
199+
this.stopSubDomainRunningAgent()
200+
}
201+
this.stopClock()
202+
}
203+
},
204+
stopRootDomainRunningAgent () {
205+
this.stopRunningAgentToServer(
206+
{
207+
agent: this.nameAgent,
208+
target: this.$route.params.targetName,
209+
rootdomain: this.$route.params.rootdomainName
210+
}
211+
).then(response => {
212+
if (response.status) {
194213
this.updateStatusRootDomainAgent({
195214
status: this.$entityStatus.FINISHED,
196-
idTarget: this.$route.params.idTarget,
197-
idRoot: this.$route.params.id,
198215
idAgent: this.idAgent
199216
})
217+
this.updateOperationStatus(this.$entityStatus.SUCCESS, this.$message.successMessageForRootDomainInsertion)
200218
} else {
219+
this.updateOperationStatus(this.$entityStatus.FAILED, response.message)
220+
}
221+
})
222+
},
223+
stopSubDomainRunningAgent () {
224+
this.stopRunningAgentToServer(
225+
{
226+
agent: this.nameAgent,
227+
target: this.$route.params.targetName,
228+
rootdomain: this.$route.params.rootdomainName,
229+
subdomain: this.$route.params.subdomainName
230+
}
231+
).then(response => {
232+
if (response.status) {
201233
this.updateStatusSubDomainAgent({
202234
status: this.$entityStatus.FINISHED,
203-
idTarget: this.$route.params.idTarget,
204-
idRoot: this.$route.params.id,
205-
idAgent: this.idAgent,
206-
idSubDomain: this.$route.params.idsubdomain
235+
idAgent: this.idAgent
207236
})
237+
this.updateOperationStatus(this.$entityStatus.SUCCESS, this.$message.successMessageForRootDomainInsertion)
238+
} else {
239+
this.updateOperationStatus(this.$entityStatus.FAILED, response.message)
208240
}
209-
this.stopClock()
210-
}
241+
})
211242
}
212243
}
213244
}

src/components/Target/AgentListTable.vue

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h6 class="text-center mt-2">List of Agents</h6>
44
<div class="card card-style">
55
<div class="card-body">
6-
<div v-if="agentsList.length > 0" class="card card-table">
6+
<div v-if="rootDomainAgents.length > 0" class="card card-table">
77
<div class=" row mb-2" >
88
<div class="col-2 border-left-radius border-right text-light-white domain-names-list p-2" v-bind:style ="{'background':color}"> <p class="ml-2 m-0" v-on:click="orderByName()"> Name
99
<i class="material-icons right float-right" v-show="active_arrow_down">keyboard_arrow_down</i>
@@ -17,7 +17,7 @@
1717
<div class="col-2 p-2 border-right-radius text-light-white text-center domain-names-list" v-bind:style ="{'background':color}">
1818
Actions</div>
1919
</div>
20-
<div class="row mb-2" v-for="item of this.agentsList" :key="item.id">
20+
<div class="row mb-2" v-for="item of rootDomainAgents" :key="item.id">
2121
<div class="col-2 border-left-radius border">
2222
<p class="m-2"> {{item.name}}</p>
2323
</div>
@@ -31,9 +31,10 @@
3131
</div>
3232
<div class="col-2 border border-right-radius text-center">
3333
<button v-if="parseInt(item.status) === parseInt(this.$entityStatus.RUNNING)" type="button" @click="selectAgent" class="color-rgb-0-177-255 agent-border btn create-agent-buttons-main-action m-1 p-0" data-toggle="modal" data-target="#agentExecutionModalForm" :data-id="item.id" :data-name="item.name">Running...</button>
34-
<button v-else :disabled="isRunningAgent !== -1 && isRunningAgent !== parseInt(item.id)" @click="selectAgent" type="button" class="color-rgb-0-177-255 agent-border btn create-agent-buttons-main-action m-1 p-0" data-toggle="modal" data-target="#agentExecutionModalForm" :data-id="item.id" :data-name="item.name">Run</button>
34+
<button v-else :disabled="isRunningAgent !== -1 && isRunningAgent !== item.id" type="button" class="color-rgb-0-177-255 agent-border btn create-agent-buttons-main-action m-1 p-0" data-toggle="modal" data-target="#confirmation-before-run-an-agent" :data-id="item.id" :data-name="item.name">Run</button>
3535
</div>
3636
<AgentExecution :id-agent="this.selectedAgentId" :name-agent="selectedAgentName"/>
37+
<ConfirmationBeforeRunAnAgent @run-agent="runAgent" :dataId="item.id" :dataName="item.name"/>
3738
</div>
3839
</div>
3940
<div v-else>
@@ -45,12 +46,16 @@
4546
</div></div>
4647
</template>
4748
<script>
48-
import { mapGetters, mapState, mapMutations } from 'vuex'
49+
import { mapGetters, mapState, mapMutations, mapActions } from 'vuex'
4950
import AgentExecution from '@/components/Target/AgentExecution.vue'
51+
import ConfirmationBeforeRunAnAgent from '@/components/Target/ConfirmationBeforeRunAnAgent.vue'
52+
import { StatusMessageMixin } from '@/mixins/StatusMessageMixin'
53+
import jQuery from 'jquery'
5054
export default {
5155
name: 'AgentListTable',
5256
components: {
53-
AgentExecution
57+
AgentExecution,
58+
ConfirmationBeforeRunAnAgent
5459
},
5560
props: {
5661
color: String
@@ -65,25 +70,20 @@ export default {
6570
selectedAgentId: '-1'
6671
}
6772
},
73+
mixins: [StatusMessageMixin],
6874
computed: {
6975
...mapGetters('agent', ['getLastAgentRootDomain', 'getAgentsByType']),
7076
...mapGetters('target', ['listRootDomainsAgents', 'listCurrentRunningRootDomainsAgent']),
7177
...mapState('target', ['agentStatus']),
72-
...mapState('agent', ['agentListStore']),
73-
listAgents: function () {
74-
return this.listRootDomainsAgents({
75-
idTarget: this.$route.params.idTarget,
76-
idRoot: this.$route.params.id
77-
})
78-
},
78+
...mapState('agent', ['agentListStore', 'rootDomainAgents']),
7979
isRunningAgent: function () {
80-
return this.listCurrentRunningRootDomainsAgent({ idTarget: this.$route.params.idTarget, idRoot: this.$route.params.id, idAgent: this.selectedAgentId })
80+
return this.listCurrentRunningRootDomainsAgent({ idTarget: this.$route.params.targetName, idRoot: this.$route.params.rootdomainName, idAgent: this.selectedAgentId })
8181
},
8282
agentsList: function () {
8383
const rootDomainAgentsType = JSON.parse(JSON.stringify(this.getAgentsByType(this.$agentType.ROOTDOMAIN)))
8484
const rootDoaminsAgentsCurentView = this.listRootDomainsAgents({
85-
idTarget: this.$route.params.idTarget,
86-
idRoot: this.$route.params.id
85+
targetName: this.$route.params.targetName,
86+
rootDomainName: this.$route.params.rootdomainName
8787
})
8888
let searchedAgent = null
8989
rootDomainAgentsType.forEach(element => {
@@ -96,6 +96,10 @@ export default {
9696
}
9797
},
9898
methods: {
99+
...mapMutations('target', ['setAgentStatus', 'insertAgentIfNotExistInRootDomain']),
100+
...mapMutations('agent', ['updateStatusRootDomainAgent']),
101+
...mapMutations('notification', ['addNewNotification']),
102+
...mapActions('agent', ['runAgentToServer']),
99103
orderByName: function () {
100104
if (this.active_arrow_down === true) {
101105
return this.orderByNameDesc()
@@ -104,20 +108,18 @@ export default {
104108
}
105109
},
106110
selectAgent (e) {
107-
this.selectedAgentName = e.currentTarget.getAttribute('data-name')
108-
this.selectedAgentId = e.currentTarget.getAttribute('data-id')
111+
this.selectedAgentName = ''
112+
this.selectedAgentId = ''
113+
if (e.currentTarget) {
114+
this.selectedAgentName = e.currentTarget.getAttribute('data-name')
115+
this.selectedAgentId = e.currentTarget.getAttribute('data-id')
116+
} else {
117+
this.selectedAgentName = e.dataName
118+
this.selectedAgentId = e.dataId
119+
}
109120
this.addNewNotification('Running agent' + ' ' + this.selectedAgentName)
110-
this.insertAgentIfNotExistInRootDomain(
111-
{
112-
idTarget: this.$route.params.idTarget,
113-
idRoot: this.$route.params.id,
114-
agentData: this.agentListStore.find(item => item.id === this.selectedAgentId)
115-
}
116-
)
117121
this.updateStatusRootDomainAgent({
118122
status: this.$entityStatus.RUNNING,
119-
idTarget: this.$route.params.idTarget,
120-
idRoot: this.$route.params.id,
121123
idAgent: this.selectedAgentId
122124
})
123125
this.setAgentStatus({ status: this.$entityStatus.RUNNING, id: this.selectedAgentId })
@@ -156,8 +158,25 @@ export default {
156158
)
157159
}
158160
},
159-
...mapMutations('target', ['setAgentStatus', 'updateStatusRootDomainAgent', 'insertAgentIfNotExistInRootDomain']),
160-
...mapMutations('notification', ['addNewNotification'])
161+
runAgent (e) {
162+
jQuery('#agentExecutionModalForm').modal('show')
163+
this.runAgentToServer(
164+
{
165+
agent: e.dataName,
166+
target: this.$route.params.targetName,
167+
rootdomain: this.$route.params.rootdomainName,
168+
command: e.command,
169+
activateNotification: e.activateNotification
170+
}
171+
).then(response => {
172+
if (response.status) {
173+
this.selectAgent(e)
174+
this.updateOperationStatus(this.$entityStatus.SUCCESS, '')
175+
} else {
176+
this.updateOperationStatus(this.$entityStatus.FAILED, response.message)
177+
}
178+
})
179+
}
161180
}
162181
}
163182
</script>

src/components/Target/BasicModal.vue

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<template>
2+
<div class="col-12">
3+
<div class="modal fade" :id="modalId" data-backdrop="static" data-keyboard="false">
4+
<div class="modal-dialog modal-dialog-centered modal-md">
5+
<div class="modal-content">
6+
<div class="modal-header dialog-without-lines-header">
7+
<h4 class="modal-title"><b>{{ modalTitle }}</b></h4>
8+
</div>
9+
<div class="modal-body">
10+
<slot name="body-content"></slot>
11+
</div>
12+
<div class="modal-footer dialog-without-lines-footer">
13+
<slot name="footer-content"></slot>
14+
</div>
15+
</div><!-- /.modal-content -->
16+
</div><!-- /.modal-dialog -->
17+
</div><!-- /#debug-modal -->
18+
</div>
19+
</template>
20+
<script>
21+
export default {
22+
name: 'BasicModal',
23+
props: {
24+
modalTitle: String,
25+
modalId: String
26+
}
27+
}
28+
</script>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<template>
2+
<BasicModal modalId="confirmation-before-run-an-agent" modalTitle="Confirm Command">
3+
<template #body-content>
4+
<input v-model="command" class="mb-4 form-control agent-placeholder form-input-without-lines" placeholder="Command">
5+
<div class="custom-control custom-checkbox form-check">
6+
<input class="form-check-input custom-control-input" type="checkbox" id="agent_customCheckbox6" v-model="activateNotification">
7+
<label class="form-check-label custom-control-label agent-regular-font black-text agent-disable-weigth" for="agent_customCheckbox6">Activate Notification</label>
8+
</div>
9+
</template>
10+
<template #footer-content>
11+
<button type="button" @click="executeAgent" class="agent-border btn create-agent-buttons-main-action btn-block btn-danger delete_btn">Run</button>
12+
<button type="button" @click="resetData" data-dismiss="modal" class="blue-text agent-border btn create-agent-buttons-main-action">Cancel</button>
13+
</template>
14+
</BasicModal>
15+
</template>
16+
<script>
17+
import BasicModal from '@/components/Target/BasicModal.vue'
18+
import jQuery from 'jquery'
19+
export default {
20+
name: 'ConfirmationBeforeRunAnAgent',
21+
components: {
22+
BasicModal
23+
},
24+
props: {
25+
dataId: String,
26+
dataName: String
27+
},
28+
data () {
29+
return {
30+
command: '',
31+
activateNotification: false
32+
}
33+
},
34+
methods: {
35+
executeAgent () {
36+
jQuery('#confirmation-before-run-an-agent').modal('hide')
37+
const self = this
38+
setTimeout(
39+
function () {
40+
self.$emit('run-agent', { dataId: self.dataId, dataName: self.dataName, command: self.command, activateNotification: self.activateNotification })
41+
self.resetData()
42+
},
43+
500
44+
)
45+
},
46+
resetData () {
47+
this.command = ''
48+
this.activateNotification = false
49+
}
50+
}
51+
}
52+
</script>

0 commit comments

Comments
 (0)