Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentar usuários por agência #29

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 59 additions & 42 deletions src/components/gerenciamento_usuarios/GerenciamentoUsuarios.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
<template>
<div>
<titulo-principal titulo="Gerencimaneto de Usuários"></titulo-principal>

<span class="titulo_categoria" v-if="users_activates.length > 0">Usuários Ativos</span>
<md-card class="md-layout-item md-larger-size card" v-if="users_activates.length > 0">
<md-list class="lista_usuarios">
<md-list-item v-for="user in users_activates" :key="user.id" class="usuario">
{{user.email}} ({{user.permission}})
<md-icon class="md-size-2x desativar_usuario" @click.native="gerenciaUsuario(user.id, 'desativa')">toggle_on</md-icon>
</md-list-item>
</md-list>
</md-card>
<span class="titulo_categoria" v-if="users_deactivates.length > 0">Usuários Desativados</span>
<md-card class="md-layout-item md-larger-size card" v-if="users_deactivates.length > 0">
<md-list class="lista_usuarios_desativados lista_usuarios">
<md-list-item v-for="user in users_deactivates" :key="user.id" class="usuario">
<titulo-principal titulo="Gerenciamento de Usuários"></titulo-principal>

<span class="titulo_categoria" v-if="usersActivates.length > 0">Usuários Ativos</span>
<md-list class="lista_usuarios" v-for="adOpsTeam in adOpsTeams_active" :key="adOpsTeam">
<md-list-item class="lista_adOpsTeam">
<div class="name_adOpsTeam">{{adOpsTeam}}</div>
</md-list-item>

<md-card class="md-layout-item md-larger-size card">
<md-list-item v-for="user in usersActivates.filter(activeUser => activeUser.adOpsTeam === adOpsTeam)" :key="user.id" class="usuario">
{{user.email}} ({{user.permission}})
<md-icon class="md-size-2x ativar_usuario usuario" @click.native="gerenciaUsuario(user.id, 'ativa')">toggle_off</md-icon>
<md-icon v-if="user.permission !== 'admin'" class="md-size-2x desativar_usuario" @click.native="gerenciaUsuario(user.id, 'desativa')">toggle_on</md-icon>
</md-list-item>
</md-list>
</md-card>
</md-card>
</md-list>

<span class="titulo_categoria" v-if="usersDeactivates.length > 0">Usuários Desativados</span>
<md-list class="lista_usuarios" v-for="adOpsTeam in adOpsTeams_deactivate" :key="adOpsTeam">
<md-list-item class="lista_adOpsTeam">
<div class="name_adOpsTeam">{{adOpsTeam}}</div>
</md-list-item>
<md-card class="md-layout-item md-larger-size card">
<md-list-item v-for="user in usersDeactivates.filter(deactivateUser => deactivateUser.adOpsTeam === adOpsTeam)" :key="user.id" class="usuario">
{{user.email}} ({{user.permission}})
<md-icon v-if="user.permission !== 'admin'" class="md-size-2x ativar_usuario usuario" @click.native="gerenciaUsuario(user.id, 'ativa')">toggle_off</md-icon>
</md-list-item>
</md-card>
</md-list>

<div class="load" v-show="show_load">
<md-progress-spinner md-mode="indeterminate"></md-progress-spinner>
Expand All @@ -31,7 +39,7 @@
{{ apiErrorMessage }}
</p>
</div>
<md-snackbar :md-position="position" :md-duration="isInfinity ? Infinity : duration" :md-active.sync="showSnackbar" md-persistent>
<md-snackbar :md-position="position" :md-duration="6000" :md-active.sync="showSnackbar" md-persistent>
Fsouza986 marked this conversation as resolved.
Show resolved Hide resolved
Fsouza986 marked this conversation as resolved.
Show resolved Hide resolved
<span>{{ snackbar_message }}</span>
<md-button class="md-primary" @click="showSnackbar = false">OK</md-button>
</md-snackbar>
Expand All @@ -41,7 +49,6 @@
</template>

