Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadDataTask = function*({ paginationData, sortData, filterData }) {
yield timeout(250);
let params = {
sortBy: sortData.map((s) => s.prop),
sortDir: sortData.map((s) => s.direction),
pageNumber: paginationData.pageNumber,
pageSize: paginationData.pageSize,
filter: filterData.filter
};
let users = yield this.store.query('user', params);
// we need to inform Yeti Table about the total number of rows
// for pagination to work correctly. Check out the pagination guide.
this.set('totalRows', users.get('meta.totalRows'));
return users;
dirX = -1;
}
// Ember.Logger.log(start, end, `tx:${targetX}, ty:${targetY}, ox:${offsetX}, oy:${offsetY}, ${axis}`)
while (index < steps) {
if (axis === 'x') {
// scroll x axis
scrollTo(eases[index] * targetX * dirX + offsetX, startY);
} else if (axis === 'xy' || axis === 'both') {
// scroll x and y axis
scrollTo(eases[index] * targetX * dirX + offsetX, eases[index] * targetY * dirY + offsetY);
} else {
// scroll y axis
scrollTo(startX, eases[index] * targetY * dirY + offsetY);
}
index++;
yield timeout(delay);
}
}).keepLatest(),
_poll: task(function* () {
let url = this.get('ghostPaths.count');
let pattern = /(-?\d+)(\d{3})/;
try {
let data = yield this.ajax.request(url);
let count = data.count.toString();
while (pattern.test(count)) {
count = count.replace(pattern, '$1,$2');
}
this.set('count', count);
if (config.environment !== 'test') {
yield timeout(2000);
this._poll.perform();
}
} catch (e) {
// no-op - we don't want to create noise for a failed download count
}
})
});
_autosave: task(function* () {
if (!this.get('_canAutosave')) {
return;
}
// force an instant save on first body edit for new posts
if (this.get('post.isNew')) {
return this.get('autosave').perform();
}
yield timeout(AUTOSAVE_TIMEOUT);
this.get('autosave').perform();
}).restartable(),
yield timeout(this.debounce);
let email = this.email;
if (validator.isEmail(email || '')) {
let size = this.size;
let gravatarUrl = `//www.gravatar.com/avatar/${md5(email)}?s=${size}&d=404`;
try {
// HEAD request is needed otherwise jquery attempts to process
// binary data as JSON and throws an error
yield request(gravatarUrl, {type: 'HEAD'});
// gravatar exists so switch style and let browser load it
this._setAvatarImage(gravatarUrl);
// wait for fade-in animation to finish before removing placeholder
yield timeout(ANIMATION_TIMEOUT);
this._setPlaceholderImage('');
} catch (e) {
// gravatar doesn't exist so make sure we're still showing the placeholder
this._setPlaceholderImage(this._defaultImageUrl);
// then make sure the avatar isn't visible
this._setAvatarImage('');
}
}
}).restartable(),
function * taskFn() {
yield timeout(1500);
}
fetchStats: task(function*() {
do {
if (this.stats) {
try {
yield this.get('stats.poll').perform();
this.set('statsError', false);
} catch (error) {
this.set('statsError', true);
}
}
yield timeout(500);
} while (this.enablePolling);
}).drop(),
});
searchModels: withTestWaiter(task(function* (term, options, initialLoad = false) {
let createOption;
if(this.get('withCreate') && term){
createOption = {
__value__: term,
__isSuggestion__: true
};
createOption[this.get('labelProperty')] = this.get('buildSuggestion')
? this.get('buildSuggestion')(term)
: `Add "${term}"...`;
this.set('_options', A([createOption]));
}
if(!initialLoad){
yield timeout(this.get('debounceDuration'));
}
yield this.get('loadModels').perform(term, createOption);
}).restartable()),
stop: task(function * (delay) {
yield timeout(delay);
this.$()[0].pause();
}).drop()
});
save: task(function * (){
this.set('isSaving', true);
yield timeout(10);
this.send('addErrorDisplaysFor', ['title', 'selectedYear']);
let {validations} = yield this.validate();
if (validations.get('isInvalid')) {
this.set('isSaving', false);
return;
}
const commonAjax = this.get('commonAjax');
const courseId = this.get('course.id');
const expandAdvancedOptions = this.get('expandAdvancedOptions');
const year = this.get('selectedYear');
const newCourseTitle = this.get('title');
const selectedCohortIds = this.get('selectedCohorts').mapBy('id');
let newStartDate = moment(this.get('startDate')).format('YYYY-MM-DD');
let skipOfferings = this.get('skipOfferings');