Exemplo n.º 1
7
 'deleteListItem': function(documentId) {
   var currentUser = Meteor.userId();
   var data = {
     _id: documentId,
     createdBy: currentUser
   }
   if (!currentUser) {
     throw new Meteor.Error("not-logged-in", "You're not logged in.");
   }
   return Todos.remove(data);
 }
Exemplo n.º 2
0
    Meteor.publish("depts.findYear", function (year) {
        console.log(year)
        var self = this
        if (year !== undefined) {
            data = Depts.find({
                "année": year
            }, {
                fields: {
                    "année": 1,
                    "nom": 1,
                    "population": 1
                }
            });
            console.log(data.fetch().length)
            data.forEach(function (depts) {
                self.added("depts.list", depts._id, depts)
            });
            return data;
        } else {
            data = Depts.find({}, {
                fields: {
                    "année": 1,
                    "nom": 1,
                    "population": 1
                }
            });
        }
        self.ready();

    });   
Exemplo n.º 3
0
        tabular: function(tbl_id) {
            let qs = GenotoxHumanExposureEvidence.getTableEvidence(tbl_id),
                header = GenotoxHumanExposureEvidence.getTabularHeader(),
                data;

            data = _.chain(qs)
                    .map(function(d){
                        return GenotoxHumanExposureEvidence.getTabularRow(d);
                    }).flatten(true)
                    .value();
            data.unshift(header);
            return data;
        },
Exemplo n.º 4
0
 'completeListItem': function(documentId, isCompleted) {
   check(isCompleted, Boolean);
   var currentUser = Meteor.userId();
   var data = {
     _id: documentId,
     createdBy: currentUser
   }
   if (!currentUser) {
     throw new Meteor.Error("not-logged-in", "You're not logged in.");
   }
   if (isCompleted) {
     return Todos.update(data, {$set: {completed: false}});
   } else {
     return Todos.update(data, {$set: {completed: true}});
   }
 },
