File

src/pages/profile/profile.ts

Description

Generated class for the ProfilePage page.

Metadata

selector page-profile
templateUrl profile.html

Index

Properties
Methods

Constructor

constructor(navCtrl: NavController, navParams: NavParams, userService: UserService, upSvc: UploadService, popoverCtrl: PopoverController, zone: NgZone, chatManager: ChatManager, events: Events)
Parameters :
Name Type Optional Description
navCtrl NavController
navParams NavParams
userService UserService
upSvc UploadService
popoverCtrl PopoverController
zone NgZone
chatManager ChatManager
events Events

Methods

displayImage
displayImage(uidContact: )

carico url immagine profilo passando id utente

Parameters :
Name Type Optional Description
uidContact
Returns : void
goBack
goBack()

chiudo il popup profilo utente

Returns : void
initialize
initialize()

imposto subsribe dettaglio utente controllo se sono nel profilo currentuser oppure usercon cui converso carico dettaglio user

Returns : void
ngOnInit
ngOnInit()
Returns : void
presentPopover
presentPopover(myEvent: )

metodo richiamato dalla pg html del current user alla pressione sul pulsante modifica della foto profillo apro PopoverProfilePage passando id current user

Parameters :
Name Type Optional Description
myEvent
Returns : void

Properties

Public chatManager
chatManager: ChatManager
Type : ChatManager
Public currentUserDetail
currentUserDetail: UserModel
Type : UserModel
Public events
events: Events
Type : Events
Public navCtrl
navCtrl: NavController
Type : NavController
Public navParams
navParams: NavParams
Type : NavParams
Public popoverCtrl
popoverCtrl: PopoverController
Type : PopoverController
Public profileYourself
profileYourself: boolean
Type : boolean
Public uidUser
uidUser: string
Type : string
Public upSvc
upSvc: UploadService
Type : UploadService
Public userDetail
userDetail: UserModel
Type : UserModel
Public userService
userService: UserService
Type : UserService
Public zone
zone: NgZone
Type : NgZone
import { Component, NgZone } from '@angular/core';
import { PopoverController, IonicPage, NavController, NavParams } from 'ionic-angular';
import { Events } from 'ionic-angular';
// models
import { UserModel } from '../../models/user';
// services
import { UploadService } from '../../providers/upload-service/upload-service';
import { UserService } from '../../providers/user/user';
import { ChatManager } from '../../providers/chat-manager/chat-manager';
// pages
import { PopoverProfilePage } from '../popover-profile/popover-profile';

/**
 * Generated class for the ProfilePage page.
 */
@IonicPage()
@Component({
  selector: 'page-profile',
  templateUrl: 'profile.html',
})
export class ProfilePage {
  public userDetail: UserModel;
  public currentUserDetail: UserModel;
  public uidUser: string;

  public profileYourself: boolean;
  //public selectedFiles: FileList;
  //public currentUpload: UploadModel;
  
