Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b466650

Browse files
committed
scroll
1 parent 2e508dd commit b466650

File tree

5 files changed

+129
-6
lines changed

5 files changed

+129
-6
lines changed

src/client/app/modules/components/search-form.jsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
import {ConnectedCodeView} from 'components/code-view';
1212
import {
1313
updateFileUrl,
14-
toggleCodeView
14+
toggleCodeView,
15+
setLastUpdate,
1516
} from 'reducers/ui-filters'
1617
import {resultsFromLocationSelector} from 'selectors/results';
1718
import 'whatwg-fetch';
@@ -26,7 +27,16 @@ export class SearchForm extends React.Component {
2627
this.handleSearchCaseSensitiveToggle = this.handleSearchCaseSensitiveToggle.bind(this)
2728
this.handleLocationChange = this.handleLocationChange.bind(this)
2829
this.getSearchParamsFromProps = this.getSearchParamsFromProps.bind(this);
29-
this.debounceUpdateSearch = _.debounce(this.updateSearch, 200)
30+
this.debounceUpdateSearch = _.debounce(this.updateSearch, 200);
31+
}
32+
33+
componentDidMount() {
34+
fetch('/api/lastupdate')
35+
.then((response) => {
36+
return response.json()
37+
}).then((response) => {
38+
this.props.setLastUpdate(moment(response))
39+
})
3040
}
3141

