Commit 5f648542b2e76c8b95a8cf3d790ceddefbca463a
Merge branch 'ww' into 'main'
feat: implement not has permission user can not save content See merge request huang/thingskit-drawio!41
Showing
6 changed files
with
86 additions
and
34 deletions
| 1 | class ConfigurationNodeApi { | 1 | class ConfigurationNodeApi { |
| 2 | + | ||
| 3 | + /** | ||
| 4 | + * @description 获取用户权限 | ||
| 5 | + */ | ||
| 6 | + static getUserPermissions(){ | ||
| 7 | + return defHttp.get('/yt/role/me/permissions') | ||
| 8 | + } | ||
| 9 | + | ||
| 2 | /** | 10 | /** |
| 3 | * @description 获取组态信息 | 11 | * @description 获取组态信息 |
| 4 | * @param {'CONFIGURE' | 'CONTENT' | 'NODE'} levelType - 组态资源类型 | 12 | * @param {'CONFIGURE' | 'CONTENT' | 'NODE'} levelType - 组态资源类型 |
| @@ -18,6 +18,19 @@ const GLOBAL_TOKEN = (() => { | @@ -18,6 +18,19 @@ const GLOBAL_TOKEN = (() => { | ||
| 18 | } | 18 | } |
| 19 | })() | 19 | })() |
| 20 | 20 | ||
| 21 | +/** | ||
| 22 | + * @description 写权限 key | ||
| 23 | + */ | ||
| 24 | +const CAN_WRITE = 'api:yt:admin:designConfiguration' | ||
| 25 | + | ||
| 26 | +const USER_PERMISSION = { | ||
| 27 | + permission: [] | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +const hasSavePermission = () => { | ||
| 31 | + return USER_PERMISSION.permission.includes(CAN_WRITE) | ||
| 32 | +} | ||
| 33 | + | ||
| 21 | const GLOBAL_WS_URL = () => { | 34 | const GLOBAL_WS_URL = () => { |
| 22 | const { host, href } = location | 35 | const { host, href } = location |
| 23 | const reg = /^https/ | 36 | const reg = /^https/ |
| @@ -5037,7 +5037,23 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | @@ -5037,7 +5037,23 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | ||
| 5037 | 5037 | ||
| 5038 | getToken() | 5038 | getToken() |
| 5039 | 5039 | ||
| 5040 | - //调用API,获取保存的内容 | 5040 | + var updateButtonContainer = this.updateButtonContainer |
| 5041 | + // var lockUnlock = this.actions.actions.lockUnlock.funct | ||
| 5042 | + // var selectAll = this.actions.actions.selectAll.funct | ||
| 5043 | + function getUserPermission() { | ||
| 5044 | + defHttp.get('/yt/role/me/permissions') | ||
| 5045 | + .then(res => { | ||
| 5046 | + USER_PERMISSION.permission = res | ||
| 5047 | + updateButtonContainer() | ||
| 5048 | + // var flag = hasSavePermission() | ||
| 5049 | + // if (!flag) { | ||
| 5050 | + // selectAll() | ||
| 5051 | + // lockUnlock() | ||
| 5052 | + // } | ||
| 5053 | + }) | ||
| 5054 | + } | ||
| 5055 | + | ||
| 5056 | + // 调用API,获取保存的内容 | ||
| 5041 | function getSaveContent() { | 5057 | function getSaveContent() { |
| 5042 | defHttp.get('/yt/configuration/center/getConfigurationInfo/'+Editor.configurationId) | 5058 | defHttp.get('/yt/configuration/center/getConfigurationInfo/'+Editor.configurationId) |
| 5043 | .then(function (response) { | 5059 | .then(function (response) { |
| @@ -5085,6 +5101,8 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | @@ -5085,6 +5101,8 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { | ||
| 5085 | } else { | 5101 | } else { |
| 5086 | fn(); | 5102 | fn(); |
| 5087 | } | 5103 | } |
| 5104 | + | ||
| 5105 | + getUserPermission() | ||
| 5088 | }) | 5106 | }) |
| 5089 | .catch(function (error) { | 5107 | .catch(function (error) { |
| 5090 | console.log(error); | 5108 | console.log(error); |
| @@ -5960,27 +5978,31 @@ App.prototype.updateButtonContainer = function() | @@ -5960,27 +5978,31 @@ App.prototype.updateButtonContainer = function() | ||
| 5960 | this.buttonContainer.appendChild(this.shareButton); | 5978 | this.buttonContainer.appendChild(this.shareButton); |
| 5961 | 5979 | ||
| 5962 | // TODO thingsKit 保存按钮 | 5980 | // TODO thingsKit 保存按钮 |
| 5963 | - this.saveButton = document.createElement('div'); | ||
| 5964 | - this.saveButton.className = 'geBtn gePrimaryBtn'; | ||
| 5965 | - this.saveButton.style.display = 'inline-block'; | ||
| 5966 | - this.saveButton.style.backgroundColor = '#F2931E'; | ||
| 5967 | - this.saveButton.style.borderColor = '#F08705'; | ||
| 5968 | - this.saveButton.style.backgroundImage = 'none'; | ||
| 5969 | - this.saveButton.style.marginTop = '-10px'; | ||
| 5970 | - this.saveButton.style.lineHeight = '28px'; | ||
| 5971 | - this.saveButton.style.minWidth = '0px'; | ||
| 5972 | - this.saveButton.style.cssFloat = 'right'; | ||
| 5973 | - this.saveButton.setAttribute('title', '保存'); | ||
| 5974 | - mxUtils.write(this.saveButton, '保存'); | ||
| 5975 | - mxEvent.addListener(this.saveButton, 'click', mxUtils.bind(this, function() | ||
| 5976 | - { | ||
| 5977 | - this.currentFile.ui.actions.get( | ||
| 5978 | - (this.currentFile.mode == null || !this.currentFile.isEditable()) | ||
| 5979 | - ? 'saveAs' | ||
| 5980 | - : 'save') | ||
| 5981 | - .funct(); | ||
| 5982 | - })); | ||
| 5983 | - this.buttonContainer.appendChild(this.saveButton); | 5981 | + var flag = hasSavePermission() |
| 5982 | + if (flag) { | ||
| 5983 | + this.saveButton = document.createElement('div'); | ||
| 5984 | + this.saveButton.className = 'geBtn gePrimaryBtn'; | ||
| 5985 | + this.saveButton.style.display = 'inline-block'; | ||
| 5986 | + this.saveButton.style.backgroundColor = '#F2931E'; | ||
| 5987 | + this.saveButton.style.borderColor = '#F08705'; | ||
| 5988 | + this.saveButton.style.backgroundImage = 'none'; | ||
| 5989 | + this.saveButton.style.marginTop = '-10px'; | ||
| 5990 | + this.saveButton.style.lineHeight = '28px'; | ||
| 5991 | + this.saveButton.style.minWidth = '0px'; | ||
| 5992 | + this.saveButton.style.cssFloat = 'right'; | ||
| 5993 | + this.saveButton.setAttribute('title', '保存'); | ||
| 5994 | + mxUtils.write(this.saveButton, '保存'); | ||
| 5995 | + mxEvent.addListener(this.saveButton, 'click', mxUtils.bind(this, function() | ||
| 5996 | + { | ||
| 5997 | + this.currentFile.ui.actions.get( | ||
| 5998 | + (this.currentFile.mode == null || !this.currentFile.isEditable()) | ||
| 5999 | + ? 'saveAs' | ||
| 6000 | + : 'save') | ||
| 6001 | + .funct(); | ||
| 6002 | + })); | ||
| 6003 | + this.buttonContainer.appendChild(this.saveButton); | ||
| 6004 | + } | ||
| 6005 | + | ||
| 5984 | 6006 | ||
| 5985 | 6007 | ||
| 5986 | // this.shareButton = document.createElement('div'); | 6008 | // this.shareButton = document.createElement('div'); |
| @@ -134,6 +134,9 @@ LocalFile.prototype.getLatestVersion = function (success, error) { | @@ -134,6 +134,9 @@ LocalFile.prototype.getLatestVersion = function (success, error) { | ||
| 134 | * @param {number} dy Y-coordinate of the translation. | 134 | * @param {number} dy Y-coordinate of the translation. |
| 135 | */ | 135 | */ |
| 136 | LocalFile.prototype.saveFile = function (title, revision, success, error, useCurrentData) { | 136 | LocalFile.prototype.saveFile = function (title, revision, success, error, useCurrentData) { |
| 137 | + // TODO thingskit 保存权限 | ||
| 138 | + var flag = hasSavePermission() | ||
| 139 | + if (!flag) return error({error: '没有权限'}) | ||
| 137 | if (title != this.title) { | 140 | if (title != this.title) { |
| 138 | this.fileHandle = null; | 141 | this.fileHandle = null; |
| 139 | this.desc = null; | 142 | this.desc = null; |
| @@ -412,13 +412,15 @@ | @@ -412,13 +412,15 @@ | ||
| 412 | { | 412 | { |
| 413 | type: 'gauge', | 413 | type: 'gauge', |
| 414 | center: ['50%', '60%'], | 414 | center: ['50%', '60%'], |
| 415 | + radius: '100%', | ||
| 415 | startAngle: 200, | 416 | startAngle: 200, |
| 416 | endAngle: -20, | 417 | endAngle: -20, |
| 417 | min: 0, | 418 | min: 0, |
| 418 | max: 100, | 419 | max: 100, |
| 419 | splitNumber: 10, | 420 | splitNumber: 10, |
| 420 | itemStyle: { | 421 | itemStyle: { |
| 421 | - color: '#FFAB91' | 422 | + color: '#5479c6' |
| 423 | + // color: '#FFAB91' | ||
| 422 | }, | 424 | }, |
| 423 | progress: { | 425 | progress: { |
| 424 | show: true, | 426 | show: true, |
| @@ -433,7 +435,7 @@ | @@ -433,7 +435,7 @@ | ||
| 433 | } | 435 | } |
| 434 | }, | 436 | }, |
| 435 | axisTick: { | 437 | axisTick: { |
| 436 | - distance: -45, | 438 | + distance: 0, |
| 437 | splitNumber: 5, | 439 | splitNumber: 5, |
| 438 | lineStyle: { | 440 | lineStyle: { |
| 439 | width: 2, | 441 | width: 2, |
| @@ -441,7 +443,7 @@ | @@ -441,7 +443,7 @@ | ||
| 441 | } | 443 | } |
| 442 | }, | 444 | }, |
| 443 | splitLine: { | 445 | splitLine: { |
| 444 | - distance: -52, | 446 | + distance: 0, |
| 445 | length: 14, | 447 | length: 14, |
| 446 | lineStyle: { | 448 | lineStyle: { |
| 447 | width: 3, | 449 | width: 3, |
| @@ -449,9 +451,9 @@ | @@ -449,9 +451,9 @@ | ||
| 449 | } | 451 | } |
| 450 | }, | 452 | }, |
| 451 | axisLabel: { | 453 | axisLabel: { |
| 452 | - distance: -20, | 454 | + distance: 35, |
| 453 | color: '#999', | 455 | color: '#999', |
| 454 | - fontSize: 20 | 456 | + fontSize: 20 |
| 455 | }, | 457 | }, |
| 456 | anchor: { | 458 | anchor: { |
| 457 | show: false | 459 | show: false |
| @@ -13743,13 +13743,15 @@ class HandleDataSource { | @@ -13743,13 +13743,15 @@ class HandleDataSource { | ||
| 13743 | { | 13743 | { |
| 13744 | type: 'gauge', | 13744 | type: 'gauge', |
| 13745 | center: ['50%', '60%'], | 13745 | center: ['50%', '60%'], |
| 13746 | + radius: '100%', | ||
| 13746 | startAngle: 200, | 13747 | startAngle: 200, |
| 13747 | endAngle: -20, | 13748 | endAngle: -20, |
| 13748 | min: 0, | 13749 | min: 0, |
| 13749 | max: 100, | 13750 | max: 100, |
| 13750 | splitNumber: 10, | 13751 | splitNumber: 10, |
| 13751 | itemStyle: { | 13752 | itemStyle: { |
| 13752 | - color: '#FFAB91' | 13753 | + color: '#5479c6' |
| 13754 | + // color: '#FFAB91' | ||
| 13753 | }, | 13755 | }, |
| 13754 | progress: { | 13756 | progress: { |
| 13755 | show: true, | 13757 | show: true, |
| @@ -13764,7 +13766,7 @@ class HandleDataSource { | @@ -13764,7 +13766,7 @@ class HandleDataSource { | ||
| 13764 | } | 13766 | } |
| 13765 | }, | 13767 | }, |
| 13766 | axisTick: { | 13768 | axisTick: { |
| 13767 | - distance: -45, | 13769 | + distance: 0, |
| 13768 | splitNumber: 5, | 13770 | splitNumber: 5, |
| 13769 | lineStyle: { | 13771 | lineStyle: { |
| 13770 | width: 2, | 13772 | width: 2, |
| @@ -13772,7 +13774,7 @@ class HandleDataSource { | @@ -13772,7 +13774,7 @@ class HandleDataSource { | ||
| 13772 | } | 13774 | } |
| 13773 | }, | 13775 | }, |
| 13774 | splitLine: { | 13776 | splitLine: { |
| 13775 | - distance: -52, | 13777 | + distance: 0, |
| 13776 | length: 14, | 13778 | length: 14, |
| 13777 | lineStyle: { | 13779 | lineStyle: { |
| 13778 | width: 3, | 13780 | width: 3, |
| @@ -13780,7 +13782,7 @@ class HandleDataSource { | @@ -13780,7 +13782,7 @@ class HandleDataSource { | ||
| 13780 | } | 13782 | } |
| 13781 | }, | 13783 | }, |
| 13782 | axisLabel: { | 13784 | axisLabel: { |
| 13783 | - distance: -20, | 13785 | + distance: 35, |
| 13784 | color: '#999', | 13786 | color: '#999', |
| 13785 | fontSize: 20 | 13787 | fontSize: 20 |
| 13786 | }, | 13788 | }, |
| @@ -13803,10 +13805,10 @@ class HandleDataSource { | @@ -13803,10 +13805,10 @@ class HandleDataSource { | ||
| 13803 | }, | 13805 | }, |
| 13804 | data: [ | 13806 | data: [ |
| 13805 | { | 13807 | { |
| 13806 | - value | 13808 | + value: 20 |
| 13807 | } | 13809 | } |
| 13808 | ] | 13810 | ] |
| 13809 | - } | 13811 | + }, |
| 13810 | ] | 13812 | ] |
| 13811 | } | 13813 | } |
| 13812 | } | 13814 | } |
| @@ -13815,8 +13817,10 @@ class HandleDataSource { | @@ -13815,8 +13817,10 @@ class HandleDataSource { | ||
| 13815 | * @description 获取仪表盘配置 | 13817 | * @description 获取仪表盘配置 |
| 13816 | */ | 13818 | */ |
| 13817 | getRealTimeUpdateDashboardChartOption(params = { dataList: [] }) { | 13819 | getRealTimeUpdateDashboardChartOption(params = { dataList: [] }) { |
| 13818 | - const { dataList = [] } = params | 13820 | + const { dataList = [], oldOptions } = params |
| 13821 | + console.log({oldOptions}) | ||
| 13819 | const [timespan, value] = dataList[0] || [] | 13822 | const [timespan, value] = dataList[0] || [] |
| 13823 | + console.log(value) | ||
| 13820 | return { | 13824 | return { |
| 13821 | series: [ | 13825 | series: [ |
| 13822 | { | 13826 | { |