cleaning message/confirm usage

This commit is contained in:
les
2020-10-07 11:12:13 +02:00
parent a67751928c
commit 3616eeefe5
20 changed files with 53 additions and 287 deletions

View File

@@ -61,10 +61,10 @@ export default {
this.$root.$confirm = this.open this.$root.$confirm = this.open
}, },
methods: { methods: {
open (title, message, options) { open (message, options) {
this.dialog = true this.dialog = true
this.title = title this.title = option.title || 'Confirm'
this.message = message this.message = this.$t(message, options)
this.options = Object.assign(this.options, options) this.options = Object.assign(this.options, options)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.resolve = resolve this.resolve = resolve

View File

@@ -98,14 +98,10 @@ export default {
}, },
methods: { methods: {
copyLink () { copyLink () {
this.$root.$message({ this.$root.$message('common.feed_url_copied')
message: this.$t('common.feed_url_copied')
})
}, },
logout () { logout () {
this.$root.$message({ this.$root.$message('common.logout_ok')
message: this.$t('common.logout_ok')
})
this.$auth.logout() this.$auth.logout()
}, },
async createTrustedInstance () { async createTrustedInstance () {
@@ -123,11 +119,7 @@ export default {
} }
this.setSetting({ key: 'trusted_instances', value: this.settings.trusted_instances.concat(trusted_instance) }) this.setSetting({ key: 'trusted_instances', value: this.settings.trusted_instances.concat(trusted_instance) })
} catch (e) { } catch (e) {
console.error(e) this.$root.$message(e, { color: 'error' })
this.$root.$message({
type: 'error',
message: e
})
} }
} }
} }

View File

@@ -29,10 +29,11 @@ export default {
} }
}, },
created () { created () {
this.$root.$message = snackbar => { this.$root.$message = (message, opts) => {
this.active = true this.active = true
this.message = snackbar.message this.message = this.$t(message, opts)
this.color = snackbar.color || 'primary' this.color = opts.color || 'primary'
this.icon = opts.icon || 'md-alert'
} }
} }
} }

View File

@@ -2,7 +2,7 @@
v-container v-container
v-card-title {{$t('common.announcements')}} v-card-title {{$t('common.announcements')}}
v-card-subtitle(v-html="$t('admin.announcement_description')") v-card-subtitle(v-html="$t('admin.announcement_description')")
v-dialog(v-model='dialog' width='800') v-dialog(v-model='dialog' width='800px')
v-card v-card
v-card-title {{$t('admin.new_announcement')}} v-card-title {{$t('admin.new_announcement')}}
v-card-text v-card-text
@@ -72,18 +72,12 @@ export default {
this.setAnnouncements(cloneDeep(this.announcements.filter(a => a.visible))) this.setAnnouncements(cloneDeep(this.announcements.filter(a => a.visible)))
} catch (e) {} } catch (e) {}
}, },
remove (announcement) { async remove (announcement) {
this.$root.$confirm(this.$t('admin.delete_announcement_confirm'), const ret = await this.$root.$confirm('admin.delete_announcement_confirm')
this.$t('common.confirm'), { if (!ret) return
confirmButtonText: this.$t('common.ok'), this.$axios.delete(`/announcements/${announcement.id}`)
cancelButtonText: this.$t('common.cancel'),
type: 'error'
})
.then(() => this.$axios.delete(`/announcements/${announcement.id}`))
.then(() => { .then(() => {
this.$root.$message({ this.$root.$message('admin.announcement_remove_ok')
message: this.$t('admin.announcement_remove_ok')
})
this.announcements = this.announcements.filter(a => a.id !== announcement.id) this.announcements = this.announcements.filter(a => a.id !== announcement.id)
}) })
}, },

View File

@@ -45,13 +45,10 @@ export default {
} catch (e) {} } catch (e) {}
}, },
async remove (event) { async remove (event) {
const ret = await this.$root.$confirm(this.$t('common.confirm'), const ret = await this.$root.$confirm('event.remove_confirmation')
this.$t('event.remove_confirmation'))
if (!ret) { return } if (!ret) { return }
await this.$axios.delete(`/event/${event.id}`) await this.$axios.delete(`/event/${event.id}`)
this.$root.$message({ this.$root.$message('admin.event_remove_ok')
message: this.$t('admin.event_remove_ok')
})
} }
} }
} }

View File

