Skip to main content

aaa

import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';

import { Session } from 'meteor/session';
import { FriendRequest } from './../../import/collections/insert.js';
import { UserInfo } from './../../import/collections/insert.js';
import { Message } from './../../import/collections/insert.js';

    Template.messagingpage.onRendered(function(){
      $("ul.tabs").tabs();
    });

Template.messanging.helpers({
show_connections(){
// alert('hi');
var sent_to = Session.get("userId");
//alert(sent_to);
// db.friend.find({sent_to: 'user_1224544',req_status: 0}).pretty()
var show_pending = FriendRequest.find({ $or: [ { $and: [ { sent_to: sent_to },{ req_status: 1 } ] }, { $and: [{ sent_by: sent_to },{ req_status: 1 } ] } ] }).fetch();
// var show_pending = FriendRequest.find({sent_to: sent_to,req_status: 1}).fetch();
var length = show_pending.length;
// alert('Length: '+length);
if(length > 0){
return show_pending;
}
},

show_connections_2(){
var use_id = this.sent_by;
var logged_in = Session.get("userId");
if(use_id == logged_in){
use_id = this.sent_to;
var connection_details = UserInfo.find({user_id: use_id}).fetch();
var show_details = connection_details[0];
// //alert(show_details.name);
console.log(connection_details);
//alert(connection_details[0]);
return connection_details;
}
else{
//alert(use_id);
var connection_details = UserInfo.find({user_id: use_id}).fetch();
var show_details = connection_details[0];
// //alert(show_details.name);
console.log(connection_details);
//alert(connection_details[0]);
return connection_details;
}},
msg_rightbox(){
// alert('right side');
var show_session = Session.get('msgid_forright');
// alert(show_session);
// use_id = this.sent_to;
var connection_details = UserInfo.find({user_id: show_session}).fetch();
var show_details = connection_details[0];
// //alert(show_details.name);
// console.log(connection_details);
//alert(connection_details[0]);
return connection_details;

},
message_content(){
var sent_by = Session.get("userId");
     var sent_to = Session.get('msgid_forright');
     // alert("Database change");
// find({ $or: [ { $and: [ { sent_to: sent_by },{ sent_by: sent_to } ] }, { $and: [{ sent_to: sent_to },{ sent_by: sent_by } ] } ] }).fetch();
// ind({ $or: [  { sent_to: sent_to },{ sent_by: sent_to } ] }).fetch();
var result = Message.find({ $or: [
{
$and:
[
{
sent_to: sent_by
},
{
sent_by: sent_to
}
]
} ,
{ 
$and:
  [
{
sent_to: sent_to
},
{
sent_by: sent_by
}
]
}
] }).fetch();
// var result = Message.find({}).fetch();
// alert(result);
return result;
},
sender(){
var sent_by = this.sent_by;
var current_login_user = Session.get("userId");/*
if( sent_by == current_login_user){

$("#div_display_msg").addClass('base_sent');
$("#div_display_msg").removeClass('base_receive');

return 1;
}else{
$("#div_display_msg").addClass('base_receive');
$("#div_display_msg").removeClass('base_sent');

}*/

return 0;
}

// },
// sender2(){
// var sent_to = this.sent_to;
// var current_login_user = Session.get("userId");

// if( sent_to == current_login_user){
// return 0;
// }
// }

});

Template.messanging.events({
'click .change_msg_onright': function(){
var show_id = this.user_id;
// alert(show_id);
Session.setPersistent("msgid_forright",show_id);
},
'click #send_msg': function(){
var msg_text = $('#msg_text').val();
// alert(msg_text);
   msg_text = jQuery.trim(msg_text);
if(msg_text == null || msg_text == "")
        {
          $('#msg_text').addClass('emptyfield').focus();
          return false;
        }
        else{
          $('#msg_text').removeClass('emptyfield');
            }

            var sent_by = Session.get("userId");
            var sent_to = Session.get('msgid_forright');
            msg_id = 'msg_'+ Math.floor((Math.random() * 2465789) + 1);
            alert('above insert');
            Meteor.call('insert_message',sent_by,sent_to,msg_text,msg_id,function(error,result){
            if(error){
            alert(' message sending failed! ');
            }else{
            alert(' message Sucessfully sent ');
            }
            $(".form_reset").trigger('reset');
            });
}

});












<template name="messagingpage">
  <head>
  <title>messanging</title>
</head>


  {{> header}}
  {{> messanging}}

</template>

<!-- <template name="header">
 
<nav>
  <div class="nav-wrapper">
    <a href="" class="brand-logo">Logo</a>
    <ul id="nav-mobile" class="right hide-on-med-and-down">
      <li><a href="">sass</a></li>
      <li><a href="">sass <span class="new badge">4</span></a></li>
      <li><a href="">sass</a></li>
    </ul>
  </div>
