-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Display histories of alablility status
- Loading branch information
Showing
23 changed files
with
303 additions
and
6 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
app/controllers/api/v1/accounts/agent_histories_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class Api::V1::Accounts::AgentHistoriesController < ApplicationController | ||
before_action :fetch_agent_histories, only: [:show] | ||
def index | ||
@agent_histories = agent_histories | ||
end | ||
|
||
def show | ||
Rails.logger.info "--------------USER: #{@agent_histories}" | ||
# return @agent_histories | ||
render partial: 'api/v1/models/agent_histories.json.jbuilder', locals: { resource: @agent_histories } | ||
end | ||
|
||
private | ||
|
||
def fetch_agent_histories | ||
@agent_histories = Current.account.users.find(params[:id]).availability_statuses | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module Api::V1::Accounts::AgentHistoriesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ApiClient from './ApiClient'; | ||
|
||
class AgentHistories extends ApiClient { | ||
constructor() { | ||
super('agent_histories', { accountScoped: true }); | ||
} | ||
} | ||
|
||
export default new AgentHistories(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
app/javascript/dashboard/routes/dashboard/settings/agents/Histories.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<template> | ||
<div class="column content-box"> | ||
<div class="row"> | ||
<div class="small-8 columns"> | ||
<p v-if="!historyList.length" class="no-items-erro-message"> | ||
{{ $t('AGENT_MGMT.VIEW_TRACKS.LIST.404') }} | ||
</p> | ||
<table v-if="historyList.length" class="woot-table"> | ||
<!-- Header --> | ||
<thead> | ||
<th | ||
v-for="thHeader in $t('AGENT_MGMT.VIEW_TRACKS.LIST.TABLE_HEADER')" | ||
:key="thHeader" | ||
> | ||
{{ thHeader}} | ||
</th> | ||
</thead> | ||
<tbody> | ||
<tr v-for="(history, index) in historyList" :key="history.availability"> | ||
<td> | ||
<span class="agent-name">{{ agent.name }}</span> | ||
</td> | ||
<td> | ||
<span class="history-availability">{{ history.availability }}</span> | ||
</td> | ||
<td> | ||
<span class="history-time">{{ history.updated_at }}</span> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
<div class="small-4 columns"> | ||
<span | ||
v-html=" | ||
useInstallationName( | ||
$t('AGENT_MGMT.VIEW_TRACKS.SIDEBAR_TXT'), | ||
globalConfig.installationName | ||
) | ||
" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
<script> | ||
import { mapGetters } from 'vuex'; | ||
import globalConfigMixin from 'shared/mixins/globalConfigMixin'; | ||
import accountMixin from '../../../../mixins/account'; | ||
export default { | ||
components: { | ||
}, | ||
mixins: [globalConfigMixin, accountMixin], | ||
data() { | ||
return { | ||
historyList: [], | ||
currentAgent: {}, | ||
showHistories: false, | ||
agent: {}, | ||
}; | ||
}, | ||
computed: { | ||
...mapGetters({ | ||
// historyList: 'agents/getAgentHistories', | ||
agentList: 'agents/getAgents', | ||
globalConfig: 'globalConfig/get', | ||
}), | ||
selectedAgentId() { | ||
return this.$route.params.agent_id; | ||
}, | ||
}, | ||
watch: { | ||
$route(to) { | ||
if (to.name === 'agent_histories') { | ||
this.fetchHistories(); | ||
this.getSelectedAgent(); | ||
} | ||
}, | ||
}, | ||
mounted() { | ||
this.fetchHistories(); | ||
this.getSelectedAgent(); | ||
}, | ||
methods: { | ||
// Show SnackBar | ||
showAlert(message) { | ||
// Reset loading, current selected agent | ||
this.loading[this.currentAgent.id] = false; | ||
this.currentAgent = {}; | ||
// Show message | ||
this.agentAPI.message = message; | ||
bus.$emit('newToastMessage', message); | ||
}, | ||
fetchHistories() { | ||
this.$store.dispatch('agents/getHistories', this.selectedAgentId).then(() => { | ||
this.historyList = this.$store.getters['agents/getAgentHistories']; | ||
}); | ||
}, | ||
getSelectedAgent() { | ||
this.agent = this.agentList.filter(agent => this.selectedAgentId.includes(agent.id))[0]; | ||
console.log(this.agent); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# == Schema Information | ||
# | ||
# Table name: availability_statuses | ||
# | ||
# id :bigint not null, primary key | ||
# availability :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# user_id :integer | ||
# | ||
class AvailabilityStatus < ApplicationRecord | ||
include RegexHelper | ||
belongs_to :user | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,6 @@ | |
# account_id :integer | ||
# | ||
class Code < ApplicationRecord | ||
include RegexHelper | ||
belongs_to :account | ||
end |
Oops, something went wrong.