Skip to content

Commit d24be4a

Browse files
author
CrazyWisdom
authored
Merge pull request #157 from emqx/develop
Develop
2 parents 161f8c0 + 4c7e7a9 commit d24be4a

27 files changed

+331
-151
lines changed

main/getMenuTemplate.ts

+15
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ const getMenuTemplate = (win: BrowserWindow): $TSFixed => {
6868
},
6969
]
7070
: [{ role: 'delete' }, { type: 'separator' }, { role: 'selectAll' }]),
71+
{ type: 'separator' },
72+
{
73+
label: 'Send payload',
74+
accelerator: 'CmdOrCtrl + Enter',
75+
click: () => {
76+
win.webContents.send('sendPayload')
77+
},
78+
},
79+
{
80+
label: 'Search by Topic',
81+
accelerator: 'CmdOrCtrl + F',
82+
click: () => {
83+
win.webContents.send('searchByTopic')
84+
},
85+
},
7186
],
7287
},
7388
{

main/updateChecker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { dialog, shell } from 'electron'
22
import axios from 'axios'
33

4-
const version = 'v1.2.1'
4+
const version = 'v1.2.2'
55
const release = 'https://api.github.com/repos/emqx/MQTTX/releases/latest'
66
const downloadUrl = 'https://github.com/emqx/MQTTX/releases/latest'
77

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "MQTTX",
33
"author": "EMQ X Team",
4-
"version": "1.2.1",
4+
"version": "1.2.2",
55
"license": "Apache",
66
"description": "MQTT desktop client",
77
"repository": "https://github.com/emqx/MQTTX",
@@ -21,7 +21,7 @@
2121
"axios": "^0.19.0",
2222
"chai-as-promised": "^7.1.1",
2323
"core-js": "^2.6.5",
24-
"element-ui": "^2.9.1",
24+
"element-ui": "^2.13.0",
2525
"fs-extra": "^8.1.0",
2626
"jump.js": "^1.0.2",
2727
"lodash-id": "^0.14.0",
@@ -54,7 +54,7 @@
5454
"electron": "^5.0.0",
5555
"node-sass": "^4.9.0",
5656
"sass-loader": "^7.1.0",
57-
"typescript": "^3.4.3",
57+
"typescript": "^3.7.4",
5858
"vue-cli-plugin-electron-builder": "^1.4.4",
5959
"vue-template-compiler": "^2.6.10"
6060
},

public/app.ico

3.07 KB
Binary file not shown.

public/app.png

38.2 KB
Loading

src/assets/images/brokers.png

-13.7 KB
Binary file not shown.

src/assets/images/mqttx-dark.png

2.89 KB
Loading

src/assets/images/mqttx-light.png

3.73 KB
Loading

src/assets/scss/base.scss

