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
| ... | ... | @@ -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 | 34 | const GLOBAL_WS_URL = () => { |
| 22 | 35 | const { host, href } = location |
| 23 | 36 | const reg = /^https/ | ... | ... |
| ... | ... | @@ -5037,7 +5037,23 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { |
| 5037 | 5037 | |
| 5038 | 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 | 5057 | function getSaveContent() { |
| 5042 | 5058 | defHttp.get('/yt/configuration/center/getConfigurationInfo/'+Editor.configurationId) |
| 5043 | 5059 | .then(function (response) { |
| ... | ... | @@ -5085,6 +5101,8 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { |
| 5085 | 5101 | } else { |
| 5086 | 5102 | fn(); |
| 5087 | 5103 | } |
| 5104 | + | |
| 5105 | + getUserPermission() | |
| 5088 | 5106 | }) |
| 5089 | 5107 | .catch(function (error) { |
| 5090 | 5108 | console.log(error); |
| ... | ... | @@ -5960,27 +5978,31 @@ App.prototype.updateButtonContainer = function() |
| 5960 | 5978 | this.buttonContainer.appendChild(this.shareButton); |
| 5961 | 5979 | |
| 5962 | 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 | 6008 | // this.shareButton = document.createElement('div'); | ... | ... |
| ... | ... | @@ -134,6 +134,9 @@ LocalFile.prototype.getLatestVersion = function (success, error) { |
| 134 | 134 | * @param {number} dy Y-coordinate of the translation. |
| 135 | 135 | */ |
| 136 | 136 | LocalFile.prototype.saveFile = function (title, revision, success, error, useCurrentData) { |
| 137 | + // TODO thingskit 保存权限 | |
| 138 | + var flag = hasSavePermission() | |
| 139 | + if (!flag) return error({error: '没有权限'}) | |
| 137 | 140 | if (title != this.title) { |
| 138 | 141 | this.fileHandle = null; |
| 139 | 142 | this.desc = null; | ... | ... |
| ... | ... | @@ -412,13 +412,15 @@ |
| 412 | 412 | { |
| 413 | 413 | type: 'gauge', |
| 414 | 414 | center: ['50%', '60%'], |
| 415 | + radius: '100%', | |
| 415 | 416 | startAngle: 200, |
| 416 | 417 | endAngle: -20, |
| 417 | 418 | min: 0, |
| 418 | 419 | max: 100, |
| 419 | 420 | splitNumber: 10, |
| 420 | 421 | itemStyle: { |
| 421 | - color: '#FFAB91' | |
| 422 | + color: '#5479c6' | |
| 423 | + // color: '#FFAB91' | |
| 422 | 424 | }, |
| 423 | 425 | progress: { |
| 424 | 426 | show: true, |
| ... | ... | @@ -433,7 +435,7 @@ |
| 433 | 435 | } |
| 434 | 436 | }, |
| 435 | 437 | axisTick: { |
| 436 | - distance: -45, | |
| 438 | + distance: 0, | |
| 437 | 439 | splitNumber: 5, |
| 438 | 440 | lineStyle: { |
| 439 | 441 | width: 2, |
| ... | ... | @@ -441,7 +443,7 @@ |
| 441 | 443 | } |
| 442 | 444 | }, |
| 443 | 445 | splitLine: { |
| 444 | - distance: -52, | |
| 446 | + distance: 0, | |
| 445 | 447 | length: 14, |
| 446 | 448 | lineStyle: { |
| 447 | 449 | width: 3, |
| ... | ... | @@ -449,9 +451,9 @@ |
| 449 | 451 | } |
| 450 | 452 | }, |
| 451 | 453 | axisLabel: { |
| 452 | - distance: -20, | |
| 454 | + distance: 35, | |
| 453 | 455 | color: '#999', |
| 454 | - fontSize: 20 | |
| 456 | + fontSize: 20 | |
| 455 | 457 | }, |
| 456 | 458 | anchor: { |
| 457 | 459 | show: false | ... | ... |
| ... | ... | @@ -13743,13 +13743,15 @@ class HandleDataSource { |
| 13743 | 13743 | { |
| 13744 | 13744 | type: 'gauge', |
| 13745 | 13745 | center: ['50%', '60%'], |
| 13746 | + radius: '100%', | |
| 13746 | 13747 | startAngle: 200, |
| 13747 | 13748 | endAngle: -20, |
| 13748 | 13749 | min: 0, |
| 13749 | 13750 | max: 100, |
| 13750 | 13751 | splitNumber: 10, |
| 13751 | 13752 | itemStyle: { |
| 13752 | - color: '#FFAB91' | |
| 13753 | + color: '#5479c6' | |
| 13754 | + // color: '#FFAB91' | |
| 13753 | 13755 | }, |
| 13754 | 13756 | progress: { |
| 13755 | 13757 | show: true, |
| ... | ... | @@ -13764,7 +13766,7 @@ class HandleDataSource { |
| 13764 | 13766 | } |
| 13765 | 13767 | }, |
| 13766 | 13768 | axisTick: { |
| 13767 | - distance: -45, | |
| 13769 | + distance: 0, | |
| 13768 | 13770 | splitNumber: 5, |
| 13769 | 13771 | lineStyle: { |
| 13770 | 13772 | width: 2, |
| ... | ... | @@ -13772,7 +13774,7 @@ class HandleDataSource { |
| 13772 | 13774 | } |
| 13773 | 13775 | }, |
| 13774 | 13776 | splitLine: { |
| 13775 | - distance: -52, | |
| 13777 | + distance: 0, | |
| 13776 | 13778 | length: 14, |
| 13777 | 13779 | lineStyle: { |
| 13778 | 13780 | width: 3, |
| ... | ... | @@ -13780,7 +13782,7 @@ class HandleDataSource { |
| 13780 | 13782 | } |
| 13781 | 13783 | }, |
| 13782 | 13784 | axisLabel: { |
| 13783 | - distance: -20, | |
| 13785 | + distance: 35, | |
| 13784 | 13786 | color: '#999', |
| 13785 | 13787 | fontSize: 20 |
| 13786 | 13788 | }, |
| ... | ... | @@ -13803,10 +13805,10 @@ class HandleDataSource { |
| 13803 | 13805 | }, |
| 13804 | 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 | 13817 | * @description 获取仪表盘配置 |
| 13816 | 13818 | */ |
| 13817 | 13819 | getRealTimeUpdateDashboardChartOption(params = { dataList: [] }) { |
| 13818 | - const { dataList = [] } = params | |
| 13820 | + const { dataList = [], oldOptions } = params | |
| 13821 | + console.log({oldOptions}) | |
| 13819 | 13822 | const [timespan, value] = dataList[0] || [] |
| 13823 | + console.log(value) | |
| 13820 | 13824 | return { |
| 13821 | 13825 | series: [ |
| 13822 | 13826 | { | ... | ... |