  constructor(
    public navCtrl: NavController, 
    public navParams: NavParams,
    public userService: UserService,
    //public navProxy: NavProxyService,
    public upSvc: UploadService,
    public popoverCtrl: PopoverController,
    public zone: NgZone,
    public chatManager: ChatManager,
    public events: Events
  ) {
    this.uidUser = navParams.get('uidUser');
  }
  /**
   * 
   */
  ngOnInit() {
    this.initialize();
  }
  /**
   * imposto subsribe dettaglio utente
   * controllo se sono nel profilo currentuser oppure usercon cui converso
   * carico dettaglio user
   */
  initialize(){
    this.events.subscribe('loadUserDetail:complete', userDetail => {
      this.userDetail = userDetail;
    });
    if (!this.uidUser){ // || this.userDetail.uid == this.uidUser
      this.profileYourself = true;
      this.currentUserDetail = this.chatManager.getLoggedUser();
      this.displayImage(this.currentUserDetail.uid);
    }
    else {
      this.profileYourself = false;
      console.log('this.uidUser',this.uidUser);
      this.userDetail = new UserModel(this.uidUser, '', '', this.uidUser, '', '');
      this.userService.loadUserDetail(this.uidUser);
      this.displayImage(this.uidUser);
    }
  }
  /**
   * metodo richiamato dalla pg html del current user 
   * alla pressione sul pulsante modifica della foto profillo
   * apro PopoverProfilePage passando id current user
   * @param myEvent 
   */
  presentPopover(myEvent) {
    let popover = this.popoverCtrl.create(PopoverProfilePage,{uidContact:this.currentUserDetail.uid});
    popover.present({
      ev: myEvent
    });
    popover.onDidDismiss((data: string) => {
      //alert("popover.onDidDismiss: "+data);
      console.log(" ********* data::: ", data);
    });
  }
  /**
   * carico url immagine profilo passando id utente
   */
  displayImage(uidContact){
    const that = this;
    this.upSvc.display(uidContact)
    .then((url) => {
      that.zone.run(() => {
        if(that.profileYourself){
          that.currentUserDetail.imageurl = url;
        }else{
          that.userDetail.imageurl = url;
        }
      });
    })
    .catch((error)=>{
      console.log("error::: ",error);
    });
  }
  /**
   * chiudo il popup profilo utente
   */
  goBack(){
    this.navCtrl.pop();
  }
}
<!--
  Generated template for the ProfilePage page.

  See http://ionicframework.com/docs/components/#navigation for more info on
  Ionic pages and navigation.
-->
<ion-header>
  <ion-navbar hideBackButton>
    <ion-title>
      <div *ngIf="profileYourself">{{currentUserDetail.fullname}}</div>
      <div *ngIf="!profileYourself">{{userDetail.fullname}}</div>
    </ion-title>
    <ion-buttons left>
      <button ion-button icon-only (click)="goBack()">
        <ion-icon name="close"></ion-icon>
      </button>
    </ion-buttons>
  </ion-navbar>
</ion-header>
      
<ion-content padding class="speaker-detail">
  <div text-center>
    <img class="clip-circle" *ngIf="profileYourself" src="{{this.currentUserDetail.imageurl}}" alt="user" onError="this.src='assets/img/no_image.png';">
    <img class="clip-circle" *ngIf="!profileYourself" src="{{this.userDetail.imageurl}}" alt="user" onError="this.src='assets/img/no_image.png';">
    <!-- <button ion-button icon-only clear small color="twitter">
      <ion-icon name="logo-twitter"></ion-icon>
    </button>
    <button ion-button icon-only clear small color="github">
      <ion-icon name="logo-github"></ion-icon>
    </button>
    <button ion-button icon-only clear small color="instagram">
      <ion-icon name="logo-instagram"></ion-icon>
    </button> -->
    <button *ngIf="profileYourself" class="icon_modify" icon-only (click)="presentPopover($event)">
      <ion-icon name="create"></ion-icon>
    </button>
  </div>


  <div class="uid-contact">
    <div *ngIf="profileYourself">{{currentUserDetail.uid}}</div>
    <div *ngIf="!profileYourself">{{userDetail.uid}}</div>
  </div>
  <ion-item detail-push class="fullname">
      <div *ngIf="profileYourself" >{{currentUserDetail.fullname}}</div>
      <div *ngIf="!profileYourself">{{userDetail.fullname}}</div>
  </ion-item>
  <ion-item detail-push *ngIf="profileYourself">
    <div class="email">email: {{currentUserDetail.email}}</div>
  </ion-item>

      <!-- <label>
         <input type="file" (change)="detectFiles($event)" multiple>
      </label>
        <button
                [disabled]="!selectedFiles"
                (click)="uploadMulti()">
          Upload Multiple
        </button> -->
  <!-- <p>{{speaker.about}}</p> -->

</ion-content>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""