How to get local notification everyday at specific time in ionic? - ionic-framework

I want to get local notification everyday at 10:00 AM .
my code is:
var pushTime = moment().add(0, 'days').hours(10).minutes(0).seconds(0);
cordova.plugins.notification.local.schedule({
id: 1,
text: 'Tracking Enabled ',
trigger: { at: pushTime.toDate() },
every: 'day'
});

Try to use trigger as below:
trigger: {
firstAt: pushTime.toDate(),
every: ELocalNotificationTriggerUnit.DAY
}

let notifications = []
let template = {
data: "value",
id: 1,
title: "daily alarm",
text: 'Code something epic today!',
launch: true,
foreground: true,
trigger: { every: { hour: 10, minute: 0 } },
}
notifications.push(template)
cordova.plugins.notification.local.schedule(notifications);

Related

Nested populate match query

Here is an example of the data I am working with:
// group
{
name: 'Group 1',
phases: [ {name: 'Period 1', startDate: "some date", endDate: "someDate", schedules: [{startTime: '1:00', endTime: '2:00', schedule: 'mongoIdRef'}]}, { name: 'Period 2', startDate: "some date", endDate: "someDate", schedules: []}, { name: 'Period 3', startDate: "some date", endDate: "someDate", schedules: []}, { name: 'Period 4', startDate: "some date", endDate: "someDate", schedules: [] } ]
}
// schedule
{
condition: 'active',
tz: 'US/Mountain',
daysOfWeek: [{startTime: 9, endTime: 22, days: [2,3,4,5]}, {startTime: 2, endTime: 5, days: [2,5,6]}]
}
The group's nested "schedule" property needs to get populated. I am doing this successfully here:
Group.statics.findForDate = function (date) {
date = moment(date);
return this.findForDate({
phases: {
$elemMatch: {
startDate: {$lte: date},
endDate: {$gte: date }
}
}
}).populate( {
{
path: 'phases.schedules.schedule',
match: {'daysOfWeek': { $elemMatch: {days: date.day() } } }
}
})
}
However, the match doesn't match properly. I want to return only groups that have a schedule that has the date.day() (which is a number 0-6) in the days array. How can I get .match to do this? Is there another approach?

Starting a new tour on the end of a tour not working

// Take the tour
takeToTour() {
const tour = {
id: "cryptex-tour",
showPrevButton: true,
i18n: {
closeTooltip: String.fromCharCode(10060)
},
onEnd: () => {
// Clearing cookies for next tour
this.hopscotch.endTour(true);
const endtour = {
id: "tour-later",
i18n: {
closeTooltip: String.fromCharCode(10060)
},
steps: [
{
title: "Access Ticker:",
content: "dummy tour"
target: "later",
placement: "bottom",
xOffset: 40
}
]
}
this.hopscotch.startTour(endtour, 0);
},
steps: [
{
title: "Price Ticker:",
content: "You can navigate between markets and select your desired currency"
target: "marketstour",
placement: "bottom",
xOffset: 40,
delay: 300
},
{
title: "Balances & Wallets:",
content: "You have a separate wallet for each currency"
target: "balancewallettour",
placement: "bottom",
xOffset: 40
},
{
title: "Order Form:",
content: "Order form gives you the number of order types of which market"
target: "orderformtour",
placement: "right",
yOffset: 30
}
]
};
this.hopscotch.startTour(tour, 0);
}
In the above code, I am trying to invoke another hopscotch tour after finishing the first tour. But it is not starting the next tour. Help me know where I went wrong.
Thank you...

Dispatch total of Vue child computed values to parent

