-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vue.js UI implementation #4868
Vue.js UI implementation #4868
Conversation
code/modules/byvue/external.dm
Outdated
/datum/proc/byvue_state_change(var/list/newstate, var/mob/user, var/datum/byvueui/ui) | ||
return | ||
|
||
/mob/var/list/open_byvue_uis = list() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually this should be made lazy - = list()
vars on core types are bad.
@@ -0,0 +1,79 @@ | |||
var/datum/controller/subsystem/processing/byvue/SSbyvue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a good idea to make it clearer that this is a UI SS?
code/modules/byvue/ui.dm
Outdated
// object that contains this ui | ||
var/datum/object | ||
// apperant object that contains ui, used for checks | ||
var/atom/wobject = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between object
and wobject
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
object is the one receiving calls, and managing data, wobject is optional supplemented object that is present in world and it's coordinates can be checked like, if it is near user. if object is already an atom, then it should be used for checks, if it is not, then wobject. if both are unavailable for checks, then it should be used as 'admin' ui.
return 0 // Wasn't open. | ||
|
||
STOP_PROCESSING(SSvueui, ui) | ||
if(ui.user) // Sanity check in case a user has been deleted (say a blown up borg watching the alarm interface) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (QDELETED(ui.user))
no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(!QDELETED(ui.user))
yes?
Well, this should fix #4714 as it replaces fax machine ui and adds checks, |
.travis.yml
Outdated
- (! grep -E "<\s*span\s+class\s*=\s*('[^'>]+|[^'>]+')\s*>" **/*.dm) | ||
- (num=`grep -E '\\\\(red|blue|green|black|b|i[^mc])' **/*.dm | wc -l`; echo "$num escapes (expecting ${MACRO_COUNT} or less)"; [ $num -le ${MACRO_COUNT} ]) | ||
- awk -f tools/indentation.awk **/*.dm | ||
- md5sum -c - <<< "94c0d540b3b0f008fbc4353e667de690 *html/changelogs/example.yml" | ||
- python tools/TagMatcher/tag-matcher.py ../.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a code check. So is the step below it as well, they should both be there.
@@ -0,0 +1,6 @@ | |||
-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration needs a version bump.
*/ | ||
/datum/controller/subsystem/processing/vueui/proc/get_open_uis(var/src_object) | ||
var/src_object_key = SOFTREF(src_object) | ||
if (!LAZYLEN(open_uis[src_object_key])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This proc can be done without the if-check. Accessing a key that is not set in the list, as long as the key is not a number, returns null anyways. So:
/datum/controller/subsystem/processing/vueui/proc/get_open_uis(var/src_object)
var/src_obj_key = SOFTREF(src_object)
. = open_uis[src_object_key]
* | ||
* @param src_object - object that hosts the ui we are looking for | ||
* | ||
* @return list of ui datums |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment is a lie.
List of UI datums or null.
* @param user - user that has that ui open | ||
* @param src_object - object that hosts the ui we are looking for | ||
* | ||
* @return ui datum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lie.
UI datum or null.
@@ -0,0 +1,173 @@ | |||
var/datum/controller/subsystem/processing/vueui/SSvueui |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire file is indented with spaces. Please reindent with tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more!
* | ||
* @param src_object - object that hosts ui that should be updated | ||
* | ||
* @return nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be discarded.
code/modules/vueui/external.dm
Outdated
@@ -0,0 +1,23 @@ | |||
/client/verb/vueuiclose(var/uiref as text) | |||
set hidden = 1 // hide this verb from the user's panel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space indented file.
@@ -0,0 +1,321 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space indented file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more!
@@ -0,0 +1,173 @@ | |||
var/datum/controller/subsystem/processing/vueui/SSvueui | |||
|
|||
#define NULL_OR_EQUAL(self,other) (!(self) || (self) == (other)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be just moved to misc defines if it's used in more than one place (NUI).
@@ -1,3 +1,4 @@ | |||
#define VUEUI_SET_CHECK(a, b, c, d) if (a != b) { a = b; c = d; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is used in multiple places, it should probably go in misc defines.
code/modules/vueui/themes.dm
Outdated
#define THEME_TYPE_DARK 1 | ||
#define THEME_TYPE_LIGHT 0 | ||
|
||
/var/available_html_themes = list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be a var on SSvueui?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also should be typed as /list
.
code/modules/vueui/ui.dm
Outdated
Byond Vue UI framework | ||
main ui datum. | ||
*/ | ||
#define UIDEBUG 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use #ifdef
gating instead of checking a boolean?
code/modules/vueui/ui.dm
Outdated
cl << browse_rsc(file("vueui/dist/main.js"), "vueui.js") | ||
cl << browse_rsc(file("vueui/dist/main.css"), "vueui.css") | ||
#else | ||
var/datum/asset/assets = get_asset_datum(/datum/asset/simple/vueui) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a way to check if an asset has already been sent to the client instead of re-sending it each time?
vueui/README.md
Outdated
### `ui.header` | ||
Determines header component that is used with this ui. Should be set before `ui.open()`. | ||
### `ui.auto_update_content` | ||
Constantly checks for change using `ui.check_for_change()`. This should be only used when data changes unpredictably , |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing ,
. What do you mean by constantly?
### `ui.add_asset(name, image)` | ||
Adds asset for ui use, but does not send it to client. It will be sent in during next `ui.open()` call or if it's done manually with `ui.send_asset(name)` combined with `push_change(null)`. | ||
### `ui.remove_asset(name)` | ||
Removes asset from future use in ui. But client-side asset index isn't updated immediately to reflect removal of asset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe the asset cache supports removing assets. It's also global.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This asset part isn't part of asset cache, it's special server generated image asset management proc. Was designed mostly having records in mind.
vueui/README.md
Outdated
### `ui.push_change(data).` | ||
Pushes data change to client. This also pushes changes to metadata, what includes: title, world time, ui status, active ui component, client-side asset index. | ||
### `ui.check_for_change(forcedPush)` | ||
Checks with `object.vueui_data_change` if data has changed, if so, then change is pushed. If forcedPush is resolving to true, then it pushes change anyways. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"is resolving to true" is a bit awkward; maybe "If forcedPush is true"?
vueui/README.md
Outdated
### `ui.check_for_change(forcedPush)` | ||
Checks with `object.vueui_data_change` if data has changed, if so, then change is pushed. If forcedPush is resolving to true, then it pushes change anyways. | ||
### `ui.update_status()` | ||
This call should be used if external change was detected. It checks if user still can use this ui, and what's it usability level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it
=> its
Topic status, used to determine how interactive is ui. Meanings of numbers can be seen `\code\__defines\machinery.dm`. | ||
#### `assets` - This makes `add_asset`, `remove_asset` and `<vui-img>` tick | ||
As described, this makes them tick. This ***should*** shouldn't be used, unless you know what you are doing. | ||
#### `active` - Representation of `ui.activeui` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly does this var do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It mostly tells ui what template should be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I do not know JS, nor I am familiar with Vue. To me JS looks like some merge of Java and python. Anyways, I know JSON and it seems that all code involving JSON read/write encoding/decoding is correct and JSON files are to the format. I would say that this is good!
I can't say if it is easy to use or not!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
I´ll try to build something with it in the next days to see if there are any issues / questions that should be answered in the readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good so far, it does not seem more complex than what we already use, and I had a positive experience when we did a run test with this implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I looked over the mechanics of this and the actual VueUI implementation of this. And it looks relatively good on that end as well. The ability to utilize component variables and the like is neat. So this seems great on that count.
It would actually be super if we could utilize each template's own variables, instead of having a state global, but I'm unsure how effective and realistic this would be to implement. So this works and works well enough.
Also, minor code things.
@@ -93,16 +93,27 @@ obj/machinery/computer/general_air_control/Destroy() | |||
SSradio.remove_object(src, frequency) | |||
return ..() | |||
|
|||
/obj/machinery/computer/general_air_control/vueui_data_change(var/list/data, var/mob/user, var/vueui/ui) | |||
if(!data) | |||
. = data = list("sensors" = list()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be . = data || list("sensors" = list())
I'm psure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure that doesn't set data var, this is mostly short hand for, and having same list ref
. = list("sensors" = list())
data = list("sensors" = list())
|
||
output += "<B>Tank Control System</B><BR><BR>" | ||
/obj/machinery/computer/general_air_control/large_tank_control/vueui_data_change(var/list/data, var/mob/user, var/vueui/ui) | ||
. = ..() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be shortened to: data = ..() || data
I thiiink? If ..()
returns null
, it'll swap back to data
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if ..()
returns not null, .
will be unset and no way to know if it returned not null, to be able to set .
at a latter point.
|
||
output += "<B>Core Cooling Control System</B><BR><BR>" | ||
/obj/machinery/computer/general_air_control/supermatter_core/vueui_data_change(var/list/data, var/mob/user, var/vueui/ui) | ||
. = ..() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, data = ..() || data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although you'll also want to set return value I think?
@@ -341,62 +271,44 @@ Min Core Pressure: [pressure_limit] kPa<BR>"} | |||
|
|||
/obj/machinery/computer/general_air_control/supermatter_core/Topic(href, href_list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return value should not be removed from this proc! It's meaningful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will it be used? VueUI doesn't use Topic()
return value to do anything, it's just droped.
Look at https://github.com/Aurorastation/Aurora.3/pull/4868/files/4babde452dbc70d167be6f302f2e0110784cd917#diff-384c1ecb0c07ace2ea7785c878f6e836R244
code/game/machinery/atmo_control.dm
Outdated
output_info = null | ||
signal.data = list ("tag" = output_tag, "set_external_pressure" = "[pressure_setting]", "checks" = 1) | ||
. = 1 | ||
signal.data = list ("tag" = output_tag, "set_external_pressure" = "[setpressure]", "checks" = 1) | ||
|
||
signal.data["sigtype"]="command" | ||
radio_connection.post_signal(src, signal, filter = RADIO_ATMOSIA) | ||
|
||
spawn(5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timer this.
|
||
output += "<B>Fuel Injection System</B><BR>" | ||
/obj/machinery/computer/general_air_control/fuel_injection/vueui_data_change(var/list/data, var/mob/user, var/vueui/ui) | ||
. = ..() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data = ..() || data
watch_var("copyitem", "gotitem", CALLBACK(null, .proc/transform_to_boolean, FALSE)) | ||
|
||
/obj/machinery/photocopier/vueui_data_change(var/list/data, var/mob/user, var/vueui/ui) | ||
var/monitordata = ..() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Psure you could make this proc use an early return somehow? Though I can't figure it out atm. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this?
. = ..()
if (.)
data = .
code/modules/vueui/ui.dm
Outdated
send_resources_and_assets(user.client) | ||
user << browse(generate_html(), params) | ||
winset(user, "mapwindow.map", "focus=true") | ||
spawn(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timer callback time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. To start off, a lot of good work has clearly gone into this. That said I know next to nothing about Vue.js other than its' existance and why it is being used here.
Giving a brief look over of this PR it looks very very solid currently and I can not fault it. I wish I could provide more but I can't find anything faulty or anything that needs improving that hasn't already been mentioned.
For whatever it's worth, this is looking excellent and, assuming it's given a thorough test, shouldn't be an issue with adding.
…e.Added neat thing when you open template.html
Oh jeez how come this one took months before I knew of it. Is this another "people who have no idea how Nano worked re-inventing Nano and failing" episode? I looked at the docs in the repo and they look incredibly unwieldy to work with. Also Nano was absolutely perfect. Change my mind. |
This PR is depending on #4868 for it's ui framework. This PR mostly makes new SSrecords subsystem responsible for storing records. This should replace old datacore. Make new SSrecords. Make things use SSrecords and whole code compile Made VueUi button <vui-button> to push parameters as JSON, preserving client side data stricture. Add new records console and admin record management. I am mostly looking for feedback regarding SSrecords and it's data storage mechanism criticism (It's using lists for storage)
…rastation#4878) This PR is depending on Aurorastation#4868 for it's ui framework. This PR mostly makes new SSrecords subsystem responsible for storing records. This should replace old datacore. Make new SSrecords. Make things use SSrecords and whole code compile Made VueUi button <vui-button> to push parameters as JSON, preserving client side data stricture. Add new records console and admin record management. I am mostly looking for feedback regarding SSrecords and it's data storage mechanism criticism (It's using lists for storage)
This UI is going to be more integrated with BYOND host objects. It's update principal is very different from nanoui's. It is based around state that is being synchronized with server and client (browser). Such synchronization has it's problems, like it can't handle rapid changes, what could cause client and server to become out of sync and client state to be discard.
Progress so fair:
Extras that come with this PR:
I am open to comments and criticism regarding this framework.