Lista con el nombre de la comunidad
Listado con el nombre de la comunidad en la tabla de administradores de comunidades
This commit is contained in:
		
							parent
							
								
									d6e468ca03
								
							
						
					
					
						commit
						2df92e1135
					
				| 
						 | 
					@ -57,6 +57,11 @@ export class AppController {
 | 
				
			||||||
    return this.appService.allUsersAdminSistema();
 | 
					    return this.appService.allUsersAdminSistema();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get('user/findAdminComunidad')
 | 
				
			||||||
 | 
					  allUsersAdminComunidad() {
 | 
				
			||||||
 | 
					    return this.appService.allUsersAdminComunidad();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Get('user/find/:dni')
 | 
					  @Get('user/find/:dni')
 | 
				
			||||||
  findUser(
 | 
					  findUser(
 | 
				
			||||||
    @Param('dni') paramUserDNI: string
 | 
					    @Param('dni') paramUserDNI: string
 | 
				
			||||||
| 
						 | 
					@ -97,6 +102,13 @@ export class AppController {
 | 
				
			||||||
    return this.appService.findCommunity(paramCommunityId);
 | 
					    return this.appService.findCommunity(paramCommunityId);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get('community/findCommunityName/:id')
 | 
				
			||||||
 | 
					  findCommunityName(
 | 
				
			||||||
 | 
					    @Param('id') paramCommunityId: string
 | 
				
			||||||
 | 
					  ) {
 | 
				
			||||||
 | 
					    return this.appService.findCommunityName(paramCommunityId);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // #==== API Common Areas
 | 
					  // #==== API Common Areas
 | 
				
			||||||
  @Post('commonArea/createCommonArea')
 | 
					  @Post('commonArea/createCommonArea')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,6 +70,16 @@ export class AppService {
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  allUsersAdminComunidad() {
 | 
				
			||||||
 | 
					    const pattern = { cmd: 'findAdminComunidad' };
 | 
				
			||||||
 | 
					    const payload = {};
 | 
				
			||||||
 | 
					    return this.clientUserApp
 | 
				
			||||||
 | 
					      .send<string>(pattern, payload)
 | 
				
			||||||
 | 
					      .pipe(
 | 
				
			||||||
 | 
					        map((message: string) => ({ message })),
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //GET parameter from API
 | 
					  //GET parameter from API
 | 
				
			||||||
  findUser(paramUserDNI: string) {
 | 
					  findUser(paramUserDNI: string) {
 | 
				
			||||||
    const pattern = { cmd: 'findUserDNI' };
 | 
					    const pattern = { cmd: 'findUserDNI' };
 | 
				
			||||||
| 
						 | 
					@ -129,6 +139,16 @@ export class AppService {
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  findCommunityName(paramCommunityId: string) {
 | 
				
			||||||
 | 
					    const pattern = { cmd: 'findCommunityName' };
 | 
				
			||||||
 | 
					    const payload = { id: paramCommunityId };
 | 
				
			||||||
 | 
					    return this.clientCommunityApp
 | 
				
			||||||
 | 
					      .send<string>(pattern, payload)
 | 
				
			||||||
 | 
					      .pipe(
 | 
				
			||||||
 | 
					        map((message: string) => ({ message })),
 | 
				
			||||||
 | 
					      );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // ====================== COMMON AREAS =============================== 
 | 
					  // ====================== COMMON AREAS =============================== 
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,6 +23,12 @@ export class CommunitiesController {
 | 
				
			||||||
    return this.communitiesService.findOne(_id);
 | 
					    return this.communitiesService.findOne(_id);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @MessagePattern({cmd: 'findCommunityName'})
 | 
				
			||||||
 | 
					  findOneName(@Payload() id: string) {
 | 
				
			||||||
 | 
					    let _id = id['_id'];
 | 
				
			||||||
 | 
					    return this.communitiesService.findOneName(_id);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @MessagePattern({cmd: 'updateCommunity'})
 | 
					  @MessagePattern({cmd: 'updateCommunity'})
 | 
				
			||||||
  update(@Payload() community: CommunityDocument) {
 | 
					  update(@Payload() community: CommunityDocument) {
 | 
				
			||||||
    return this.communitiesService.update(community.id, community);
 | 
					    return this.communitiesService.update(community.id, community);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,6 +24,9 @@ export class CommunitiesService {
 | 
				
			||||||
  findOne(id: string): Promise<Community> {
 | 
					  findOne(id: string): Promise<Community> {
 | 
				
			||||||
    return this.communityModel.findOne({ _id: id }).exec();
 | 
					    return this.communityModel.findOne({ _id: id }).exec();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  findOneName(id: string): Promise<Community> {
 | 
				
			||||||
 | 
					    return this.communityModel.findOne({ _id: "62be68215692582bbfd77134" }).exec();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  update(id: string, community: CommunityDocument) {
 | 
					  update(id: string, community: CommunityDocument) {
 | 
				
			||||||
    return this.communityModel.findOneAndUpdate({ _id: id }, community, {
 | 
					    return this.communityModel.findOneAndUpdate({ _id: id }, community, {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,4 +52,10 @@ export class UsersController {
 | 
				
			||||||
  allUsersAdminSistema() {
 | 
					  allUsersAdminSistema() {
 | 
				
			||||||
    return this.userService.allUsersAdminSistema();
 | 
					    return this.userService.allUsersAdminSistema();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //buscar solo admins de comunidad
 | 
				
			||||||
 | 
					    @MessagePattern({ cmd: 'findAdminComunidad' })
 | 
				
			||||||
 | 
					    allUsersAdminComunidad() {
 | 
				
			||||||
 | 
					      return this.userService.allUsersAdminComunidad();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,4 +69,11 @@ export class UsersService {
 | 
				
			||||||
  async allUsersAdminSistema(): Promise<User[]> { 
 | 
					  async allUsersAdminSistema(): Promise<User[]> { 
 | 
				
			||||||
    return this.userModel.find({ user_type: 1 }).exec();
 | 
					    return this.userModel.find({ user_type: 1 }).exec();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //find admin de comunidad
 | 
				
			||||||
 | 
					    async allUsersAdminComunidad(): Promise<User[]> { 
 | 
				
			||||||
 | 
					      return this.userModel.find({ user_type: 2 }).exec();   
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,16 +6,26 @@ import { Column } from 'primereact/column';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const AdministradoresComunidad = () => {
 | 
					const AdministradoresComunidad = () => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const [pokemones,setPokemones]=useState([]);
 | 
					    const [listaAdmins,setListaAdmins]=useState([]);
 | 
				
			||||||
    const [urlFetch,setUrlFetch]=useState('http://localhost:4000/user/findAdminSistema/');
 | 
					    const [listaAdminComunidad,setListaAdminComunidad]=useState([]);
 | 
				
			||||||
    async function fetchP(){
 | 
					
 | 
				
			||||||
    let nombres=await fetch(urlFetch, {method:'GET'});
 | 
					    async function listaAdmin(){
 | 
				
			||||||
    let pokemonesRes= await nombres.json();
 | 
					    let nombres=await fetch('http://localhost:4000/user/findAdminComunidad/', {method:'GET'});
 | 
				
			||||||
    setPokemones(pokemonesRes.message);
 | 
					    let nombresRes= await nombres.json();
 | 
				
			||||||
    console.log(pokemones);
 | 
					    setListaAdmins(nombresRes.message);
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    async function listaComunidades(nombre){
 | 
				
			||||||
 | 
					    let nombres=await fetch('http://localhost:4000/community/findCommunityName/'+nombre, {method:'GET'});
 | 
				
			||||||
 | 
					    let nombresRes= await nombres.json();
 | 
				
			||||||
 | 
					    setListaAdminComunidad(nombresRes.message);
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					   listaAdmins.map(function(administrador){
 | 
				
			||||||
 | 
					        listaComunidades(administrador.community_id);
 | 
				
			||||||
 | 
					        administrador.community_id=listaAdminComunidad.name;
 | 
				
			||||||
 | 
					   })
 | 
				
			||||||
    useEffect(()=>{
 | 
					    useEffect(()=>{
 | 
				
			||||||
      fetchP();
 | 
					        listaAdmin();
 | 
				
			||||||
    },[])
 | 
					    },[])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
| 
						 | 
					@ -23,12 +33,13 @@ const AdministradoresComunidad = () => {
 | 
				
			||||||
            <div className="col-12">
 | 
					            <div className="col-12">
 | 
				
			||||||
                <div className="card">
 | 
					                <div className="card">
 | 
				
			||||||
                    <h5>Administradores de comunidad</h5>
 | 
					                    <h5>Administradores de comunidad</h5>
 | 
				
			||||||
                    <DataTable value={pokemones}  scrollable scrollHeight="400px" scrollDirection="both" className="mt-3">
 | 
					                    <DataTable value={listaAdmins}  scrollable scrollHeight="400px" scrollDirection="both" className="mt-3">
 | 
				
			||||||
                        <Column field="name" header="Nombre" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
 | 
					                        <Column field="name" header="Nombre" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
 | 
				
			||||||
                        <Column field="last_name" header="Apellidos" style={{ flexGrow: 1, flexBasis: '160px' }} alignFrozen="left"></Column>
 | 
					                        <Column field="last_name" header="Apellidos" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
 | 
				
			||||||
                        <Column field="dni" header="Identificación" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
 | 
					                        <Column field="dni" header="Identificación" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
 | 
				
			||||||
                        <Column field="email" header="Correo electrónico" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
 | 
					                        <Column field="email" header="Correo electrónico" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
 | 
				
			||||||
                        <Column field="phone" header="Telefóno" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
 | 
					                        <Column field="phone" header="Telefóno" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
 | 
				
			||||||
 | 
					                        <Column field="community_id" header="Comunidad" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
 | 
				
			||||||
                    </DataTable>
 | 
					                    </DataTable>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue