Skip to content

Commit

Permalink
Merge pull request #4 from dodosophia/feature/snapshot
Browse files Browse the repository at this point in the history
add Feature:Support SnapShot
  • Loading branch information
dodosophia authored Jun 30, 2020
2 parents 682dc9d + 1aeafa2 commit be86ef4
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 50 deletions.
9 changes: 5 additions & 4 deletions frontend/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export const getEvent = (options) => {
})
}

export const getChannelNames = () => {
export const getDefaultChannelNames = () => {
return axios({
url: '/api/channel'
url: '/api/channel/default'
})
}

Expand All @@ -54,14 +54,15 @@ export const saveImage = (id, imageData) => {
})
}

export const createIssue = (templateInfo, issue, attachments) => {
export const createIssue = (templateInfo, issue, attachments, snapshots) => {
return axios({
url: API_PREFIX + '/issue',
method: 'POST',
data: {
template: templateInfo,
issue,
attachments
attachments,
snapshots
}
})
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/event/ChannelColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default {
return '#0fccbf'
} else if (this.channel === 'notice') {
return '#ff9900'
} else if (this.channel === 'snapshot') {
return '#52A7F9'
} else {
return '#808695'
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/event/EventInspector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export default {
message: eventObj.message
})
}
if (eventObj.snapshot) {
this.$bus.$emit('addSnapshot', eventObj)
}
if (eventObj.attachments) {
this.$bus.$emit('addAttachments', eventObj.attachments)
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/form/AttachmentItem.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<FormItem>
<Tooltip content="Click to preview" placement="top">
<a style="padding-right:10px;color:#515a6e" @click="displayFile(data)">{{data.name}}</a>
<a style="padding-right:10px;color:#515a6e" @click="displayAttach(data)">{{data.name}}</a>
</Tooltip>
<Tooltip content="Delete this attachment" placement="top">
<a @click="deleteAttach(data)">delete</a>
Expand All @@ -16,8 +16,8 @@ export default {
deleteAttach(data) {
this.$store.dispatch('removeAttachment', { id: data.id, index: this.index })
},
displayFile(data) {
this.$bus.$emit('displayFile', data)
displayAttach(data) {
this.$bus.$emit('displayAttach', data)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
:src="'/plugins/bugit/api/attachments/' + this.attachmentId"
/>
</p>
<p v-else-if="isSnapshot">
<CodeEditor read-only language="json" v-model="this.attachmentContent" style="height:500px"/>
</p>
<p v-else>
<FileViewer :attachmentId="attachmentId"/>
</p>
Expand All @@ -31,20 +34,24 @@
<script>
import ImageEditor from '@/components/form/ImageEditor.vue'
import FileViewer from '@/components/form/FileViewer.vue'
import CodeEditor from '@/components/event/CodeEditor.vue'
export default {
components: {
ImageEditor,
FileViewer
FileViewer,
CodeEditor
},
created() {
this.$bus.$on('displayFile', this.displayFile)
this.$bus.$on('displayAttach', this.displayAttach)
},
data() {
return {
isDisplayFile: false,
attachmentName: null,
attachmentId: null
attachmentId: null,
attachmentContent: null
}
},
computed: {
Expand All @@ -58,13 +65,22 @@ export default {
let nameSuffix = nameSplit[nameSplit.length - 1]
return imageFileSuffix.indexOf(nameSuffix) > -1
},
isSnapshot() {
if (this.attachmentContent) {
this.attachmentContent = JSON.stringify(this.attachmentContent, null, 2)
return true
}else {
return false
}
}
},
methods: {
displayFile(data) {
displayAttach(data) {
this.isDisplayFile = true
this.attachmentName = data.name
this.attachmentId = data.id
this.attachmentContent = data.eventObj
},
saveImage() {
this.$bus.$emit('saveImage')
Expand Down
18 changes: 16 additions & 2 deletions frontend/src/components/form/AttachmentsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,46 @@
<AttachmentItem :data="attachment" :index="index"/>
</p>
</div>
<div v-else>
<div v-if="snapshots.length">
<p v-for="(snapshot, index) in snapshots" :key="index">
<SnapshotItem :data="snapshot" :index="index"/>
</p>
</div>
<div v-else-if="!attachments.length">
<p style="color:#c5c8ce">No attachment</p>
</div>
</FormItem>
</template>

<script>
import AttachmentItem from '@/components/form/AttachmentItem.vue'
import SnapshotItem from '@/components/form/SnapshotItem.vue'
export default {
components: {
AttachmentItem
AttachmentItem,
SnapshotItem
},
created() {
this.$io.on('attachments', this.addAttachment)
this.$bus.$on('addAttachments', this.addAttachment)
this.$bus.$on('addSnapshot', this.addSnapshot)
this.$store.dispatch('loadAttachment')
},
computed: {
attachments() {
return this.$store.state.form.attachmentsList
},
snapshots() {
return this.$store.state.form.snapshotList
}
},
methods: {
addAttachment() {
this.$store.dispatch('loadAttachment')
},
addSnapshot(snapshot) {
this.$store.commit('addSnapshot', snapshot)
}
}
};
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/form/BugItForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</Form>
<Submit></Submit>
</div>
<FileModal/>
<AttachmentModal/>
</div>
</template>

Expand All @@ -22,7 +22,7 @@ import InputFormItem from '@/components/form/InputFormItem.vue'
import SelectFormItem from '@/components/form/SelectFormItem.vue'
import CompoundTextAreaFormItem from '@/components/form/CompoundTextAreaFormItem.vue'
import AttachmentsList from '@/components/form/AttachmentsList.vue'
import FileModal from '@/components/form/FileModal.vue'
import AttachmentModal from '@/components/form/AttachmentModal.vue'
import Submit from '@/components/form/Submit.vue'
export default {
Expand All @@ -31,7 +31,7 @@ export default {
SelectFormItem,
CompoundTextAreaFormItem,
AttachmentsList,
FileModal,
AttachmentModal,
Submit
},
computed: {
Expand Down
24 changes: 24 additions & 0 deletions frontend/src/components/form/SnapshotItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<FormItem>
<Tooltip content="Click to preview" placement="top">
<a style="padding-right:10px;color:#515a6e" @click="displayAttach(data)">{{data.name}}</a>
</Tooltip>
<Tooltip content="Delete this snapshot" placement="top">
<a @click="deleteAttach(data)">delete</a>
</Tooltip>
</FormItem>
</template>

<script>
export default {
props: ['data', 'index'],
methods: {
deleteAttach(data) {
this.$store.commit('deleteSnapshot', this.index )
},
displayAttach(data) {
this.$bus.$emit('displayAttach', data)
}
}
}
</script>
15 changes: 12 additions & 3 deletions frontend/src/store/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { bus } from '@/eventbus'
export default {
state: {
channelNames: [],
channelFilters: ['flow', 'notice', 'page', 'android.crash', 'ios.crash'],
channelFilters: ['flow'],
events: [],
selectedEventId: null,
eventDetail: '',
Expand Down Expand Up @@ -33,7 +33,12 @@ export default {
actions: {
loadChannelNames({ commit }) {
// Filter out the target channel
commit('setChannelNames', ['flow', 'notice', 'page', 'android.crash', 'ios.crash'])
api.getDefaultChannelNames().then(response => {
if (response.data.code === 1000) {
commit('setChannelNames', response.data.data)
commit('setChannelFilters', response.data.data)
}
})
},
loadEvents({ state, commit }, options = {}) {
let eventId = null
Expand Down Expand Up @@ -74,7 +79,11 @@ export default {
dispatch('updateChannelFilters', ['notice'])
},
showAll({ dispatch }) {
dispatch('updateChannelFilters', ['flow', 'notice', 'page', 'android.crash', 'ios.crash'])
api.getDefaultChannelNames().then(response => {
if (response.data.code === 1000) {
dispatch('updateChannelFilters', response.data.data)
}
})
}
}
}
Loading

0 comments on commit be86ef4

Please sign in to comment.