Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open-web
Commits
3cace204
Commit
3cace204
authored
Feb 12, 2018
by
Andrew Hrdy
Browse files
Merge branch 'master' into development
parents
1d66f6e5
32acc6e6
Pipeline
#2119
passed with stages
in 2 minutes and 2 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
3cace204
# Changelog
## [2.1.1] - 2018-02-11
### Changed
-
Updated service worker
### Fixed
-
Fixed searching by location friendly name
## [2.1.0] - 2018-02-08
### Added
...
...
@@ -12,7 +22,7 @@
-
Facility cards now sorted by open / closed
-
Facility card shadowing
-
Search now includes friendly name
-
Search now includes
location
friendly name
### Fixed
...
...
@@ -31,4 +41,5 @@
[
2.0.1
]:
https://git.gmu.edu/srct/whats-open-web/compare/v2.0...v2.0.1
[
2.1.0
]:
https://git.gmu.edu/srct/whats-open-web/compare/v2.0.1...v2.1-Midnight-Cherry
\ No newline at end of file
[
2.1.0
]:
https://git.gmu.edu/srct/whats-open-web/compare/v2.0.1...v2.1-Midnight-Cherry
[
2.1.1
]:
https://git.gmu.edu/srct/whats-open-web/compare/v2.1-Midnight-Cherry...v2.1.1
\ No newline at end of file
src/components/CardContainer.js
View file @
3cace204
...
...
@@ -14,8 +14,7 @@ const CardContainer = ({searchTerm, campusRegion, facilities}) => {
const
facilityLocation
=
facility
.
facility_location
.
building
.
toLowerCase
();
const
facilityCategory
=
facility
.
facility_category
.
name
.
toLowerCase
().
normalize
(
'
NFD
'
).
replace
(
/
[\u
0300-
\u
036f
]
/g
,
''
);
const
facilityTags
=
facility
.
facility_product_tags
;
const
friendlyName
=
facility
.
friendly_building
;
const
friendlyName
=
facility
.
facility_location
.
friendly_building
.
toLowerCase
();
facilityTags
.
forEach
((
tag
)
=>
{
return
tag
.
toLowerCase
();
});
...
...
@@ -27,7 +26,7 @@ const CardContainer = ({searchTerm, campusRegion, facilities}) => {
const
hasTag
=
index
!==
-
1
;
return
facilityName
.
includes
(
lSearchTerm
)
||
facilityLocation
.
includes
(
lSearchTerm
)
||
facilityCategory
.
includes
(
lSearchTerm
)
||
hasTag
||
f
acilityLocation
.
includes
(
friendlyName
);
facilityCategory
.
includes
(
lSearchTerm
)
||
hasTag
||
f
riendlyName
.
includes
(
lSearchTerm
);
};
return
(
...
...
src/registerServiceWorker.js
View file @
3cace204
// In production, we register a service worker to serve assets from local cache.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on the "N+1" visit to a page, since previously
// cached resources are updated in the background.
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
// This link also includes instructions on opting out of this behavior.
// cached resources are updated in the background. To learn more about the
// benefits of this model, read https://goo.gl/KwvDNy. This link also includes
// instructions on opting out of this behavior.
const
isLocalhost
=
Boolean
(
window
.
location
.
hostname
===
'
localhost
'
||
// [::1] is the IPv6 localhost address.
window
.
location
.
hostname
===
'
[::1]
'
||
// 127.0.0.1/8 is considered localhost for IPv4.
window
.
location
.
hostname
.
match
(
/^127
(?:\.(?:
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
01
]?[
0-9
][
0-9
]?)){3}
$/
)
);
const
isLocalhost
=
Boolean
(
window
.
location
.
hostname
===
'
localhost
'
||
// [::1] is the IPv6 localhost address.
window
.
location
.
hostname
===
'
[::1]
'
||
// 127.0.0.1/8 is considered localhost for IPv4.
window
.
location
.
hostname
.
match
(
/^127
(?:\.(?:
25
[
0-5
]
|2
[
0-4
][
0-9
]
|
[
01
]?[
0-9
][
0-9
]?)){3}
$/
));
export
default
function
register
()
{
if
(
process
.
env
.
NODE_ENV
===
'
production
'
&&
'
serviceWorker
'
in
navigator
)
{
// The URL constructor is available in all browsers that support SW.
// The URL constructor is available in all browsers that support SW.
const
publicUrl
=
new
URL
(
process
.
env
.
PUBLIC_URL
,
window
.
location
);
if
(
publicUrl
.
origin
!==
window
.
location
.
origin
)
{
// Our service worker won't work if PUBLIC_URL is on a different origin
//
from
what our page is served on. This might happen if a CDN is used to
//
serve
assets; see https://github.com/facebookincubator/create-react-app/issues/2374
// Our service worker won't work if PUBLIC_URL is on a different origin
from
// what our page is served on. This might happen if a CDN is used to
serve
// assets; see https://github.com/facebookincubator/create-react-app/issues/2374
return
;
}
window
.
addEventListener
(
'
load
'
,
()
=>
{
const
swUrl
=
`
${
process
.
env
.
PUBLIC_URL
}
/service-worker.js`
;
if
(
!
isLocalhost
)
{
// Is not local host. Just register service worker
registerValidSW
(
swUrl
);
}
else
{
// This is running on localhost. Lets check if a service worker still exists or not.
if
(
isLocalhost
)
{
// This is running on localhost. Lets check if a service worker still exists or
// not.
checkValidServiceWorker
(
swUrl
);
// Add some additional logging to localhost, pointing developers to the service
// worker/PWA documentation.
navigator
.
serviceWorker
.
ready
.
then
(()
=>
{
console
.
log
(
'
This web app is being served cache-first by a service worker. To learn more, vis
'
+
'
it https://goo.gl/SC7cgQ
'
);
});
}
else
{
// Is not local host. Just register service worker
registerValidSW
(
swUrl
);
}
});
}
}
function
registerValidSW
(
swUrl
)
{
navigator
.
serviceWorker
.
register
(
swUrl
)
.
then
((
registration
)
=>
{
registration
.
onupdatefound
=
(
)
=>
{
const
installingWorker
=
registration
.
installing
;
installingWorker
.
onstatechange
=
()
=>
{
if
(
installingWorker
.
state
===
'
installed
'
)
{
if
(
navigator
.
serviceWorker
.
contro
lle
r
)
{
// At this point, the old content will have been purged and
//
the fresh
content will have been
added to the cache.
// It's the perfect time to display a "New
content is
// available; please refresh." message in your web app.
console
.
log
(
'
New content is available; please refresh.
'
);
}
else
{
// At this point, everything has been precached.
//
It's the perfect time to display a
// "
Content is cached for offline use.
" message.
console
.
log
(
'
Content is cached for offline use.
'
);
navigator
.
serviceWorker
.
register
(
swUrl
)
.
then
((
registration
)
=>
{
registration
.
onupdatefound
=
()
=>
{
const
installingWorker
=
registration
.
installing
;
installingWorker
.
on
state
change
=
()
=>
{
if
(
installingWorker
.
state
===
'
insta
lle
d
'
)
{
if
(
navigator
.
serviceWorker
.
controller
)
{
//
At this point, the old
content will have been
purged and the fresh content
//
will have been added to the cache.
It's the perfect time to display a "New
//
content is
available; please refresh." message in your web app.
console
.
log
(
'
New content is available; please refresh.
'
);
}
else
{
// At this point, everything has been precached.
It's the perfect time to
//
display a "Content is cached for offline use." message.
console
.
log
(
'
Content is cached for offline use.
'
);
}
}
}
}
;
};
};
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Error during service worker registration:
'
,
error
);
});
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Error during service worker registration:
'
,
error
);
});
}
function
checkValidServiceWorker
(
swUrl
)
{
// Check if the service worker can be found. If it can't reload the page.
fetch
(
swUrl
)
.
then
((
response
)
=>
{
// Ensure service worker exists, and that we really are getting a JS file.
if
(
response
.
status
===
404
||
response
.
headers
.
get
(
'
content-type
'
).
indexOf
(
'
javascript
'
)
===
-
1
)
{
// No service worker found. Probably a different app. Reload the page.
navigator
.
serviceWorker
.
ready
.
then
((
registration
)
=>
{
registration
.
unregister
().
then
(()
=>
{
window
.
location
.
reload
();
// Check if the service worker can be found. If it can't reload the page.
fetch
(
swUrl
).
then
((
response
)
=>
{
// Ensure service worker exists, and that we really are getting a JS file.
if
(
response
.
status
===
404
||
response
.
headers
.
get
(
'
content-type
'
).
indexOf
(
'
javascript
'
)
===
-
1
)
{
// No service worker found. Probably a different app. Reload the page.
navigator
.
serviceWorker
.
ready
.
then
((
registration
)
=>
{
registration
.
unregister
()
.
then
(()
=>
{
window
.
location
.
reload
();
});
});
});
}
else
{
// Service worker found. Proceed as normal.
// Service worker found. Proceed as normal.
registerValidSW
(
swUrl
);
}
})
.
catch
(()
=>
{
console
.
log
(
'
No internet connection found. App is running in offline mode.
'
);
}).
catch
(()
=>
{
console
.
log
(
'
No internet connection found. App is running in offline mode.
'
);
});
}
export
function
unregister
()
{
if
(
'
serviceWorker
'
in
navigator
)
{
navigator
.
serviceWorker
.
ready
.
then
((
registration
)
=>
{
registration
.
unregister
();
});
navigator
.
serviceWorker
.
ready
.
then
((
registration
)
=>
{
registration
.
unregister
();
});
}
}
yarn.lock
View file @
3cace204
...
...
@@ -1789,6 +1789,14 @@ create-hmac@^1.1.0, create-hmac@^1.1.2, create-hmac@^1.1.4:
safe-buffer "^5.0.1"
sha.js "^2.4.8"
create-react-class@^15.5.1:
version "15.6.3"
resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.6.3.tgz#2d73237fb3f970ae6ebe011a9e66f46dbca80036"
dependencies:
fbjs "^0.8.9"
loose-envify "^1.3.1"
object-assign "^4.1.1"
create-react-class@^15.6.0:
version "15.6.2"
resolved "https://registry.yarnpkg.com/create-react-class/-/create-react-class-15.6.2.tgz#cf1ed15f12aad7f14ef5f2dfe05e6c42f91ef02a"
...
...
@@ -5846,7 +5854,7 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"
prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.8, prop-types@^15.6.0:
prop-types@^15.5.10, prop-types@^15.5.4,
prop-types@^15.5.6,
prop-types@^15.5.8, prop-types@^15.6.0:
version "15.6.0"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
dependencies:
...
...
@@ -6097,6 +6105,14 @@ react-mapbox-gl@^2.5.2:
deep-equal "1.0.1"
supercluster "3.0.1"
react-notification-system@^0.2.16:
version "0.2.16"
resolved "https://registry.yarnpkg.com/react-notification-system/-/react-notification-system-0.2.16.tgz#9b9da20b0d34786b60057c52b42516ea1295374a"
dependencies:
create-react-class "^15.5.1"
object-assign "^4.0.1"
prop-types "^15.5.6"
react-popper@^0.7.4:
version "0.7.4"
resolved "https://registry.yarnpkg.com/react-popper/-/react-popper-0.7.4.tgz#8649d539837e7c6f47bc9b24c9cf57a404e199a1"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment