Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Commit

Permalink
Version 2.1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya.P committed Sep 17, 2018
1 parent eae54a9 commit a143182
Show file tree
Hide file tree
Showing 28 changed files with 94 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import MediaQuery from 'react-responsive'
import classes from './SearchInput.scss'

class SearchInput extends Component {
static timeoutId = null

componentDidMount() {
this.refs.search_input.focus()
}
Expand All @@ -34,7 +32,7 @@ class SearchInput extends Component {
<SearchIcon style={{ color: 'white', height: '100%' }} onTouchTap={() => search(0, query)} />
</div>
<div style={{ display: 'flex', alignItems: 'center', width: '100%' }} >
<TextField
<TextField
ref='search_input'
name='search_input'
fullWidth={true}
Expand All @@ -43,25 +41,17 @@ class SearchInput extends Component {
hintStyle={{ color: '#EEEEEE' }}
hintText={hintText}
spellCheck={false}
value={query}
value={query}
onKeyPress={(event) => {
if (event.charCode === 13) {
search(0, query)
return
}
}}
onKeyDown={(event) => {
clearTimeout(this.timeoutId)
}}
onChange={(event, newValue) => {
clearTimeout(this.timeoutId)
setQuery(newValue)

this.timeoutId = setTimeout(() => {
search(0, newValue)
}, 500)
}}
underlineShow={false}
}}
underlineShow={false}
/>
</div>
</div>
Expand Down
17 changes: 7 additions & 10 deletions FrontEnd/src/index.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<!doctype html>
<html lang="en">

<head>
<title>Loading...</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#00bcd4">
<meta name="apple-mobile-web-app-title" content="Ambar">
<meta name="application-name" content="Ambar">
<meta name="theme-color" content="#ffffff">
<!-- start Mixpanel -->
<script type="text/javascript">(function(e,a){if(!a.__SV){var b=window;try{var c,l,i,j=b.location,g=j.hash;c=function(a,b){return(l=a.match(RegExp(b+"=([^&]*)")))?l[1]:null};g&&c(g,"state")&&(i=JSON.parse(decodeURIComponent(c(g,"state"))),"mpeditor"===i.action&&(b.sessionStorage.setItem("_mpcehash",g),history.replaceState(i.desiredHash||"",e.title,j.pathname+j.search)))}catch(m){}var k,h;window.mixpanel=a;a._i=[];a.init=function(b,c,f){function e(b,a){var c=a.split(".");2==c.length&&(b=b[c[0]],a=c[1]);b[a]=function(){b.push([a].concat(Array.prototype.slice.call(arguments,
0)))}}var d=a;"undefined"!==typeof f?d=a[f]=[]:f="mixpanel";d.people=d.people||[];d.toString=function(b){var a="mixpanel";"mixpanel"!==f&&(a+="."+f);b||(a+=" (stub)");return a};d.people.toString=function(){return d.toString(1)+".people (stub)"};k="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
for(h=0;h<k.length;h++)e(d,k[h]);a._i.push([b,c,f])};a.__SV=1.2;b=e.createElement("script");b.type="text/javascript";b.async=!0;b.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";c=e.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c)}})(document,window.mixpanel||[]);
</script>
<!-- end Mixpanel -->
<meta name="theme-color" content="#ffffff">
</head>

<body>
<div id="root" style="height: 100%"></div>
<div id="root" style="height: 100%"></div>
</body>
</html>

</html>
25 changes: 15 additions & 10 deletions FrontEnd/src/routes/CoreLayout/modules/CoreLayout.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { titles, stateValueExtractor, urls, constants, analytics } from 'utils'
import { titles, stateValueExtractor, urls, constants } from 'utils'
import 'whatwg-fetch'

const CHANGE_FIELD = 'CORE.CHANGE_FIELD'
Expand All @@ -22,10 +22,7 @@ export const loadConfig = () => {
const urls = stateValueExtractor.getUrls(getState())

dispatch(changeField('version', apiInfo.version))
dispatch(changeField('lang', apiInfo.uiLang))

analytics(apiInfo.analyticsToken)
analytics().register({ apiUrl: urls.apiHost })
dispatch(changeField('lang', apiInfo.uiLang))

})
.then(() => dispatch(stopLoadingIndicator()))
Expand Down Expand Up @@ -56,23 +53,32 @@ const stopLoadingIndicator = () => {

const getApiUrl = () => new Promise((resolve, reject) => {
fetch('apiUrl.txt', {
method: 'GET'
method: 'GET',
mode: 'cors',
credentials: 'include',
cache: 'no-cache'
})
.then(resp => resolve(resp.text()))
.catch(err => reject(err))
})

const getLocalizationsJson = () => new Promise((resolve, reject) => {
fetch('localizations.json', {
method: 'GET'
method: 'GET',
mode: 'cors',
credentials: 'include',
cache: 'no-cache'
})
.then(resp => resolve(resp.text()))
.catch(err => reject(err))
})

const getWebApiInfo = (url) => new Promise((resolve, reject) => {
fetch(url, {
method: 'GET'
method: 'GET',
mode: 'cors',
credentials: 'include',
cache: 'no-cache'
})
.then(resp => resolve(resp.json()))
.catch(err => reject(err))
Expand All @@ -88,8 +94,7 @@ export function showInfo(message) {
export function handleError(error, showErrorMessage = false) {
if (error.constructor === Response) {
error = `Response ${error.status} ${error.statusText} at ${error.url}`
}
analytics().event('ERROR', { description: error ? error.toString() : 'no info' })
}
console.log(error)

return {
Expand Down
5 changes: 2 additions & 3 deletions FrontEnd/src/routes/MainLayout/modules/MainLayout.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { urls, titles, stateValueExtractor, analytics } from 'utils'
import { urls, titles, stateValueExtractor } from 'utils'
import { push } from 'react-router-redux'
import { handleError } from 'routes/CoreLayout/modules/CoreLayout'

Expand Down Expand Up @@ -43,8 +43,7 @@ export function stopLoadingIndicator() {

export const toggleRateUsModal = (value) => {
return (dispatch, getState) => {
dispatch(changeField('showRateUsModal', value))
analytics().event('ACCOUNT.RATE_US_MODAL_OPENED')
dispatch(changeField('showRateUsModal', value))
}
}

Expand Down
2 changes: 0 additions & 2 deletions FrontEnd/src/routes/SearchPage/modules/DetailedView.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { stateValueExtractor } from 'utils/'
import { hitsModel } from 'models/'
import { analytics } from 'utils'
import { handleError } from 'routes/CoreLayout/modules/CoreLayout'
import { startLoadingIndicator, stopLoadingIndicator } from 'routes/MainLayout/modules/MainLayout'

Expand All @@ -25,7 +24,6 @@ export const loadHighlight = (fileId, query) => {
.then((resp) => {
dispatch(setContentHighlight(fileId, hitsModel.contentHighlightFromApi(resp)))
dispatch(startStopHighlightLoadingIndicator(fileId, false))
analytics().event('SEARCH.LOAD_HIGHLIGHT')
})
.catch((errorPayload) => {
dispatch(startStopHighlightLoadingIndicator(fileId, false))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { stateValueExtractor, analytics } from 'utils'
import { stateValueExtractor } from 'utils'
import { hitsModel } from 'models/'
import { handleError } from 'routes/CoreLayout/modules/CoreLayout'
import { startLoadingIndicator, stopLoadingIndicator } from 'routes/MainLayout/modules/MainLayout'
Expand All @@ -18,7 +18,6 @@ export const hideFile = (fileId) => {
})
.then(resp => {
if (resp.status == 200) {
analytics().event('FILE.HIDE')
return
}
else { throw resp }
Expand All @@ -43,7 +42,6 @@ export const showFile = (fileId) => {
})
.then(resp => {
if (resp.status == 200) {
analytics().event('FILE.SHOW')
return
}
else { throw resp }
Expand Down
4 changes: 0 additions & 4 deletions FrontEnd/src/routes/SearchPage/modules/ImagePreview.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { analytics } from 'utils'

export const TOGGLE_IMAGE_PREVIEW_MODAL = 'IMAGE_PREVIEW.TOGGLE_IMAGE_PREVIEW_MODAL'

export const toggleImagePreview = (imageUrl) => {
analytics().event('IMAGE_PREVIEW.TOGGLE_IMAGE_PREIVEW')

return {
type: TOGGLE_IMAGE_PREVIEW_MODAL,
imageUrl
Expand Down
1 change: 0 additions & 1 deletion FrontEnd/src/routes/SearchPage/modules/SearchPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { analytics } from 'utils'
import { handleError } from 'routes/CoreLayout/modules/CoreLayout'
import { search, updateQuery } from 'routes/SearchPage/modules/SearchReducer'

Expand Down
6 changes: 2 additions & 4 deletions FrontEnd/src/routes/SearchPage/modules/SearchReducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { stateValueExtractor, constants, titles, analytics } from 'utils/'
import { stateValueExtractor, constants, titles } from 'utils/'
import { hitsModel, folderHitsModel } from 'models/'
import { handleError } from 'routes/CoreLayout/modules/CoreLayout'
import { startLoadingIndicator, stopLoadingIndicator } from 'routes/MainLayout/modules/MainLayout'
Expand Down Expand Up @@ -154,9 +154,7 @@ const performSearch = (page, query) => {
const hasMore = (hits.size > 0)
const clean = (page == 0)
dispatch(stopLoadingIndicator())
dispatch(fillHits(clean, hits, data.found, query, hasMore, page))

if (page === 0) { analytics().event('SEARCH.PERFORM', { query: query }) }
dispatch(fillHits(clean, hits, data.found, query, hasMore, page))
})
.catch((errorPayload) => {
dispatch(stopLoadingIndicator())
Expand Down
8 changes: 3 additions & 5 deletions FrontEnd/src/routes/SearchPage/modules/TagsReducer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { stateValueExtractor, constants, analytics } from 'utils/'
import { stateValueExtractor, constants } from 'utils/'
import { hitsModel } from 'models/'
import { handleError } from 'routes/CoreLayout/modules/CoreLayout'
import { startLoadingIndicator, stopLoadingIndicator } from 'routes/MainLayout/modules/MainLayout'
Expand Down Expand Up @@ -52,8 +52,7 @@ export const addTagToFile = (fileId, tagType, tagName) => {
})
.then(resp => {
if (resp.status == 200 || resp.status == 201) {
dispatch(markTagAsCreated(fileId, tagType, tagName))
analytics().event('TAGS.ADD', { name: tagName })
dispatch(markTagAsCreated(fileId, tagType, tagName))
return resp.json()
}
else { throw resp }
Expand All @@ -80,8 +79,7 @@ export const removeTagFromFile = (fileId, tagType, tagName) => {
...defaultSettings
})
.then(resp => {
if (resp.status == 200) {
analytics().event('TAGS.REMOVED', { name: tagName })
if (resp.status == 200) {
return resp.json()
}
else { throw resp }
Expand Down
4 changes: 1 addition & 3 deletions FrontEnd/src/routes/SearchPage/modules/UploadModal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { stateValueExtractor } from 'utils/'
import { analytics, FormDataPolyfill } from 'utils'
import { FormDataPolyfill } from 'utils'
import { handleError, showInfo } from 'routes/CoreLayout/modules/CoreLayout'
import 'whatwg-fetch'

Expand Down Expand Up @@ -41,7 +41,6 @@ export const uploadFiles = () => {
dispatch(toggleUploadModal())
dispatch(cleanFilesToUpload())
dispatch(showInfo('Files succesfully uploaded'))
analytics().event('SEARCH.UPLOAD_FILES', { count: uploadPromises.length })
})
.catch((errorPayload) => {
dispatch(filesUploading(false))
Expand All @@ -50,7 +49,6 @@ export const uploadFiles = () => {
dispatch(handleError('No free space left in your account', true))
} else {
dispatch(handleError(errorPayload))
analytics().event('SEARCH.UPLOAD_FILES_ERROR', { error: errorPayload })
}

console.error('uploadFile', errorPayload)
Expand Down
3 changes: 1 addition & 2 deletions FrontEnd/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ import * as stateValueExtractor from './stateValueExtractor'
import * as titles from './titles'
import * as constants from './constants'
import FormDataPolyfill from './formDataPolyfill'
import analytics from './analytics'

export { validators, urls, dates, files, dom, stateValueExtractor, titles, constants, analytics, FormDataPolyfill }
export { validators, urls, dates, files, dom, stateValueExtractor, titles, constants, FormDataPolyfill }
3 changes: 2 additions & 1 deletion FrontEnd/src/utils/stateValueExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export const getLocalization = (state) => {
export const getDefaultSettings = () => {
return {
mode: 'cors',
credentials: 'include',
credentials: 'include',
cache: 'no-cache',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
Expand Down
4 changes: 0 additions & 4 deletions FrontEnd/src/utils/titles.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import analytics from './analytics'

export const setPageTitle = (title) => {
document.title = title
analytics().register({ title: title })
analytics().event('LOCATION_CHANGED')
}
27 changes: 18 additions & 9 deletions LocalCrawler/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ import cluster from 'cluster'
import 'babel-core/register'
import 'idempotent-babel-polyfill'

import { FileWatchService, ApiProxy } from './services'
import { FileWatchService, ApiProxy, QueueProxy } from './services'

let app = null
if (cluster.isMaster) {
ApiProxy.logData(config.name, 'info', 'API runs on master thread')
ApiProxy.logData(config.name, 'info', 'Creating fork for the file-watcher process')
cluster.fork()

const worker = cluster.fork()
worker.on('exit', () => {
ApiProxy.logData(config.name, 'error', 'Worker thread crashed')
process.exit(1)
})

app = express()
app.server = http.createServer(app)
Expand All @@ -34,16 +39,20 @@ if (cluster.isMaster) {
app.server.listen(process.env.PORT || config.port)

console.log(`Started API on ${app.server.address().address}:${app.server.address().port}`)


} else {
ApiProxy.logData(config.name, 'info', 'File-watcher runs on worker thread')

FileWatchService.startWatch()
.catch(err => {
ApiProxy.logData(config.name, 'error', `Error: ${err}`)

const rabbitErrorHandler = (error) => {
ApiProxy.logData(config.name, 'error', `Rabbit Error: ${error}`)
process.exit(1)
})
}

QueueProxy.initRabbit(rabbitErrorHandler)
.then(() => FileWatchService.startWatch())
.catch(err => {
ApiProxy.logData(config.name, 'error', `Error: ${err}`)
process.exit(1)
})
}

export default app
Expand Down
Loading

0 comments on commit a143182

Please sign in to comment.