Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (err) {
console.log(err);
return navigateTo('/strange-place');
}
if (authResult && authResult.accessToken && authResult.idToken) {
return (
this.setSession(authResult)
.then(user => {
updateUserSignedIn(true);
return fetchUserComplete(user);
})
// this could be current-challenge
.then(() => navigateTo('/#'))
);
}
return navigateTo('/strange-place');
});
}
const navigate = (to, options = {}) => {
// Temp hack while awaiting https://github.com/reach/router/issues/119
if (!options.replace) {
window.__navigatingToLink = true
}
let { pathname } = parsePath(to)
const redirect = redirectMap[pathname]
// If we're redirecting, just replace the passed in pathname
// to the one we want to redirect to.
if (redirect) {
to = redirect.toPath
pathname = parsePath(to).pathname
}
// If we had a service worker update, no matter the path, reload window and
// reset the pathname whitelist
if (window.___swUpdated) {
window.location = pathname
return
}
// Start a timer to wait for a second before transitioning and showing a
// loader in case resources aren't around yet.
const timeoutId = setTimeout(() => {
emitter.emit(`onDelayedLoadPageResources`, { pathname })
apiRunner(`onRouteUpdateDelayed`, {
location: window.location,
})
const navigate = (to, options = {}) => {
// Temp hack while awaiting https://github.com/reach/router/issues/119
if (!options.replace) {
window.__navigatingToLink = true
}
let { pathname } = parsePath(to)
const redirect = redirectMap[pathname]
// If we're redirecting, just replace the passed in pathname
// to the one we want to redirect to.
if (redirect) {
to = redirect.toPath
pathname = parsePath(to).pathname
}
// If we had a service worker update, no matter the path, reload window and
// reset the pathname whitelist
if (window.___swUpdated) {
window.location = pathname
return
}
// Start a timer to wait for a second before transitioning and showing a
// loader in case resources aren't around yet.
const timeoutId = setTimeout(() => {
emitter.emit(`onDelayedLoadPageResources`, { pathname })
apiRunner(`onRouteUpdateDelayed`, {
location: window.location,
})
private trainTestAndSaveModels = async () => {
const files = [
withPrefix('/models/dictionary.json'),
withPrefix('/models/ngram_to_id_dictionary.json'),
withPrefix('/models/dataset_params.json'),
withPrefix('/models/dataset_training.json'),
withPrefix('/models/dataset_testing.json')
];
const jsonFiles = await this.downloadFiles(files);
const pretrainedNGramVectors = new Map(jsonFiles[0].data);
const ngramToIdDictionary = jsonFiles[1].data;
const datasetParams = jsonFiles[2].data;
const datasetTraining = jsonFiles[3].data;
const datasetTest = jsonFiles[4].data;
await this.timeoutInMs(200); // give some time for the state update after the model setup (before the gpu blocks)
this.setState({
datasetParams,
datasetTest,
datasetTraining,
embeddingsAndTrainingDatasetLoaded: true,
ngramToIdDictionary,
pretrainedNGramVectors
});
private trainTestAndSaveModels = async () => {
const files = [
withPrefix('/models/dictionary.json'),
withPrefix('/models/ngram_to_id_dictionary.json'),
withPrefix('/models/dataset_params.json'),
withPrefix('/models/dataset_training.json'),
withPrefix('/models/dataset_testing.json')
];
const jsonFiles = await this.downloadFiles(files);
const pretrainedNGramVectors = new Map(jsonFiles[0].data);
const ngramToIdDictionary = jsonFiles[1].data;
const datasetParams = jsonFiles[2].data;
const datasetTraining = jsonFiles[3].data;
const datasetTest = jsonFiles[4].data;
await this.timeoutInMs(200); // give some time for the state update after the model setup (before the gpu blocks)
this.setState({
datasetParams,
datasetTest,
datasetTraining,
embeddingsAndTrainingDatasetLoaded: true,
ngramToIdDictionary,
pretrainedNGramVectors
import PropTypes from 'prop-types';
import { withPrefix } from 'gatsby-link';
// This is a gatsby limitation will be fixed in newer version
let globalStyles = require(`!raw-loader!@patternfly/react-core/../dist/styles/base.css`);
globalStyles = globalStyles.replace(/\.\/assets\//g, withPrefix('/assets/'));
const localStyles = require(`!raw-loader!./index.css`);
import { injectGlobal } from 'emotion';
injectGlobal(globalStyles);
injectGlobal(localStyles);
const propTypes = {
children: PropTypes.func.isRequired
};
const Layout = ({ children }) => children();
Layout.propTypes = propTypes;
export default Layout;
const navigate = (to, options = {}) => {
// Temp hack while awaiting https://github.com/reach/router/issues/119
if (!options.replace) {
window.__navigatingToLink = true
}
let { pathname } = parsePath(to)
const redirect = redirectMap[pathname]
// If we're redirecting, just replace the passed in pathname
// to the one we want to redirect to.
if (redirect) {
to = redirect.toPath
pathname = parsePath(to).pathname
}
// If we had a service worker update, no matter the path, reload window and
// reset the pathname whitelist
if (window.___swUpdated) {
window.location = pathname
return
}
const navigate = (to, options = {}) => {
// Temp hack while awaiting https://github.com/reach/router/issues/119
if (!options.replace) {
window.__navigatingToLink = true
}
let { pathname } = parsePath(to)
const redirect = redirectMap[pathname]
// If we're redirecting, just replace the passed in pathname
// to the one we want to redirect to.
if (redirect) {
to = redirect.toPath
pathname = parsePath(to).pathname
}
// If we had a service worker update, no matter the path, reload window and
// reset the pathname whitelist
if (window.___swUpdated) {
window.location = pathname
return
}
onClick={() => {
navigateTo(withPrefix(item.url));
toggleDrawer(false);
}}
>
const formatStorybookUrl = ({componentName, componentStory}) => withPrefix(
url.format({
pathname: '/storybook/index.html',
query: {
selectedKind: componentName,
selectedStory: componentStory,
},
})
);