From 4c59f95a131b18cc6688ae4c95e95095670685f0 Mon Sep 17 00:00:00 2001 From: solvd Date: Fri, 14 Jun 2024 14:51:34 -0300 Subject: [PATCH 01/13] #940 Update data from a new device in the list --- .../column/device-column-service.js | 26 +++++++++++++++++- .../details/device-list-details-directive.js | 27 ++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/res/app/device-list/column/device-column-service.js b/res/app/device-list/column/device-column-service.js index 322b5add..e064eea5 100755 --- a/res/app/device-list/column/device-column-service.js +++ b/res/app/device-list/column/device-column-service.js @@ -199,7 +199,7 @@ module.exports = function DeviceColumnService($filter, gettext, SettingsService, return (device.network.type || '').toUpperCase() } }) - , display: TextCell({ + , display: ScreenCell({ title: gettext('Screen') , defaultOrder: 'desc' , value: function(device) { @@ -420,6 +420,30 @@ function TextCell(options) { }) } +function ScreenCell(options) { + return _.defaults(options, { + title: options.title + , defaultOrder: 'asc' + , build: function() { + var td = document.createElement('td') + td.appendChild(document.createTextNode('')) + td.id = 'device-screen' + return td + } + , update: function(td, item) { + var t = td.firstChild + t.nodeValue = options.value(item) + return td + } + , compare: function(a, b) { + return compareIgnoreCase(options.value(a), options.value(b)) + } + , filter: function(item, filter) { + return filterIgnoreCase(options.value(item), filter.query) + } + }) +} + function NumberCell(options) { return _.defaults(options, { title: options.title diff --git a/res/app/device-list/details/device-list-details-directive.js b/res/app/device-list/details/device-list-details-directive.js index 019839a8..1f2e48cd 100755 --- a/res/app/device-list/details/device-list-details-directive.js +++ b/res/app/device-list/details/device-list-details-directive.js @@ -664,6 +664,26 @@ module.exports = function DeviceListDetailsDirective( } + function checkUpdatedData(device) { + if (device.using && device.state === 'using' && (!device.display.width || !device.display.height)) { + setTimeout(() => { + return $route.reload() + }, 1000); + } + + const deviceRow = tbody.querySelector(`#${calculateId(device)}`) + + if (deviceRow && device.display.width && device.display.height) { + const sizeText = `${device.display.width.toString()}x${device.display.height.toString()}` + + const sizeTd = deviceRow.querySelector('td#device-screen'); + + if (sizeTd && sizeTd.innerText !== sizeText) { + $route.reload() + } + } + } + // Triggers when the tracker sees a device for the first time. function addListener(device) { let deviceData = localStorage.getItem('deviceData') ? JSON.parse(localStorage.getItem('deviceData')) : []; @@ -721,18 +741,23 @@ module.exports = function DeviceListDetailsDirective( localStorage.setItem('deviceData', JSON.stringify(deviceData)) let row = createRow(device) + filterRow(row, device) insertRow(row, device) } storeRows() updateFilters(scope.filter()) + + checkUpdatedData(device) } // Triggers when the tracker notices that a device changed. function changeListener(device) { var id = calculateId(device) var tr = tbody.children[id] + + checkUpdatedData(device) storeDevices(device) @@ -750,8 +775,8 @@ module.exports = function DeviceListDetailsDirective( // Should go lower in the list insertRowToSegment(tr, device, tr.rowIndex + 1, rows.length - 1); } - } + } // Triggers when a device is removed entirely from the tracker. From 50d49fb993646011b0fb7415236dd01d928224a4 Mon Sep 17 00:00:00 2001 From: solvd Date: Fri, 21 Jun 2024 04:49:07 -0300 Subject: [PATCH 02/13] #978 Case for special characters --- .../device-list/details/device-list-details-directive.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/res/app/device-list/details/device-list-details-directive.js b/res/app/device-list/details/device-list-details-directive.js index 1f2e48cd..c729b525 100755 --- a/res/app/device-list/details/device-list-details-directive.js +++ b/res/app/device-list/details/device-list-details-directive.js @@ -664,6 +664,10 @@ module.exports = function DeviceListDetailsDirective( } + function escapeCSSSelector(id) { + return id.replace(/([!\"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~])/g, '\\$1'); + } + function checkUpdatedData(device) { if (device.using && device.state === 'using' && (!device.display.width || !device.display.height)) { setTimeout(() => { @@ -671,7 +675,8 @@ module.exports = function DeviceListDetailsDirective( }, 1000); } - const deviceRow = tbody.querySelector(`#${calculateId(device)}`) + const escapedId = escapeCSSSelector(calculateId(device)); + const deviceRow = tbody.querySelector(`#${escapedId}`); if (deviceRow && device.display.width && device.display.height) { const sizeText = `${device.display.width.toString()}x${device.display.height.toString()}` From 616a9cbb688ea624d391356fe2b18250a76e3102 Mon Sep 17 00:00:00 2001 From: solvd Date: Sun, 7 Jul 2024 17:42:22 -0300 Subject: [PATCH 03/13] #980 Loading icon during swipe --- lib/units/ios-device/plugins/screen/stream.js | 29 ++++++++++++------- .../components/stf/screen/screen-directive.js | 29 ++++++++++++++++++- .../screen/screen-loader/screen-loader.css | 1 + 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/lib/units/ios-device/plugins/screen/stream.js b/lib/units/ios-device/plugins/screen/stream.js index 9106e7f8..36fc7d32 100755 --- a/lib/units/ios-device/plugins/screen/stream.js +++ b/lib/units/ios-device/plugins/screen/stream.js @@ -9,6 +9,7 @@ const wire = require('../../../../wire') const logger = require('../../../../util/logger') const iosutil = require('../util/iosutil') +const { Transform } = require('stream') module.exports = syrup.serial() .dependency(require('../solo')) @@ -63,18 +64,26 @@ module.exports = syrup.serial() chain .then(() => handleSocketError({message: 'Connection failed to WDA MJPEG port'}, 'Consumer error')) .catch(result => { - if(result) { - result.response.pipe(consumer).pipe(stream) - //[VD] We can't launch homeBtn otherwise opening in STF corrupt test automation run. Also no sense to execute connect - WdaClient.startSession() - //WdaClient.homeBtn() //no existing session detected so we can press home button to wake up device automatically - - // override already existing error handler + if (result) { + const transformStream = new Transform({ + transform(chunk, encoding, callback) { + if (WdaClient.isSwiping) { + console.log('Swiping detected, frame received.'); + ws.send(JSON.stringify({ type: 'swiping', message: 'Swiping detected' })); + } + callback(null, chunk); + } + }); + + result.response.pipe(consumer).pipe(transformStream).pipe(stream); + + WdaClient.startSession(); + result.frameStream.on('error', function(err) { - handleSocketError(err, 'frameStream error ') - }) + handleSocketError(err, 'frameStream error'); + }); } - }) + }); } consumer.on('error', err => { diff --git a/res/app/components/stf/screen/screen-directive.js b/res/app/components/stf/screen/screen-directive.js index 0c9b70e4..1577f380 100755 --- a/res/app/components/stf/screen/screen-directive.js +++ b/res/app/components/stf/screen/screen-directive.js @@ -77,6 +77,7 @@ module.exports = function DeviceScreenDirective( let wsReconnectionTimeoutID = null let wsReconnecting = false let tempUnavailableModalInstance = null + let swipeMessage = false $scope.screen = screen ScreenLoaderService.show() @@ -220,6 +221,32 @@ module.exports = function DeviceScreenDirective( function messageListener(message) { screen.rotation = $scope.device.display.rotation + let swipeTimeout; + + + if (typeof message.data === 'string') { + const data = JSON.parse(message.data); + if (data.type === 'swiping') { + swipeMessage = true; + const loadingScreen = document.getElementsByClassName('lds-roller')[0] + if (loadingScreen) { + console.log('swiping detected') + ScreenLoaderService.show() + loadingScreen.style.backdropFilter = 'none' + loadingScreen.style.backgroundColor = 'transparent' + + if (swipeTimeout) { + clearTimeout(swipeTimeout); + } + + swipeTimeout = setTimeout(() => { + swipeMessage = false; + }, 1500); + + return; + } + } + } if (message.data instanceof Blob) { if (shouldUpdateScreen()) { @@ -228,7 +255,7 @@ module.exports = function DeviceScreenDirective( $scope.displayError = false }) } - if (ScreenLoaderService.isVisible) { + if (ScreenLoaderService.isVisible && !swipeMessage) { ScreenLoaderService.hide() } diff --git a/res/app/components/stf/screen/screen-loader/screen-loader.css b/res/app/components/stf/screen/screen-loader/screen-loader.css index f99033fc..c104ec77 100644 --- a/res/app/components/stf/screen/screen-loader/screen-loader.css +++ b/res/app/components/stf/screen/screen-loader/screen-loader.css @@ -31,6 +31,7 @@ border-radius: 50%; background: #fff; margin: -4px 0 0 -4px; + box-shadow: rgba(6, 24, 44, 0.4) 0px 0px 0px 1px, rgba(6, 24, 44, 0.65) 0px 0px 0px -1px, rgba(255, 255, 255, 0.08) 0px 1px 0px inset } .lds-roller__item:nth-child(1) { animation-delay: -0.036s; From 05a2814a7b9fb00bede2380ae886c3ab6671447c Mon Sep 17 00:00:00 2001 From: solvd Date: Mon, 8 Jul 2024 08:28:41 -0300 Subject: [PATCH 04/13] remove logs --- lib/units/ios-device/plugins/screen/stream.js | 6 ++++-- res/app/components/stf/screen/screen-directive.js | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/units/ios-device/plugins/screen/stream.js b/lib/units/ios-device/plugins/screen/stream.js index 36fc7d32..b5bfea20 100755 --- a/lib/units/ios-device/plugins/screen/stream.js +++ b/lib/units/ios-device/plugins/screen/stream.js @@ -68,7 +68,6 @@ module.exports = syrup.serial() const transformStream = new Transform({ transform(chunk, encoding, callback) { if (WdaClient.isSwiping) { - console.log('Swiping detected, frame received.'); ws.send(JSON.stringify({ type: 'swiping', message: 'Swiping detected' })); } callback(null, chunk); @@ -76,9 +75,12 @@ module.exports = syrup.serial() }); result.response.pipe(consumer).pipe(transformStream).pipe(stream); + //[VD] We can't launch homeBtn otherwise opening in STF corrupt test automation run. Also no sense to execute connect WdaClient.startSession(); - + //WdaClient.homeBtn() //no existing session detected so we can press home button to wake up device automatically + + // override already existing error handler result.frameStream.on('error', function(err) { handleSocketError(err, 'frameStream error'); }); diff --git a/res/app/components/stf/screen/screen-directive.js b/res/app/components/stf/screen/screen-directive.js index 1577f380..c56cd701 100755 --- a/res/app/components/stf/screen/screen-directive.js +++ b/res/app/components/stf/screen/screen-directive.js @@ -230,7 +230,6 @@ module.exports = function DeviceScreenDirective( swipeMessage = true; const loadingScreen = document.getElementsByClassName('lds-roller')[0] if (loadingScreen) { - console.log('swiping detected') ScreenLoaderService.show() loadingScreen.style.backdropFilter = 'none' loadingScreen.style.backgroundColor = 'transparent' From cda7f2975c549aa5ad865bf84e3721598545bc4a Mon Sep 17 00:00:00 2001 From: solvd Date: Wed, 10 Jul 2024 10:53:38 -0300 Subject: [PATCH 05/13] #941 New landscape coords. approach, no portrait reset --- lib/units/ios-device/plugins/screen/stream.js | 24 +++---------------- lib/units/ios-device/plugins/wda/WdaClient.js | 21 +++++++++++++++- .../stf/screen/scaling/scaling-service.js | 7 ------ 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/lib/units/ios-device/plugins/screen/stream.js b/lib/units/ios-device/plugins/screen/stream.js index 9106e7f8..0bd3e9ba 100755 --- a/lib/units/ios-device/plugins/screen/stream.js +++ b/lib/units/ios-device/plugins/screen/stream.js @@ -93,27 +93,9 @@ module.exports = syrup.serial() ws.on('close', function() { // @TODO handle close event // stream.socket.onclose() - const orientation = WdaClient.orientation - - const stoppingSession = () => { - WdaClient.stopSession() - isConnectionAlive = false - log.important('ws on close event') - } - - if (WdaClient.deviceType === 'Apple TV' || orientation === 'PORTRAIT') { - return stoppingSession() - } - - // #770: Reset rotation to Portrait when closing device - - const rotationPromise = new Promise((resolve, reject) => { - // Ensure that rotation is done, then stop session - WdaClient.rotation({orientation: 'PORTRAIT'}) - resolve() - }) - - rotationPromise.delay(2000).then(() => stoppingSession()) + WdaClient.stopSession() + isConnectionAlive = false + log.important('ws on close event') }) ws.on('error', function() { // @TODO handle error event diff --git a/lib/units/ios-device/plugins/wda/WdaClient.js b/lib/units/ios-device/plugins/wda/WdaClient.js index 83af1043..ce79e2e6 100644 --- a/lib/units/ios-device/plugins/wda/WdaClient.js +++ b/lib/units/ios-device/plugins/wda/WdaClient.js @@ -334,7 +334,10 @@ module.exports = syrup.serial() if(((new Date()).getTime() - this.tapStartAt) <= 1000 || !this.tapStartAt) { - const body = { + let body + + if (this.orientation === 'PORTRAIT' || !this.orientation) { + body = { actions: [ { type: 'pointer', @@ -348,6 +351,22 @@ module.exports = syrup.serial() }, ], } + } else { + body = { + actions: [ + { + type: 'pointer', + id: 'finger1', + parameters: {pointerType: 'touch'}, + actions: [ + {type: 'pointerMove', duration: 0, x: y, y: x}, + {type: 'pointerMove', duration: 0, x: y, y: x}, + {type: 'pointerUp'}, + ], + }, + ], + } + } if (this.deviceType !== 'Apple TV') { log.info(options.deviceName) diff --git a/res/app/components/stf/screen/scaling/scaling-service.js b/res/app/components/stf/screen/scaling/scaling-service.js index 5f3cade1..4400559e 100755 --- a/res/app/components/stf/screen/scaling/scaling-service.js +++ b/res/app/components/stf/screen/scaling/scaling-service.js @@ -141,13 +141,6 @@ module.exports = function ScalingServiceFactory() { w = scaledValue } - if (rotation === 90 && isIosDevice) { - return { - xP: y / h, - yP: x / w - } - } - return { xP: x / w , yP: y / h From a34cca5f0e639f2c0d586ce055d0f3e40107af65 Mon Sep 17 00:00:00 2001 From: solvd Date: Thu, 11 Jul 2024 10:04:55 -0300 Subject: [PATCH 06/13] fix for landscape swipe --- lib/units/ios-device/plugins/util/iosutil.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/units/ios-device/plugins/util/iosutil.js b/lib/units/ios-device/plugins/util/iosutil.js index f59503a8..21ee0e05 100755 --- a/lib/units/ios-device/plugins/util/iosutil.js +++ b/lib/units/ios-device/plugins/util/iosutil.js @@ -124,10 +124,10 @@ let iosutil = { } case 'LANDSCAPE': return { - fromX: params.fromX * deviceSize.width, - fromY: params.fromY * deviceSize.height, - toX: params.toX * deviceSize.width, - toY: params.toY * deviceSize.height, + fromX: params.fromY * deviceSize.height, + fromY: params.fromX * deviceSize.width, + toX: params.toY * deviceSize.height, + toY: params.toX * deviceSize.width, duration: params.duration } default: From 57365f40cdecc276d23ffa21e6e041e30416c1e0 Mon Sep 17 00:00:00 2001 From: solvd Date: Fri, 12 Jul 2024 09:42:53 -0300 Subject: [PATCH 07/13] better body syntax --- lib/units/ios-device/plugins/wda/WdaClient.js | 45 ++++++------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/lib/units/ios-device/plugins/wda/WdaClient.js b/lib/units/ios-device/plugins/wda/WdaClient.js index ce79e2e6..119baba9 100644 --- a/lib/units/ios-device/plugins/wda/WdaClient.js +++ b/lib/units/ios-device/plugins/wda/WdaClient.js @@ -334,38 +334,19 @@ module.exports = syrup.serial() if(((new Date()).getTime() - this.tapStartAt) <= 1000 || !this.tapStartAt) { - let body - - if (this.orientation === 'PORTRAIT' || !this.orientation) { - body = { - actions: [ - { - type: 'pointer', - id: 'finger1', - parameters: {pointerType: 'touch'}, - actions: [ - {type: 'pointerMove', duration: 0, x, y}, - {type: 'pointerMove', duration: 0, x, y}, - {type: 'pointerUp'}, - ], - }, - ], - } - } else { - body = { - actions: [ - { - type: 'pointer', - id: 'finger1', - parameters: {pointerType: 'touch'}, - actions: [ - {type: 'pointerMove', duration: 0, x: y, y: x}, - {type: 'pointerMove', duration: 0, x: y, y: x}, - {type: 'pointerUp'}, - ], - }, - ], - } + let body = { + actions: [ + { + type: 'pointer', + id: 'finger1', + parameters: {pointerType: 'touch'}, + actions: [ + {type: 'pointerMove', duration: 0, x: this.orientation === 'PORTRAIT' ? x : y, y: this.orientation === 'PORTRAIT' ? y : x}, + {type: 'pointerMove', duration: 0, x: this.orientation === 'PORTRAIT' ? x : y, y: this.orientation === 'PORTRAIT' ? y : x}, + {type: 'pointerUp'}, + ], + }, + ], } if (this.deviceType !== 'Apple TV') { From a1e8f54b4e7dcedf1d52cf9f5f3f522139ae659b Mon Sep 17 00:00:00 2001 From: solvd Date: Fri, 19 Jul 2024 11:02:12 -0300 Subject: [PATCH 08/13] #892 Change rotation icon smoothly --- .../device-control-controller.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/res/app/control-panes/device-control/device-control-controller.js b/res/app/control-panes/device-control/device-control-controller.js index deeec29b..370cf3a0 100755 --- a/res/app/control-panes/device-control/device-control-controller.js +++ b/res/app/control-panes/device-control/device-control-controller.js @@ -92,18 +92,12 @@ module.exports = function DeviceControlCtrl($scope, DeviceService, GroupService, if (rotation === 'portrait') { $scope.control.rotate(0) $timeout(function() { - if (isLandscape()) { - console.log('tryToRotate is Landscape') - $scope.currentRotation = 'landscape' - } + isLandscape() ? $scope.currentRotation = 'landscape' : $scope.currentRotation = 'portrait' }, 400) } else if (rotation === 'landscape') { $scope.control.rotate(90) $timeout(function() { - if (isPortrait()) { - console.log('tryToRotate but it still porttrait') - $scope.currentRotation = 'portrait' - } + isPortrait() ? $scope.currentRotation = 'portrait' : $scope.currentRotation = 'landscape' }, 400) } } @@ -111,10 +105,15 @@ module.exports = function DeviceControlCtrl($scope, DeviceService, GroupService, $scope.currentRotation = 'portrait' $scope.$watch('device.display.rotation', function(newValue) { + $scope.currentRotation = 'rotating' if (isPortrait(newValue)) { - $scope.currentRotation = 'portrait' + $timeout(function() { + isLandscape() ? $scope.currentRotation = 'landscape' : $scope.currentRotation = 'portrait' + }, 400) } else if (isLandscape(newValue)) { - $scope.currentRotation = 'landscape' + $timeout(function() { + isPortrait() ? $scope.currentRotation = 'portrait' : $scope.currentRotation = 'landscape' + }, 400) } }) From 77427232890edb69b3370a35a6902fa32b4d6e59 Mon Sep 17 00:00:00 2001 From: solvd Date: Fri, 26 Jul 2024 10:54:55 -0300 Subject: [PATCH 09/13] #880 Prevent submit on blank space --- .../generate-access-token/generate-access-token-directive.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/res/app/components/stf/tokens/generate-access-token/generate-access-token-directive.js b/res/app/components/stf/tokens/generate-access-token/generate-access-token-directive.js index e895cdea..aaffdfa9 100755 --- a/res/app/components/stf/tokens/generate-access-token/generate-access-token-directive.js +++ b/res/app/components/stf/tokens/generate-access-token/generate-access-token-directive.js @@ -12,6 +12,10 @@ module.exports = function generateAccessTokenDirective() { } $scope.generateToken = function() { + if (!$scope.generateForm.title) { + return + } + AccessTokenService.generateAccessToken($scope.generateForm.title) $scope.closeGenerateToken() } From 9da586b603634cef7e0da0035ed7234bc39bf6b3 Mon Sep 17 00:00:00 2001 From: solvd Date: Fri, 2 Aug 2024 10:56:43 -0300 Subject: [PATCH 10/13] #844 Improving date input --- .../general/date-format/date-format-controller.js | 12 +++++++++--- res/app/settings/general/date-format/date-format.pug | 3 +-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/res/app/settings/general/date-format/date-format-controller.js b/res/app/settings/general/date-format/date-format-controller.js index 3f10f0c4..10fd1dcd 100644 --- a/res/app/settings/general/date-format/date-format-controller.js +++ b/res/app/settings/general/date-format/date-format-controller.js @@ -1,18 +1,24 @@ /** * Copyright © 2019 code initially contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0 **/ - module.exports = function DateFormatCtrl( $scope , SettingsService ) { - $scope.defaultDateFormat = 'M/d/yy h:mm:ss a' SettingsService.bind($scope, { target: 'dateFormat' , source: 'dateFormat' , defaultValue: $scope.defaultDateFormat }) + + $scope.validateInput = function(event) { + const validChars = 'dmy/:has ' + const key = String.fromCharCode(event.which || event.keyCode) + if (!validChars.includes(key)) { + event.preventDefault() + } + } $scope.$watch( function() { @@ -24,4 +30,4 @@ module.exports = function DateFormatCtrl( } } ) -} +} \ No newline at end of file diff --git a/res/app/settings/general/date-format/date-format.pug b/res/app/settings/general/date-format/date-format.pug index 24c83968..3889ec9f 100644 --- a/res/app/settings/general/date-format/date-format.pug +++ b/res/app/settings/general/date-format/date-format.pug @@ -13,5 +13,4 @@ .input-group-addon.input-sm i.fa.fa-clock-o( uib-tooltip="{{'Define your own Date format' | translate}}" tooltip-placement='auto top-right' tooltip-popup-delay='500') - input.form-control.input-sm(size='30' type='text' placeholder='M/d/yy h:mm:ss a' ng-model='dateFormat') - + input.form-control.input-sm(size='30' type='text' placeholder='M/d/yy h:mm:ss a' ng-model='dateFormat' ng-keypress='validateInput($event)') \ No newline at end of file From f0431a8dbee941b1160ca77f3e3e821c376b73e7 Mon Sep 17 00:00:00 2001 From: solvd Date: Mon, 5 Aug 2024 09:19:30 -0300 Subject: [PATCH 11/13] #833 Display device top bar correctly --- res/app/control-panes/device-control/device-control.pug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/app/control-panes/device-control/device-control.pug b/res/app/control-panes/device-control/device-control.pug index 7bbec2d0..d085686c 100755 --- a/res/app/control-panes/device-control/device-control.pug +++ b/res/app/control-panes/device-control/device-control.pug @@ -1,7 +1,7 @@ .interact-control.fill-height.as-table.stf-device-control(ng-controller='DeviceControlCtrl') .as-cell.fill-height .as-table.fill-height - .stf-vnc-navbar.as-row(ng-show='!$root.basicMode && !$root.standalone') + .stf-vnc-navbar.as-row(ng-show='!$root.standalone') .stf-vnc-control-header.as-cell .stf-vnc-right-buttons.pull-right .btn-group From 8d0336eb9fed4ddfd3708fc39345f469618dd86d Mon Sep 17 00:00:00 2001 From: solvd Date: Tue, 6 Aug 2024 10:12:22 -0300 Subject: [PATCH 12/13] #880 Handle token data correctly --- lib/units/websocket/index.js | 4 ++-- .../components/stf/tokens/access-token-service.js | 6 +++--- .../generate-access-token-directive.js | 1 + .../keys/access-tokens/access-tokens-controller.js | 12 +++++------- .../settings/keys/access-tokens/access-tokens.pug | 8 ++++---- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/units/websocket/index.js b/lib/units/websocket/index.js index 9ee8bce3..d79e6dde 100755 --- a/lib/units/websocket/index.js +++ b/lib/units/websocket/index.js @@ -535,8 +535,8 @@ module.exports = function(options) { }) .on('user.keys.accessToken.remove', function(data) { return dbapi - .removeUserAccessToken(user.email, data.title) - .then(function() { + .removeAccessToken(data.id) + .then(function() { socket.emit('user.keys.accessToken.updated') }) }) diff --git a/res/app/components/stf/tokens/access-token-service.js b/res/app/components/stf/tokens/access-token-service.js index 00a4e388..d1a2ea42 100755 --- a/res/app/components/stf/tokens/access-token-service.js +++ b/res/app/components/stf/tokens/access-token-service.js @@ -10,7 +10,7 @@ module.exports = function AccessTokenServiceFactory( var AccessTokenService = {} AccessTokenService.getAccessTokens = function() { - return $http.get('/api/v1/user/accessTokens') + return $http.get('/api/v1/user/fullAccessTokens') } AccessTokenService.generateAccessToken = function(title) { @@ -19,9 +19,9 @@ module.exports = function AccessTokenServiceFactory( }) } - AccessTokenService.removeAccessToken = function(title) { + AccessTokenService.removeAccessToken = function(id) { socket.emit('user.keys.accessToken.remove', { - title: title + id: id }) } diff --git a/res/app/components/stf/tokens/generate-access-token/generate-access-token-directive.js b/res/app/components/stf/tokens/generate-access-token/generate-access-token-directive.js index aaffdfa9..81014353 100755 --- a/res/app/components/stf/tokens/generate-access-token/generate-access-token-directive.js +++ b/res/app/components/stf/tokens/generate-access-token/generate-access-token-directive.js @@ -22,6 +22,7 @@ module.exports = function generateAccessTokenDirective() { $scope.closeGenerateToken = function() { $scope.title = '' + $scope.generateForm.title = '' $scope.showGenerate = false } } diff --git a/res/app/settings/keys/access-tokens/access-tokens-controller.js b/res/app/settings/keys/access-tokens/access-tokens-controller.js index 81095bcd..dc838660 100755 --- a/res/app/settings/keys/access-tokens/access-tokens-controller.js +++ b/res/app/settings/keys/access-tokens/access-tokens-controller.js @@ -1,17 +1,17 @@ module.exports = function AccessTokensCtrl($scope, AccessTokenService) { - $scope.accessTokenTitles = [] + $scope.accessTokens = [] $scope.newToken = null function updateTokens() { AccessTokenService.getAccessTokens() .success(function(response) { - $scope.accessTokenTitles = response.titles || [] + $scope.accessTokens = response.tokens || [] }) } - $scope.removeToken = function(title) { - AccessTokenService.removeAccessToken(title) + $scope.removeToken = function(id) { + AccessTokenService.removeAccessToken(id) } $scope.closeGenerated = function() { @@ -24,8 +24,6 @@ module.exports = function AccessTokensCtrl($scope, AccessTokenService) { $scope.newToken = token $scope.showGenerated = true }) - $scope.$on('user.keys.accessTokens.updated', updateTokens) - updateTokens() -} +} \ No newline at end of file diff --git a/res/app/settings/keys/access-tokens/access-tokens.pug b/res/app/settings/keys/access-tokens/access-tokens.pug index ad65b042..74e08e12 100755 --- a/res/app/settings/keys/access-tokens/access-tokens.pug +++ b/res/app/settings/keys/access-tokens/access-tokens.pug @@ -14,7 +14,7 @@ .widget-content.padded nothing-to-show(icon='fa-key', message='{{"No access tokens" | translate}}', - ng-if='!accessTokenTitles.length && !showGenerate && !showGenerated') + ng-if='!accessTokens.length && !showGenerate && !showGenerated') generate-access-token(show-clipboard='true', show-generate='showGenerate') @@ -29,12 +29,12 @@ textarea(readonly, rows='2', text-focus-select, ng-model='newToken.tokenId').form-control.token-id-textarea ul.list-group.key-list - li.list-group-item(ng-repeat='title in accessTokenTitles track by $index').animate-repeat + li.list-group-item(ng-repeat='token in accessTokens track by token.id').animate-repeat a i.fa.fa-key.fa-2x.fa-fw.key-list-icon .key-list-details.selectable - .key-list-title(ng-bind='title') + .key-list-title(ng-bind='token.title') - button.btn.btn-xs.btn-danger-outline.pull-right.key-list-remove(ng-click='removeToken(title)') + button.btn.btn-xs.btn-danger-outline.pull-right.key-list-remove(ng-click='removeToken(token.id)') i.fa.fa-trash-o span(translate) Remove From 944d535baeb1091b15086be4ede9e6d5453f93e5 Mon Sep 17 00:00:00 2001 From: solvd Date: Fri, 9 Aug 2024 09:36:30 -0300 Subject: [PATCH 13/13] #844 Add missing char. in validChars --- res/app/settings/general/date-format/date-format-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/app/settings/general/date-format/date-format-controller.js b/res/app/settings/general/date-format/date-format-controller.js index 10fd1dcd..35dae829 100644 --- a/res/app/settings/general/date-format/date-format-controller.js +++ b/res/app/settings/general/date-format/date-format-controller.js @@ -13,7 +13,7 @@ module.exports = function DateFormatCtrl( }) $scope.validateInput = function(event) { - const validChars = 'dmy/:has ' + const validChars = 'dmy/:has M' const key = String.fromCharCode(event.which || event.keyCode) if (!validChars.includes(key)) { event.preventDefault()