I cannot figure out how to use the $dispatch method to send data from a Vue child to a Vue parent. I have a component with multiple instances as follows:
Vue.component('receipt', {
template: '#receipt-template',
data: function() {
return {
tip: ''
};
},
methods: {
addSale: function() {
this.sales.push(
{amount: 1, desc: '', price: 0.00}
);
},
removeSale: function(index) {
this.sales.splice(index, 1)
}
},
computed: {
subtotal: function() {
var result = 0;
this.sales.forEach(function (sale) {
return result += +sale.price;
});
var subtotal = Math.round(100 * result) / 100;
return subtotal.toFixed(2);
},
tax: function() {
var tax = this.subtotal * .08;
return tax.toFixed(2);
},
total: function() {
var total = Number(this.subtotal) + Number(this.tax) + Number(this.tip);
return total.toFixed(2);
this.$dispatch(this.total);
}
},
props: [ 'header', 'date', 'sales' ]
})
And my Vue instance looks like:
var vm = new Vue({
el: '#content',
data: {
sales1: [
{amount: 1, desc: "Dante's Inferno", price: 13.99},
{amount: 1, desc: "Espresso", price: 5.25},
{amount: 1, desc: "The Sun Also Rises", price: 11.99},
{amount: 1, desc: "Spanish Coffee", price: 1.99}
],
sales2: [
{amount: 1, desc: "Huckleberry Finn", price: 14.95},
{amount: 1, desc: "Americano", price: 2.29},
{amount: 1, desc: "Pride & Prejudice", price: 12.95},
{amount: 1, desc: "Black Tea Latte", price: 4.25},
{amount: 1, desc: "Scone", price: 3.25}
],
company: 'Between The Covers & Grinders Cafe'
},
computed: {
grand: function() {
}
}
})
I have multiple instances of the 'Receipt' component and therefore multiple values being computed from the component's computed 'total' function. How can I dispatch the values of the component's instances 'total' functions and get my 'grandtotal' in the parent instance
You have to create a method in your component that 'dispatches' an event, like this:
methods: {
yourMethodName: function(){
this.$dispatch('eventName', data);
}
}
eventName is the name of the event that your app will be expecting and will pick when it's dispatched, the data is just the data that will be available for use when the event is picked.
In your app instance you can just define a prop called 'events' pick the event and do something with it. Like this:
events: {
'eventName': function(data){
//do something with it
}
}
Like this, everytime 'yourMethod' (your component's method) is called it will dispatch the event named 'eventName' and your app will pick and handle it.
Hope that helps!

Using upsert with simpleschema returns null with no collection inserts

Hey guys I'm trying to use Meteor upsert like so.
console.log(vendorReviewArr);
var updateQuery = {$set: {vendorID: vendorIDVal}, $push: {reviews:vendorReviewArr}};
VendorReviews.upsert(
{vendorID: vendorIDVal},
updateQuery,
function(error){
console.log("There is an error!");
console.log(error);
console.log("VENDOR ID: "+vendorIDVal);
}
);
vendorReviewArr looks like this in console.log
{ title: 'This is a test title title title',
body: 'This is a test title body' }
Here is my simpleschema for VendorReviews.
VendorReviews = new Mongo.Collection('vendorsReviews'); //Define the collection.
VendorReviewObjSchema = new SimpleSchema({
authorID: {
type: String,
label: "authorID",
autoValue: function(){
return this.userId
},
optional: true
},
title: {
type: String,
label: "title",
min: 25,
},
body: {
type: String,
label: "body",
min: 25,
max: 1000
}
});
VendorReviewsSchema = new SimpleSchema({
vendorID: {
type: String,
label: "vendorID HERE",
},
reviews : {
type : [VendorReviewObjSchema],
label : "Vendor Reviews",
optional: true
}
});
VendorReviews.attachSchema(VendorReviewsSchema);
Now for some reason when this method is called from the server the collection doesn't record any data. All I see is
I20160110-23:54:38.031(-5)? There is an error!
I20160110-23:54:38.032(-5)? null
I20160110-23:54:38.032(-5)? VENDOR ID: iXdqzcSNmMwrRj3jf
Checking the collection in mongo shell shows no data.
Can anyone help me out with this please? Thank you for reading.

How Do I Create Multiple Header Rows Using Footable & AJAX

I would like to create footables that have multiple header rows and am having no luck doing this. I'm using a combination of web services/json to pull in my headers and data from a SQL database.
The code below works great but obviously produces just one header row:
function loadTable() {
$('#eocScreen').footable({
ajaxEnabled: true,
sorting: {
enabled: false
},
paging: {
enabled: false,
total: rowData.length,
size: 15,
current: parseInt(FooTable.utils.getURLParameter('page')) || 1
},
filtering: {
enabled: false
},
//columns: colIndex,
columns: {
0: {name: 'locationName', title: 'school' },
1: { name: 'graduate', title: 'Number of Graduates' }
},
ajax: FAjax.request
})
}
I've tried various methods to add a second row, but I'm just not skilled enough to figure it out at this point...a couple of things I've tried are:
columns: {
0: {name: 'locationName', title: 'school' },
1: { name: 'graduate', title: 'Number of Graduates' }
}
{
0: { title: 'loc' },
1: { title: 'seniors' }
},
columns: [{
0: {name: 'locationName', title: 'school' },
1: { name: 'graduate', title: 'Number of Graduates' }
},
{
0: { title: 'loc' },
1: { title: 'seniors' }
}],
Any help would be greatly appreciated!!