fix: eslint for vue components

This commit is contained in:
NGPixel
2017-10-29 21:36:05 -04:00
parent 72e3bacc2e
commit 98d311145b
45 changed files with 953 additions and 1253 deletions

View File

@@ -6,16 +6,16 @@
</template>
<script>
export default {
name: 'alert',
data () {
return {}
},
computed: {
shown() { return this.$store.state.alert.shown },
style() { return 'is-' + this.$store.state.alert.style },
icon() { return 'nc-icon-outline ' + this.$store.state.alert.icon },
msg() { return this.$store.state.alert.msg },
}
export default {
name: 'alert',
data () {
return {}
},
computed: {
shown() { return this.$store.state.alert.shown },
style() { return 'is-' + this.$store.state.alert.style },
icon() { return 'nc-icon-outline ' + this.$store.state.alert.icon },
msg() { return this.$store.state.alert.msg }
}
}
</script>

View File

@@ -17,39 +17,39 @@
</template>
<script>
export default {
name: 'anchor',
data () {
return {}
export default {
name: 'anchor',
data () {
return {}
},
computed: {
anchorURL () {
return window.location.href.split('#')[0] + '#' + this.$store.state.anchor.hash
},
computed: {
anchorURL () {
return window.location.href.split('#')[0] + '#' + this.$store.state.anchor.hash
},
isShown () {
return this.$store.state.anchor.shown
}
isShown () {
return this.$store.state.anchor.shown
}
},
methods: {
cancel () {
this.$store.dispatch('anchor/close')
},
methods: {
cancel () {
this.$store.dispatch('anchor/close')
},
clipboardSuccess () {
this.$store.dispatch('alert', {
style: 'blue',
icon: 'business_notes',
msg: this.$t('modal.anchorsuccess')
})
this.$store.dispatch('anchor/close')
},
clipboardError () {
this.$store.dispatch('alert', {
style: 'red',
icon: 'business_notes',
msg: this.$t('modal.anchorerror')
})
this.$refs.anchorURLinput.select()
}
clipboardSuccess () {
this.$store.dispatch('alert', {
style: 'blue',
icon: 'business_notes',
msg: this.$t('modal.anchorsuccess')
})
this.$store.dispatch('anchor/close')
},
clipboardError () {
this.$store.dispatch('alert', {
style: 'red',
icon: 'business_notes',
msg: this.$t('modal.anchorerror')
})
this.$refs.anchorURLinput.select()
}
}
}
</script>

View File

@@ -4,38 +4,38 @@
</template>
<script>
export default {
name: 'color-picker',
props: ['value'],
data () {
return {
colors: [
'red',
'pink',
'purple',
'deep-purple',
'indigo',
'blue',
'light-blue',
'cyan',
'teal',
'green',
'light-green',
'lime',
'yellow',
'amber',
'orange',
'deep-orange',
'brown',
'grey',
'blue-grey'
]
}
},
methods: {
setColor(color) {
this.$emit('input', color)
}
export default {
name: 'color-picker',
props: ['value'],
data () {
return {
colors: [
'red',
'pink',
'purple',
'deep-purple',
'indigo',
'blue',
'light-blue',
'cyan',
'teal',
'green',
'light-green',
'lime',
'yellow',
'amber',
'orange',
'deep-orange',
'brown',
'grey',
'blue-grey'
]
}
},
methods: {
setColor(color) {
this.$emit('input', color)
}
}
}
</script>

View File

@@ -27,29 +27,28 @@ export default {
results: []
},
conf: {
telemetry: true,
upgrade: false,
title: siteConfig.title || 'Wiki',
path: siteConfig.path || '/',
port: siteConfig.port || 80,
lang: siteConfig.lang || 'en',
public: (siteConfig.public === true),
pathData: './data',
pathRepo: './repo',
gitUseRemote: (siteConfig.git !== false),
gitUrl: '',
gitBranch: 'master',
gitAuthType: 'ssh',
gitAuthSSHKey: '',
gitAuthUser: '',
gitAuthPass: '',
gitAuthSSL: true,
gitShowUserEmail: true,
gitServerEmail: '',
mongo: 'mongodb://',
adminEmail: '',
adminPassword: '',
adminPasswordConfirm: ''
adminPasswordConfirm: '',
gitAuthPass: '',
gitAuthSSHKey: '',
gitAuthSSL: true,
gitAuthType: 'ssh',
gitAuthUser: '',
gitBranch: 'master',
gitServerEmail: '',
gitShowUserEmail: true,
gitUrl: '',
gitUseRemote: (siteConfig.git !== false),
lang: siteConfig.lang || 'en',
mongo: 'mongodb://',
path: siteConfig.path || '/',
pathRepo: './repo',
port: siteConfig.port || 80,
public: (siteConfig.public === true),
telemetry: true,
title: siteConfig.title || 'Wiki',
upgrade: false
},
considerations: {
https: false,

View File

@@ -81,7 +81,7 @@ export default {
self.isLoading = true
self.$http.get('/js/ace/mode-' + m + '.js').then(resp => {
if (resp.ok) {
eval(resp.bodyText)
eval(resp.bodyText) // eslint-disable-line no-eval
self.modelistLoaded.push(m)
ace.acequire('ace/mode/' + m)
codeEditor.getSession().setMode('ace/mode/' + m)

View File

@@ -128,476 +128,478 @@
</template>
<script>
export default {
name: 'editor-file',
data () {
return {
isLoading: false,
isLoadingText: '',
newFolderName: '',
newFolderShow: false,
newFolderError: false,
fetchFromUrlURL: '',
fetchFromUrlShow: false,
folders: [],
currentFolder: '',
currentFile: '',
currentAlign: 'left',
files: [],
uploadSucceeded: false,
postUploadChecks: 0,
renameFileShow: false,
renameFileId: '',
renameFileFilename: '',
deleteFileShow: false,
deleteFileId: '',
deleteFileFilename: ''
}
/* global $, socket */
export default {
name: 'editor-file',
data () {
return {
isLoading: false,
isLoadingText: '',
newFolderName: '',
newFolderShow: false,
newFolderError: false,
fetchFromUrlURL: '',
fetchFromUrlShow: false,
folders: [],
currentFolder: '',
currentFile: '',
currentAlign: 'left',
files: [],
uploadSucceeded: false,
postUploadChecks: 0,
renameFileShow: false,
renameFileId: '',
renameFileFilename: '',
deleteFileShow: false,
deleteFileId: '',
deleteFileFilename: ''
}
},
computed: {
isShown () {
return this.$store.state.editorFile.shown
},
computed: {
isShown () {
return this.$store.state.editorFile.shown
},
mode () {
return this.$store.state.editorFile.mode
}
mode () {
return this.$store.state.editorFile.mode
}
},
methods: {
init () {
$(this.$refs.editorFileUploadInput).on('change', this.upload)
this.refreshFolders()
},
cancel () {
$(this.$refs.editorFileUploadInput).off('change', this.upload)
this.$store.dispatch('editorFile/close')
},
filesize (rawSize) {
return this.$helpers.common.filesize(rawSize)
},
methods: {
init () {
$(this.$refs.editorFileUploadInput).on('change', this.upload)
this.refreshFolders()
},
cancel () {
$(this.$refs.editorFileUploadInput).off('change', this.upload)
this.$store.dispatch('editorFile/close')
},
filesize (rawSize) {
return this.$helpers.common.filesize(rawSize)
},
// -------------------------------------------
// INSERT LINK TO FILE
// -------------------------------------------
// -------------------------------------------
// INSERT LINK TO FILE
// -------------------------------------------
selectFile(fileId) {
this.currentFile = fileId
},
insertFileLink() {
let selFile = this._.find(this.files, ['_id', this.currentFile])
selFile.normalizedPath = (selFile.folder === 'f:') ? selFile.filename : selFile.folder.slice(2) + '/' + selFile.filename
selFile.titleGuess = this._.startCase(selFile.basename)
selectFile(fileId) {
this.currentFile = fileId
},
insertFileLink() {
let selFile = this._.find(this.files, ['_id', this.currentFile])
selFile.normalizedPath = (selFile.folder === 'f:') ? selFile.filename : selFile.folder.slice(2) + '/' + selFile.filename
selFile.titleGuess = this._.startCase(selFile.basename)
let textToInsert = ''
let textToInsert = ''
if (this.mode === 'image') {
textToInsert = '![' + selFile.titleGuess + '](/uploads/' + selFile.normalizedPath + ' "' + selFile.titleGuess + '")'
switch (this.currentAlign) {
case 'center':
textToInsert += '{.align-center}'
break
case 'right':
textToInsert += '{.align-right}'
break
case 'logo':
textToInsert += '{.pagelogo}'
break
}
} else {
textToInsert = '[' + selFile.titleGuess + '](/uploads/' + selFile.normalizedPath + ' "' + selFile.titleGuess + '")'
if (this.mode === 'image') {
textToInsert = '![' + selFile.titleGuess + '](/uploads/' + selFile.normalizedPath + ' "' + selFile.titleGuess + '")'
switch (this.currentAlign) {
case 'center':
textToInsert += '{.align-center}'
break
case 'right':
textToInsert += '{.align-right}'
break
case 'logo':
textToInsert += '{.pagelogo}'
break
}
} else {
textToInsert = '[' + selFile.titleGuess + '](/uploads/' + selFile.normalizedPath + ' "' + selFile.titleGuess + '")'
}
this.$store.dispatch('editor/insert', textToInsert)
this.$store.dispatch('alert', {
style: 'blue',
icon: 'ui-1_check-square-09',
msg: (this.mode === 'file') ? this.$t('editor.filesuccess') : this.$t('editor.imagesuccess')
this.$store.dispatch('editor/insert', textToInsert)
this.$store.dispatch('alert', {
style: 'blue',
icon: 'ui-1_check-square-09',
msg: (this.mode === 'file') ? this.$t('editor.filesuccess') : this.$t('editor.imagesuccess')
})
this.cancel()
},
// -------------------------------------------
// NEW FOLDER
// -------------------------------------------
newFolder() {
let self = this
this.newFolderName = ''
this.newFolderError = false
this.newFolderShow = true
this._.delay(() => { self.$refs.editorFileNewFolderInput.focus() }, 400)
},
newFolderDiscard() {
this.newFolderShow = false
},
newFolderCreate() {
let self = this
let regFolderName = new RegExp('^[a-z0-9][a-z0-9-]*[a-z0-9]$')
this.newFolderName = this._.kebabCase(this._.trim(this.newFolderName))
if (this._.isEmpty(this.newFolderName) || !regFolderName.test(this.newFolderName)) {
this.newFolderError = true
return
}
this.newFolderDiscard()
this.isLoadingText = this.$t('modal.newfolderloading')
this.isLoading = true
this.$nextTick(() => {
socket.emit('uploadsCreateFolder', { foldername: self.newFolderName }, (data) => {
self.folders = data
self.currentFolder = self.newFolderName
self.files = []
self.isLoading = false
self.$store.dispatch('alert', {
style: 'blue',
icon: 'files_folder-check',
msg: self.$t('modal.newfoldersuccess', { name: self.newFolderName })
})
})
this.cancel()
},
})
},
// -------------------------------------------
// NEW FOLDER
// -------------------------------------------
// -------------------------------------------
// FETCH FROM URL
// -------------------------------------------
newFolder() {
let self = this
this.newFolderName = ''
this.newFolderError = false
this.newFolderShow = true
this._.delay(() => { self.$refs.editorFileNewFolderInput.focus() }, 400)
},
newFolderDiscard() {
this.newFolderShow = false
},
newFolderCreate() {
let self = this
let regFolderName = new RegExp('^[a-z0-9][a-z0-9-]*[a-z0-9]$')
this.newFolderName = this._.kebabCase(this._.trim(this.newFolderName))
fetchFromUrl() {
let self = this
this.fetchFromUrlURL = ''
this.fetchFromUrlShow = true
this._.delay(() => { self.$refs.editorFileFetchInput.focus() }, 400)
},
fetchFromUrlDiscard() {
this.fetchFromUrlShow = false
},
fetchFromUrlGo() {
let self = this
this.fetchFromUrlDiscard()
this.isLoadingText = 'Fetching image...'
this.isLoading = true
if (this._.isEmpty(this.newFolderName) || !regFolderName.test(this.newFolderName)) {
this.newFolderError = true
return
}
this.newFolderDiscard()
this.isLoadingText = this.$t('modal.newfolderloading')
this.isLoading = true
this.$nextTick(() => {
socket.emit('uploadsCreateFolder', { foldername: self.newFolderName }, (data) => {
self.folders = data
self.currentFolder = self.newFolderName
self.files = []
this.$nextTick(() => {
socket.emit('uploadsFetchFileFromURL', { folder: self.currentFolder, fetchUrl: self.fetchFromUrlURL }, (data) => {
if (data.ok) {
self.waitChangeComplete(self.files.length, true)
} else {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'blue',
icon: 'files_folder-check',
msg: self.$t('modal.newfoldersuccess', { name: self.newFolderName })
})
})
})
},
// -------------------------------------------
// FETCH FROM URL
// -------------------------------------------
fetchFromUrl() {
let self = this
this.fetchFromUrlURL = ''
this.fetchFromUrlShow = true
this._.delay(() => { self.$refs.editorFileFetchInput.focus() }, 400)
},
fetchFromUrlDiscard() {
this.fetchFromUrlShow = false
},
fetchFromUrlGo() {
let self = this
this.fetchFromUrlDiscard()
this.isLoadingText = 'Fetching image...'
this.isLoading = true
this.$nextTick(() => {
socket.emit('uploadsFetchFileFromURL', { folder: self.currentFolder, fetchUrl: self.fetchFromUrlURL }, (data) => {
if (data.ok) {
self.waitChangeComplete(self.files.length, true)
} else {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.fileuploaderror', { err: data.msg })
})
}
})
})
},
// -------------------------------------------
// RENAME FILE
// -------------------------------------------
renameFile() {
let self = this
let c = this._.find(this.files, [ '_id', this.renameFileId ])
this.renameFileFilename = c.basename || ''
this.renameFileShow = true
this._.delay(() => {
self.$refs.editorFileRenameInput.select()
}, 100)
},
renameFileDiscard() {
this.renameFileShow = false
},
renameFileGo() {
let self = this
this.renameFileDiscard()
this.isLoadingText = this.$t('modal.renamefileloading')
this.isLoading = true
this.$nextTick(() => {
socket.emit('uploadsRenameFile', { uid: self.renameFileId, folder: self.currentFolder, filename: self.renameFileFilename }, (data) => {
if (data.ok) {
self.waitChangeComplete(self.files.length, false)
} else {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('modal.renamefileerror', { err: data.msg })
})
}
})
})
},
// -------------------------------------------
// MOVE FILE
// -------------------------------------------
moveFile(uid, fld) {
let self = this
this.isLoadingText = this.$t('editor.filemoveloading')
this.isLoading = true
this.$nextTick(() => {
socket.emit('uploadsMoveFile', { uid, folder: fld }, (data) => {
if (data.ok) {
self.loadFiles()
self.$store.dispatch('alert', {
style: 'blue',
icon: 'files_check',
msg: self.$t('editor.filemovesuccess')
})
} else {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.filemoveerror', { err: data.msg })
})
}
})
})
},
// -------------------------------------------
// DELETE FILE
// -------------------------------------------
deleteFileWarn(show) {
if (show) {
let c = this._.find(this.files, [ '_id', this.deleteFileId ])
this.deleteFileFilename = c.filename || this.$t('editor.filedeletedefault')
}
this.deleteFileShow = show
},
deleteFileGo() {
let self = this
this.deleteFileWarn(false)
this.isLoadingText = this.$t('editor.filedeleteloading')
this.isLoading = true
this.$nextTick(() => {
socket.emit('uploadsDeleteFile', { uid: this.deleteFileId }, (data) => {
self.loadFiles()
self.$store.dispatch('alert', {
style: 'blue',
icon: 'ui-1_trash',
msg: self.$t('editor.filedeletesuccess')
})
})
})
},
// -------------------------------------------
// LOAD FROM REMOTE
// -------------------------------------------
selectFolder(fldName) {
this.currentFolder = fldName
this.loadFiles()
},
refreshFolders() {
let self = this
this.isLoadingText = this.$t('editor.foldersloading')
this.isLoading = true
this.currentFolder = ''
this.currentImage = ''
this.$nextTick(() => {
socket.emit('uploadsGetFolders', { }, (data) => {
self.folders = data
self.loadFiles()
})
})
},
loadFiles(silent) {
let self = this
if (!silent) {
this.isLoadingText = this.$t('editor.fileloading')
this.isLoading = true
}
return new Promise((resolve, reject) => {
self.$nextTick(() => {
let loadAction = (self.mode === 'image') ? 'uploadsGetImages' : 'uploadsGetFiles'
socket.emit(loadAction, { folder: self.currentFolder }, (data) => {
self.files = data
if (!silent) {
self.isLoading = false
}
self.attachContextMenus()
resolve(true)
})
})
})
},
waitChangeComplete(oldAmount, expectChange) {
let self = this
expectChange = (this._.isBoolean(expectChange)) ? expectChange : true
this.postUploadChecks++
this.isLoadingText = this.$t('editor.fileprocessing')
this.$nextTick(() => {
self.loadFiles(true).then(() => {
if ((self.files.length !== oldAmount) === expectChange) {
self.postUploadChecks = 0
self.isLoading = false
} else if (self.postUploadChecks > 5) {
self.postUploadChecks = 0
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.fileerror')
})
} else {
self._.delay(() => {
self.waitChangeComplete(oldAmount, expectChange)
}, 1500)
}
})
})
},
// -------------------------------------------
// IMAGE CONTEXT MENU
// -------------------------------------------
attachContextMenus() {
let self = this
let moveFolders = this._.map(this.folders, (f) => {
return {
name: (f !== '') ? f : '/ (root)',
icon: 'nc-icon-outline files_folder-15',
callback: (key, opt) => {
let moveFileId = self._.toString($(opt.$trigger).data('uid'))
let moveFileDestFolder = self._.nth(self.folders, key)
self.moveFile(moveFileId, moveFileDestFolder)
}
}
})
$.contextMenu('destroy', '.editor-modal-choices > figure')
$.contextMenu({
selector: '.editor-modal-choices > figure',
appendTo: '.editor-modal-choices',
position: (opt, x, y) => {
$(opt.$trigger).addClass('is-contextopen')
let trigPos = $(opt.$trigger).position()
let trigDim = { w: $(opt.$trigger).width() / 5, h: $(opt.$trigger).height() / 2 }
opt.$menu.css({ top: trigPos.top + trigDim.h, left: trigPos.left + trigDim.w })
},
events: {
hide: (opt) => {
$(opt.$trigger).removeClass('is-contextopen')
}
},
items: {
rename: {
name: self.$t('editor.filerenameaction'),
icon: 'nc-icon-outline files_vector',
callback: (key, opt) => {
self.renameFileId = self._.toString(opt.$trigger[0].dataset.uid)
self.renameFile()
}
},
move: {
name: self.$t('editor.filemoveaction'),
icon: 'fa-folder-open-o',
items: moveFolders
},
delete: {
name: self.$t('editor.filedeleteaction'),
icon: 'icon-trash2',
callback: (key, opt) => {
self.deleteFileId = self._.toString(opt.$trigger[0].dataset.uid)
self.deleteFileWarn(true)
}
}
}
})
},
upload() {
let self = this
let curFileAmount = this.files.length
let uplUrl = (self.mode === 'image') ? '/uploads/img' : '/uploads/file'
$(this.$refs.editorFileUploadInput).simpleUpload(uplUrl, {
name: (self.mode === 'image') ? 'imgfile' : 'binfile',
data: {
folder: self.currentFolder
},
limit: 20,
expect: 'json',
allowedExts: (self.mode === 'image') ? ['jpg', 'jpeg', 'gif', 'png', 'webp'] : undefined,
allowedTypes: (self.mode === 'image') ? ['image/png', 'image/jpeg', 'image/gif', 'image/webp'] : undefined,
maxFileSize: (self.mode === 'image') ? 3145728 : 0, // max 3 MB
init: (totalUploads) => {
self.uploadSucceeded = false
self.isLoadingText = 'Preparing to upload...'
self.isLoading = true
},
progress: (progress) => {
self.isLoadingText = 'Uploading...' + Math.round(progress) + '%'
},
success: (data) => {
if (data.ok) {
let failedUpls = self._.filter(data.results, ['ok', false])
if (failedUpls.length) {
self._.forEach(failedUpls, (u) => {
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.fileuploaderror', { err: u.msg })
})
})
if (failedUpls.length < data.results.length) {
self.uploadSucceeded = true
}
} else {
self.uploadSucceeded = true
self.$store.dispatch('alert', {
style: 'blue',
icon: 'arrows-1_cloud-upload-96',
msg: self.$t('editor.fileuploadsuccess')
})
}
} else {
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.fileuploaderror', { err: data.msg })
})
}
},
error: (error) => {
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.fileuploaderror', { err: error.message })
msg: self.$t('editor.fileuploaderror', { err: data.msg })
})
},
}
})
})
},
finish: () => {
if (self.uploadSucceeded) {
self.waitChangeComplete(curFileAmount, true)
} else {
// -------------------------------------------
// RENAME FILE
// -------------------------------------------
renameFile() {
let self = this
let c = this._.find(this.files, [ '_id', this.renameFileId ])
this.renameFileFilename = c.basename || ''
this.renameFileShow = true
this._.delay(() => {
self.$refs.editorFileRenameInput.select()
}, 100)
},
renameFileDiscard() {
this.renameFileShow = false
},
renameFileGo() {
let self = this
this.renameFileDiscard()
this.isLoadingText = this.$t('modal.renamefileloading')
this.isLoading = true
this.$nextTick(() => {
socket.emit('uploadsRenameFile', { uid: self.renameFileId, folder: self.currentFolder, filename: self.renameFileFilename }, (data) => {
if (data.ok) {
self.waitChangeComplete(self.files.length, false)
} else {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('modal.renamefileerror', { err: data.msg })
})
}
})
})
},
// -------------------------------------------
// MOVE FILE
// -------------------------------------------
moveFile(uid, fld) {
let self = this
this.isLoadingText = this.$t('editor.filemoveloading')
this.isLoading = true
this.$nextTick(() => {
socket.emit('uploadsMoveFile', { uid, folder: fld }, (data) => {
if (data.ok) {
self.loadFiles()
self.$store.dispatch('alert', {
style: 'blue',
icon: 'files_check',
msg: self.$t('editor.filemovesuccess')
})
} else {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.filemoveerror', { err: data.msg })
})
}
})
})
},
// -------------------------------------------
// DELETE FILE
// -------------------------------------------
deleteFileWarn(show) {
if (show) {
let c = this._.find(this.files, [ '_id', this.deleteFileId ])
this.deleteFileFilename = c.filename || this.$t('editor.filedeletedefault')
}
this.deleteFileShow = show
},
deleteFileGo() {
let self = this
this.deleteFileWarn(false)
this.isLoadingText = this.$t('editor.filedeleteloading')
this.isLoading = true
this.$nextTick(() => {
socket.emit('uploadsDeleteFile', { uid: this.deleteFileId }, (data) => {
self.loadFiles()
self.$store.dispatch('alert', {
style: 'blue',
icon: 'ui-1_trash',
msg: self.$t('editor.filedeletesuccess')
})
})
})
},
// -------------------------------------------
// LOAD FROM REMOTE
// -------------------------------------------
selectFolder(fldName) {
this.currentFolder = fldName
this.loadFiles()
},
refreshFolders() {
let self = this
this.isLoadingText = this.$t('editor.foldersloading')
this.isLoading = true
this.currentFolder = ''
this.currentImage = ''
this.$nextTick(() => {
socket.emit('uploadsGetFolders', { }, (data) => {
self.folders = data
self.loadFiles()
})
})
},
loadFiles(silent) {
let self = this
if (!silent) {
this.isLoadingText = this.$t('editor.fileloading')
this.isLoading = true
}
return new Promise((resolve, reject) => {
self.$nextTick(() => {
let loadAction = (self.mode === 'image') ? 'uploadsGetImages' : 'uploadsGetFiles'
socket.emit(loadAction, { folder: self.currentFolder }, (data) => {
self.files = data
if (!silent) {
self.isLoading = false
}
}
self.attachContextMenus()
resolve(true)
})
})
}
})
},
mounted() {
this.$root.$on('editorFile/init', this.init)
waitChangeComplete(oldAmount, expectChange) {
let self = this
expectChange = (this._.isBoolean(expectChange)) ? expectChange : true
this.postUploadChecks++
this.isLoadingText = this.$t('editor.fileprocessing')
this.$nextTick(() => {
self.loadFiles(true).then(() => {
if ((self.files.length !== oldAmount) === expectChange) {
self.postUploadChecks = 0
self.isLoading = false
} else if (self.postUploadChecks > 5) {
self.postUploadChecks = 0
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.fileerror')
})
} else {
self._.delay(() => {
self.waitChangeComplete(oldAmount, expectChange)
}, 1500)
}
})
})
},
// -------------------------------------------
// IMAGE CONTEXT MENU
// -------------------------------------------
attachContextMenus() {
let self = this
let moveFolders = this._.map(this.folders, (f) => {
return {
name: (f !== '') ? f : '/ (root)',
icon: 'nc-icon-outline files_folder-15',
callback: (key, opt) => {
let moveFileId = self._.toString($(opt.$trigger).data('uid'))
let moveFileDestFolder = self._.nth(self.folders, key)
self.moveFile(moveFileId, moveFileDestFolder)
}
}
})
$.contextMenu('destroy', '.editor-modal-choices > figure')
$.contextMenu({
selector: '.editor-modal-choices > figure',
appendTo: '.editor-modal-choices',
position: (opt, x, y) => {
$(opt.$trigger).addClass('is-contextopen')
let trigPos = $(opt.$trigger).position()
let trigDim = { w: $(opt.$trigger).width() / 5, h: $(opt.$trigger).height() / 2 }
opt.$menu.css({ top: trigPos.top + trigDim.h, left: trigPos.left + trigDim.w })
},
events: {
hide: (opt) => {
$(opt.$trigger).removeClass('is-contextopen')
}
},
items: {
rename: {
name: self.$t('editor.filerenameaction'),
icon: 'nc-icon-outline files_vector',
callback: (key, opt) => {
self.renameFileId = self._.toString(opt.$trigger[0].dataset.uid)
self.renameFile()
}
},
move: {
name: self.$t('editor.filemoveaction'),
icon: 'fa-folder-open-o',
items: moveFolders
},
delete: {
name: self.$t('editor.filedeleteaction'),
icon: 'icon-trash2',
callback: (key, opt) => {
self.deleteFileId = self._.toString(opt.$trigger[0].dataset.uid)
self.deleteFileWarn(true)
}
}
}
})
},
upload() {
let self = this
let curFileAmount = this.files.length
let uplUrl = (self.mode === 'image') ? '/uploads/img' : '/uploads/file'
$(this.$refs.editorFileUploadInput).simpleUpload(uplUrl, {
name: (self.mode === 'image') ? 'imgfile' : 'binfile',
data: {
folder: self.currentFolder
},
limit: 20,
expect: 'json',
allowedExts: (self.mode === 'image') ? ['jpg', 'jpeg', 'gif', 'png', 'webp'] : undefined,
allowedTypes: (self.mode === 'image') ? ['image/png', 'image/jpeg', 'image/gif', 'image/webp'] : undefined,
maxFileSize: (self.mode === 'image') ? 3145728 : 0, // max 3 MB
init: (totalUploads) => {
self.uploadSucceeded = false
self.isLoadingText = 'Preparing to upload...'
self.isLoading = true
},
progress: (progress) => {
self.isLoadingText = 'Uploading...' + Math.round(progress) + '%'
},
success: (data) => {
if (data.ok) {
let failedUpls = self._.filter(data.results, ['ok', false])
if (failedUpls.length) {
self._.forEach(failedUpls, (u) => {
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.fileuploaderror', { err: u.msg })
})
})
if (failedUpls.length < data.results.length) {
self.uploadSucceeded = true
}
} else {
self.uploadSucceeded = true
self.$store.dispatch('alert', {
style: 'blue',
icon: 'arrows-1_cloud-upload-96',
msg: self.$t('editor.fileuploadsuccess')
})
}
} else {
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.fileuploaderror', { err: data.msg })
})
}
},
error: (error) => {
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: self.$t('editor.fileuploaderror', { err: error.message })
})
},
finish: () => {
if (self.uploadSucceeded) {
self.waitChangeComplete(curFileAmount, true)
} else {
self.isLoading = false
}
}
})
}
},
mounted() {
this.$root.$on('editorFile/init', this.init)
}
}
</script>

