Merge branch 'siddhant1-feature'
This commit is contained in:
commit
5710ebf414
6 changed files with 35 additions and 25 deletions
|
@ -1,13 +1,13 @@
|
|||
import format from 'date-fns/format';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import moment from 'moment';
|
||||
import { Link, browserHistory } from 'react-router';
|
||||
import InlineSVG from 'react-inlinesvg';
|
||||
import { Helmet } from 'react-helmet';
|
||||
import * as SketchActions from '../actions/projects';
|
||||
import InlineSVG from 'react-inlinesvg';
|
||||
import { connect } from 'react-redux';
|
||||
import { browserHistory, Link } from 'react-router';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import * as ProjectActions from '../actions/project';
|
||||
import * as SketchActions from '../actions/projects';
|
||||
import * as ToastActions from '../actions/toast';
|
||||
|
||||
const trashCan = require('../../../images/trash-can.svg');
|
||||
|
@ -73,8 +73,8 @@ class SketchList extends React.Component {
|
|||
})()}
|
||||
</td>
|
||||
<th scope="row"><Link to={`/${username}/sketches/${sketch.id}`}>{sketch.name}</Link></th>
|
||||
<td>{moment(sketch.createdAt).format('MMM D, YYYY h:mm A')}</td>
|
||||
<td>{moment(sketch.updatedAt).format('MMM D, YYYY h:mm A')}</td>
|
||||
<td>{format(new Date(sketch.createdAt), 'MMM D, YYYY h:mm A')}</td>
|
||||
<td>{format(new Date(sketch.updatedAt), 'MMM D, YYYY h:mm A')}</td>
|
||||
</tr>)}
|
||||
</tbody>
|
||||
</table>}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import classNames from 'classnames';
|
||||
import differenceInMilliseconds from 'date-fns/difference_in_milliseconds';
|
||||
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import moment from 'moment';
|
||||
import classNames from 'classnames';
|
||||
|
||||
class Timer extends React.Component {
|
||||
constructor(props) {
|
||||
|
@ -20,16 +21,19 @@ class Timer extends React.Component {
|
|||
}
|
||||
|
||||
showSavedTime() {
|
||||
if (Math.abs(moment().diff(this.props.projectSavedTime)) < 10000) {
|
||||
const now = new Date();
|
||||
if (Math.abs(differenceInMilliseconds(now, this.props.projectSavedTime) < 10000)) {
|
||||
return 'Saved: just now';
|
||||
} else if (Math.abs(moment().diff(this.props.projectSavedTime)) < 20000) {
|
||||
} else if (differenceInMilliseconds(now, this.props.projectSavedTime) < 20000) {
|
||||
return 'Saved: 15 seconds ago';
|
||||
} else if (Math.abs(moment().diff(this.props.projectSavedTime)) < 30000) {
|
||||
} else if (differenceInMilliseconds(now, this.props.projectSavedTime) < 30000) {
|
||||
return 'Saved: 25 seconds ago';
|
||||
} else if (Math.abs(moment().diff(this.props.projectSavedTime)) < 46000) {
|
||||
} else if (differenceInMilliseconds(now, this.props.projectSavedTime) < 46000) {
|
||||
return 'Saved: 35 seconds ago';
|
||||
}
|
||||
return `Saved: ${moment(this.props.projectSavedTime).fromNow()}`;
|
||||
return `Saved: ${distanceInWordsToNow(this.props.projectSavedTime, {
|
||||
includeSeconds: true
|
||||
})} ago`;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -3442,6 +3442,11 @@
|
|||
"semver": "^5.5.0"
|
||||
}
|
||||
},
|
||||
"date-fns": {
|
||||
"version": "1.30.1",
|
||||
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.30.1.tgz",
|
||||
"integrity": "sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw=="
|
||||
},
|
||||
"date-now": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz",
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
"cors": "^2.8.5",
|
||||
"cross-env": "^5.2.0",
|
||||
"csslint": "^0.10.0",
|
||||
"date-fns": "^1.30.1",
|
||||
"decomment": "^0.8.7",
|
||||
"dotenv": "^2.0.0",
|
||||
"dropzone": "^4.3.0",
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import each from 'async/each';
|
||||
import moment from 'moment';
|
||||
|
||||
import isBefore from 'date-fns/is_before';
|
||||
import Project from '../models/project';
|
||||
import { resolvePathToFile } from '../utils/filePath';
|
||||
import { deleteObjectsFromS3, getObjectKey } from './aws.controller';
|
||||
|
@ -56,7 +55,7 @@ function deleteMany(files, ids) {
|
|||
each(ids, (id, cb) => {
|
||||
if (files.id(id).url) {
|
||||
if (!process.env.S3_DATE
|
||||
|| (process.env.S3_DATE && moment(process.env.S3_DATE) < moment(files.id(id).createdAt))) {
|
||||
|| (process.env.S3_DATE && isBefore(new Date(process.env.S3_DATE), new Date(files.id(id).createdAt)))) {
|
||||
const objectKey = getObjectKey(files.id(id).url);
|
||||
objectKeys.push(objectKey);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import archiver from 'archiver';
|
||||
import request from 'request';
|
||||
import moment from 'moment';
|
||||
import format from 'date-fns/format';
|
||||
import isUrl from 'is-url';
|
||||
import slugify from 'slugify';
|
||||
import jsdom, { serializeDocument } from 'jsdom';
|
||||
import { resolvePathToFile } from '../utils/filePath';
|
||||
import generateFileSystemSafeName from '../utils/generateFileSystemSafeName';
|
||||
import isBefore from 'date-fns/is_before';
|
||||
import request from 'request';
|
||||
import slugify from 'slugify';
|
||||
import Project from '../models/project';
|
||||
import User from '../models/user';
|
||||
import { resolvePathToFile } from '../utils/filePath';
|
||||
import generateFileSystemSafeName from '../utils/generateFileSystemSafeName';
|
||||
import { deleteObjectsFromS3, getObjectKey } from './aws.controller';
|
||||
|
||||
export function createProject(req, res) {
|
||||
|
@ -109,7 +110,7 @@ export function getProject(req, res) {
|
|||
function deleteFilesFromS3(files) {
|
||||
deleteObjectsFromS3(files.filter((file) => {
|
||||
if (file.url) {
|
||||
if (!process.env.S3_DATE || (process.env.S3_DATE && moment(process.env.S3_DATE) < moment(file.createdAt))) {
|
||||
if (!process.env.S3_DATE || (process.env.S3_DATE && isBefore(new Date(process.env.S3_DATE), new Date(file.createdAt)))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +292,7 @@ function buildZip(project, req, res) {
|
|||
res.status(500).send({ error: err.message });
|
||||
});
|
||||
|
||||
const currentTime = moment().format('YYYY_MM_DD_HH_mm_ss');
|
||||
const currentTime = format(new Date(), 'YYYY_MM_DD_HH_mm_ss');
|
||||
project.slug = slugify(project.name, '_');
|
||||
res.attachment(`${generateFileSystemSafeName(project.slug)}_${currentTime}.zip`);
|
||||
zip.pipe(res);
|
||||
|
|
Loading…
Reference in a new issue