+1
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,5 @@ img {
9797
/* Titlebar */
9898
.titlebar {
9999
padding: 16px 0;
100+
-webkit-app-region: drag;
100101
}

src/assets/scss/element/element-reset.scss

+24
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@
168168
border-bottom-color: var(--color-bg-messagebox);
169169
}
170170
}
171+
.el-popper[x-placement^="top"] .popper__arrow {
172+
border-top-color: var(--color-border-default);
173+
174+
&:after {
175+
border-top-color: var(--color-bg-messagebox);
176+
}
177+
}
171178
.el-select-dropdown__item.hover,
172179
.el-select-dropdown__item:hover {
173180
background: var(--color-bg-item);
@@ -186,3 +193,20 @@
186193
.el-tooltip__popper.is-light {
187194
color: #616161;
188195
}
196+
197+
/* Color picker */
198+
.el-color-picker__panel {
199+
background: var(--color-bg-normal);
200+
border-color: var(--color-border-default);
201+
}
202+
.el-color-dropdown__btn {
203+
border-color: var(--color-border-default);
204+
background: transparent;
205+
color: var(--color-text-default);
206+
}
207+
208+
/* Icon */
209+
.el-icon-refresh {
210+
cursor: pointer;
211+
color: var(--color-main-green);
212+
}

src/components/MsgPublish.vue

+21-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<el-input
44
placeholder="Topic"
55
v-model="msgRecord.topic"
6-
@focus="handleInputFoucs">
6+
@focus="handleInputFoucs"
7+
@blur="handleInputBlur">
78
</el-input>
89
<div class="qos-retain">
910
<span class="publish-label">QoS: </span>
@@ -20,7 +21,8 @@
2021
rows="3"
2122
placeholder="Payload"
2223
v-model="msgRecord.payload"
23-
@focus="handleInputFoucs">
24+
@focus="handleInputFoucs"
25+
@blur="handleInputBlur">
2426
</el-input>
2527
<a
2628
href="javascript:;"
@@ -31,8 +33,10 @@
3133
</div>
3234
</template>
3335

36+
3437
<script lang="ts">
35-
import { Component, Vue, Prop } from 'vue-property-decorator'
38+
import { Component, Vue } from 'vue-property-decorator'
39+
import { ipcRenderer } from 'electron'
3640
import jump from 'jump.js'
3741
import { MessageModel } from '../views/connections/types'
3842
@@ -47,13 +51,23 @@ export default class MsgPublish extends Vue {
4751
payload: JSON.stringify({ msg: 'hello' }, null, 2),
4852
}
4953
50-
private send(): void {
54+
private send() {
5155
this.$emit('handleSend', this.msgRecord)
5256
}
5357
54-
private handleInputFoucs(): void {
58+
private handleInputFoucs() {
59+
ipcRenderer.on('sendPayload', () => {
60+
this.send()
61+
})
5562
jump(document.body.scrollHeight)
5663
}
64+
private handleInputBlur() {
65+
ipcRenderer.removeAllListeners('sendPayload')
66+
}
67+
68+
private beforeDestroy() {
69+
ipcRenderer.removeAllListeners('sendPayload')
70+
}
5771
}
5872
</script>
5973

@@ -109,6 +123,7 @@ export default class MsgPublish extends Vue {
109123
.el-textarea__inner {
110124
border: 0px;
111125
border-top: 1px solid var(--color-border-default);
126+
border-radius: 0px;
112127
padding: 8px 0px;
113128
&:focus,
114129
&:hover {
@@ -125,7 +140,7 @@ export default class MsgPublish extends Vue {
125140
}
126141
}
127142
&.message {
128-
height: 120px;
143+
height: 125px;
129144
}
130145
}
131146
</style>

src/components/MyDialog.vue

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
<template>
22
<el-dialog
33
class="my-dialog"
4-
:append-to-body="true"
5-
:show-close="false"
6-
:center="true"
7-
:visible.sync="showDialog"
8-
:title="title"
9-
:width="width"
10-
:close-on-click-modal="false"
11-
:close-on-press-escape="false"
4+
v-bind="$props"
125
@open="open"
136
@close="close">
147

src/components/SubscriptionsList.vue

+79-29
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
:effect="theme !== 'light' ? 'light' : 'dark'"
2929
:disabled="sub.topic.length < 25"
3030
:content="sub.topic"
31+
:open-delay="500"
3132
placement="top">
3233
<span class="topic">
3334
{{ sub.topic }}
@@ -45,26 +46,56 @@
4546
<my-dialog
4647
:title="$t('connections.newSubscription')"
4748
:visible.sync="showDialog"
49+
width="500px"
50+
class="topic-dialog"
4851
@confirm="saveSubs"
4952
@close="resetSubs">
50-
<el-form
51-
ref="form"
52-
:model="subRecord"
53-
:rules="rules">
54-
<el-form-item label="Topic" prop="topic">
55-
<el-input v-model="subRecord.topic" placeholder="testtopic/#"></el-input>
56-
</el-form-item>
57-
<el-form-item label="QoS" prop="qos">
58-
<el-select v-model="subRecord.qos">
59-
<el-option
60-
v-for="qos in qosOption"
61-
:key="qos"
62-
:label="qos"
63-
:value="qos">
64-
</el-option>
65-
</el-select>
66-
</el-form-item>
67-
</el-form>
53+
<el-row :gutter="20">
54+
<el-form
55+
ref="form"
56+
:model="subRecord"
57+
:rules="rules">
58+
<el-col :span="24">
59+
<el-form-item label="Topic" prop="topic">
60+
<el-input v-model="subRecord.topic" placeholder="testtopic/#" size="small">
61+
</el-input>
62+
</el-form-item>
63+
</el-col>
64+
<el-col :span="12">
65+
<el-form-item label="QoS" prop="qos">
66+
<el-select v-model="subRecord.qos" size="small">
67+
<el-option
68+
v-for="qos in qosOption"
69+
:key="qos"
70+
:label="qos"
71+
:value="qos">
72+
</el-option>
73+
</el-select>
74+
</el-form-item>
75+
</el-col>
76+
<el-col :span="12">
77+
<el-form-item :label="$t('connections.color')">
78+
<el-color-picker
79+
v-model="topicColor"
80+
size="mini"
81+
color-format="hex"
82+
:predefine="predefineColors">
83+
</el-color-picker>
84+
<el-input
85+
v-model="topicColor"
86+
size="small"
87+
placeholder="#34C388">
88+
<i
89+
slot="suffix"
90+
title="Refresh"
91+
class="el-icon-refresh"
92+
@click="setColor">
93+
</i>
94+
</el-input>
95+
</el-form-item>
96+
</el-col>
97+
</el-form>
98+
</el-row>
6899
</my-dialog>
69100
</div>
70101
</template>
@@ -74,6 +105,7 @@
74105
import { Component, Vue, Prop, Watch } from 'vue-property-decorator'
75106
import { Getter, Action } from 'vuex-class'
76107
import { updateConnection } from '@/utils/api/connection'
108+
import { defineColors, getRandomColor } from '@/utils/colors'
77109
import LeftPanel from '@/components/LeftPanel.vue'
78110
import MyDialog from '@/components/MyDialog.vue'
79111
import { ConnectionModel } from '../views/connections/types'
@@ -95,6 +127,7 @@ export default class SubscriptionsList extends Vue {
95127
@Getter('activeConnection') private activeConnection: $TSFixed
96128
@Getter('currentTheme') private theme!: Theme
97129
130+
private topicColor = ''
98131
private currentConnection: $TSFixed = {}
99132
private showDialog: boolean = false
100133
private subRecord: SubscriptionModel = {
@@ -115,35 +148,42 @@ export default class SubscriptionsList extends Vue {
115148
return this.$refs.form as VueForm
116149
}
117150
151+
get predefineColors(): string[] {
152+
return defineColors
153+
}
154+
118155
@Watch('record')
119156
private handleRecordChanged(val: ConnectionModel) {
120157
this.getCurrentConnection(val.id as string)
121158
}
122159
160+
private setColor() {
161+
this.topicColor = getRandomColor()
162+
}
123163
private getBorderColor(): string {
124164
let $index: number = this.subsList.length
125165
const lastSubs: SubscriptionModel = this.subsList[$index - 1]
126-
const colors = ['#34C388', '#6ECBEE', '#D08CF1', '#907AEF', '#EDB16E']
127166
128167
if ($index === 0) {
129-
return colors[0]
168+
return this.predefineColors[0]
130169
}
131-
const subIndex = colors.findIndex((color) => color === lastSubs.color)
132-
if (colors[subIndex + 1]) {
170+
const subIndex = this.predefineColors.findIndex((color) => color === lastSubs.color)
171+
if (this.predefineColors[subIndex + 1]) {
133172
$index = subIndex + 1
134173
} else {
135174
$index = 0
136175
}
137-
return colors[$index]
176+
return this.predefineColors[$index]
138177
}
139178
140179
private hideSubsList() {
141180
this.$emit('update:subsVisible', false)
142181
this.changeShowSubscriptions({ showSubscriptions: false })
143182
}
144183
145-
private openDialog(): void {
184+
private openDialog() {
146185
this.showDialog = true
186+
this.setColor()
147187
}
148188
149189
private saveSubs(): void | boolean {
@@ -160,7 +200,7 @@ export default class SubscriptionsList extends Vue {
160200
return false
161201
}
162202
const { topic, qos } = this.subRecord
163-
this.subRecord.color = this.getBorderColor()
203+
this.subRecord.color = this.topicColor || this.getBorderColor()
164204
this.currentConnection.client.subscribe(
165205
topic,
166206
{ qos },
@@ -226,12 +266,12 @@ export default class SubscriptionsList extends Vue {
226266
})
227267
}
228268
229-
private resetSubs(): void {
269+
private resetSubs() {
230270
this.vueForm.clearValidate()
231271
this.vueForm.resetFields()
232272
}
233273
234-
private getCurrentConnection(id: string): void {
274+
private getCurrentConnection(id: string) {
235275
const $activeConnection = this.activeConnection[id]
236276
const { clean } = this.record
237277
if ($activeConnection) {
@@ -303,8 +343,8 @@ export default class SubscriptionsList extends Vue {
303343
border-radius: 50%;
304344
background: var(--color-second-red);
305345
position: absolute;
306-
right: -7px;
307-
top: -7px;
346+
right: -5px;
347+
top: -5px;
308348
width: 18px;
309349
height: 18px;
310350
text-align: center;
@@ -321,4 +361,14 @@ export default class SubscriptionsList extends Vue {
321361
}
322362
}
323363
}
364+
.topic-dialog {
365+
.el-dialog__body {
366+
padding: 20px 20px 0 20px;
367+
.el-color-picker {
368+
position: absolute;
369+
right: 0;
370+
top: 6px;
371+
}
372+
}
373+
}
324374
</style>

0 commit comments

Comments
 (0)