View File

@@ -33,62 +33,62 @@
</template>
<script>
const videoRules = {
'youtube': new RegExp('/(?:(?:youtu\\.be\\/|v\\/|vi\\/|u\\/\\w\\/|embed\\/)|(?:(?:watch)?\\?v(?:i)?=|&v(?:i)?=))([^#&?]*).*/', 'i'),
'vimeo': new RegExp('/vimeo.com\\/(?:channels\\/(?:\\w+\\/)?|groups\\/(?:[^/]*)\\/videos\\/|album\\/(?:\\d+)\\/video\\/|)(\\d+)(?:$|\\/|\\?)/', 'i'),
'dailymotion': new RegExp('/(?:dailymotion\\.com(?:\\/embed)?(?:\\/video|\\/hub)|dai\\.ly)\\/([0-9a-z]+)(?:[-_0-9a-zA-Z]+(?:#video=)?([a-z0-9]+)?)?/', 'i')
}
const videoRules = {
'youtube': new RegExp('/(?:(?:youtu\\.be\\/|v\\/|vi\\/|u\\/\\w\\/|embed\\/)|(?:(?:watch)?\\?v(?:i)?=|&v(?:i)?=))([^#&?]*).*/', 'i'),
'vimeo': new RegExp('/vimeo.com\\/(?:channels\\/(?:\\w+\\/)?|groups\\/(?:[^/]*)\\/videos\\/|album\\/(?:\\d+)\\/video\\/|)(\\d+)(?:$|\\/|\\?)/', 'i'),
'dailymotion': new RegExp('/(?:dailymotion\\.com(?:\\/embed)?(?:\\/video|\\/hub)|dai\\.ly)\\/([0-9a-z]+)(?:[-_0-9a-zA-Z]+(?:#video=)?([a-z0-9]+)?)?/', 'i')
}
export default {
name: 'editor-video',
data () {
return {
link: '',
isInvalid: false
}
},
computed: {
isShown () {
return this.$store.state.editorVideo.shown
}
},
methods: {
init () {
let self = this
self.isInvalid = false
self._.delay(() => {
self.$refs.editorVideoInput.focus()
}, 100)
},
cancel () {
this.$store.dispatch('editorVideo/close')
},
insertVideo () {
let self = this
if (this._.isEmpty(self.link) || self.link.length < 5) {
this.isInvalid = true
return
}
let videoType = this._.findKey(videoRules, (vr) => {
return vr.test(self.link)
})
if (this._.isNil(videoType)) {
videoType = 'video'
}
let videoText = '[video](' + this.link + '){.' + videoType + '}\n'
this.$store.dispatch('editor/insert', videoText)
this.$store.dispatch('alert', {
style: 'blue',
icon: 'media-1_action-74',
msg: self.$t('editor.videosuccess')
})
this.cancel()
}
},
mounted () {
this.$root.$on('editorVideo/init', this.init)
export default {
name: 'editor-video',
data () {
return {
link: '',
isInvalid: false
}
},
computed: {
isShown () {
return this.$store.state.editorVideo.shown
}
},
methods: {
init () {
let self = this
self.isInvalid = false
self._.delay(() => {
self.$refs.editorVideoInput.focus()
}, 100)
},
cancel () {
this.$store.dispatch('editorVideo/close')
},
insertVideo () {
let self = this
if (this._.isEmpty(self.link) || self.link.length < 5) {
this.isInvalid = true
return
}
let videoType = this._.findKey(videoRules, (vr) => {
return vr.test(self.link)
})
if (this._.isNil(videoType)) {
videoType = 'video'
}
let videoText = '[video](' + this.link + '){.' + videoType + '}\n'
this.$store.dispatch('editor/insert', videoText)
this.$store.dispatch('alert', {
style: 'blue',
icon: 'media-1_action-74',
msg: self.$t('editor.videosuccess')
})
this.cancel()
}
},
mounted () {
this.$root.$on('editorVideo/init', this.init)
}
}
</script>

View File

@@ -44,6 +44,8 @@
</template>
<script>
/* global wiki, Diff2HtmlUI */
let diffui
let diffuiIsReady = false
export default {
@@ -98,7 +100,7 @@ export default {
let self = this
diffuiIsReady = false
self.current = cm
self.$http.post(siteRoot + '/hist', {
self.$http.post(wiki.siteRoot + '/hist', {
path: self.currentPath,
commit: cm.commit
}).then(resp => {

View File

@@ -3,10 +3,10 @@
</template>
<script>
import { mapState } from 'vuex'
import { mapState } from 'vuex'
export default {
name: 'loading-spinner',
computed: mapState(['loading'])
}
export default {
name: 'loading-spinner',
computed: mapState(['loading'])
}
</script>

View File

@@ -24,6 +24,8 @@
</template>
<script>
/* global CONSTANTS, graphQL, siteConfig */
export default {
name: 'login',
data() {
@@ -67,4 +69,3 @@ export default {
}
}
</script>

View File

@@ -18,50 +18,50 @@
</template>
<script>
export default {
name: 'modal-create-page',
props: ['basepath'],
data () {
return {
currentPath: '',
userPath: '',
isLoading: false,
isInvalid: false
}
},
computed: {
isShown () {
if(this.$store.state.modalCreatePage.shown) {
this.makeSelection()
}
return this.$store.state.modalCreatePage.shown
}
},
methods: {
makeSelection: function () {
let self = this;
self._.delay(() => {
let startPos = (self.currentPath.length > 0) ? self.currentPath.length + 1 : 0
self.$helpers.form.setInputSelection(self.$refs.createPageInput, startPos, self.userPath.length)
}, 100)
},
cancel: function () {
this.$store.dispatch('modalCreatePage/close')
},
create: function () {
this.isInvalid = false
let newDocPath = this.$helpers.pages.makeSafePath(this.userPath)
if (this._.isEmpty(newDocPath)) {
this.isInvalid = true
} else {
this.isLoading = true
window.location.assign('/create/' + newDocPath)
}
}
},
mounted () {
this.currentPath = (this.basepath === 'home') ? '' : this.basepath
this.userPath = (this._.isEmpty(this.currentPath)) ? 'new-page' : this.currentPath + '/new-page'
export default {
name: 'modal-create-page',
props: ['basepath'],
data () {
return {
currentPath: '',
userPath: '',
isLoading: false,
isInvalid: false
}
},
computed: {
isShown () {
if (this.$store.state.modalCreatePage.shown) {
this.makeSelection()
}
return this.$store.state.modalCreatePage.shown
}
},
methods: {
makeSelection: function () {
let self = this
self._.delay(() => {
let startPos = (self.currentPath.length > 0) ? self.currentPath.length + 1 : 0
self.$helpers.form.setInputSelection(self.$refs.createPageInput, startPos, self.userPath.length)
}, 100)
},
cancel: function () {
this.$store.dispatch('modalCreatePage/close')
},
create: function () {
this.isInvalid = false
let newDocPath = this.$helpers.pages.makeSafePath(this.userPath)
if (this._.isEmpty(newDocPath)) {
this.isInvalid = true
} else {
this.isLoading = true
window.location.assign('/create/' + newDocPath)
}
}
},
mounted () {
this.currentPath = (this.basepath === 'home') ? '' : this.basepath
this.userPath = (this._.isEmpty(this.currentPath)) ? 'new-page' : this.currentPath + '/new-page'
}
}
</script>

View File

@@ -18,49 +18,49 @@
</template>
<script>
export default {
name: 'modal-delete-page',
props: ['currentPath'],
data () {
return {
isLoading: false
}
export default {
name: 'modal-delete-page',
props: ['currentPath'],
data () {
return {
isLoading: false
}
},
computed: {
isShown () {
return this.$store.state.modalDeletePage.shown
}
},
methods: {
discard () {
this.isLoading = false
this.$store.dispatch('modalDeletePage/close')
},
computed: {
isShown () {
return this.$store.state.modalDeletePage.shown
}
},
methods: {
discard () {
this.isLoading = false
this.$store.dispatch('modalDeletePage/close')
},
deletePage () {
let self = this
this.isLoading = true
this.$http.delete(window.location.href).then(resp => {
return resp.json()
}).then(resp => {
if (resp.ok) {
window.location.assign('/')
} else {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: resp.msg
})
}
}).catch(err => {
deletePage () {
let self = this
this.isLoading = true
this.$http.delete(window.location.href).then(resp => {
return resp.json()
}).then(resp => {
if (resp.ok) {
window.location.assign('/')
} else {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.msg
msg: resp.msg
})
}
}).catch(err => {
self.isLoading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.msg
})
}
})
}
}
}
</script>

View File

@@ -16,28 +16,28 @@
</template>
<script>
export default {
name: 'modal-discard-page',
props: ['mode', 'currentPath'],
data () {
return {}
export default {
name: 'modal-discard-page',
props: ['mode', 'currentPath'],
data () {
return {}
},
computed: {
isShown () {
return this.$store.state.modalDiscardPage.shown
}
},
methods: {
stay: function () {
this.$store.dispatch('modalDiscardPage/close')
},
computed: {
isShown () {
return this.$store.state.modalDiscardPage.shown
}
},
methods: {
stay: function () {
this.$store.dispatch('modalDiscardPage/close')
},
discard: function () {
if(this.mode === 'create') {
window.location.assign('/')
} else {
window.location.assign('/' + this.currentPath)
}
discard: function () {
if (this.mode === 'create') {
window.location.assign('/')
} else {
window.location.assign('/' + this.currentPath)
}
}
}
}
</script>

View File

@@ -19,68 +19,68 @@
</template>
<script>
export default {
name: 'modal-move-page',
props: ['currentPath'],
data () {
return {
movePath: '',
isLoading: false,
isInvalid: false
export default {
name: 'modal-move-page',
props: ['currentPath'],
data () {
return {
movePath: '',
isLoading: false,
isInvalid: false
}
},
computed: {
isShown () {
if (this.$store.state.modalMovePage.shown) {
this.movePath = this.currentPath
this.makeSelection()
}
return this.$store.state.modalMovePage.shown
}
},
methods: {
makeSelection() {
let self = this
self._.delay(() => {
let startPos = (self._.includes(self.currentPath, '/')) ? self._.lastIndexOf(self.movePath, '/') + 1 : 0
self.$helpers.form.setInputSelection(self.$refs.movePageInput, startPos, self.movePath.length)
}, 100)
},
computed: {
isShown () {
if(this.$store.state.modalMovePage.shown) {
this.movePath = this.currentPath
this.makeSelection()
}
return this.$store.state.modalMovePage.shown
}
cancel() {
this.$store.dispatch('modalMovePage/close')
},
methods: {
makeSelection() {
let self = this;
self._.delay(() => {
let startPos = (self._.includes(self.currentPath, '/')) ? self._.lastIndexOf(self.movePath, '/') + 1 : 0
self.$helpers.form.setInputSelection(self.$refs.movePageInput, startPos, self.movePath.length)
}, 100)
},
cancel() {
this.$store.dispatch('modalMovePage/close')
},
move () {
this.isInvalid = false
let newDocPath = this.$helpers.pages.makeSafePath(this.movePath)
if (this._.isEmpty(newDocPath) || newDocPath === this.currentPath || newDocPath === 'home') {
this.isInvalid = true
} else {
this.isLoading = true
this.$http.put(window.location.href, {
move: newDocPath
}).then(resp => {
return resp.json()
}).then(resp => {
if (resp.ok) {
window.location.assign('/' + newDocPath)
} else {
this.loading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: resp.msg
})
}
}).catch(err => {
move () {
this.isInvalid = false
let newDocPath = this.$helpers.pages.makeSafePath(this.movePath)
if (this._.isEmpty(newDocPath) || newDocPath === this.currentPath || newDocPath === 'home') {
this.isInvalid = true
} else {
this.isLoading = true
this.$http.put(window.location.href, {
move: newDocPath
}).then(resp => {
return resp.json()
}).then(resp => {
if (resp.ok) {
window.location.assign('/' + newDocPath)
} else {
this.loading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.msg
msg: resp.msg
})
}
}).catch(err => {
this.loading = false
self.$store.dispatch('alert', {
style: 'red',
icon: 'ui-2_square-remove-09',
msg: 'Error: ' + err.body.msg
})
}
})
}
}
}
}
</script>

View File

@@ -18,6 +18,8 @@
</template>
<script>
/* global siteRoot, socket, $ */
export default {
data() {
return {
@@ -57,9 +59,9 @@ export default {
},
searchmoveidx: function (val, oldVal) {
if (val > 0) {
this.searchmovekey = (this.searchmovearr[val - 1])
? 'res.' + this.searchmovearr[val - 1].entryPath
: 'sug.' + this.searchmovearr[val - 1]
this.searchmovekey = (this.searchmovearr[val - 1]) ?
'res.' + this.searchmovearr[val - 1].entryPath :
'sug.' + this.searchmovearr[val - 1]
} else {
this.searchmovekey = ''
}

View File

@@ -6,16 +6,16 @@
</template>
<script>
export default {
name: 'toggle',
props: ['value', 'desc'],
data () {
return { }
},
methods: {
changeToggle() {
this.$emit('input', !this.value)
}
export default {
name: 'toggle',
props: ['value', 'desc'],
data () {
return { }
},
methods: {
changeToggle() {
this.$emit('input', !this.value)
}
}
}
</script>

View File

@@ -15,68 +15,70 @@
</template>
<script>
export default {
name: 'tree',
data () {
return {
tree: []
}
},
methods: {
fetch (basePath) {
let self = this
self.$store.dispatch('startLoading')
self.$nextTick(() => {
socket.emit('treeFetch', { basePath }, (data) => {
if (self.tree.length > 0) {
let branch = self._.last(self.tree)
branch.hasChildren = true
self._.find(branch.pages, { _id: basePath }).isActive = true
}
self.tree.push({
hasChildren: false,
pages: data
})
self.$store.dispatch('stopLoading')
})
})
},
goto (entryPath) {
window.location.assign(siteRoot + '/' + entryPath)
},
unfold (entryPath) {
let self = this
let lastIndex = 0
self._.forEach(self.tree, branch => {
lastIndex++
if (self._.find(branch.pages, { _id: entryPath }) !== undefined) {
return false
}
})
self.tree = self._.slice(self.tree, 0, lastIndex)
let branch = self._.last(self.tree)
branch.hasChildren = false
branch.pages.forEach(page => {
page.isActive = false
})
},
mainAction (page) {
let self = this
if (page.isActive) {
self.unfold(page._id)
} else if (page.isDirectory) {
self.fetch(page._id)
} else {
self.goto(page._id)
}
}
},
mounted () {
let basePath = window.location.pathname.slice(0, -4)
if (basePath.length > 1) {
basePath = basePath.slice(1)
}
this.fetch(basePath)
/* global socket, siteRoot */
export default {
name: 'tree',
data () {
return {
tree: []
}
},
methods: {
fetch (basePath) {
let self = this
self.$store.dispatch('startLoading')
self.$nextTick(() => {
socket.emit('treeFetch', { basePath }, (data) => {
if (self.tree.length > 0) {
let branch = self._.last(self.tree)
branch.hasChildren = true
self._.find(branch.pages, { _id: basePath }).isActive = true
}
self.tree.push({
hasChildren: false,
pages: data
})
self.$store.dispatch('stopLoading')
})
})
},
goto (entryPath) {
window.location.assign(siteRoot + '/' + entryPath)
},
unfold (entryPath) {
let self = this
let lastIndex = 0
self._.forEach(self.tree, branch => {
lastIndex++
if (self._.find(branch.pages, { _id: entryPath }) !== undefined) {
return false
}
})
self.tree = self._.slice(self.tree, 0, lastIndex)
let branch = self._.last(self.tree)
branch.hasChildren = false
branch.pages.forEach(page => {
page.isActive = false
})
},
mainAction (page) {
let self = this
if (page.isActive) {
self.unfold(page._id)
} else if (page.isDirectory) {
self.fetch(page._id)
} else {
self.goto(page._id)
}
}
},
mounted () {
let basePath = window.location.pathname.slice(0, -4)
if (basePath.length > 1) {
basePath = basePath.slice(1)
}
this.fetch(basePath)
}
}
</script>