fix lint errors and get setup working

This commit is contained in:
Kode 2020-02-19 11:18:07 +00:00
parent 52353d04ae
commit ae6f893463
9 changed files with 88 additions and 51 deletions

View File

@ -41,7 +41,7 @@ export default {
this.$store.dispatch('app/ping')
// this.$store.dispatch('tiles/getApps')
// this.$store.dispatch('tags/getTags')
this.$store.dispatch('tiles/getPossibleApps')
// this.$store.dispatch('tiles/getPossibleApps')
this.$store.dispatch('app/getUsers')
}
}

View File

@ -189,7 +189,7 @@ export default {
this.possibletags = this.application.tags || []
} else {
const needle = val.toLowerCase()
let tags = this.application.tags || []
const tags = this.application.tags || []
this.possibletags = tags.filter(
v => v.toLowerCase().indexOf(needle) > -1
)

View File

@ -189,7 +189,7 @@ export default {
this.possibletags = this.application.tags || []
} else {
const needle = val.toLowerCase()
let tags = this.application.tags || []
const tags = this.application.tags || []
this.possibletags = tags.filter(
v => v.toLowerCase().indexOf(needle) > -1
)

View File

@ -22,16 +22,16 @@ export default {
computed: {
textColor () {
let bgColor = this.application.color
let lightColor = '#ffffff'
let darkColor = '#000000'
let color = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor
let alpha = (bgColor.charAt(0) === '#') ? bgColor.substring(7, 9) : bgColor.substring(6, 8)
let r = parseInt(color.substring(0, 2), 16) // hexToR
let g = parseInt(color.substring(2, 4), 16) // hexToG
let b = parseInt(color.substring(4, 6), 16) // hexToB
let a = parseFloat(parseInt((parseInt(alpha, 16) / 255) * 1000) / 1000)
let brightness = r * 0.299 + g * 0.587 + b * 0.114 + (1 - a) * 255
const bgColor = this.application.color
const lightColor = '#ffffff'
const darkColor = '#000000'
const color = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor
const alpha = (bgColor.charAt(0) === '#') ? bgColor.substring(7, 9) : bgColor.substring(6, 8)
const r = parseInt(color.substring(0, 2), 16) // hexToR
const g = parseInt(color.substring(2, 4), 16) // hexToG
const b = parseInt(color.substring(4, 6), 16) // hexToB
const a = parseFloat(parseInt((parseInt(alpha, 16) / 255) * 1000) / 1000)
const brightness = r * 0.299 + g * 0.587 + b * 0.114 + (1 - a) * 255
return brightness > 186 ? darkColor : lightColor
}
},

View File

@ -86,7 +86,6 @@
<q-stepper-navigation>
<q-btn @click="saveSettings" color="primary" label="Continue" />
<q-btn flat @click="step = 1" color="primary" label="Back" class="q-ml-sm" />
</q-stepper-navigation>
</q-step>
@ -95,13 +94,10 @@
:title="this.$t('select_system_defaults')"
icon="add_comment"
>
Try out different ad text to see what brings in the most customers, and learn how to
enhance your ads using features like ad extensions. If you run into any problems with
your ads, find out how to tell if they're running and how to resolve approval issues.
Setup is complete!
<q-stepper-navigation>
<q-btn @click="saveUserSettings" color="primary" label="Finish" />
<q-btn flat @click="step = 2" color="primary" label="Back" class="q-ml-sm" />
<q-btn @click="finish" color="primary" label="Finish" />
</q-stepper-navigation>
</q-step>
</q-stepper>
@ -167,10 +163,13 @@ export default {
},
saveSettings () {
this.$store.dispatch('app/setDefaults', {
language: this.language,
show_usernames: this.showusername
language: this.language.value,
show_usernames: this.showusername.value
})
},
finish () {
this.$store.dispatch('app/setupComplete')
},
saveUserSettings () {
}
}

View File

@ -1,6 +1,11 @@
<template>
<q-page class="flex flex-center">
<div class="noapps" v-if="applications.length === 0">
There are currently no apps
<q-btn style="margin-top: 20px;" unelevated color="cyan-8" to="/item">Manage apps</q-btn>
</div>
<Tile
v-else
v-for="application in applications"
:key="application.id"
v-bind="application"
@ -39,3 +44,23 @@ export default {
}
}
</script>
<style lang="scss">
.noapps {
display: flex;
flex-direction: column;
width: 100%;
max-width: 360px;
margin: 30px;
padding: 30px;
height: 100%;
max-height: 200px;
min-height: 200px;
background: #00000075;
color: white;
justify-content: center;
align-items: center;
border-radius: 5px;
font-size: 16px;
border: 4px solid #ffffffd4;
}
</style>

View File

@ -116,7 +116,7 @@ export default {
this.$store.dispatch('app/setUser', this.selecteduser)
},
login () {
let username = (this.show_usernames === true) ? this.selecteduser.username : this.username
const username = (this.show_usernames === true) ? this.selecteduser.username : this.username
this.$store.dispatch('app/login', {
username: username,
password: this.password

View File

@ -3,9 +3,10 @@ import { Notify, Cookies, LocalStorage } from 'quasar'
export function ping (context) {
// console.log(Cookies.getAll())
// console.log('ping')
// console.log(process.env.BACKEND_LOCATION + 'ping')
// Check to see if we are in setup
let setup = LocalStorage.getItem('heimdall_setup')
const setup = LocalStorage.getItem('heimdall_setup')
if (setup !== null) {
context.commit('ping', 'setup')
context.commit('step', setup)
@ -27,7 +28,7 @@ export function ping (context) {
context.commit('setUser', response.data.result)
context.dispatch('tiles/getApps', null, { root: true })
}
}).catch(function () {
}).catch(() => {
Notify.create({
type: 'negative',
message: `Could not connect to backend server. ` + process.env.BACKEND_LOCATION + 'ping',
@ -41,7 +42,13 @@ export function ping (context) {
export async function setupUser (context, data) {
// console.log(data)
try {
await axios.post(process.env.BACKEND_LOCATION + 'users', data)
data.level = 0
const saveuser = await axios.post(process.env.BACKEND_LOCATION + 'users', data)
console.log(saveuser)
await firelogin(context, {
username: data.username,
password: data.password
})
context.commit('step', 2)
} catch (e) {
// axios returned a non-200 response
@ -50,42 +57,48 @@ export async function setupUser (context, data) {
export async function setDefaults (context, data) {
// const [ language, show_usernames ] = await Promise.all([
await Promise.all([
/* await Promise.all([
axios.put(process.env.BACKEND_LOCATION + 'settings', data.language),
axios.put(process.env.BACKEND_LOCATION + 'settings', data.show_usernames)
])
]) */
axios.put(process.env.BACKEND_LOCATION + 'settings', data)
context.commit('step', 3)
}
export function setupComplete (context) {
LocalStorage.remove('heimdall_setup')
console.log('finish')
ping(context)
}
export function setUser (context, user) {
// console.log(data)
context.commit('setUser', user)
}
export function login (context, data) {
export async function firelogin (context, data) {
const response = await axios.post(process.env.BACKEND_LOCATION + 'login', data)
// console.log(response.data)
Cookies.set('jwt', response.data.result.token, {
expires: 3600
})
return response
}
export async function login (context, data) {
// console.log(data)
axios
.post(process.env.BACKEND_LOCATION + 'login', data)
.then((response) => {
console.log(response.data)
/* Cookies.remove('jwt', {
expires: 3600
}) */
Cookies.set('jwt', response.data.result.token, {
expires: 3600
// httpOnly: true
})
// context.commit('step', 2)
ping(context)
}).catch(function () {
Notify.create({
type: 'negative',
message: `Could not log in.`,
progress: true,
position: 'top',
timeout: 1500
})
try {
await firelogin(context, data)
ping(context)
} catch (e) {
Notify.create({
type: 'negative',
message: `Could not log in.`,
progress: true,
position: 'top',
timeout: 1500
})
}
}
export function logout (context) {

View File

@ -13,8 +13,8 @@ export function getApps (context) {
}
export function getPossibleApps (context, force = false) {
let key = 'heimdall.possibleapps'
let possibleapps = LocalStorage.getItem(key)
const key = 'heimdall.possibleapps'
const possibleapps = LocalStorage.getItem(key)
// console.log(possibleapps)
if (possibleapps === null || force === true) {
axios