Added automatic retry to frontend
Better support for iOS language detection?
This commit is contained in:
parent
fb00c0baa2
commit
d0b62d38b0
@ -1,3 +1,16 @@
|
||||
<?php
|
||||
/*
|
||||
* Stairs lighting
|
||||
* Copyright 2017 (c) Mark van Renswoude
|
||||
*
|
||||
* https://git.x2software.net/pub/Stairs
|
||||
*
|
||||
* Host this file somewhere on PHP enabled non-secure HTTP webhost
|
||||
* and modify the config.h to proxy Maps API requests. Saves a ton
|
||||
* of memory on the ESP8266.
|
||||
*
|
||||
* If you care about your API key being sent across plain HTTP,
|
||||
* host this or a similar proxy on your LAN, perhaps on a Raspberry Pi.
|
||||
*/
|
||||
echo file_get_contents('https://maps.googleapis.com/maps/api/timezone/json?' . $_SERVER['QUERY_STRING']);
|
||||
?>
|
@ -4,10 +4,10 @@
|
||||
const uint8_t VersionMajor = 2;
|
||||
const uint8_t VersionMinor = 0;
|
||||
const uint8_t VersionPatch = 0;
|
||||
const uint8_t VersionMetadata = ;
|
||||
const uint8_t VersionMetadata = 0;
|
||||
const char VersionBranch[] = "master";
|
||||
const char VersionSemVer[] = "2.0.0";
|
||||
const char VersionFullSemVer[] = "2.0.0";
|
||||
const char VersionFullSemVer[] = "2.0.0+0";
|
||||
const char VersionCommitDate[] = "2018-02-17";
|
||||
|
||||
#endif
|
||||
|
10
src/main.cpp
10
src/main.cpp
@ -75,7 +75,7 @@ void setup()
|
||||
stairs = new Stairs();
|
||||
stairs->init(pwmDriver);
|
||||
|
||||
|
||||
/*
|
||||
_dln("Setup :: starting initialization sequence");
|
||||
stairs->set(0, 255);
|
||||
delay(300);
|
||||
@ -89,6 +89,7 @@ void setup()
|
||||
}
|
||||
|
||||
stairs->set(stepCount - 1, 0);
|
||||
*/
|
||||
|
||||
_dln("Setup :: initializing WiFi");
|
||||
WiFi.persistent(false);
|
||||
@ -118,13 +119,6 @@ void loop()
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
if (motionTriggerSettingsChanged)
|
||||
{
|
||||
initMotionPins();
|
||||
motionTriggerSettingsChanged = false;
|
||||
}
|
||||
|
||||
|
||||
currentTime = millis();
|
||||
updateDebugStatus();
|
||||
|
||||
|
@ -302,6 +302,13 @@ bool lastMotion = false;
|
||||
|
||||
void updateMotionTrigger()
|
||||
{
|
||||
if (motionTriggerSettingsChanged)
|
||||
{
|
||||
initMotionPins();
|
||||
activeMotionStart = 0;
|
||||
}
|
||||
|
||||
|
||||
if (!motionTriggerSettings->enabled() || !motionTriggerSettings->triggerCount())
|
||||
{
|
||||
activeMotionStart = 0;
|
||||
@ -355,6 +362,12 @@ void checkTriggers()
|
||||
bool motionChanged = (activeMotionStart > 0) != lastMotion;
|
||||
lastMotion = (activeMotionStart > 0);
|
||||
|
||||
if (motionTriggerSettingsChanged)
|
||||
{
|
||||
motionChanged = true;
|
||||
motionTriggerSettingsChanged = false;
|
||||
}
|
||||
|
||||
|
||||
if (!motionChanged && !timeTriggerChanged)
|
||||
return;
|
||||
|
65
web/app.js
65
web/app.js
@ -1,5 +1,36 @@
|
||||
function startApp()
|
||||
{
|
||||
// Source: https://github.com/axios/axios/issues/164
|
||||
axios.interceptors.response.use(undefined, function axiosRetryInterceptor(err) {
|
||||
var config = err.config;
|
||||
// If config does not exist or the retry option is not set, reject
|
||||
if(!config || !config.retry) return Promise.reject(err);
|
||||
|
||||
// Set the variable for keeping track of the retry count
|
||||
config.__retryCount = config.__retryCount || 0;
|
||||
|
||||
// Check if we've maxed out the total number of retries
|
||||
if(config.__retryCount >= config.retry) {
|
||||
// Reject with the error
|
||||
return Promise.reject(err);
|
||||
}
|
||||
|
||||
// Increase the retry count
|
||||
config.__retryCount += 1;
|
||||
|
||||
// Create new promise to handle exponential backoff
|
||||
var backoff = new Promise(function(resolve) {
|
||||
setTimeout(function() {
|
||||
resolve();
|
||||
}, config.retryDelay || 1);
|
||||
});
|
||||
|
||||
// Return the promise in which recalls axios to retry the request
|
||||
return backoff.then(function() {
|
||||
return axios(config);
|
||||
});
|
||||
});
|
||||
|
||||
Vue.component('check', {
|
||||
template: '<div class="check" :class="{ checked: value, disabled: disabled }" @keydown="handleKeyDown" @click="handleClick" tabindex="0"><div class="control"><div class="inner"></div></div><div class="label">{{ title }}</div></div>',
|
||||
props: {
|
||||
@ -119,7 +150,7 @@ function startApp()
|
||||
});
|
||||
|
||||
var i18n = new VueI18n({
|
||||
locale: navigator.language,
|
||||
locale: navigator.language.split('-')[0],
|
||||
fallbackLocale: 'en',
|
||||
messages: messages
|
||||
});
|
||||
@ -338,7 +369,7 @@ function startApp()
|
||||
loadStatus: function()
|
||||
{
|
||||
var self = this;
|
||||
return axios.get('/api/status')
|
||||
return axios.get('/api/status', { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
if (typeof response.data == 'object')
|
||||
@ -350,7 +381,7 @@ function startApp()
|
||||
loadConnection: function()
|
||||
{
|
||||
var self = this;
|
||||
return axios.get('/api/connection')
|
||||
return axios.get('/api/connection', { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
if (typeof response.data == 'object')
|
||||
@ -362,7 +393,7 @@ function startApp()
|
||||
loadSystem: function()
|
||||
{
|
||||
var self = this;
|
||||
return axios.get('/api/system')
|
||||
return axios.get('/api/system', { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
if (typeof response.data == 'object')
|
||||
@ -374,7 +405,7 @@ function startApp()
|
||||
loadTimeTriggers: function()
|
||||
{
|
||||
var self = this;
|
||||
return axios.get('/api/triggers/time')
|
||||
return axios.get('/api/triggers/time', { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
if (typeof response.data == 'object')
|
||||
@ -419,7 +450,7 @@ function startApp()
|
||||
loadMotionTriggers: function()
|
||||
{
|
||||
var self = this;
|
||||
return axios.get('/api/triggers/motion')
|
||||
return axios.get('/api/triggers/motion', { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
if (typeof response.data == 'object')
|
||||
@ -431,7 +462,7 @@ function startApp()
|
||||
loadSteps: function()
|
||||
{
|
||||
var self = this;
|
||||
return axios.get('/api/steps/values')
|
||||
return axios.get('/api/steps/values', { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
if (Array.isArray(response.data))
|
||||
@ -481,7 +512,7 @@ function startApp()
|
||||
ip: self.connection.ip,
|
||||
subnetmask: self.connection.subnetmask,
|
||||
gateway: self.connection.gateway,
|
||||
})
|
||||
}, { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
})
|
||||
@ -499,7 +530,7 @@ function startApp()
|
||||
|
||||
self.saving = true;
|
||||
|
||||
axios.post('/api/system', self.system)
|
||||
axios.post('/api/system', self.system, { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
self.showNotification(i18n.t('rebootPending'));
|
||||
@ -595,7 +626,7 @@ function startApp()
|
||||
var self = this;
|
||||
if (!self.saving)
|
||||
{
|
||||
axios.get('/api/connection/status')
|
||||
axios.get('/api/connection/status', { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
if (typeof response.data == 'object')
|
||||
@ -693,7 +724,9 @@ function startApp()
|
||||
|
||||
axios.post('/api/steps/values', {
|
||||
transitionTime: 1000,
|
||||
values: steps
|
||||
values: steps,
|
||||
retry: 10,
|
||||
retryDelay: 1000
|
||||
})
|
||||
.then(function(response)
|
||||
{
|
||||
@ -761,7 +794,7 @@ function startApp()
|
||||
});
|
||||
}
|
||||
|
||||
axios.post('/api/triggers/time', timeSettings)
|
||||
axios.post('/api/triggers/time', timeSettings, { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
})
|
||||
@ -806,7 +839,7 @@ function startApp()
|
||||
|
||||
self.saving = true;
|
||||
|
||||
axios.post('/api/triggers/motion', self.triggers.motion)
|
||||
axios.post('/api/triggers/motion', self.triggers.motion, { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
})
|
||||
@ -857,7 +890,7 @@ function startApp()
|
||||
{
|
||||
var self = this;
|
||||
|
||||
axios.get('/api/steps')
|
||||
axios.get('/api/steps', { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
if (typeof response.data == 'object')
|
||||
@ -945,7 +978,7 @@ function startApp()
|
||||
count: self.calibration.count,
|
||||
useCurve: self.calibration.useCurve,
|
||||
ranges: self.calibration.ranges
|
||||
})
|
||||
}, { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
})
|
||||
@ -960,7 +993,7 @@ function startApp()
|
||||
{
|
||||
var self = this;
|
||||
|
||||
return axios.get('/api/stacktrace/delete')
|
||||
return axios.get('/api/stacktrace/delete', { retry: 10, retryDelay: 1000 })
|
||||
.then(function(response)
|
||||
{
|
||||
self.status.resetReason = 0;
|
||||
|
2
web/dist/bundle.js
vendored
2
web/dist/bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -54,11 +54,9 @@
|
||||
{{ $t('error.stackTrace') }}
|
||||
</p>
|
||||
|
||||
<div v-if="status.stackTrace">
|
||||
<a class="button button-primary" href="/api/stacktrace/get">{{ $t('error.stackTraceDownload') }}</a>
|
||||
<a class="button button-primary" href="/api/stacktrace/get" v-if="status.stackTrace">{{ $t('error.stackTraceDownload') }}</a>
|
||||
<a class="button" @click="deleteStackTrace">{{ $t('error.stackTraceDelete') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="navigation tabs">
|
||||
|
@ -165,7 +165,7 @@ var messages = {
|
||||
},
|
||||
stackTrace: 'A stack trace is available. Please send it to your nearest developer and/or delete it from this Stairs device to remove this message.',
|
||||
stackTraceDownload: 'Download',
|
||||
stackTraceDelete: 'Remove',
|
||||
stackTraceDelete: 'Hide',
|
||||
|
||||
stackTraceDeleteError: 'Could not remove stack trace'
|
||||
},
|
||||
@ -348,7 +348,7 @@ var messages = {
|
||||
},
|
||||
stackTrace: 'Een stack trace is beschikbaar. Stuur het naar de dichtsbijzijnde ontwikkelaar en/of verwijder het van deze Trap module om dit bericht te verbergen.',
|
||||
stackTraceDownload: 'Downloaden',
|
||||
stackTraceDelete: 'Verwijderen',
|
||||
stackTraceDelete: 'Verbergen',
|
||||
|
||||
stackTraceDeleteError: 'Kan stack trace niet verwijderen'
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user