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, { useState, useEffect } from 'react' | |
const Typing = ({ label, showCursor = true, error = false, cb = () => { return true } }) => { | |
const [text, setText] = useState(['']) | |
const [cursor, setCursor] = useState(['']) | |
useEffect(() => { | |
let tempText = [''] | |
let timer1; | |
//set new text every 100ms |
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
// declare machine router files | |
const machines = require('./api/machines'); | |
//Machine Routes | |
app.use('/machines', machines.add); | |
app.use('/machines', machines.update); | |
app.use('/machines', machines.remove); | |
app.use('/machines', machines.get); | |
app.use('/machines', machines.sort); |
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 add = require('./add'); | |
const update = require('./update'); | |
const remove = require('./remove'); | |
const get = require('./get'); | |
const sort = require('./sort'); | |
module.exports = { add, update, remove, get, sort }; |
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 router = require('express').Router(); | |
//middlewares | |
const auth = require('../pathToAuth'); // <- not the actual code, placed for presentation purposes | |
const validate = require('../middleware/validation').validateQuery; | |
const sort = require('../middleware/dbActions').sort; | |
//returns all equipments sorted as requested | |
//endpoint: /machines/sort | |
router.get('/sort',auth, validate, sort , (req, res) => { |
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 collection = db.collection('shortTerm'); | |
// Create a new document with an expiration date, create an Index for expireAt field and specify the expireAfterSeconds value of 60: | |
const addShortTerm = (data, cb = ()=>{return}) => { | |
newData = { | |
type: data.type, | |
category: data.category, | |
make: data.make, | |
model: data.model, | |
rent: data.rent, |
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
//=============convert file to readable URL: good for image previews before uploads===== | |
const fileToUrl = (files, result = [], index = 0) => { | |
let reader = new FileReader(); | |
return new Promise((resolve, reject) => { | |
reader.onerror = () => { | |
reader.abort(); | |
reject(new DOMException("Problem parsing input file.")); | |
}; | |
reader.onload = () => { |
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 {Gallery, GalleryMobile} from './pathToGallery'; | |
//Usage, send an array of image paths or urls as a prop, images will be resized to fit in the frame. | |
// notes: Although gallery has two versions, GalleryMobile and Gallery, the GalleryMobile is optimized for touch devices, | |
// for non touch devices there are so many options out there. | |
const Example= ()=>{ | |
return( | |
<GalleryMobile images={['/katena.png', '/machinerypal.png', '/katena.png']} /> |
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 Buff from './pathToBuff'; | |
//add some styles to the components | |
const Example =()=>{ | |
styles{ | |
div:{ | |
display: 'flex', | |
justifyContent: 'center', | |
alignItems: 'center', |
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
//upload image files to aws s3 bucket with multerS3, and use SHA256 for naming purposes. | |
const upload = multer({ | |
storage: multerS3({ | |
s3: s3, | |
bucket: bucket, | |
acl: 'public-read', | |
key: function (req, file, cb) { | |
cb(null, SHA256(Date.now() + path.basename(file.originalname, path.extname(file.originalname))) + '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
import React from 'react'; | |
import RangeSlider from './pathToRangeSlider'; | |
//There is a prop 'cb' which can be used to retrieve the data from the range slider, by default the cb is the following: | |
//cb={(startValue, endValue) => { console.log('Start=', startValue, ' End=', endValue); }} | |
// Check the console to see the cb in action. | |
// options: | |
// range: [startValue, endValue] | |
// label: string on the left | |
// colorButtonLeft: string |
OlderNewer