@@ -124,15 +124,11 @@ export default {
}) })
this.instance_url = '' this.instance_url = ''
} catch (e) { } catch (e) {
this.$root.$message({ this.$root.$message(e, { color: 'error' })
type: 'error',
message: e
})
} }
}, },
async deleteInstance (instance) { async deleteInstance (instance) {
const ret = await this.$root.$confirm(this.$t('common.confirm'), const ret = await this.$root.$confirm('admin.delete_trusted_instance_confirm')
this.$t('admin.delete_trusted_instance_confirm'))
if (!ret) { return } if (!ret) { return }
this.setSetting({ this.setSetting({
key: 'trusted_instances', key: 'trusted_instances',

View File

@@ -67,10 +67,10 @@ export default {
computed: mapState(['settings']), computed: mapState(['settings']),
methods: { methods: {
async deleteUser (user) { async deleteUser (user) {
const ret = await this.$root.$confirm(this.$t('common.confirm'), this.$t('admin.delete_user_confirm')) const ret = await this.$root.$confirm('admin.delete_user_confirm')
if (!ret) { return } if (!ret) { return }
await this.$axios.delete(`/user/${user.id}`) await this.$axios.delete(`/user/${user.id}`)
this.$root.$message({ message: this.$t('admin.user_remove_ok') }) this.$root.$message('admin.user_remove_ok')
this.users_ = this.users_.filter(u => u.id !== user.id) this.users_ = this.users_.filter(u => u.id !== user.id)
}, },
toggle (user) { toggle (user) {
@@ -90,16 +90,10 @@ export default {
const user = await this.$axios.$post('/user', this.new_user) const user = await this.$axios.$post('/user', this.new_user)
this.new_user = { email: '', is_admin: false } this.new_user = { email: '', is_admin: false }
this.$root.$message({ this.$root.$message('admin.user_create_ok', { color: 'success'})
type: 'success',
message: this.$t('admin.user_create_ok')
})
this.users_.push(user) this.users_.push(user)
} catch (e) { } catch (e) {
this.$root.$message({ this.$root.$message(e, { color: 'error' })
type: 'error',
message: this.$t(e)
})
} }
} }
} }

View File

@@ -32,7 +32,6 @@ export default {
</script> </script>
<style lang="less"> <style lang="less">
.v-dialog { .v-dialog {
width: unset !important; max-width: 800px;
max-width: 600px;
} }
</style> </style>

View File

@@ -205,7 +205,8 @@
"add_link": "Add link", "add_link": "Add link",
"footer_links": "Footer links", "footer_links": "Footer links",
"delete_footer_link_confirm": "Sure to remove this link?", "delete_footer_link_confirm": "Sure to remove this link?",
"edit_place": "Edit place" "edit_place": "Edit place",
"new_announcement": "New announcement"
}, },
"auth": { "auth": {
"not_confirmed": "Not confirmed yet...", "not_confirmed": "Not confirmed yet...",

View File

@@ -88,17 +88,11 @@ export default {
this.$router.push(`/event/${id}`) this.$router.push(`/event/${id}`)
}, },
async confirm (id) { async confirm (id) {
try { this.loading = true
this.loading = true await this.$axios.$get(`/event/confirm/${id}`)
await this.$axios.$get(`/event/confirm/${id}`) this.loading = false
this.loading = false this.$root.$message('event.confirmed', { color: 'succes' })
this.$root.$message({ this.unconfirmedEvents = this.unconfirmedEvents.filter(e => e.id !== id)
message: this.$t('event.confirmed'),
type: 'success'
})
this.unconfirmedEvents = this.unconfirmedEvents.filter(e => e.id !== id)
} catch (e) {
}
} }
}, },
head () { head () {

View File

@@ -65,7 +65,7 @@ export default {
this.loading = true this.loading = true
await this.$axios.$post('/user/recover', { email: this.email }) await this.$axios.$post('/user/recover', { email: this.email })
this.loading = false this.loading = false
this.$root.$message({ message: this.$t('login.check_email'), color: 'success' }) this.$root.$message('login.check_email', { color: 'success' })
}, },
async submit (e) { async submit (e) {
e.preventDefault() e.preventDefault()
@@ -78,9 +78,9 @@ export default {
data.append('client_id', 'self') data.append('client_id', 'self')
await this.$auth.loginWith('local', { data }) await this.$auth.loginWith('local', { data })
this.loading = false this.loading = false
this.$root.$message({ message: this.$t('login.ok'), color: 'success' }) this.$root.$message('login.ok',{ color: 'success' })
} catch (e) { } catch (e) {
this.$root.$message({ message: this.$t('login.error'), color: 'error' }) this.$root.$message('login.error',{ color: 'error' })
this.loading = false this.loading = false
return return
} }

View File

@@ -67,13 +67,11 @@ export default {
const user = await this.$axios.$post('/user/register', this.user) const user = await this.$axios.$post('/user/register', this.user)
// this is the first user registered // this is the first user registered
const first_user = user && user.is_admin && user.is_active const first_user = user && user.is_admin && user.is_active
this.$root.$message({ this.$root.$message(first_user ? 'register.first_user': 'register.complete')
message: first_user ? this.$t('register.first_user') : this.$t('register.complete')
})
this.$router.replace('/') this.$router.replace('/')
} catch (e) { } catch (e) {
const error = get(e, 'response.data.errors[0].message', String(e)) const error = get(e, 'response.data.errors[0].message', String(e))
this.$root.$message({ message: this.$t(error), color: 'error' }) this.$root.$message(error, { color: 'error' })
} }
this.loading = false this.loading = false
} }

View File

@@ -25,10 +25,7 @@ export default {
methods: { methods: {
...mapActions(['setSetting']), ...mapActions(['setSetting']),
save () { save () {
this.$root.$message({ this.$root.$message('commmon.done', { color: 'success' })
type: 'success',
message: this.$t('common.done')
})
this.setSetting({ key: 'about', value: this.about }) this.setSetting({ key: 'about', value: this.about })
} }
}, },

View File

@@ -447,15 +447,15 @@ export default {
this.updateMeta() this.updateMeta()
this.$router.replace('/') this.$router.replace('/')
this.loading = false this.loading = false
this.$root.$message({ type: 'success', message: this.$auth.loggedIn ? this.$t('event.added') : this.$t('event.added_anon') }) this.$root.$message(this.$auth.loggedIn ? 'event.added' : 'event.added_anon', { color: 'success' })
} catch (e) { } catch (e) {
console.error(e.response) console.error(e.response)
switch (e.request.status) { switch (e.request.status) {
case 413: case 413:
this.$root.$message({ type: 'error', message: this.$t('event.image_too_big') }) this.$root.$message('event.image_too_big', { color: 'error' })
break break
default: default:
this.$root.$message({ type: 'error', message: e.response.data }) this.$root.$message(e.response.data, { color: 'error' })
} }
this.loading = false this.loading = false
} }
@@ -477,26 +477,5 @@ export default {
.container { .container {
max-width: 1400px; max-width: 1400px;
} }
/* #edit_page
i {
font-size: 1.3em;
}
#picker {
max-width: 600px;
}
#edit_page .el-form-item {
display: inline-flex;
}
.el-upload,
.el-upload-dragger {
overflow: hidden;
text-align: center;
margin: 0 auto;
max-width: 80%;
font-size: 2em;
} */
</style> </style>

View File

@@ -243,22 +243,22 @@ export default {
}, },
async blockUser (resource) { async blockUser (resource) {
try { try {
const ret = await this.$root.$confirm(this.$t('common.confirm'), this.$t('admin.user_block_confirm', { user: resource.ap_user.ap_id })) const ret = await this.$root.$confirm('admin.user_block_confirm', { user: resource.ap_user.ap_id })
if (!ret) { return } if (!ret) { return }
await this.$axios.post('/instances/toggle_user_block', { ap_id: resource.ap_user.ap_id }) await this.$axios.post('/instances/toggle_user_block', { ap_id: resource.ap_user.ap_id })
this.$root.$message({ message: this.$t('admin.user_blocked', { user: resource.ap_user.ap_id }), type: 'success' }) this.$root.$message('admin.user_blocked', { user: resource.ap_user.ap_id, color: 'success' })
} catch (e) { } } catch (e) { }
}, },
async deleteResource (resource) { async deleteResource (resource) {
try { try {
const ret = await this.$root.$confirm(this.$t('common.confirm'), this.$t('admin.delete_resource_confirm')) const ret = await this.$root.$confirm('admin.delete_resource_confirm')
if (!ret) { return } if (!ret) { return }
await this.$axios.delete(`/resources/${resource.id}`) await this.$axios.delete(`/resources/${resource.id}`)
this.event.resources = this.event.resources.filter(r => r.id !== resource.id) this.event.resources = this.event.resources.filter(r => r.id !== resource.id)
} catch (e) { } } catch (e) { }
}, },
copyLink () { copyLink () {
this.$root.$message({ message: this.$t('common.copied'), type: 'success' }) this.$root.$message('common.copied', { color: 'success' })
}, },
// TOFIX // TOFIX
resource_filter (value) { resource_filter (value) {
@@ -285,163 +285,5 @@ export default {
margin: 0 auto; margin: 0 auto;
max-height: 83vh; max-height: 83vh;
} }
} }
// time {
// margin: 0rem 0rem 0rem 1rem;
// display: inline-block;
// }
// #arrow {
// position: absolute;
// top: 1em;
// right: 1em;
// }
// .el-header {
// height: auto !important;
// position: sticky;
// padding-top: .4em;
// top: 0px;
// border-bottom: 1px solid lightgray;
// z-index: 1;
// overflow: hidden;
// }
// .embedDialog {
// .el-dialog {
// min-height: 500px;
// max-width: 1000px;
// width: 100%;
// }
// }
// .followDialog {
// .el-dialog {
// min-height: 300px;
// max-width: 600px;
// width: 100%;
// .el-dialog__body {
// word-break: normal !important;
// }
// }
// }
// .head {
// z-index: 1;
// position: sticky;
// top: 0px;
// padding-top: 10px;
// padding-bottom: 10px;
// background-color: white;
// border-bottom: 1px solid #e6e6e6;
// }
// .menu {
// border-right: none;
// background-color: transparent;
// }
// div.menu {
// border-left: 1px solid #e6e6e6;
// p {
// margin: 1rem 0rem 1rem 1rem;
// }
// }
// .title {
// display: table-cell;
// padding-right: 70px;
// height: 2.1em;
// font-size: 1.6rem;
// color: #404246;
// line-height: 1;
// vertical-align: middle;
// }
// pre {
// white-space: pre-line;
// word-break: break-word;
// font-size: 1em;
// font-family: inherit;
// p:empty {
// min-height: 1em;
// }
// // font-family: BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Oxygen,
// // Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, Helvetica, Arial,
// // sans-serif !important;
// }
// .main_image {
// width: 100%;
// transition: height .100s;
// height: auto;
// img {
// // object-fit: contain;
// margin: 0 auto;
// max-height: 88vh;
// }
// .loading {
// display: flex;
// justify-content: center;
// align-items: center;
// font-size: 30px;
// margin: 0 auto;
// height: 100px;
// }
// }
// #resources {
// img {
// max-width: 100%;
// }
// .card-header {
// border-left: 3px solid transparent;
// }
// .card-header:hover {
// border-left: 3px solid #888;
// }
// .invisible {
// visibility: visible !important;
// }
// .disabled {
// opacity: 0.5;
// }
// .previewImage {
// display: flex;
// flex-flow: wrap;
// justify-content: space-evenly;
// img {
// margin-left: 5px;
// margin-top: 5px;
// object-fit: cover;
// min-height: 100px;
// max-width: 45%;
// border-radius: 5px;
// border: 1px solid #ccc;
// }
// }
// }
// .nextprev {
// font-size: 10px;
// margin-bottom: 5px;
// }
// }
// @media only screen and (max-width: 768px) {
// #eventDetail {
// .menu {
// border: 0px !important;
// }
// .title {
// // font-size: 1.1em;
// line-height: 1.4em;
// color: black;
// }
// }
// }
</style> </style>

View File

@@ -28,7 +28,7 @@ export default {
}, },
methods: { methods: {
copyLink () { copyLink () {
this.$root.$message({ message: this.$t('common.copied'), type: 'success' }) this.$root.$message('common.copied', { color: 'success' })
} }
} }
} }

