Skip to content

Commit

Permalink
Merge pull request #410 from wazuh/3.8-tooltips-typos
Browse files Browse the repository at this point in the history
3.8 tooltips typos
  • Loading branch information
Jesús Ángel authored Dec 19, 2018
2 parents 3696f03 + b2c4483 commit ebda37e
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ define([
* @param {Object} $stateParams
* @param {Object} $state
* @param {Object} agent
* @param {Object} $dateDiffService
*/

constructor(
Expand All @@ -41,7 +42,8 @@ define([
$stateParams,
$currentDataService,
agent,
$state
$state,
$dateDiffService
) {
this.state = $state
this.urlTokenModel = $urlTokenModel
Expand All @@ -62,6 +64,7 @@ define([
`{"agent.id":"${this.agent[0].data.data.id}", "implicit":true}`
)
this.filters = this.currentDataService.getSerializedFilters()
this.dateDiffService = $dateDiffService
this.timePicker = new TimePicker(
'#timePicker',
this.urlTokenModel.handleValueChange
Expand Down Expand Up @@ -144,10 +147,15 @@ define([
syscheck: this.agent[1].data.data,
rootcheck: this.agent[2].data.data
}

this.agentInfo.syscheck.duration = this.dateDiffService.getDateDiff(this.agentInfo.syscheck.start, this.agentInfo.syscheck.end).duration
this.agentInfo.rootcheck.duration = this.dateDiffService.getDateDiff(this.agentInfo.rootcheck.start, this.agentInfo.rootcheck.end).duration
this.agentInfo.syscheck.inProgress = this.dateDiffService.getDateDiff(this.agentInfo.syscheck.start, this.agentInfo.syscheck.end).inProgress
this.agentInfo.rootcheck.inProgress = this.dateDiffService.getDateDiff(this.agentInfo.rootcheck.start, this.agentInfo.rootcheck.end).inProgress

this.scope.agentInfo = this.agent[0].data.data

this.scope.agentInfo = this.agentInfo
this.scope.id = this.stateParams.id

} catch (err) {
this.agentInfo = {}
this.agentInfo.id =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Find more information about this on the LICENSE file.
*/

define(['../../module'], function(app) {
define(['../../module'], function (app) {
'use strict'

class AgentsOverview {
Expand All @@ -34,7 +34,8 @@ define(['../../module'], function(app) {
agent,
groups,
$mdDialog,
$groupHandler
$groupHandler,
$dateDiffService
) {
this.stateParams = $stateParams
this.scope = $scope
Expand All @@ -43,6 +44,7 @@ define(['../../module'], function(app) {
this.notificationService = $notificationService
this.agent = agent
this.extensions = extensions
this.dateDiffService = $dateDiffService
this.scope.editGroup = false
this.groups = groups
this.$mdDialog = $mdDialog
Expand All @@ -59,9 +61,76 @@ define(['../../module'], function(app) {
this.agent[0].data &&
typeof this.agent[0].data.data === 'object'
) {
this.scope.agent = this.agent[0].data.data
this.scope.agent = this.agent[0].data.data
this.scope.agentOS = `${this.scope.agent.os.name || '-'} ${this.scope
.agent.os.codename || '-'} ${this.scope.agent.os.version || '-'}`
this.scope.syscheck =
this.agent.length > 0 &&
typeof this.agent[1] === 'object' &&
typeof this.agent[1].data === 'object' &&
!this.agent[1].data.error
? this.agent[1].data.data
: (this.scope.syscheck = { start: 'Unknown', end: 'Unknown' })
this.scope.id = this.stateParams.id
this.scope.rootcheck =
this.agent.length > 1 &&
typeof this.agent[2] === 'object' &&
typeof this.agent[2].data === 'object' &&
!this.agent[2].data.error
? this.agent[2].data.data
: { start: 'Unknown', end: 'Unknown' }
if (!this.scope.agent.error) {
const keys = Object.keys(this.extensions)
keys.map(key => {
this.extensions[key] === 'true'
? (this.scope[key] = key)
: (this.scope[key] = null)
}
)

this.scope.groups = this.groups.data.data.items.map(item => item.name).filter(item => this.scope.agent.group && !this.scope.agent.group.includes(item))
this.scope.formatAgentStatus = agentStatus =>
this.formatAgentStatus(agentStatus)
this.scope.getAgentStatusClass = agentStatus =>
this.getAgentStatusClass(agentStatus)
this.scope.goGroups = group => this.goGroups(group)
this.scope.switchGroupEdit = () => this.switchGroupEdit()

this.scope.syscheck.duration = this.dateDiffService.getDateDiff(this.scope.syscheck.start, this.scope.syscheck.end).duration
this.scope.rootcheck.duration = this.dateDiffService.getDateDiff(this.scope.rootcheck.start, this.scope.rootcheck.end).duration
this.scope.syscheck.inProgress = this.dateDiffService.getDateDiff(this.scope.syscheck.start, this.scope.syscheck.end).inProgress
this.scope.rootcheck.inProgress = this.dateDiffService.getDateDiff(this.scope.rootcheck.start, this.scope.rootcheck.end).inProgress

this.scope.showConfirm = (ev, group) => {

const confirm = this.$mdDialog
.confirm()
.title(`Add group "${group}" to agent "${this.scope.agent.id}"?`)
.targetEvent(ev)
.ok('Agree')
.cancel('Cancel')

this.$mdDialog.show(confirm).then(
() => {
this.groupHandler.addAgentToGroup(group, this.scope.agent.id)
.then(() => this.requestService.apiReq(`/agents/${this.scope.agent.id}`))
.then(agent => {
this.scope.agent.group = agent.data.data.group
this.scope.groups = this.scope.groups.filter(item => !agent.data.data.group.includes(item))
if (!this.scope.$$phase) this.scope.$digest()
})
.catch(error =>
this.$notificationService.showSimpleToast(
error.message || error
)
)
},
() => { }
)
}
}
//Check OS type
if (this.agent[0].data.data) {
if (this.agent[0].data.data && this.agent[0].data.data.os && this.agent[0].data.data.os.uname) {
this.scope.isLinux = this.agent[0].data.data.os.uname.includes("Linux")
}
if (this.scope.agent.status == 'Never connected') {
Expand Down Expand Up @@ -89,69 +158,12 @@ define(['../../module'], function(app) {
this.scope.agent.error =
this.agent[0].data.message || this.agent[0].data.error
} else {
this.scope.agent.error = 'Unable to load agent data from API'
}
}

this.scope.agentOS = `${this.scope.agent.os.name || '-'} ${this.scope
.agent.os.codename || '-'} ${this.scope.agent.os.version || '-'}`
this.scope.syscheck =
this.agent.length > 0 &&
typeof this.agent[1] === 'object' &&
typeof this.agent[1].data === 'object' &&
!this.agent[1].data.error
? this.agent[1].data.data
: (this.scope.syscheck = { start: 'Unknown', end: 'Unknown' })
this.scope.id = this.stateParams.id
this.scope.rootcheck =
this.agent.length > 1 &&
typeof this.agent[2] === 'object' &&
typeof this.agent[2].data === 'object' &&
!this.agent[2].data.error
? this.agent[2].data.data
: { start: 'Unknown', end: 'Unknown' }
if (!this.scope.agent.error) {
const keys = Object.keys(this.extensions)
keys.map(key =>
this.extensions[key] === 'true'
? (this.scope[key] = key)
: (this.scope[key] = null)
)

this.scope.groups = this.groups.data.data.items.map(item => item.name).filter(item => this.scope.agent.group && !this.scope.agent.group.includes(item))
this.scope.formatAgentStatus = agentStatus =>
this.formatAgentStatus(agentStatus)
this.scope.getAgentStatusClass = agentStatus =>
this.getAgentStatusClass(agentStatus)
this.scope.goGroups = group => this.goGroups(group)
this.scope.switchGroupEdit = () => this.switchGroupEdit()

this.scope.showConfirm = (ev, group) => {

const confirm = this.$mdDialog
.confirm()
.title(`Add group "${group}" to agent "${this.scope.agent.id}"?`)
.targetEvent(ev)
.ok('Agree')
.cancel('Cancel')

this.$mdDialog.show(confirm).then(
() => {
this.groupHandler.addAgentToGroup(group,this.scope.agent.id)
.then(() => this.requestService.apiReq(`/agents/${this.scope.agent.id}`))
.then(agent => {
this.scope.agent.group = agent.data.data.group
this.scope.groups = this.scope.groups.filter(item => !agent.data.data.group.includes(item))
if(!this.scope.$$phase) this.scope.$digest()
})
.catch(error =>
this.$notificationService.showSimpleToast(
error.message || error
)
)
},
() => {}
)
this.scope.agent = { group: null, name: 'Unknown', id: null, status: null, ip: 'Unknown', os: { name: 'Unknown', codename: 'Unknown', version: 'Unknown' }, version: 'Unknown', dateAdd: 'Unknown', lastKeepAlive: 'Unknown' }
if (this.agent[0].data.error) {
this.scope.agent.error = this.agent[0].data.message || this.agent[0].data.error
} else {
this.scope.agent.error = 'Unable to load agent data from API'
}
}
}
}
Expand Down Expand Up @@ -207,7 +219,7 @@ define(['../../module'], function(app) {

switchGroupEdit() {
this.scope.editGroup = !!!this.scope.editGroup
if(!this.scope.$$phase) this.scope.$digest()
if (!this.scope.$$phase) this.scope.$digest()
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@
</i>
<i ng-click="removeManager(entry)" class="fa fa-trash wz-margin-left-7 cursor-pointer" aria-hidden="true">
<md-tooltip md-direction="bottom" class="wz-tooltip">
BacRemove managek
Remove manager
</md-tooltip>
</i>
<i ng-click="checkManager(entry)" class="fa fa-refresh wz-margin-left-7 cursor-pointer" aria-hidden="true">
<md-tooltip md-direction="bottom" class="wz-tooltip">
Check connection
Check API connection
</md-tooltip>
</i>
<i ng-click="editEntry(entry)" class="fa fa-pencil wz-margin-left-7 cursor-pointer" aria-hidden="true">
<md-tooltip md-direction="bottom" class="wz-tooltip">
Edit
Edit API
</md-tooltip>
</i>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<i class="fa fa-star fa-fw wz-color-orange" aria-hidden="true"></i>{{currentAPI}}
<span>&nbsp;&ndash;&nbsp;</span>
<md-tooltip md-direction="bottom" class="wz-tooltip">
"Selected API
Selected API
</md-tooltip>
</span>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
define(['../module'], function (module) {
'use strict'

class DateDiffService {
constructor() {
this.start = null
this.end = null
}

/**
* Returns the difference between dates
*/
getDateDiff(start, end) {
this.start = new Date(start)
this.end = new Date(end)
const result = {
duration: 'Unknown',
inProgress: false,
end: this.end || 'Unknown',
start: this.start || 'Unknown'
}
if (this.end && this.start) {
result.duration = (this.end - this.start) / 1000 / 60;
result.duration = Math.round(result.duration * 100) / 100;
if (result.duration <= 0) {
result.inProgress = true;
}
}
return result
}
}

module.service('$dateDiffService', DateDiffService)
})
1 change: 1 addition & 0 deletions SplunkAppForWazuh/appserver/static/js/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ define([
'./get-ids/getIdService',
'./token-model/urlTokenModelService',
'./group-handler/group-handler',
'./date-diff/dateDiffService'
], function() {})

0 comments on commit ebda37e

Please sign in to comment.