Exemplo n.º 5
0
    getCurrentCoordinates(function(position){
      var lat = position.coords.latitude;
      var long = position.coords.longitude;

      // iterate over only doc with lat/long
      if(HostedPlaylists.find().count() !== 0){
        var count = 0;
        NearbyPlaylists.remove({}); // clear
        HostedPlaylists.find({latitude: { $exists: true }}, {longitude: { $exists: true }}).forEach(function (row) {
            if(row){
              var distance = getDistanceFromLatLonInMiles(lat, long, row.latitude, row.longitude);
              if(distance < /* max miles */ 3){
                var roundedDistance = Math.round( distance * 10 ) / 10;
                NearbyPlaylists.insert({name: row.name, publicId: row.publicId, distanceInMiles: roundedDistance, dateCreated: row.dateCreated});
                count++;
              }
            }
        }); 

        if(count > 0){
          $("#nearby-button").text("Nearby playlists");
          $(".playlists-container").show();
        }
        else{
          $("#nearby-button").html("No playlists nearby");
        }
      }
      else{
        $("#nearby-button").html("No playlists");
      }

    },function(error){
Exemplo n.º 6
0
function defaultName(currentUser) {
    var nextLetter = 'A'
    var nextName = 'Untitled List ' + nextLetter;
    while (Lists.findOne({ name: nextName, createdBy: currentUser })) {
        nextLetter = String.fromCharCode(nextLetter.charCodeAt(0) + 1);
        nextName = 'Untitled List ' + nextLetter;
    }
    return nextName;
}
Exemplo n.º 7
0
 HostedPlaylists.find({latitude: { $exists: true }}, {longitude: { $exists: true }}).forEach(function (row) {
     if(row){
       var distance = getDistanceFromLatLonInMiles(lat, long, row.latitude, row.longitude);
       if(distance < /* max miles */ 3){
         var roundedDistance = Math.round( distance * 10 ) / 10;
         NearbyPlaylists.insert({name: row.name, publicId: row.publicId, distanceInMiles: roundedDistance, dateCreated: row.dateCreated});
         count++;
       }
     }
 }); 
Tracker.autorun(function () {
  if (Meteor.subscribe('__ddp-messages__').ready()) {
    const doc = messages.findOne();
    if (!doc) return;
    if (!map[doc.name]) {
      map[doc.name] = new ReactiveVar();
    }
    map[doc.name].set(doc.data);
  }
})
Exemplo n.º 9
0
 'createListItem': function(todoName, currentList) {
   check(todoName, String);
   check(currentList, String);
   var currentUser = Meteor.userId();
   var data = {
     name: todoName,
     completed: false,
     createdAt: new Date(),
     createdBy: currentUser,
     listId: currentList
   }
   if (!currentUser) {
     throw new Meteor.Error("not-logged-in", "You're not logged in.");
   }
   var currentList = Lists.findOne(currentList);
   if (currentList.createdBy != currentUser) {
     throw new Meteor.Error("invalid-user", "You don't own that list");
   }
   return Todos.insert(data);
 },
Exemplo n.º 10
0
 'editListItem': function(documentId, todoItem) {
   check(todoItem, String);
   var currentUser = Meteor.userId();
   var data = {
     _id: documentId,
     createdBy: currentUser
   }
   if (!currentUser) {
     throw new Meteor.Error("not-logged-in", "You're not logged in.");
   }
   return Todos.update(data, {$set: { name: todoItem }});
 },
Exemplo n.º 11
0
	'keypress textarea': function(e, instance){
		if(e.keyCode == 13) {
			e.preventDefault();
			var value = instance.find('textarea').value;
			instance.find('textarea').value = '';

			Messages.insert({
				message: value,
				timestamp: new Date(),
				user: Meteor.userId()
			});
		}
	}
Exemplo n.º 12
0
 'createNewList': function(listName){
   var currentUser = Meteor.userId();
   check(listName, String);
   if(listName == ""){
   listName = defaultName(currentUser);
   }
   var data = {
     name: listName,
     createdBy: currentUser
   }
   if(!currentUser){
     throw new Meteor.Error("not-logged-in", "You're not logged-in.");
   }
   return Lists.insert(data);
 },
Exemplo n.º 13
0
 Meteor.publish("depts.list",function () {
     var self = this;
     var data = Depts.find({}, {
         fields: {
             "année": 1,
             "code": 1,
             "nom": 1,
             "population": 1
         }
     });
     data.forEach(function(depts, index){
         self.added("depts.list", depts._id, depts)
     });
     console.log(data.fetch().length)
     return data;
     self.ready();
 });
Exemplo n.º 14
0
        wordContext: function(tbl_id){
            var tbl = Tables.findOne(tbl_id),
                rows = GenotoxHumanExposureEvidence.find(
                    {tbl_id: tbl_id, isHidden: false},
                    {sort: {sortIdx: 1}}
                ).fetch();

            rows.forEach((d) => {
                d.getReference();
                d.getResults();
            });

            return {
                table: tbl,
                objects: rows,
            };
        },
Exemplo n.º 15
0
Meteor.publish('lists', function(){
  var currentUser = this.userId;
  return Lists.find({ createdBy: currentUser });
});
Exemplo n.º 16
0
// data model
// Loaded on both the client and the server
import { Meteor } from 'meteor/meteor'
import { isSandstorm } from './init/sandstorm'
import { FS, SimpleSchema } from '../lib/globals-lib'

export let SettingsToClient = new Meteor.Collection('settings_to_client')
export let NeuronCatalogConfig = new Meteor.Collection('neuron_catalog_config')
export let DriverLines = new Meteor.Collection('driver_lines')
export let BinaryData = new Meteor.Collection('binary_data')
export let NeuronTypes = new Meteor.Collection('neuron_types')
export let BrainRegions = new Meteor.Collection('brain_regions')
export let ArchiveFileStore = new FS.Collection('archive_filestore', {
  stores: [new FS.Store.GridFS('archive_gridfs')]
})
export let CacheFileStore = new FS.Collection('cache_filestore', {
  stores: [new FS.Store.GridFS('cache_gridfs')]
})

let store_opts = {}
if (Meteor.isServer && isSandstorm()) {
  store_opts.path = process.env.TEMP_UPLOADS_DIR || '/var'
}
export const UploadTempStoreName = 'uploaded_temp_files'
export let UploadedTempFileStore = new FS.Collection('upload_temp_filestore', {
  stores: [new FS.Store.FileSystem(UploadTempStoreName, store_opts)]
})

// ----------------------------------------
export let ReaderRoles = ['read', 'admin']
export let WriterRoles = ['write', 'admin']
Exemplo n.º 17
0
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';

export const Posts = new Meteor.Collection('posts');

if(Meteor.isServer) {
  Posts.remove({});
  Posts.insert({
    _id: 'one', title: 'New Meteor Rocks', content: 'Yeah! Check our Meteor Blog for more!'
  });
  Posts.insert({_id: 'two', title: 'MeteorHacks + Kadira => Kadira++', content: 'Something new soon.'});
  Posts.insert({_id: 'three', title: 'My Secret Post', category: 'private'});
}
Exemplo n.º 18
0
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { _ } from 'meteor/underscore';
import { moment } from 'meteor/momentjs:moment';
import { Router } from 'meteor/iron:router';

export const Events = new Meteor.Collection("events", {idGeneration : 'MONGO'});

//schemas
import { Countries_SELECT,Countries_SELECT_LABEL,PostalAddress,GeoCoordinates,GeoPosition } from './schema.js'

//collection
import { Lists } from './lists.js'

export const SchemasEventsRest = new SimpleSchema({
    name : {
      type : String
    },
    type : {
      type : String,
      autoform: {
        type: "select",
        options: function () {
          if (Meteor.isClient) {
            let listSelect = Lists.findOne({name:'eventTypes'});
            if(listSelect && listSelect.list){
              return _.map(listSelect.list,function (value,key) {
                return {label: value, value: key};
              });
            }
Exemplo n.º 19
0
 Meteor.publish("getManagedRepos", function() {
     return ManagedRepos.find({ owner: this.userId });
 });
Exemplo n.º 20
0
 Meteor.publish("getBuildLogs", function() {
     return BuildLogs.find({ owner: this.userId });
 });
Exemplo n.º 21
0
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { check } from 'meteor/meteor'
export const Tweets = new Meteor.Collection("tweets");

if (Meteor.isServer) {
  Meteor.startup(function() {
    // code to run on server at startup
  });
}


Meteor.methods({

  'tweets.insert'(text){
    if(! this.userId){
      throw new Meteor.Error('You are not logged in');
    }

     Tweets.insert({
       message: text,
       createdAt: new Date(),
       user: Meteor.user().username
     });
  }

});
Exemplo n.º 22
0
 Fiber(function() {
     BuildLogs.update({ _id: docId }, { $push: { 'logs': "" + data + "\n\n" } })
 }).run();
Exemplo n.º 23
0
	messages: function(){
		return Messages.find()
	}
Exemplo n.º 24
0
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
import { _ } from 'meteor/underscore';

//Person
export const Citoyens = new Meteor.Collection("citoyens", {idGeneration : 'MONGO'});

//schemas
import { PostalAddress,GeoCoordinates,GeoPosition,linksCitoyens } from './schema.js'

//Social
const socialNetwork = new SimpleSchema({
  facebook: {
    type : String,
    optional: true
  },
  twitter: {
    type : String,
    optional: true
  },
  github: {
    type : String,
    optional: true
  },
  skype: {
    type : String,
    optional: true
  }
});
Exemplo n.º 25
0
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { buildNameObject } from '../lib/utils';

const Groups = new Meteor.Collection('groups');

Meteor.methods({
	'Groups.new'(title){
		if(!this.userId){ throw new Meteor.Error('not-authorized'); }

		check(title, String);

		return Groups.insert({
			title: title,
			creator: this.userId,
			createdAt: new Date()
		});
	}
});

export default Groups;
Exemplo n.º 26
0
import { Meteor } from 'meteor/meteor';
import SimpleSchema from 'simpl-schema';

const Missions = new Meteor.Collection('missions');

Missions.attachSchema(new SimpleSchema({
  deleted: Date,
  created: Date,
  approved: Date,
  sent: Date,
  finished: Date,
  specificationId: String,
  userId: String,
  isTrial: Boolean,
  isLastMission: Boolean,
  isLongMission: Boolean,
  start: Date,
  end: Date,
}, { requiredByDefault: false }));

export default Missions;
Exemplo n.º 27
0
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { Session } from 'meteor/session';
import { FlowRouter } from 'meteor/kadira:flow-router';

import { HostedPlaylists } from './api/hosted-playlists.js';

import './services/geolocator.js';

import './join-jukebox.html';

// storing playlists in a client-side meteor collection so they can load and be rendered dynamically (i.e. won't block page load)
var NearbyPlaylists = new Meteor.Collection(null);

Template.join_page.onRendered(function playPageOnCreated() {
  this.subscribe('publicPlaylists');
});

Template.join_page.helpers({
  nearbyPlaylists(){
    return NearbyPlaylists.find({}, {sort: { distanceInMiles: 1, dateCreated: -1 }});
  }
});

Template.join_page.events({
  'click #js-party-joiner'() {

  	var playlistId = parseInt($('#playlist-id').val(), 10);
    var playlist = HostedPlaylists.findOne({publicId: playlistId});

    if(!playlist){
Exemplo n.º 28
0
 parser.parseString(data, function(err, result) {
     if (!err) {
         BuildLogs.update({ _id: docId }, { $set: parseResult(result) });
     }
 });
Exemplo n.º 29
0
            function handleLastCommit(commit) {
                //Insert a new build log
                var data = {
                    "repoId": activeApp._id,
                    "owner": Meteor.userId(),
                    "started": new Date(),
                    "status": "running",
                    "author": commit.commit.author.name,
                    "revision": commit.sha,
                    "commit_message": commit.commit.message,
                    "logs": []
                }
                BuildLogs.insert(data, function(error, docId) {
                    //build exec steps
                    if (docId) {
                        var home = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
                        var buildLocation = home + "/mutatebuilds/" + docId;
                        shell.mkdir("-p", buildLocation);
                        shell.exec("git clone " + activeApp.clone_url + " " + buildLocation, function(code, stdout, stderr) {
                            if (code == 0) {
                                var mutationSettings = JSON.parse(shell.cat(buildLocation + "/mut-settings.json"));
                                //prepare config string
                                var config = [
                                    'sourceRootDir="' + buildLocation + '";',
                                    'executablePath="' + docId + "/" + mutationSettings.executable + '";',
                                    'source=' + (JSON.stringify(mutationSettings.source).replace("[", "(").replace("]", ")")) + ";",
                                    'testingFramework="' + mutationSettings.testingFramework + '";',
                                    'CuTestLibSource="' + mutationSettings.CuTestLibSource + '";'
                                ]
                                shell.exec("touch " + buildLocation + "/config.cfg", function(code, stdout, stderr) {
                                    _.each(config, function(c) {
                                        var sc = ShellString(c + "\n");
                                        sc.toEnd(buildLocation + "/config.cfg");
                                    })

                                    bash = spawn('bash', [home + "/runMutation.sh", docId]);

                                    bash.stdout.on('data', function(data) {
                                        Fiber(function() {
                                            BuildLogs.update({ _id: docId }, { $push: { 'logs': "" + data + "\n\n" } })
                                        }).run();
                                    });

                                    bash.on('exit', function(code) {
                                        if (code == 0) {
                                            var resultsLocation = home + "/mutatebuilds/exec_" + docId + '/gstats.xml';
                                            var parser = new xml2js.Parser();
                                            fs.readFile(resultsLocation, function(err, data) {
                                                if (!err) {
                                                    Fiber(function() {
                                                        parser.parseString(data, function(err, result) {
                                                            if (!err) {
                                                                BuildLogs.update({ _id: docId }, { $set: parseResult(result) });
                                                            }
                                                        });
                                                    }).run();
                                                }
                                            });
                                        }
                                    });
                                });
                            }
                        });
                    }
                });
            }
Exemplo n.º 30
0
import { Meteor } from 'meteor/meteor'

var CurrentData = new Meteor.Collection("CurrentData", {
  transform: function(doc){
    return doc;
  }
});
var FastData = new Meteor.Collection("fast_market_data");
var FeedsVwap = require("/imports/api/vwap/collections").feedsVwap;
var Metrics = new Meteor.Collection('Metrics')
var Extras = new Meteor.Collection("extras")
var MarketData = new Meteor.Collection("MarketData")
var AcountsHistory = new Meteor.Collection("accountsHistory")
var AddressesLists = new Meteor.Collection("AdressesLists")
var Addresses = new Meteor.Collection("Addresses")

if (Meteor.isServer) {
  AcountsHistory._ensureIndex({
    timestamp: -1
  });

  AcountsHistory._ensureIndex({
    refId: 1, timestamp: -1
  });

  AcountsHistory._ensureIndex({
    accountId: 1, timestamp: -1
  });
}

AcountsHistory.allow({