View File

@@ -129,8 +129,7 @@ export default {
}, },
methods: { methods: {
copyLink () { copyLink () {
// Message({ message: this.$t('common.copied'), type: 'success', showClose: true }) this.$root.$message('common.feed_url_copied')
this.$root.$message({ message: this.$t('common.feed_url_copied') })
}, },
add_notification () { add_notification () {
if (!this.notification.email) { if (!this.notification.email) {

View File

@@ -38,15 +38,10 @@ export default {
async change_password () { async change_password () {
try { try {
await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password }) await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
this.$root.$message({ this.$root.$message('common.password_updated')
message: this.$t('common.password_updated')
})
this.$router.replace('/login') this.$router.replace('/login')
} catch (e) { } catch (e) {
this.$root.$message({ this.$root.$message(e, { color: 'warning' })
type: 'warning',
message: e
})
} }
} }
}, },

View File

@@ -34,16 +34,10 @@ export default {
async change_password () { async change_password () {
try { try {
await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password }) await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
this.$root.$message({ this.$root.$message('common.password_updated', { color: 'success' })
type: 'success',
message: this.$t('common.password_updated')
})
this.$router.replace('/login') this.$router.replace('/login')
} catch (e) { } catch (e) {
this.$root.$message({ this.$root.$message(e, { color: 'warning' })
type: 'warning',
message: e
})
} }
} }
} }

View File

@@ -33,16 +33,10 @@ export default {
async change_password () { async change_password () {
try { try {
await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password }) await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
this.$root.$message({ this.$root.$message('common.password_updated', { color: 'succes' })
type: 'success',
message: this.$t('common.password_updated')
})
this.$router.replace('/login') this.$router.replace('/login')
} catch (e) { } catch (e) {
this.$root.$message({ this.$root.$message(e, { color: 'warning' })
type: 'warning',
message: e
})
} }
} }
} }