nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,18 @@
'use strict';
/* global __resourceQuery WorkerGlobalScope self */
/* eslint prefer-destructuring: off */
var querystring = require('querystring');
var url = require('url');
var stripAnsi = require('strip-ansi');
var log = require('loglevel').getLogger('webpack-dev-server');
var socket = require('./socket');
var overlay = require('./overlay');
function getCurrentScriptSource() {
@@ -14,30 +20,35 @@ function getCurrentScriptSource() {
// but is not supported in all browsers.
if (document.currentScript) {
return document.currentScript.getAttribute('src');
}
// Fall back to getting all scripts in the document.
} // Fall back to getting all scripts in the document.
var scriptElements = document.scripts || [];
var currentScript = scriptElements[scriptElements.length - 1];
if (currentScript) {
return currentScript.getAttribute('src');
}
// Fail as there was no script to use.
} // Fail as there was no script to use.
throw new Error('[WDS] Failed to get current script source.');
}
var urlParts = void 0;
var urlParts;
var hotReload = true;
if (typeof window !== 'undefined') {
var qs = window.location.search.toLowerCase();
hotReload = qs.indexOf('hotreload=false') === -1;
}
if (typeof __resourceQuery === 'string' && __resourceQuery) {
// If this bundle is inlined, use the resource query to get the correct url.
urlParts = url.parse(__resourceQuery.substr(1));
} else {
// Else, get the url from the <script> this file was called with.
var scriptHost = getCurrentScriptSource();
// eslint-disable-next-line no-useless-escape
var scriptHost = getCurrentScriptSource(); // eslint-disable-next-line no-useless-escape
scriptHost = scriptHost.replace(/\/[^\/]+$/, '');
urlParts = url.parse(scriptHost || '/', false, true);
}
@@ -52,20 +63,17 @@ var currentHash = '';
var useWarningOverlay = false;
var useErrorOverlay = false;
var useProgress = false;
var INFO = 'info';
var WARNING = 'warning';
var ERROR = 'error';
var NONE = 'none';
var NONE = 'none'; // Set the default log level
// Set the default log level
log.setDefaultLevel(INFO);
log.setDefaultLevel(INFO); // Send messages to the outside, so plugins can consume it.
// Send messages to the outside, so plugins can consume it.
function sendMsg(type, data) {
if (typeof self !== 'undefined' && (typeof WorkerGlobalScope === 'undefined' || !(self instanceof WorkerGlobalScope))) {
self.postMessage({
type: 'webpack' + type,
type: "webpack".concat(type),
data: data
}, '*');
}
@@ -77,15 +85,14 @@ var onSocketMsg = {
log.info('[WDS] Hot Module Replacement enabled.');
},
invalid: function invalid() {
log.info('[WDS] App updated. Recompiling...');
// fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
log.info('[WDS] App updated. Recompiling...'); // fixes #1042. overlay doesn't clear if errors are fixed but warnings remain.
if (useWarningOverlay || useErrorOverlay) overlay.clear();
sendMsg('Invalid');
},
hash: function hash(_hash) {
currentHash = _hash;
},
'still-ok': function stillOk() {
log.info('[WDS] Nothing changed.');
if (useWarningOverlay || useErrorOverlay) overlay.clear();
@@ -93,23 +100,28 @@ var onSocketMsg = {
},
'log-level': function logLevel(level) {
var hotCtx = require.context('webpack/hot', false, /^\.\/log$/);
if (hotCtx.keys().indexOf('./log') !== -1) {
hotCtx('./log').setLogLevel(level);
}
switch (level) {
case INFO:
case ERROR:
log.setLevel(level);
break;
case WARNING:
// loglevel's warning name is different from webpack's
log.setLevel('warn');
break;
case NONE:
log.disableAll();
break;
default:
log.error('[WDS] Unknown clientLogLevel \'' + level + '\'');
log.error("[WDS] Unknown clientLogLevel '".concat(level, "'"));
}
},
overlay: function overlay(value) {
@@ -128,44 +140,52 @@ var onSocketMsg = {
useProgress = _progress;
}
},
'progress-update': function progressUpdate(data) {
if (useProgress) log.info('[WDS] ' + data.percent + '% - ' + data.msg + '.');
if (useProgress) log.info("[WDS] ".concat(data.percent, "% - ").concat(data.msg, "."));
sendMsg('Progress', data);
},
ok: function ok() {
sendMsg('Ok');
if (useWarningOverlay || useErrorOverlay) overlay.clear();
if (initial) return initial = false; // eslint-disable-line no-return-assign
reloadApp();
},
'content-changed': function contentChanged() {
log.info('[WDS] Content base changed. Reloading...');
self.location.reload();
},
warnings: function warnings(_warnings) {
log.warn('[WDS] Warnings while compiling.');
var strippedWarnings = _warnings.map(function (warning) {
return stripAnsi(warning);
});
sendMsg('Warnings', strippedWarnings);
for (var i = 0; i < strippedWarnings.length; i++) {
log.warn(strippedWarnings[i]);
}
if (useWarningOverlay) overlay.showMessage(_warnings);
if (useWarningOverlay) overlay.showMessage(_warnings);
if (initial) return initial = false; // eslint-disable-line no-return-assign
reloadApp();
},
errors: function errors(_errors) {
log.error('[WDS] Errors while compiling. Reload prevented.');
var strippedErrors = _errors.map(function (error) {
return stripAnsi(error);
});
sendMsg('Errors', strippedErrors);
for (var i = 0; i < strippedErrors.length; i++) {
log.error(strippedErrors[i]);
}
if (useErrorOverlay) overlay.showMessage(_errors);
initial = false;
},
@@ -177,11 +197,9 @@ var onSocketMsg = {
sendMsg('Close');
}
};
var hostname = urlParts.hostname;
var protocol = urlParts.protocol;
var protocol = urlParts.protocol; // check ipv4 and ipv6 `all hostname`
// check ipv4 and ipv6 `all hostname`
if (hostname === '0.0.0.0' || hostname === '::') {
// why do we need this check?
// hostname n/a for file protocol (example, when using electron, ionic)
@@ -190,12 +208,12 @@ if (hostname === '0.0.0.0' || hostname === '::') {
if (self.location.hostname && !!~self.location.protocol.indexOf('http')) {
hostname = self.location.hostname;
}
}
// `hostname` can be empty when the script path is relative. In that case, specifying
} // `hostname` can be empty when the script path is relative. In that case, specifying
// a protocol would result in an invalid URL.
// When https is used in the app, secure websockets are always necessary
// because the browser doesn't accept non-secure websockets.
if (hostname && (self.location.protocol === 'https:' || urlParts.hostname === '0.0.0.0')) {
protocol = self.location.protocol;
}
@@ -205,11 +223,12 @@ var socketUrl = url.format({
auth: urlParts.auth,
hostname: hostname,
port: urlParts.port,
pathname: urlParts.path == null || urlParts.path === '/' ? '/sockjs-node' : urlParts.path
// If sockPath is provided it'll be passed in via the __resourceQuery as a
// query param so it has to be parsed out of the querystring in order for the
// client to open the socket to the correct location.
pathname: urlParts.path == null || urlParts.path === '/' ? '/sockjs-node' : querystring.parse(urlParts.path).sockPath || urlParts.path
});
socket(socketUrl, onSocketMsg);
var isUnloading = false;
self.addEventListener('beforeunload', function () {
isUnloading = true;
@@ -219,24 +238,28 @@ function reloadApp() {
if (isUnloading || !hotReload) {
return;
}
if (_hot) {
log.info('[WDS] App hot update...');
// eslint-disable-next-line global-require
log.info('[WDS] App hot update...'); // eslint-disable-next-line global-require
var hotEmitter = require('webpack/hot/emitter');
hotEmitter.emit('webpackHotUpdate', currentHash);
if (typeof self !== 'undefined' && self.window) {
// broadcast update to window
self.postMessage('webpackHotUpdate' + currentHash, '*');
self.postMessage("webpackHotUpdate".concat(currentHash), '*');
}
} else {
var rootWindow = self;
// use parent window for reload (in case we're in an iframe with no valid src)
var rootWindow = self; // use parent window for reload (in case we're in an iframe with no valid src)
var intervalId = self.setInterval(function () {
if (rootWindow.location.protocol !== 'about:') {
// reload immediately if protocol is valid
applyReload(rootWindow, intervalId);
} else {
rootWindow = rootWindow.parent;
if (rootWindow.parent === rootWindow) {
// if parent equals current window we've reached the root which would continue forever, so trigger a reload anyways
applyReload(rootWindow, intervalId);

File diff suppressed because one or more lines are too long

View File

@@ -1,13 +1,11 @@
'use strict';
// The error overlay is inspired (and mostly copied) from Create React App (https://github.com/facebookincubator/create-react-app)
'use strict'; // The error overlay is inspired (and mostly copied) from Create React App (https://github.com/facebookincubator/create-react-app)
// They, in turn, got inspired by webpack-hot-middleware (https://github.com/glenjamin/webpack-hot-middleware).
var ansiHTML = require('ansi-html');
var Entities = require('html-entities').AllHtmlEntities;
var entities = new Entities();
var colors = {
reset: ['transparent', 'transparent'],
black: '181818',
@@ -71,34 +69,33 @@ function ensureOverlayDivExists(onOverlayDivReady) {
// Everything is ready, call the callback right away.
onOverlayDivReady(overlayDiv);
return;
}
// Creating an iframe may be asynchronous so we'll schedule the callback.
} // Creating an iframe may be asynchronous so we'll schedule the callback.
// In case of multiple calls, last callback wins.
lastOnOverlayDivReady = onOverlayDivReady;
if (overlayIframe) {
// We're already creating it.
return;
}
} // Create iframe and, when it is ready, a div inside it.
// Create iframe and, when it is ready, a div inside it.
overlayIframe = createOverlayIframe(function () {
overlayDiv = addOverlayDivTo(overlayIframe);
// Now we can talk!
lastOnOverlayDivReady(overlayDiv);
});
overlayDiv = addOverlayDivTo(overlayIframe); // Now we can talk!
// Zalgo alert: onIframeLoad() will be called either synchronously
lastOnOverlayDivReady(overlayDiv);
}); // Zalgo alert: onIframeLoad() will be called either synchronously
// or asynchronously depending on the browser.
// We delay adding it so `overlayIframe` is set when `onIframeLoad` fires.
document.body.appendChild(overlayIframe);
}
function showMessageOverlay(message) {
ensureOverlayDivExists(function (div) {
// Make it look similar to our terminal.
div.innerHTML = '<span style="color: #' + colors.red + '">Failed to compile.</span><br><br>' + ansiHTML(entities.encode(message));
div.innerHTML = "<span style=\"color: #".concat(colors.red, "\">Failed to compile.</span><br><br>").concat(ansiHTML(entities.encode(message)));
});
}
@@ -106,21 +103,21 @@ function destroyErrorOverlay() {
if (!overlayDiv) {
// It is not there in the first place.
return;
}
} // Clean up and reset internal state.
// Clean up and reset internal state.
document.body.removeChild(overlayIframe);
overlayDiv = null;
overlayIframe = null;
lastOnOverlayDivReady = null;
}
} // Successful compilation.
// Successful compilation.
exports.clear = function handleSuccess() {
destroyErrorOverlay();
};
}; // Compilation with errors (e.g. syntax error or missing modules).
// Compilation with errors (e.g. syntax error or missing modules).
exports.showMessage = function handleMessage(messages) {
showMessageOverlay(messages[0]);
};

View File

@@ -15,19 +15,17 @@ var socket = function initSocket(url, handlers) {
sock.onclose = function onclose() {
if (retries === 0) {
handlers.close();
}
} // Try to reconnect.
// Try to reconnect.
sock = null;
// After 10 retries stop trying, to prevent logspam.
sock = null; // After 10 retries stop trying, to prevent logspam.
if (retries <= 10) {
// Exponentially increase timeout to reconnect.
// Respectfully copied from the package `got`.
// eslint-disable-next-line no-mixed-operators, no-restricted-properties
var retryInMs = 1000 * Math.pow(2, retries) + Math.random() * 100;
retries += 1;
setTimeout(function () {
socket(url, handlers);
}, retryInMs);
@@ -37,6 +35,7 @@ var socket = function initSocket(url, handlers) {
sock.onmessage = function onmessage(e) {
// This assumes that all data sent via the websocket is JSON.
var msg = JSON.parse(e.data);
if (handlers[msg.type]) {
handlers[msg.type](msg.data);
}

File diff suppressed because one or more lines are too long