<script>

import TituloAreaPrincipal from '../shared/titulo_area_principal/TituloAreaPrincipal.vue';
import InvalidUserAlert from '../shared/login/InvalidUser.vue';
import { validationMixin } from 'vuelidate'
Expand All @@ -66,8 +73,12 @@ export default {
downloadError: false,
downloadErrorMessage: 'Erro no Download!',
responseVisibility: false,
users_activates: [],
users_deactivates: [],
adOpsTeams_active: new Set(),
adOpsTeams_deactivate: new Set(),
allUsers: [],
adOpsTeam: '',
usersActivates: [],
usersDeactivates: [],
snackbar_message: '',
position: 'center',
showSnackbar: false
Expand All @@ -90,8 +101,10 @@ export default {
throw new Error(response.responseText || response.errorMessage);
}
const allUsers = JSON.parse(response.responseText).filter(user => user.email !== localStorage.getItem('email'));
this.users_activates = allUsers.filter(user => user.active == true);
this.users_deactivates = allUsers.filter(user => user.active == false);
this.usersActivates = allUsers.filter(user => user.active == true);
this.usersDeactivates = allUsers.filter(user => user.active == false);
this.usersActivates.forEach(user => this.adOpsTeams_active.add(user.adOpsTeam));
this.usersDeactivates.forEach(user => this.adOpsTeams_deactivate.add(user.adOpsTeam));
Fsouza986 marked this conversation as resolved.
Show resolved Hide resolved
}).catch((err) => {
this.apiError = true;
this.apiErrorMessage = err.message;
Expand All @@ -108,6 +121,12 @@ export default {
this.apiError = true;
return false;
},
resetAdOpsTeams(){
this.adOpsTeams_active.clear();
this.adOpsTeams_deactivate.clear();
this.usersActivates.forEach(user => this.adOpsTeams_active.add(user.adOpsTeam));
this.usersDeactivates.forEach(user => this.adOpsTeams_deactivate.add(user.adOpsTeam));
},
gerenciaUsuario(id, opcao) {
let url;
if(opcao === 'ativa') {
Expand Down Expand Up @@ -146,8 +165,9 @@ export default {
throw new Error(response.responseText || response.errorMessage);
}
const allUsers = JSON.parse(response.responseText).filter(user => user.email !== localStorage.getItem('email'));
this.users_activates = allUsers.filter(user => user.active == true);
this.users_deactivates = allUsers.filter(user => user.active == false);
this.usersActivates = allUsers.filter(user => user.active == true);
this.usersDeactivates = allUsers.filter(user => user.active == false);
this.resetAdOpsTeams();
}).catch((err) => {
this.showAuthAlert = this.isAuthError(this.statusCode);
this.snackbar_message = 'Erro ao mudar status do usuário!';
Expand All @@ -158,63 +178,60 @@ export default {
}
}
}

</script>

<style scoped>

.card {
margin-left: 50px;
margin-top: 10px;
margin-left: 10px;
}

.load {
margin-top: 50px;
text-align: center;
}

.respostas {
width: 100%;
}

p.response {
margin-left: 60px;
}

ul {
margin-left: 15px;
list-style: none;
}

.titulo_categoria {
font-size: 20px;
font-size: 22px;
margin-left: 60px;
padding-bottom: 20px;
padding-top: 25px;
display: block;
}

.lista_usuarios {
margin-left: 0px!important;
margin-left: 40px!important;
}

.lista_usuarios_desativados {
background-color: #ececec;
}

.usuario:hover {
background-color: #ecf1fd;
}

i.ativar_usuario {
font-size: 20px;
cursor: pointer;
color: red!important;
}

i.desativar_usuario {
font-size: 20px;
cursor: pointer;
color: green!important;
}

.lista_adOpsTeam {
margin-left: 8px;
border-bottom: 1px solid #a8c0ff;
}
.name_adOpsTeam{
font-size: 16px;
font-weight: bold;
color: #3f2b96;
}
</style>