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

Meteor JS REST API

WRITE A POST Shahid Shaikh FOLLOW Engineer, Blogger from Mumbai. RESTful CRUD Operations in Meteor.js Published Dec 31, 2015 Last updated Jan 19, 2017 Introduction Meteor is a popular framework for building real-time web applications. We have already covered a tutorial which explains  how to build chat system using Meteor.js . In this tutorial, we will learn how to develop a RESTful API using Meteor which perform CRUD operations. Creating new project Create a new meteor project using the following command: meteor create appName Choose an application name of your choice. Once Meteor is done creating the project, you will see the directories and files created by Meteor in the folder name. We will not need them as of now, so we will delete all of those files and create whatever we need in the coming section. Installing iron-router In order to perform routing in Meteor, we will use  this awesome...

Meteor Mongodb Mup Commands

docker exec -it mongodb mongo docker cp mongodb:dump/ce5-meteor . If deployed with mup, you are in luck. You can find the steps here:  https://github.com/xpressabhi/mup-data-backup Here are the steps again: MongoDB Data Backup deployed via mup These commands run well only if meteor deployed with mup tool. Mup creates docker for mongodb hence taking backup becomes easy with these commands. Backup Take backup of running app data from docker then copy to local folder out of docker. docker exec -it mongodb mongodump --archive= /root/m ongodump. gz --gzip docker cp mongodb : /root/m ongodump. gz mongodump_$ (date +%Y-%m-%d_%H-%M-%S). gz Copy backup to server Move data to another server/local machine or a backup location scp /path/to/dumpfile root@ serverip : /path/ to/backup Delete old data from meteor deployment Get into mongo console running in docker then drop current database before getting new data. docker exec -it mongodb mongo appName db. runCommand ( { dropDatabase : 1 } ) ...