refactor: renderers + auth providers + fixes

This commit is contained in:
NGPixel
2018-01-14 22:05:08 -05:00
parent 24fc806b0e
commit 74bd722168
41 changed files with 466 additions and 768 deletions

View File

@@ -1,5 +1,3 @@
'use strict'
/* global $, siteRoot */
let mde

View File

@@ -55,7 +55,8 @@ export default {
this.selectedStrategy = key
this.screen = 'login'
if (!useForm) {
window.location.assign(siteConfig.path + 'login/' + key)
this.isLoading = true
window.location.assign(this.$helpers.resolvePath('login/' + key))
} else {
this.$refs.iptEmail.focus()
}

View File

@@ -15,12 +15,24 @@
use(:xlink:href='subtitleIconClass')
h2 {{subtitleText}}
.navigator-action
.navigator-action-item
.navigator-action-item(:class='{"is-active": userMenuShown}', @click='toggleUserMenu')
svg.icons.is-32(role='img')
title User
use(xlink:href='#nc-user-circle')
transition(name='navigator-action-item-dropdown')
ul.navigator-action-item-dropdown(v-show='userMenuShown', v-cloak)
li
label Account
svg.icons.is-24(role='img')
title Account
use(xlink:href='#nc-man-green')
li(@click='logout')
label Sign out
svg.icons.is-24(role='img')
title Sign Out
use(xlink:href='#nc-exit')
transition(name='navigator-sd')
.navigator-sd(v-show='sdShown')
.navigator-sd(v-show='sdShown', v-cloak)
.navigator-sd-actions
a.is-active(href='', title='Search')
svg.icons.is-24(role='img')
@@ -77,7 +89,8 @@ export default {
name: 'navigator',
data() {
return {
sdShown: false
sdShown: false,
userMenuShown: false
}
},
computed: {
@@ -104,16 +117,39 @@ export default {
methods: {
toggleMainMenu() {
this.sdShown = !this.sdShown
this.userMenuShown = false
if (this.sdShown) {
this.$nextTick(() => {
this.bindOutsideClick()
this.$refs.iptSearch.focus()
})
} else {
this.unbindOutsideClick()
}
// this.$store.dispatch('navigator/alert', {
// style: 'success',
// icon: 'gg-check',
// msg: 'Changes were saved successfully!'
// })
},
toggleUserMenu() {
this.userMenuShown = !this.userMenuShown
this.sdShown = false
if (this.userMenuShown) {
this.bindOutsideClick()
} else {
this.unbindOutsideClick()
}
},
bindOutsideClick() {
document.addEventListener('mousedown', this.handleOutsideClick, false)
},
unbindOutsideClick() {
document.removeEventListener('mousedown', this.handleOutsideClick, false)
},
handleOutsideClick(ev) {
if (!this.$el.contains(ev.target)) {
this.sdShown = false
this.userMenuShown = false
}
},
logout() {
window.location.assign(this.$helpers.resolvePath('logout'))
}
},
mounted() {

View File

@@ -24,7 +24,7 @@ export default {
final: {
ok: false,
error: '',
results: []
redirectUrl: ''
},
conf: {
adminEmail: '',
@@ -219,19 +219,32 @@ export default {
self.final = {
ok: false,
error: '',
results: []
redirectUrl: ''
}
this.$helpers._.delay(() => {
axios.post('/finalize', self.conf).then(resp => {
if (resp.data.ok === true) {
self.final.ok = true
self.final.results = resp.data.results
self.$helpers._.delay(() => {
self.final.ok = true
switch (resp.data.redirectPort) {
case 80:
self.final.redirectUrl = `http://${window.location.hostname}${resp.data.redirectPath}/login`
break
case 443:
self.final.redirectUrl = `https://${window.location.hostname}${resp.data.redirectPath}/login`
break
default:
self.final.redirectUrl = `http://${window.location.hostname}:${resp.data.redirectPort}${resp.data.redirectPath}/login`
break
}
self.loading = false
}, 5000)
} else {
self.final.ok = false
self.final.error = resp.data.error
self.loading = false
}
self.loading = false
self.$nextTick()
}).catch(err => {
window.alert(err.message)
@@ -239,18 +252,7 @@ export default {
}, 1000)
},
finish: function (ev) {
let self = this
self.state = 'restart'
this.$helpers._.delay(() => {
axios.post('/restart', {}).then(resp => {
this.$helpers._.delay(() => {
window.location.assign(self.conf.host)
}, 30000)
}).catch(err => {
window.alert(err.message)
})
}, 1000)
window.location.assign(this.final.redirectUrl)
}
}
}

View File

@@ -1,15 +0,0 @@
'use strict'
import filesize from 'filesize.js'
import toUpper from 'lodash/toUpper'
module.exports = {
/**
* Convert bytes to humanized form
* @param {number} rawSize Size in bytes
* @returns {string} Humanized file size
*/
filesize(rawSize) {
return toUpper(filesize(rawSize))
}
}

View File

@@ -1,25 +0,0 @@
'use strict'
module.exports = {
/**
* Set Input Selection
* @param {DOMElement} input The input element
* @param {number} startPos The starting position
* @param {nunber} endPos The ending position
*/
setInputSelection: (input, startPos, endPos) => {
input.focus()
if (typeof input.selectionStart !== 'undefined') {
input.selectionStart = startPos
input.selectionEnd = endPos
} else if (document.selection && document.selection.createRange) {
// IE branch
input.select()
var range = document.selection.createRange()
range.collapse(true)
range.moveEnd('character', endPos)
range.moveStart('character', startPos)
range.select()
}
}
}

View File

@@ -1,10 +1,59 @@
'use strict'
import filesize from 'filesize.js'
/* global siteConfig */
const _ = require('./lodash')
const helpers = {
_: require('./lodash'),
common: require('./common'),
form: require('./form'),
pages: require('./pages')
/**
* Minimal set of lodash functions
*/
_,
/**
* Convert bytes to humanized form
* @param {number} rawSize Size in bytes
* @returns {string} Humanized file size
*/
filesize (rawSize) {
return _.toUpper(filesize(rawSize))
},
/**
* Convert raw path to safe path
* @param {string} rawPath Raw path
* @returns {string} Safe path
*/
makeSafePath (rawPath) {
let rawParts = _.split(_.trim(rawPath), '/')
rawParts = _.map(rawParts, (r) => {
return _.kebabCase(_.deburr(_.trim(r)))
})
return _.join(_.filter(rawParts, (r) => { return !_.isEmpty(r) }), '/')
},
resolvePath (path) {
if (_.startsWith(path, '/')) { path = path.substring(1) }
return `${siteConfig.path}${path}`
},
/**
* Set Input Selection
* @param {DOMElement} input The input element
* @param {number} startPos The starting position
* @param {nunber} endPos The ending position
*/
setInputSelection (input, startPos, endPos) {
input.focus()
if (typeof input.selectionStart !== 'undefined') {
input.selectionStart = startPos
input.selectionEnd = endPos
} else if (document.selection && document.selection.createRange) {
// IE branch
input.select()
var range = document.selection.createRange()
range.collapse(true)
range.moveEnd('character', endPos)
range.moveStart('character', startPos)
range.select()
}
}
}
export default {

View File

@@ -1,5 +1,3 @@
'use strict'
// ====================================
// Load minimal lodash
// ====================================

View File

@@ -1,26 +0,0 @@
'use strict'
import deburr from 'lodash/deburr'
import filter from 'lodash/filter'
import isEmpty from 'lodash/isEmpty'
import join from 'lodash/join'
import kebabCase from 'lodash/kebabCase'
import map from 'lodash/map'
import split from 'lodash/split'
import trim from 'lodash/trim'
module.exports = {
/**
* Convert raw path to safe path
* @param {string} rawPath Raw path
* @returns {string} Safe path
*/
makeSafePath: (rawPath) => {
let rawParts = split(trim(rawPath), '/')
rawParts = map(rawParts, (r) => {
return kebabCase(deburr(trim(r)))
})
return join(filter(rawParts, (r) => { return !isEmpty(r) }), '/')
}
}

View File

@@ -45,7 +45,7 @@ module.exports = {
defaultNS: 'common',
lng: siteConfig.lang,
fallbackLng: siteConfig.lang,
ns: ['common', 'admin', 'auth']
ns: ['common', 'auth']
})
return new VueI18Next(i18next)
}

View File

@@ -1,5 +1,3 @@
'use strict'
export default {
name: 'admin-edit-user',
props: ['usrdata'],

View File

@@ -1,5 +1,3 @@
'use strict'
export default {
name: 'admin-profile',
props: ['email', 'name', 'provider', 'tfaIsActive'],

View File

@@ -1,5 +1,3 @@
'use strict'
export default {
name: 'admin-settings',
data() {

View File

@@ -1,5 +1,3 @@
'use strict'
export default {
name: 'admin-theme',
props: ['themedata'],

View File

@@ -1,5 +1,3 @@
'use strict'
/* global $ */
export default {

View File

@@ -1,5 +1,3 @@
'use strict'
export default {
name: 'source-view',
data() {

View File

@@ -1,5 +1,3 @@
'use strict'
export default {
namespaced: true,
state: {
@@ -15,7 +13,6 @@ export default {
},
actions: {
open({ commit }, hash) {
console.info('MIGUEL!')
commit('anchorChange', { shown: true, hash })
},
close({ commit }) {

View File

@@ -3,6 +3,7 @@ .navigator {
top: 0;
left: 0;
width: 100%;
z-index: 100;
&-bar {
display: flex;
@@ -123,6 +124,7 @@ .navigator {
display: flex;
justify-content: flex-end;
align-items: stretch;
position: relative;
&-item {
display: flex;
@@ -130,6 +132,7 @@ .navigator {
align-items: center;
width: 50px;
cursor: pointer;
transition: all .4s ease;
svg use {
color: #FFF;
@@ -143,6 +146,60 @@ .navigator {
fill: mc('blue', '500');
}
}
&.is-active {
background-color: #FFF;
svg use {
color: mc('grey', '500');
fill: mc('grey', '500');
}
}
&-dropdown {
position: absolute;
right: 0;
top: 100%;
width: 250px;
border-radius: 0 0 0 5px;
transition: all .4s ease;
transform-origin: top right;
&-enter-active, &-leave-active {
transform: scale(1);
}
&-enter, &-leave-to {
transform: scale(.1, 0);
}
li {
background-color: #FFF;
height: 50px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 .8rem 0 1rem;
& + li {
border-top: 1px solid mc('grey', '100');
}
&:hover {
background-color: mc('grey', '100');
}
label {
font-size: .8rem;
font-weight: 600;
color: mc('blue', '800');
text-transform: uppercase;
}
&:last-child {
border-radius: 0 0 0 5px;
}
}
}
}
}

View File

@@ -166,7 +166,7 @@
</g>
</g>
</symbol>
<symbol id="nc-man" viewBox="0 0 48 48">
<symbol id="nc-man-green" viewBox="0 0 48 48">
<g>
<g class="nc-icon-wrapper">
<rect x="18" y="24" fill-rule="evenodd" clip-rule="evenodd" fill="#EAC3A2" width="12" height="15"/>
@@ -288,7 +288,7 @@
</g>
</g>
</symbol>
<symbol id="nc-man" viewBox="0 0 48 48">
<symbol id="nc-man-black" viewBox="0 0 48 48">
<g>
<g class="nc-icon-wrapper">
<rect x="17.9983292" y="24" fill-rule="evenodd" clip-rule="evenodd" fill="#EAC3A2" width="12" height="17"/>
@@ -440,4 +440,12 @@
<path fill="#335262" d="M24,13c-6.07513,0-11,4.92487-11,11s4.92487,11,11,11s11-4.92487,11-11S30.07513,13,24,13z M24,31 c-3.86597,0-7-3.13403-7-7c0-3.86603,3.13403-7,7-7c3.86603,0,7,3.13397,7,7C31,27.86597,27.86603,31,24,31z"></path>
</g>
</symbol>
<symbol id='nc-exit' viewBox="0 0 48 48">
<g class="nc-icon-wrapper">
<rect x="2" y="2" fill="#59391F" width="24" height="30"></rect>
<path fill="#A67C52" d="M26,33H2c-0.55225,0-1-0.44727-1-1V2c0-0.55273,0.44775-1,1-1h24c0.55225,0,1,0.44727,1,1v30 C27,32.55273,26.55225,33,26,33z M3,31h22V3H3V31z"></path>
<path fill="#A67C52" d="M16.58252,11.21875l-14-10.03125C2.27686,0.96875,1.87549,0.93848,1.54297,1.11035 C1.20947,1.28223,1,1.625,1,2v30c0,0.32324,0.15576,0.62598,0.41895,0.81348l14,10C15.5918,42.9375,15.79541,43,16,43 c0.15625,0,0.31348-0.03711,0.45752-0.11035C16.79053,42.71777,17,42.375,17,42V12.03125 C17,11.70898,16.84473,11.40625,16.58252,11.21875z"></path>
<path fill="#EFD358" d="M45.61377,17.21094l-9-7c-0.30127-0.23438-0.70996-0.27734-1.05322-0.10938 C35.21777,10.26953,35,10.61816,35,11v5H22c-0.55228,0-1,0.44772-1,1v2c0,0.55228,0.44772,1,1,1h13v5 c0,0.38184,0.21777,0.73047,0.56055,0.89844C35.7002,25.9668,35.8501,26,36,26c0.21826,0,0.43506-0.07129,0.61377-0.21094l9-7 C45.85742,18.59961,46,18.30859,46,18S45.85742,17.40039,45.61377,17.21094z"></path>
</g>
</symbol>
</svg>

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 46 KiB