3242
getSearchParamsFromProps() {
@@ -94,7 +104,7 @@ export class SearchForm extends React.Component {
94104
}
95105

96106
render() {
97-
var {searchString, searchStringRegEx, searchStringCaseSensitive, location, results, full, className} = this.props;
107+
var {searchString, searchStringRegEx, searchStringCaseSensitive, location, results, full, className, lastUpdate} = this.props;
98108
var hashes = results.map((result) => result.hash);
99109
return (
100110
<div className={"SearchForm " + className}>
@@ -127,12 +137,12 @@ export class SearchForm extends React.Component {
127137
(searchString === '' && location === '') ?
128138
<span> Type in the searchbox to get started! </span> :
129139
<span>
130-
{results.length} {searchString === '' ? 'files found' : 'results found for string'} <code>{searchString === '' ? '' : `'${searchString}'`}</code> at <code>{ location === '' ? 'any path' : `'${location}'`}</code>
140+
Search results for string <code>{searchString === '' ? '' : `'${searchString}'`}</code> at <code>{ location === '' ? 'any path' : `'${location}'`}</code>
131141
</span>
132142
}
133143
</div>
134144
<div className="Results" ref={(ref) => this.resultView = this.resultView || ref} >
135-
<ConnectedInfiniteScroll loadMore={() => this.loadMore(hashes)} hasMore={true}>
145+
<ConnectedInfiniteScroll loadMore={() => this.loadMore(hashes)} hasMore={searchString || location}>
136146
{
137147
results.map((result, i) => {
138148
var {file, lno, above_lines, the_line, below_lines} = result;
@@ -152,6 +162,14 @@ export class SearchForm extends React.Component {
152162
</ConnectedInfiniteScroll>
153163
</div>
154164
</div>
165+
<div className="Footer">
166+
<div className="left">
167+
{lastUpdate ? `Last update: ${lastUpdate.fromNow()}` : null }
168+
</div>
169+
<div className="right">
170+
Made with&nbsp;<a href="https://github.com/codegrep/codegrep" className="ion-ios-heart pulse"></a>&nbsp;by Swit and Gott
171+
</div>
172+
</div>
155173
</div>
156174
)
157175
}
@@ -165,12 +183,14 @@ export const ConnectedSearchForm = connect(
165183
location: state.search.form.location,
166184
results: state.search.results,
167185
full: state.uiFilters.views.full,
186+
lastUpdate: state.uiFilters.lastUpdate,
168187
}),
169188
{
170189
updateSearchString,
171190
updateSearchStringRegEx,
172191
updateSearchStringCaseSensitive,
173192
updateLocation,
174193
updateResults,
194+
setLastUpdate,
175195
}
176196
)(SearchForm);

src/client/app/modules/reducers/ui-filters.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ export const toggleSearchView = (value) => {
1414
}
1515
};
1616

17+
export const setLastUpdate = (time) => {
18+
return {
19+
type: 'SET_LAST_UPDATE',
20+
time
21+
}
22+
};
1723

1824
export const updateFileUrl = (fileUrl, line) => {
1925
if (fileUrl) {
@@ -38,7 +44,8 @@ const getDefaultState = () => ({
3844
full: false,
3945
},
4046
fileUrl: null,
41-
line: null
47+
line: null,
48+
lastUpdate: null
4249
})
4350

4451
export default (state, action) => {
@@ -62,6 +69,11 @@ export default (state, action) => {
6269
fileUrl: action.fileUrl,
6370
line: action.line
6471
}
72+
case 'SET_LAST_UPDATE':
73+
return {
74+
...state,
75+
lastUpdate: action.time
76+
}
6577
default:
6678
return state;
6779
}

src/client/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.5.0/highlight.min.js"></script>
1414
<script src="public/vendors/cache.js" type="text/javascript"></script>
1515
<script src="public/javascripts/bundle.js" type="text/javascript"></script>
16+
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js" type="text/javascript"></script>
1617
</body>
1718
</html>

src/client/sass/index.scss

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,84 @@ button {
8888
.prism-show-language-label {
8989
display: none !important;
9090
}
91+
92+
.pulse:before {
93+
color: rgba(255,48,48,0.7);
94+
-webkit-animation: pulse2 1s linear infinite;
95+
-moz-animation: pulse2 1s linear infinite;
96+
-ms-animation: pulse2 1s linear infinite;
97+
animation: pulse2 1s linear infinite;
98+
}
99+
100+
@keyframes "pulse2" {
101+
0% {
102+
-webkit-transform: scale(1.1);
103+
-moz-transform: scale(1.1);
104+
-o-transform: scale(1.1);
105+
-ms-transform: scale(1.1);
106+
transform: scale(1.1);
107+
}
108+
50% {
109+
-webkit-transform: scale(0.8);
110+
-moz-transform: scale(0.8);
111+
-o-transform: scale(0.8);
112+
-ms-transform: scale(0.8);
113+
transform: scale(0.8);
114+
}
115+
100% {
116+
-webkit-transform: scale(1);
117+
-moz-transform: scale(1);
118+
-o-transform: scale(1);
119+
-ms-transform: scale(1);
120+
transform: scale(1);
121+
}
122+
123+
}
124+
125+
@-moz-keyframes pulse2 {
126+
0% {
127+
-moz-transform: scale(1.1);
128+
transform: scale(1.1);
129+
}
130+
50% {
131+
-moz-transform: scale(0.8);
132+
transform: scale(0.8);
133+
}
134+
100% {
135+
-moz-transform: scale(1);
136+
transform: scale(1);
137+
}
138+
139+
}
140+
141+
@-webkit-keyframes "pulse2" {
142+
0% {
143+
-webkit-transform: scale(1.1);
144+
transform: scale(1.1);
145+
}
146+
50% {
147+
-webkit-transform: scale(0.8);
148+
transform: scale(0.8);
149+
}
150+
100% {
151+
-webkit-transform: scale(1);
152+
transform: scale(1);
153+
}
154+
155+
}
156+
157+
@-ms-keyframes "pulse2" {
158+
0% {
159+
-ms-transform: scale(1.1);
160+
transform: scale(1.1);
161+
}
162+
50% {
163+
-ms-transform: scale(0.8);
164+
transform: scale(0.8);
165+
}
166+
100% {
167+
-ms-transform: scale(1);
168+
transform: scale(1);
169+
}
170+
171+
}

src/client/sass/partials/_search.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,12 @@
119119
padding: 0;
120120
}
121121
}
122+
123+
.Footer {
124+
display: flex;
125+
justify-content: space-between;
126+
color: #aaa;
127+
padding: 10px 0 4px 0;
128+
font-weight: 400;
129+
font-size: 13px;
130+
}

0 commit comments

Comments
 (0)