This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function paginate(query = {}, options = {}, callback) { | |
const limit = options.limit || 10; | |
let page = options.page || 1; | |
const countQuery = this.find(query).count(); | |
return new Promise(resolve => { | |
countQuery.exec().then(count => { | |
const pages = Math.ceil(count / limit) || 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function post(url, data) { | |
return new Promise((resolve, reject) => { | |
let xhr = new XMLHttpRequest(); | |
xhr.open('POST', url); | |
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); | |
xhr.addEventListener('load', () => { | |
let { response, status } = xhr; | |
let res = JSON.parse(response); | |
if(status >= 200 && status < 400){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
schema.statics = { | |
getSingleton: function (cb) { | |
this.findOne() | |
.sort({ updated: -1 }) | |
.limit(1) | |
.exec((err, model) => { | |
if (err) { | |
cb(err, null); | |
} else if (!model) { | |
cb(err, new this()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const dataURItoBlob = (dataURI, type) => { | |
const byteString = atob(dataURI.split(',')[1]); | |
const ab = new ArrayBuffer(byteString.length); | |
const ia = new Uint8Array(ab); | |
for (let i = 0; i < byteString.length; i++) { | |
ia[i] = byteString.charCodeAt(i); | |
} | |
return new Blob([ab], { | |
type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import classNames from 'classnames'; | |
const ANIMATION_DURATION = 1000; | |
class BatchDropZone extends React.Component { | |
static propTypes = { |
NewerOlder