Commit af6dfec6b444971ff020f3716f1ae1f40db86d9e
1 parent
326fb519
feat: basic implement image component
Showing
5 changed files
with
40 additions
and
8 deletions
... | ... | @@ -4221,8 +4221,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { |
4221 | 4221 | function getUserPermission() { |
4222 | 4222 | defHttp.get('/yt/role/me/permissions') |
4223 | 4223 | .then(res => { |
4224 | - USER_PERMISSION.permission = res | |
4225 | - console.log({ USER_PERMISSION }) | |
4224 | + USER_PERMISSION.permission = res | |
4226 | 4225 | updateButtonContainer() |
4227 | 4226 | // var flag = hasSavePermission() |
4228 | 4227 | // if (!flag) { |
... | ... | @@ -4235,8 +4234,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { |
4235 | 4234 | // 调用API,获取保存的内容 |
4236 | 4235 | function getSaveContent() { |
4237 | 4236 | defHttp.get('/yt/configuration/center/getConfigurationInfo/' + Editor.configurationId) |
4238 | - .then(function (response) { | |
4239 | - console.log({ response }) | |
4237 | + .then(function (response) { | |
4240 | 4238 | const { platform } = response || {} |
4241 | 4239 | const pageSizeControl = PageSetupDialog.getFormats |
4242 | 4240 | PageSetupDialog.getFormats = function () { |
... | ... | @@ -4283,8 +4281,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { |
4283 | 4281 | |
4284 | 4282 | getUserPermission() |
4285 | 4283 | }) |
4286 | - .catch(function (error) { | |
4287 | - console.log(error); | |
4284 | + .catch(function (error) { | |
4288 | 4285 | }); |
4289 | 4286 | } |
4290 | 4287 | ... | ... |
... | ... | @@ -268,6 +268,11 @@ |
268 | 268 | * @description 开关组件状态 {true | false | null} |
269 | 269 | */ |
270 | 270 | SWITCH_STATE: 'switchState', |
271 | + | |
272 | + /** | |
273 | + * @description 图片组件 | |
274 | + */ | |
275 | + IMAGE: 'image' | |
271 | 276 | |
272 | 277 | } |
273 | 278 | |
... | ... | @@ -717,7 +722,7 @@ |
717 | 722 | |
718 | 723 | // TODO thingsKit 设置数据绑定展示面板 |
719 | 724 | const { LINE_CHART_EXPAND, BAR_CHART_EXPAND, DASHBOARD_CHART_EXPAND, DYNAMIC_EFFECT, DATA_SOURCE, VAR_IMAGE, INTERACTION, VIDEO: VIDEO_PANEL, SWITCH_STATE_SETTING, ONLY_SINGLE_EVENT, RUNNING_AND_STOP } = this.enumPermissionPanel |
720 | - const { LINE, LINE_CHART, REAL_TIME, TITLE, VARIABLE, DEFAULT, BAR_CHART, VIDEO, SWITCH, PARAMS_SETTING_BUTTON, DASHBOARD_CHART } = this.enumComponentType | |
725 | + const { LINE, LINE_CHART, REAL_TIME, TITLE, VARIABLE, DEFAULT, BAR_CHART, VIDEO, SWITCH, PARAMS_SETTING_BUTTON, DASHBOARD_CHART, IMAGE } = this.enumComponentType | |
721 | 726 | this.setComponentPermission(LINE, [RUNNING_AND_STOP, DYNAMIC_EFFECT]) |
722 | 727 | this.setComponentPermission(DEFAULT, [DYNAMIC_EFFECT]) |
723 | 728 | this.setComponentPermission(REAL_TIME, [DYNAMIC_EFFECT]) |
... | ... | @@ -730,6 +735,7 @@ |
730 | 735 | this.setComponentPermission(VIDEO, [VIDEO_PANEL]) |
731 | 736 | this.setComponentPermission(SWITCH, [DATA_SOURCE, SWITCH_STATE_SETTING]) |
732 | 737 | this.setComponentPermission(PARAMS_SETTING_BUTTON, [DATA_SOURCE, ONLY_SINGLE_EVENT]) |
738 | + this.setComponentPermission(IMAGE, [DATA_SOURCE]) | |
733 | 739 | |
734 | 740 | var thingskitEntries = [ |
735 | 741 | { title: mxResources.get('general'), id: 'general', image: IMAGE_PATH + '/sidebar-general.png' }, | ... | ... |
... | ... | @@ -59,6 +59,12 @@ |
59 | 59 | this.setCellAttributes(cell, { [basicAttr.COMPONENT_TYPE]: componentType.VIDEO }) |
60 | 60 | return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, '视频'); |
61 | 61 | })), |
62 | + this.addEntry(this.getTagsForStencil('mxgraph.basic', '图片', 'basic').join(' '), mxUtils.bind(this, function () { | |
63 | + const cell = new mxCell(`<img class="basic-component__image" src="${Proxy_Prefix}/images/thingskit/img-placeholder.png" />`, new mxGeometry(0, 0, 190, 190), 'text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;'); | |
64 | + cell.setVertex(true) | |
65 | + this.setCellAttributes(cell, { [basicAttr.COMPONENT_TYPE]: componentType.IMAGE }) | |
66 | + return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, '图片'); | |
67 | + })), | |
62 | 68 | ]; |
63 | 69 | |
64 | 70 | this.addPaletteFunctions('component', '基础元件', true, fns); | ... | ... |
... | ... | @@ -5930,7 +5930,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
5930 | 5930 | [componentType.DEFAULT]: getSubmitValue, |
5931 | 5931 | [componentType.VIDEO]: getVideoSubmitValue, |
5932 | 5932 | [componentType.SWITCH]: getSwitchSubmitValue, |
5933 | - [componentType.PARAMS_SETTING_BUTTON]: getSwitchSubmitValue | |
5933 | + [componentType.PARAMS_SETTING_BUTTON]: getSwitchSubmitValue, | |
5934 | + [componentType.IMAGE]: getSubmitValue | |
5934 | 5935 | } |
5935 | 5936 | |
5936 | 5937 | const cell = vertices[0] |
... | ... | @@ -13453,6 +13454,11 @@ class HandleDataSource { |
13453 | 13454 | return |
13454 | 13455 | } |
13455 | 13456 | |
13457 | + if (type === this.componentType.IMAGE) { | |
13458 | + this.handleImageComponent(message) | |
13459 | + return | |
13460 | + } | |
13461 | + | |
13456 | 13462 | if (!data) return |
13457 | 13463 | const [[timespan, value]] = data[attr] |
13458 | 13464 | node.setValue(value) |
... | ... | @@ -13516,6 +13522,16 @@ class HandleDataSource { |
13516 | 13522 | }, node) |
13517 | 13523 | } |
13518 | 13524 | |
13525 | + handleImageComponent(message) { | |
13526 | + const { subscriptionId, data = {} } = message | |
13527 | + const node = this.getNodeByCmdId(subscriptionId) | |
13528 | + const { attr } = this.getBindData(subscriptionId) | |
13529 | + const [[timespan, receiveValue] = []] = data[attr] || [] | |
13530 | + this.updatePage(() => { | |
13531 | + node.setAttribute('label', `<img class="basic-component__image" alt="图片" src="${Proxy_Prefix}/${receiveValue}" />`) | |
13532 | + }, node) | |
13533 | + } | |
13534 | + | |
13519 | 13535 | /** |
13520 | 13536 | * @description 更新实时数据 |
13521 | 13537 | * @param {} message | ... | ... |