Skip to content
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

Merged
merged 92 commits into from Aug 4, 2018
Merged

Vue.js UI implementation #4868

merged 92 commits into from Aug 4, 2018

Conversation

Karolis2011
Copy link
Contributor

@Karolis2011 Karolis2011 commented Jun 6, 2018

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:

  • Add base Vue.js application capable of processing incoming data and send data
  • Add DM class that's responsible for server side management
  • Add style sheets to make things look good
  • Add checks for usability and availability.
  • Add server side generated management and display abilities
  • Improve API
  • Add components to make UI framework usable / superior.
  • Add a way to specify template inside DM (Could be used for small uis that are not complex)
  • Add UI object transfer to other object
  • Improve / Add styles that could please community

Extras that come with this PR:

  • Travis now has stages for things

I am open to comments and criticism regarding this framework.

/datum/proc/byvue_state_change(var/list/newstate, var/mob/user, var/datum/byvueui/ui)
return

/mob/var/list/open_byvue_uis = list()
Copy link
Contributor

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
Copy link
Contributor

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?

// object that contains this ui
var/datum/object
// apperant object that contains ui, used for checks
var/atom/wobject = null
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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?

@Karolis2011 Karolis2011 changed the title [WIP] Vue.js UI implementation Vue.js UI implementation Jun 11, 2018
@skull132 skull132 added the WIP The PR is a work in progress and should not be reviewed yet. label Jun 16, 2018
@Karolis2011
Copy link
Contributor Author

Implemented first ui in this framework, looks good so fair.
FAX
PAX

@Karolis2011
Copy link
Contributor Author

LIGHTUI

@Karolis2011
Copy link
Contributor Author

Well, this should fix #4714 as it replaces fax machine ui and adds checks,

@Karolis2011
Copy link
Contributor Author

Karolis2011 commented Jul 1, 2018

Also old icon set copied from nanoui was swaped out for material iconset.
For reference, as of next commit available themes will be and look like:
Nano Dark:
paveikslas
Nano Light:
paveikslas
Basic Light:
paveikslas
Basic dark:
paveikslas

.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 ../..
Copy link
Contributor

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 @@
--
Copy link
Contributor

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]))
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be discarded.

@@ -0,0 +1,23 @@
/client/verb/vueuiclose(var/uiref as text)
set hidden = 1 // hide this verb from the user's panel
Copy link
Contributor

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 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space indented file.

Copy link
Contributor Author

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))
Copy link
Contributor

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; }
Copy link
Contributor

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.

#define THEME_TYPE_DARK 1
#define THEME_TYPE_LIGHT 0

/var/available_html_themes = list(
Copy link
Contributor

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?

Copy link
Contributor

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.

Byond Vue UI framework
main ui datum.
*/
#define UIDEBUG 0
Copy link
Contributor

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?

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)
Copy link
Contributor

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 ,
Copy link
Contributor

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.
Copy link
Contributor

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.
Copy link
Contributor

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`
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@BotBOREALIS BotBOREALIS added Changelog Required Review Required 🗺️ Mapping - Aurora The PR touches the Aurora map files. Mapping: Exodus and removed Changelog Required WIP The PR is a work in progress and should not be reviewed yet. labels Jul 1, 2018
Copy link
Contributor

@Sindorman Sindorman left a 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!

Copy link
Member

@Arrow768 Arrow768 left a 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

Copy link
Contributor

@Alberyk Alberyk left a 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.

Copy link
Contributor

@skull132 skull132 left a 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())
Copy link
Contributor

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?

Copy link
Contributor Author

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)
. = ..()
Copy link
Contributor

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.

Copy link
Contributor Author

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)
. = ..()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, data = ..() || data

Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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

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)
Copy link
Contributor

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)
. = ..()
Copy link
Contributor

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 = ..()
Copy link
Contributor

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. 🤔

Copy link
Contributor Author

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 = .

send_resources_and_assets(user.client)
user << browse(generate_html(), params)
winset(user, "mapwindow.map", "focus=true")
spawn(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timer callback time.

Copy link

@YaBoiElliot YaBoiElliot left a 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.

@skull132 skull132 added this to the August Update milestone Aug 4, 2018
@skull132 skull132 merged commit 4065e29 into Aurorastation:development Aug 4, 2018
skull132 added a commit to skull132/Aurora.3 that referenced this pull request Aug 5, 2018
skull132 added a commit that referenced this pull request Aug 5, 2018
@PJB3005
Copy link
Contributor

PJB3005 commented Oct 10, 2018

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.

skull132 pushed a commit that referenced this pull request Jul 27, 2019
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)
Menown pushed a commit to Menown/Aurora.3 that referenced this pull request Jul 30, 2019
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants