Skip to content

Commit

Permalink
v1.1.2 - Bugfix/unclosed socket io (#85)
Browse files Browse the repository at this point in the history
* solve frontend lag

* footer poptip display overflow; add pending status on inspector flow; update sender in event message.

* update footer display

* update frontend build
  • Loading branch information
yumiguan authored and zhaoye committed Jan 8, 2019
1 parent 6b251cf commit 663a64c
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 26 deletions.
3 changes: 3 additions & 0 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import iView from 'iview'
import VueResource from 'vue-resource';
import 'iview/dist/styles/iview.css';
import locale from 'iview/dist/locale/en-US';
import io from 'socket.io-client'


Vue.config.productionTip = false
Vue.use(iView, {locale})
Vue.use(VueResource)

Vue.prototype['$io'] = io()

new Vue({
router,
store,
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export const readablizeBytes = (bytes) => {
if(bytes===0){
return '0 B'
}
var s = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];
var e = Math.floor(Math.log(bytes)/Math.log(1024));
return (bytes/Math.pow(1024, Math.floor(e))).toFixed(1)+" "+s[e];
Expand Down
13 changes: 5 additions & 8 deletions frontend/src/views/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</Sider>
<Layout>
<Header class="main-header" inline>
<Icon type="md-menu" color="white" size="24" @click.native="collapsedSider"></Icon>
<Icon type="md-menu" color="white" size="24" @click.native="collapsedSider"></Icon>
</Header>
<Content>
<div class="main-container">
Expand All @@ -35,9 +35,9 @@
</a>
<div slot="title"><b>💡Status</b></div>
<div slot="content">
<Row v-for="value in showedStatus" :key="value" :gutter="16">
<i-col span=12><b style="float: right">{{value}}</b></i-col>
<i-col span=12>{{status[value]}}</i-col>
<Row v-for="key in showedStatus" :key="key">
<i-col span=11><b style="float: right">{{key.toUpperCase()}}</b></i-col>
<i-col span=12 offset=1>{{status[key]}}</i-col>
</Row>
</div>
</Poptip>
Expand All @@ -48,7 +48,6 @@
</template>

<script>
import io from 'socket.io-client'
import Notice from '@/views/Notice.vue'
export default {
Expand All @@ -59,16 +58,14 @@ export default {
data() {
return {
isCollapsed: true,
alertIO: null,
showedStatus: ["ip", "mock.port", "proxy.port", "version"]
}
},
created(){
this.$Notice.config({
top: 0,
});
this.alertIO = io('/alert')
this.alertIO.on('show', this.showNotice);
this.$io.on('show', this.showNotice);
},
mounted(){
this.$store.dispatch('loadMenu')
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/views/inspector/FlowList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

<script>
import FlowListItem from '@/views/inspector/FlowListItem.vue'
import io from 'socket.io-client'
import {readablizeBytes} from '@/utils'
export default {
Expand All @@ -45,7 +44,7 @@
{
title: 'Source',
key: 'src',
width: 60,
width: 75,
align: 'center',
render: (h, params) => {
if (params.row.response.mock === 'proxy') {
Expand All @@ -62,6 +61,13 @@
size: 'small'
}
}, params.row.response.mock);
} else {
return h("Tag", {
props: {
color: 'default',
size: 'small'
}
}, 'pending');
}
}
},
Expand Down Expand Up @@ -118,8 +124,7 @@
},
created() {
const reload = this.reload
this.sio = io()
this.sio.on("action", function(){
this.$io.on("action", function(){
reload()
})
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lyrebird/client/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/ui/static/favicon.ico><title>Lyrebird</title><link href=/ui/static/js/chunk-2d0a3577.15b80f4c.js rel=prefetch><link href=/ui/static/js/chunk-2d0a43df.2e00c125.js rel=prefetch><link href=/ui/static/js/chunk-2d0aab07.ec9eaa41.js rel=prefetch><link href=/ui/static/js/chunk-2d0abc00.1e61764e.js rel=prefetch><link href=/ui/static/js/chunk-2d0ae937.22b2ec66.js rel=prefetch><link href=/ui/static/js/chunk-2d0aeb45.c571eeac.js rel=prefetch><link href=/ui/static/js/chunk-2d0afa49.65108fc0.js rel=prefetch><link href=/ui/static/js/chunk-2d0b2762.7faa5aa3.js rel=prefetch><link href=/ui/static/js/chunk-2d0b6187.1b01ea3f.js rel=prefetch><link href=/ui/static/js/chunk-2d0ba136.08ad9b83.js rel=prefetch><link href=/ui/static/js/chunk-2d0bb267.7da55a18.js rel=prefetch><link href=/ui/static/js/chunk-2d0bcec1.eed4b121.js rel=prefetch><link href=/ui/static/js/chunk-2d0bff92.5eac84e3.js rel=prefetch><link href=/ui/static/js/chunk-2d0c0494.b82491b3.js rel=prefetch><link href=/ui/static/js/chunk-2d0c0a09.ab666bda.js rel=prefetch><link href=/ui/static/js/chunk-2d0c1ed0.c7612dd8.js rel=prefetch><link href=/ui/static/js/chunk-2d0c4313.734ea760.js rel=prefetch><link href=/ui/static/js/chunk-2d0c46d1.a90d3520.js rel=prefetch><link href=/ui/static/js/chunk-2d0c512b.c2655e61.js rel=prefetch><link href=/ui/static/js/chunk-2d0cf16e.c3e2c753.js rel=prefetch><link href=/ui/static/js/chunk-2d0d056d.34332182.js rel=prefetch><link href=/ui/static/js/chunk-2d0d0645.5ba0a827.js rel=prefetch><link href=/ui/static/js/chunk-2d0d2f22.0b0ad9f9.js rel=prefetch><link href=/ui/static/js/chunk-2d0d7e63.967be54e.js rel=prefetch><link href=/ui/static/js/chunk-2d0e1b57.9ca83b35.js rel=prefetch><link href=/ui/static/js/chunk-2d0e1fbe.085b36f1.js rel=prefetch><link href=/ui/static/js/chunk-2d0e22d6.f15418dd.js rel=prefetch><link href=/ui/static/js/chunk-2d0e542a.f9c1a461.js rel=prefetch><link href=/ui/static/js/chunk-2d0e57ec.db5e2796.js rel=prefetch><link href=/ui/static/js/chunk-2d0e6553.e43be0ff.js rel=prefetch><link href=/ui/static/js/chunk-2d0ea098.59254529.js rel=prefetch><link href=/ui/static/js/chunk-2d208ac5.b30c459d.js rel=prefetch><link href=/ui/static/js/chunk-2d209408.f92607b1.js rel=prefetch><link href=/ui/static/js/chunk-2d20f745.2c8189f8.js rel=prefetch><link href=/ui/static/js/chunk-2d20ff23.57e1f9e1.js rel=prefetch><link href=/ui/static/js/chunk-2d2138c7.4a97aa4a.js rel=prefetch><link href=/ui/static/js/chunk-2d217e5b.40de0dd2.js rel=prefetch><link href=/ui/static/js/chunk-2d21b84a.4bfe2261.js rel=prefetch><link href=/ui/static/js/chunk-2d21dcd2.64e0a422.js rel=prefetch><link href=/ui/static/js/chunk-2d21f327.4df1e469.js rel=prefetch><link href=/ui/static/js/chunk-2d2214b3.4f3fe061.js rel=prefetch><link href=/ui/static/js/chunk-2d221a34.7ff16b79.js rel=prefetch><link href=/ui/static/js/chunk-2d22502a.f9b13f63.js rel=prefetch><link href=/ui/static/js/chunk-2d228ca6.741b4c1c.js rel=prefetch><link href=/ui/static/js/chunk-2d2295e9.599758ba.js rel=prefetch><link href=/ui/static/js/chunk-2d22c171.55accc8a.js rel=prefetch><link href=/ui/static/js/chunk-2d22c2b8.fef13e00.js rel=prefetch><link href=/ui/static/js/chunk-2d22ca58.fe58906c.js rel=prefetch><link href=/ui/static/js/chunk-2d2311f7.3c951f38.js rel=prefetch><link href=/ui/static/js/chunk-2d2371be.37f19019.js rel=prefetch><link href=/ui/static/js/chunk-2d237ee7.3cd1af21.js rel=prefetch><link href=/ui/static/js/chunk-2d238465.3860df71.js rel=prefetch><link href=/ui/static/js/chunk-7532b3ea.d6aa1a5e.js rel=prefetch><link href=/ui/static/css/app.533bcfe8.css rel=preload as=style><link href=/ui/static/css/chunk-vendors.7a869ba5.css rel=preload as=style><link href=/ui/static/js/app.7fbee7d9.js rel=preload as=script><link href=/ui/static/js/chunk-vendors.730af083.js rel=preload as=script><link href=/ui/static/css/chunk-vendors.7a869ba5.css rel=stylesheet><link href=/ui/static/css/app.533bcfe8.css rel=stylesheet></head><body><noscript><strong>We're sorry but Lyrebird doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/ui/static/js/chunk-vendors.730af083.js></script><script src=/ui/static/js/app.7fbee7d9.js></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/ui/static/favicon.ico><title>Lyrebird</title><link href=/ui/static/js/chunk-2d0a3577.15b80f4c.js rel=prefetch><link href=/ui/static/js/chunk-2d0a43df.2e00c125.js rel=prefetch><link href=/ui/static/js/chunk-2d0aab07.ec9eaa41.js rel=prefetch><link href=/ui/static/js/chunk-2d0abc00.1e61764e.js rel=prefetch><link href=/ui/static/js/chunk-2d0ae937.22b2ec66.js rel=prefetch><link href=/ui/static/js/chunk-2d0aeb45.c571eeac.js rel=prefetch><link href=/ui/static/js/chunk-2d0afa49.65108fc0.js rel=prefetch><link href=/ui/static/js/chunk-2d0b2762.7faa5aa3.js rel=prefetch><link href=/ui/static/js/chunk-2d0b6187.1b01ea3f.js rel=prefetch><link href=/ui/static/js/chunk-2d0ba136.08ad9b83.js rel=prefetch><link href=/ui/static/js/chunk-2d0bb267.7da55a18.js rel=prefetch><link href=/ui/static/js/chunk-2d0bcec1.eed4b121.js rel=prefetch><link href=/ui/static/js/chunk-2d0bff92.5eac84e3.js rel=prefetch><link href=/ui/static/js/chunk-2d0c0494.b82491b3.js rel=prefetch><link href=/ui/static/js/chunk-2d0c0a09.ab666bda.js rel=prefetch><link href=/ui/static/js/chunk-2d0c1ed0.c7612dd8.js rel=prefetch><link href=/ui/static/js/chunk-2d0c4313.734ea760.js rel=prefetch><link href=/ui/static/js/chunk-2d0c46d1.a90d3520.js rel=prefetch><link href=/ui/static/js/chunk-2d0c512b.c2655e61.js rel=prefetch><link href=/ui/static/js/chunk-2d0cf16e.c3e2c753.js rel=prefetch><link href=/ui/static/js/chunk-2d0d056d.34332182.js rel=prefetch><link href=/ui/static/js/chunk-2d0d0645.5ba0a827.js rel=prefetch><link href=/ui/static/js/chunk-2d0d2f22.0b0ad9f9.js rel=prefetch><link href=/ui/static/js/chunk-2d0d7e63.967be54e.js rel=prefetch><link href=/ui/static/js/chunk-2d0e1b57.9ca83b35.js rel=prefetch><link href=/ui/static/js/chunk-2d0e1fbe.085b36f1.js rel=prefetch><link href=/ui/static/js/chunk-2d0e22d6.f15418dd.js rel=prefetch><link href=/ui/static/js/chunk-2d0e542a.f9c1a461.js rel=prefetch><link href=/ui/static/js/chunk-2d0e57ec.db5e2796.js rel=prefetch><link href=/ui/static/js/chunk-2d0e6553.e43be0ff.js rel=prefetch><link href=/ui/static/js/chunk-2d0ea098.59254529.js rel=prefetch><link href=/ui/static/js/chunk-2d208ac5.b30c459d.js rel=prefetch><link href=/ui/static/js/chunk-2d209408.f92607b1.js rel=prefetch><link href=/ui/static/js/chunk-2d20f745.2c8189f8.js rel=prefetch><link href=/ui/static/js/chunk-2d20ff23.57e1f9e1.js rel=prefetch><link href=/ui/static/js/chunk-2d2138c7.4a97aa4a.js rel=prefetch><link href=/ui/static/js/chunk-2d217e5b.40de0dd2.js rel=prefetch><link href=/ui/static/js/chunk-2d21b84a.4bfe2261.js rel=prefetch><link href=/ui/static/js/chunk-2d21dcd2.64e0a422.js rel=prefetch><link href=/ui/static/js/chunk-2d21f327.4df1e469.js rel=prefetch><link href=/ui/static/js/chunk-2d2214b3.4f3fe061.js rel=prefetch><link href=/ui/static/js/chunk-2d221a34.7ff16b79.js rel=prefetch><link href=/ui/static/js/chunk-2d22502a.f9b13f63.js rel=prefetch><link href=/ui/static/js/chunk-2d228ca6.741b4c1c.js rel=prefetch><link href=/ui/static/js/chunk-2d2295e9.599758ba.js rel=prefetch><link href=/ui/static/js/chunk-2d22c171.55accc8a.js rel=prefetch><link href=/ui/static/js/chunk-2d22c2b8.fef13e00.js rel=prefetch><link href=/ui/static/js/chunk-2d22ca58.fe58906c.js rel=prefetch><link href=/ui/static/js/chunk-2d2311f7.3c951f38.js rel=prefetch><link href=/ui/static/js/chunk-2d2371be.37f19019.js rel=prefetch><link href=/ui/static/js/chunk-2d237ee7.3cd1af21.js rel=prefetch><link href=/ui/static/js/chunk-2d238465.3860df71.js rel=prefetch><link href=/ui/static/js/chunk-7532b3ea.d6aa1a5e.js rel=prefetch><link href=/ui/static/css/app.b13d2c76.css rel=preload as=style><link href=/ui/static/css/chunk-vendors.17974f4b.css rel=preload as=style><link href=/ui/static/js/app.d3a5fc77.js rel=preload as=script><link href=/ui/static/js/chunk-vendors.3c2d29be.js rel=preload as=script><link href=/ui/static/css/chunk-vendors.17974f4b.css rel=stylesheet><link href=/ui/static/css/app.b13d2c76.css rel=stylesheet></head><body><noscript><strong>We're sorry but Lyrebird doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/ui/static/js/chunk-vendors.3c2d29be.js></script><script src=/ui/static/js/app.d3a5fc77.js></script></body></html>
2 changes: 0 additions & 2 deletions lyrebird/client/static/js/app.7fbee7d9.js

This file was deleted.

1 change: 0 additions & 1 deletion lyrebird/client/static/js/app.7fbee7d9.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions lyrebird/client/static/js/app.d3a5fc77.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lyrebird/client/static/js/app.d3a5fc77.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions lyrebird/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,14 @@ def publish(self, channel, message, state=False, *args, **kwargs):
message['timestamp'] = int(time.time())
if not message.get('sender'):
stack = inspect.stack()
script_filename = stack[2].filename
script_name = script_filename[script_filename.rfind('/') + 1:]
message['sender'] = script_name
script_path = stack[2].filename
script_name = script_path[script_path.rfind('/') + 1:]
function_name = stack[2].function
sender_dict = {
"file": script_name,
"function": function_name
}
message['sender'] = sender_dict

self.event_queue.put(Event(channel, message))
if state:
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/notice_center.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def push_notice(self, msg):
display notice
"""
context.application.socket_io.emit('show', msg, namespace='/alert')
context.application.socket_io.emit('show', msg)
2 changes: 1 addition & 1 deletion lyrebird/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
IVERSION = (1, 1, 1)
IVERSION = (1, 1, 2)
VERSION = ".".join(str(i) for i in IVERSION)
LYREBIRD = "Lyrebird " + VERSION

0 comments on commit 663a64c

Please sign in to comment.