</nav>
</template> -->

<template name="messanging">

  <div class="row margin-tp">
      <div class="col s12 m3 l3">
         <p class="msg-head">Messaging</p>
         <Div class="col-md-12">
            <div class="input-group">
                     
                        </div>
        </Div>
  <div class="card">
    <div class="card-content">
      <p> <input id="btn-input" type="text" class="form-control input-sm chat_input" placeholder="Search user" /></p>
    </div>
    <div class="card-tabs">
      <ul class="tabs tabs-fixed-width">
        <li class="tab"><a class="active"  href="#recent"> Recent </a></li>
        <li class="tab"><a href="#connnection"> Connection </a></li>
     
      </ul>
    </div>
    <div class="card-content grey lighten-4">
      <div id="recent">
          <ul class="collection">
    <li class="collection-item avatar">
      <img src="https://i0.wp.com/tricksmaze.com/wp-content/uploads/2017/04/Stylish-Girls-Profile-Pictures-36.jpg?resize=300%2C300&ssl=1" alt="" class="circle">
      <span class="title">Shobhita Yaav</span>
      <p>Hey</p>
    </li>
      <li class="collection-item avatar">
      <img src="https://i0.wp.com/tricksmaze.com/wp-content/uploads/2017/04/Stylish-Girls-Profile-Pictures-36.jpg?resize=300%2C300&ssl=1" alt="" class="circle">
      <span class="title">Shobhita Yadav</span>
      <p>Ok.. </p>
    </li>
     <li class="collection-item avatar">
      <img src="https://i0.wp.com/tricksmaze.com/wp-content/uploads/2017/04/Stylish-Girls-Profile-Pictures-36.jpg?resize=300%2C300&ssl=1" alt="" class="circle">
      <span class="title">Shobhita Yadav</span>
      <p>Yes i am here </p>
    </li>
      <li class="collection-item avatar">
      <img src="https://i0.wp.com/tricksmaze.com/wp-content/uploads/2017/04/Stylish-Girls-Profile-Pictures-36.jpg?resize=300%2C300&ssl=1" alt="" class="circle">
      <span class="title">Shobhita Yadav</span>
      <p>Thanks..</p>
    </li>
  </ul>
           

      </div>

      <div id="connnection">
        <ul class="collection">
{{#each show_connections}}
{{#each show_connections_2}}
    <li class="collection-item avatar change_msg_onright" >
      <img src="./uploads/{{profile_pic}}" alt="" class="circle">
      <span class="title">{{name}}</span>
      <p>Hey</p>
    </li>
<!--       <li class="collection-item avatar">
      <img src="https://i0.wp.com/tricksmaze.com/wp-content/uploads/2017/04/Stylish-Girls-Profile-Pictures-36.jpg?resize=300%2C300&ssl=1" alt="" class="circle">
      <span class="title">Shobhita Yadav</span>
      <p>Ok.. </p>
    </li>
     <li class="collection-item avatar">
      <img src="https://i0.wp.com/tricksmaze.com/wp-content/uploads/2017/04/Stylish-Girls-Profile-Pictures-36.jpg?resize=300%2C300&ssl=1" alt="" class="circle">
      <span class="title">Shobhita Yadav</span>
      <p>Yes i am here </p>
    </li>
      <li class="collection-item avatar">
      <img src="https://i0.wp.com/tricksmaze.com/wp-content/uploads/2017/04/Stylish-Girls-Profile-Pictures-36.jpg?resize=300%2C300&ssl=1" alt="" class="circle">
      <span class="title">Shobhita Yadav</span>
      <p>Thanks..</p>
</li> -->
{{/each}}   
{{/each}}   
  </ul>

      </div>
    </div>
  </div>
  </div>

  {{#each msg_rightbox}}
  <div class="col s12 m9 l9">
     <div class="row bor_top" >
         <div class="col m1"> <img src="./uploads/{{profile_pic}}" width="50" alt="User Avatar" class="img-circle" style="width: 50px;"> </div>
         <div class="col m11" style="margin-top: 7px;"> {{name}}<br/>
                              {{headline}}
         </div>
       </div>
  <div class="card">
   
   
      <div id="test4">
            <div class="col-s12">
                  <div class="chatbody">
                  <div class="panel panel-primary">
                {{#each message_content}}
                <div class="panel-body msg_container_base">
                <!-- {{#if sender}} -->
                    <div class="row msg_container base_sent" id="div_display_msg" >
                        <div class="col-md-12 col-xs-12">
                            <div class="messages msg_sent">
                                <p>{{msg_text}}</p>
                                <time datetime="2009-11-13T20:00">{{sentAt}}</time>
                            </div>
                        </div>
                    </div>
                    <!-- {{else}}
                    <p>nothings</p> -->
                    <!-- {{/if}} -->
                    <!-- {{/if}} -->
                   <!--  {{#if sender2}}
                      <div class="row msg_container base_receive">
                        <div class="col-md-12 col-xs-12">
                            <div class="messages msg_receive text-right">
                                <p>{{msg_text}}</p>
                                <time datetime="2009-11-13T20:00">{{sentAt}}</time>
                            </div>
                        </div>
                    </div>
                    {{/if}} -->
                  <!--   <div class="row msg_container base_receive">
                       
                        <div class="col-md-12 col-xs-12">
                            <div class="messages msg_receive text-right">
                                <p>that mongodb thing looks good, huh?
                                tiny master db, and huge document store</p>
                                <time datetime="2009-11-13T20:00">Timothy • 51 min</time>
                            </div>
                        </div>
                    </div>
                    <div class="row msg_container base_sent">
                        <div class="col-md-12 col-xs-12">
                            <div class="messages msg_sent">
                                <p>that mongodb thing looks good, huh?
                                tiny master db, and huge document store</p>
                                <time datetime="2009-11-13T20:00">51 mins ago</time>
                            </div>
                        </div>
                     
                    </div> -->
                   
                </div>
                {{/each}}
                <div class="panel-footer">
                    <div class="input-controls-container">
                      <form class="form_reset">
                          <textarea class="form-control" placeholder="Add message or image here..." id="msg_text" >
                          </textarea>
                      </form>
            <div class="input-controls margin_top">
                  <div class="btn-group">
                    <span class="text-left">
                    <button class="btn btn-link send_btn">
                        <span class="glyphicon glyphicon-picture"></span>
                    </button>
                   </span>
                   <span class="text-right" style="margin-left: 10px;">
                      <button class="btn btn-link pull-right text-right send_btn" id="send_msg" >
                        <span class="glyphicon glyphicon-send"></span>
                    </button>
                    </span>
                </div>
            </div>
        </div>
                </div>
        </div>

                 </div>
             </div>
           

 
     </div>
  </div>
  </div>
{{/each}}
</div>
</template>

Comments

Popular posts from this blog

Android Commands

meteor run android-device --mobile-server="https://sitename.com" metero build (BUIld Path/home/bird/Downloads/Meteor/bit/uploads ) --server="https://sitename.com"

Using LetsEncrypt to install free SSL on AWS server ec2 machine( Meteor version 1.6)

Installation of meteor project on AWS could be a real headache if you are not familiar with AWS environment. But with the help of various blogs on Medium, you can Do the installation and your project would be live. But there is one more thing that usually causes severe pain for Developers. that is the installation of SSL certificate. Most of the content on the web is almost 2-3 years old. So many things got changed since then. so we felt an utter need for a blog that could guide us through this process. let's start. 1. Login with SSH command on your Ubuntu machine. 2. Go to your project directory by typing cd /var/www/html/ 3. go inside your project and then in app-deploy folder. Now run mup stop command to stop the current instance that is running on the server. Now go out with cd .. command to HTML folder( cd /var/www/html/ ). 4. Now install LetsEncrypt on your virtual machine. type this command git clone https://github.com/letsencrypt/letse...
curl http://localhost:8042/studies/333b2c11-52e9feea-5516186e-ecd61f37-69da2603  curl http://localhost:8042/patients/dc65762c-f476e8b9-898834f4-2f8a5014-2599bc94 bird@bird-Lenovo-ideapad-310-15IKB:/media/bird/2AE477A5E4777245/Meteor/OrthancMirror/build$ curl http://localhost:8042/patients [    "333b2c11-52e9feea-5516186e-ecd61f37-69da2603",    "da39a3ee-5e6b4b0d-3255bfef-95601890-afd80709" ] bird@bird-Lenovo-ideapad-310-15IKB:/media/bird/2AE477A5E4777245/Meteor/OrthancMirror/build$ curl http://localhost:8042/studies [    "9b5629ef-c28c48db-b3593009-35fda9cb-7a0bb799",    "abae0b24-5a718d9e-1b560140-2cda3ae0-30b846cb" ] bird@bird-Lenovo-ideapad-310-15IKB:/media/bird/2AE477A5E4777245/Meteor/OrthancMirror/build$  curl http://localhost:8042/series [    "993a521c-1b11574c-92e1c71d-a048784c-36866be0",    "5f19601c-3e5fa872-e566e9f2-36aa3b31-dc719c3e" ] bird@bird-Lenovo-ideapad-310-15IKB:/med...