openstf / stf

Control and manage Android devices from your browser.
https://openstf.io
Other
13.17k stars 2.71k forks source link

Device Booking feature #101

Closed chibamap closed 4 years ago

chibamap commented 8 years ago

Overview

This is Device booking feature. You can book device schedule on device-list. then, device scheduler unit set you to "owner" on the time. And reject other user if the device is busy. device scheduler will check device schedule per a minute.

Note

You can book schedule from one hour later.

chibamap commented 8 years ago
device-list booking-modal
sorccu commented 8 years ago

It will take time to review this PR because it is so big.

codeskyblue commented 8 years ago

wow

vbanthia-zz commented 8 years ago

:+1: (for the feature, haven't read the code yet)

chibamap commented 8 years ago

Thanks for your reply. Because my English is no good Maybe some method name or some variable name is fishy. And actually, it need more test for actual business. I continue test and I'll fix if I found any problem.

benjamin-m-kane commented 8 years ago

Great work, I was looking at implementing this myself!!

gunta commented 8 years ago

Getting a WARNING: Tried to load angular more than once. Be sure to not include angular again since its already in the global namespace.

chibamap commented 8 years ago

Thanks for check. I'll research it.

ma3tk commented 8 years ago

:+1: nice feature!

sorccu commented 8 years ago

I think I would do something like this instead of polling every minute. It's not necessarily the best way though. Also, make sure to read all the way to the end.

  1. Add lib/units/device/plugins/reserve.js
  2. In there, start listening for a ReserveUpdateMessage, and send a ReserveUpdateRequestMessage when the device worker loads (just a sample name)
  3. processor receives it, loads the full schedule for that device from the database, and a ReserveUpdateMessage back to the device with the details
  4. The device worker wait for the nearest reservation, if any.
    • By either setting a timeout for the nearest job - 10s, and then kicking out whoever is using the device (if anyone) and make the scheduled user the owner, setTimeout() isn't super accurate so it should trigger a bit earlier (and it won't do much harm)
    • OR perhaps instead of setTimeout, always have a setInterval running in the background in the device process (perhaps checked once per minute). When the callback triggers, check the internal state if the next reservation is closer than the next internal. If so, kick out current user and make the scheduled user the owner.
  5. If a new reservation is made, send a new ReserveUpdateMessage with the full schedule to the device channel
    • Update internal in-memory state
    • Clear setTimeout or setInterval, run a check immediately, and set up new timers

Step 5 could be made easier if we handled messages from the application side in the processor. That way you could just send a tiny message to the processor and it would load and send a full ReserveUpdateMessage to the device channel. However since it's not possible right now, what you'd probably have to do is to create the full ReserveUpdateMessage in the websocket or app unit, and then send it as-is to the processor.

HOWEVER, I like having the reservation functionality completely separate from the device process like it is in your patch (reaper style). It makes it easier to manage. It would be best if you could adapt the steps in your scheduler unit instead. You could then even use RethinkDB's .watch() in the scheduler unit to load schedule changes in real time, and send ReserveUpdateMessage to appropriate devices when necessary. That you you wouldn't necessarily have to send a separate message from the websocket or app unit to the scheduler unit, it would automatically see all changes.

chibamap commented 8 years ago

Thanks for check. I'll follow them. It's similar to one of my other ideas.

chibamap commented 8 years ago
  1. In there, start listening for a ReserveUpdateMessage, and send a ReserveUpdateRequestMessage when the device worker loads (just a sample name)
  2. processor receives it, loads the full schedule for that device from the database, and a ReserveUpdateMessage back to the device with the details

You mean, I can "not" access to rethinkdb from device/plugins/reserve.js right?

chibamap commented 8 years ago

my idea is as follow images.

On Device wake up.

on-wakeup-flow

On update schedule.

on-update-flow


It can make completely separate this feature.

tadesushilgithub commented 7 years ago

How can I see this feature in installed STF? or Do I need to add this plugin separately?

chibamap commented 7 years ago

It's not ready yet. Sorry.

nhanvpt102 commented 7 years ago

Hi hogehoge-banana, Thanks very much for this nice feature. I added your code and start STF but could not see the screen 'Book Device'. Would you please let me know if I missed something or how we can activate this feature?

chibamap commented 7 years ago

Hi, Thanks for check my code. While I'll research it, It will take time. Because Actually I left this project. Now, I just play "stf" on my private time.

skumar1122 commented 7 years ago

Hey @hogehoge-banana ,

This is amazing feature for STF , is this ready yet ? please let me know.

Thanks SK

chibamap commented 7 years ago

@skumar1122 Not ready yet. Sorry.

skumar1122 commented 7 years ago

@hogehoge-banana No worries !

histronger commented 4 years ago

@skumar1122 Not ready yet. Sorry.

Since it has been a long time, and have this feature finished?

chibamap commented 4 years ago

I’m sorry, but it’s not yet.

skumar1122 commented 4 years ago

Hey @hogehoge-banana @sorccu

I have a question, Can we use stf with admin rights. So that admin can maintain device usage. If its already exists please let me know ?

Thanks Shiva

asabhijitshelar commented 4 years ago

Hey @hogehoge-banana @sorccu,

Is Device Booking feature is available in Stf version 3.4.1?

I am just start elaborating open-STF. Sorry if you fill my question like new-user

chibamap commented 4 years ago

I think, it’s not available. There are big differences from I developed this feature. I’m sorry. Currently I don’t have enough time to spend for this project.

koral-- commented 4 years ago

This feature is not merged thus not available in any release. However, there is a Group feature: https://github.com/openstf/stf/blob/master/doc/GroupFeature.pdf available on latest tag (not in 3.4.1). I didn't follow this PR but it looks like these 2 features are partially overlapping.

chibamap commented 4 years ago

There are already good feature. So I close this pull request. Thanks all.