Syntax updates and such

This commit is contained in:
Henrique Dias 2017-07-31 13:40:26 +01:00
parent c80a364203
commit 4254cc6b86
No known key found for this signature in database
GPG Key ID: 936F5EB68D786730
5 changed files with 25 additions and 36 deletions

View File

@ -21,11 +21,10 @@
<!-- Add to home screen for Windows --> <!-- Add to home screen for Windows -->
<meta name="msapplication-TileImage" content="{{ .BaseURL }}/static/img/icons/msapplication-icon-144x144.png"> <meta name="msapplication-TileImage" content="{{ .BaseURL }}/static/img/icons/msapplication-icon-144x144.png">
<meta name="msapplication-TileColor" content="#2979ff"> <meta name="msapplication-TileColor" content="#2979ff">
<% for (var chunk of webpack.compilation.chunks) {
<% for (var chunk of webpack.chunks) {
for (var file of chunk.files) { for (var file of chunk.files) {
if (file.match(/\.(js|css)$/)) { %> if (file.match(/\.(js|css)$/)) { %>
<link rel="<%= chunk.initial?'preload':'prefetch' %>" href="{{ .BaseURL }}/<%= file %>" as="<%= file.match(/\.css$/)?'style':'script' %>"><% }}} %> <link rel="preload" href="{{ .BaseURL }}/<%= file %>" as="<%= file.match(/\.css$/)?'style':'script' %>"><% }}} %>
<!-- Plugins info --> <!-- Plugins info -->
<script>{{ .JavaScript }}</script> <script>{{ .JavaScript }}</script>

View File

@ -152,25 +152,19 @@ export default {
if (url[0] !== '/') url = '/' + url if (url[0] !== '/') url = '/' + url
api.fetch(url) api.fetch(url)
.then((req) => { .then((req) => {
if (!url.endsWith('/') && req.url.endsWith('/')) { if (!url.endsWith('/') && req.url.endsWith('/')) {
window.history.replaceState(window.history.state, document.title, window.location.pathname + '/') window.history.replaceState(window.history.state, document.title, window.location.pathname + '/')
} }
this.$store.commit('updateRequest', req) this.$store.commit('updateRequest', req)
document.title = req.name document.title = req.name
this.setLoading(false) this.setLoading(false)
}) })
.catch(error => { .catch(error => {
this.setLoading(false) this.setLoading(false)
this.error = error
if (typeof error === 'object') { })
this.error = error.status
return
}
this.error = error
})
}, },
keyEvent (event) { keyEvent (event) {
// Esc! // Esc!
@ -220,7 +214,6 @@ export default {
if (this.req.kind !== 'editor') { if (this.req.kind !== 'editor') {
document.getElementById('download-button').click() document.getElementById('download-button').click()
return
} }
} }
} }

View File

@ -25,13 +25,13 @@ const router = new Router({
component: Login, component: Login,
beforeEnter: function (to, from, next) { beforeEnter: function (to, from, next) {
auth.loggedIn() auth.loggedIn()
.then(() => { .then(() => {
next({ path: '/files' }) next({ path: '/files' })
}) })
.catch(() => { .catch(() => {
document.title = 'Login' document.title = 'Login'
next() next()
}) })
} }
}, },
{ {

View File

@ -24,10 +24,7 @@ function fetch (url) {
resolve(JSON.parse(request.responseText)) resolve(JSON.parse(request.responseText))
break break
default: default:
reject({ reject(new Error(request.status))
message: request.responseText,
status: request.status
})
break break
} }
} }

View File

@ -23,10 +23,10 @@ function loggedIn () {
parseToken(request.responseText) parseToken(request.responseText)
resolve() resolve()
} else { } else {
reject() reject(new Error(request.responseText))
} }
} }
request.onerror = () => reject() request.onerror = () => reject(new Error('Could not finish the request'))
request.send() request.send()
}) })
} }
@ -45,7 +45,7 @@ function login (user, password) {
reject(request.responseText) reject(request.responseText)
} }
} }
request.onerror = () => reject() request.onerror = () => reject(new Error('Could not finish the request'))
request.send(JSON.stringify(data)) request.send(JSON.stringify(data))
}) })
} }