Skip to content

Commit

Permalink
get default channel from api
Browse files Browse the repository at this point in the history
delete attachments after submit issue
  • Loading branch information
dodosophia committed Jun 30, 2020
1 parent 06f7db7 commit b0e304e
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 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 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
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', 'snapshot', 'storage'],
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', 'snapshot', 'storage'])
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)
}
})
}
}
}
2 changes: 1 addition & 1 deletion frontend/src/store/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default {
commit('updateAttachmentsList', response.data)
if (state.attachmentsList.length > 0 && state.loadAttachmentCount > 0) {
const index = state.attachmentsList.length - 1
bus.$emit('displayFile', state.attachmentsList[index])
bus.$emit('displayAttach', state.attachmentsList[index])
}
state.loadAttachmentCount += 1
})
Expand Down
2 changes: 2 additions & 0 deletions lyrebird_bugit/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def issue():
'data': issue_data
}
})
#Delete Snapshot
attachment.remove_attach()
return application.make_ok_response(message="Create issue success!")


Expand Down
12 changes: 9 additions & 3 deletions lyrebird_bugit/attachment.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from pathlib import Path
import codecs
import json
import lyrebird
import requests
import shutil
from lyrebird.application import config

BUGIT_STORAGE = lyrebird.get_plugin_storage()
ATTACHMENT_ROOT = Path(BUGIT_STORAGE)/'attachments'

EXPORT_URL = 'http://%s:%s/api/snapshot/export/event' %(config.get('ip'), config.get('mock.port'))
EXPORT_URL = f'http://{config.get("ip")}:{config.get("mock.port")}/api/snapshot/export/event'

def _check_dir():
if not ATTACHMENT_ROOT.exists():
CACHE_ROOT.mkdir(parents=True, exist_ok=True)
ATTACHMENT_ROOT.mkdir(parents=True, exist_ok=True)

def export_snapshot(snapshot):
_check_dir()
Expand All @@ -21,3 +21,9 @@ def export_snapshot(snapshot):
f.write(file_content)
return {'id':snapshot['eventObj']['id'],'name':snapshot['name']+'.lb',
'path':str(ATTACHMENT_ROOT / snapshot['name'])+'.lb'}

def remove_attach():
if not ATTACHMENT_ROOT.exists():
pass
else:
shutil.rmtree(ATTACHMENT_ROOT)

0 comments on commit b0e304e

Please sign in to comment.