Permalink
Browse files

ignore file

  • Loading branch information...
0 parents commit cc93a4cb417d259926a82abaeb0882c61fd749f5 @nordenmark committed Nov 1, 2011
@@ -0,0 +1,2 @@
+*.DS_Store
+*.beam
No changes.
@@ -0,0 +1,4 @@
+/* Example of user defined styling on top of the default styling */
+#processTable tbody td:last-child {
+ font-family: 'Lucida Console';
+}
@@ -0,0 +1,24 @@
+-module(blaha).
+-export([get_json/0, get_json/1]).
+
+%% Table data is on the format
+%% [{<<"table">>, [[row1col1, row1col2, ...], [row2col1, row2col2, ...], ... ]}]
+get_json() ->
+ Processes = erlang:processes(),
+ Fun = fun(PID, Key) ->
+ KV = erlang:process_info(PID),
+ proplists:get_value(Key, KV) end,
+ % PID, LINK, regname, curfunc
+ TableData = [
+ [PID,
+ Fun(PID,registered_name),
+ Fun(PID, current_function)] || PID <- Processes],
+ {ok, jsfw_json:encode(TableData)}.
+
+%% [[row1elem1, row1elem2], []]
+get_json(Arg) ->
+ % Pid = jsfw_utility:arg_to_pid(Arg),
+ % Info = erlang:process_info(Pid),
+ % TableData = [[Key, Value] || {Key, Value} <- Info],
+ % jsfw_json:encode(TableData).
+ {ok, jsfw_json:encode(Arg)}.
@@ -0,0 +1,42 @@
+var blaha = new function() {
+ // this.init = function() {
+ // console.log("blaha.init();");
+ // // User defined id and headers
+ // print_table("/json/blaha", "processesTable", ["PID", "Registered", "Current Function"]);
+ // }
+ // // Called when a link with class='argument' is clicked
+ // this.handle = function(arg) {
+ // print_h1("Process information. Pid: <" + arg + ">");
+ // print_table("/json/blaha/" + arg, "processTable", ["Key", "Value"]);
+ // }
+ //
+ // this.refresh = function() {
+ // var content = root();
+ // content.empty();
+ // print_table("/json/blaha", "processesTable", ["PID", "Registered", "Current Function"]);
+ // }
+
+ var body;
+ var tbl;
+
+ this.init = function() {
+ body = new Body();
+ body.add(body.toggle_button());
+
+ tbl = body.table(["PID", "Registered", "Current Function"]);
+ body.fill_json("/json/blaha", tbl);
+ body.add(tbl);
+
+ body.print();
+ }
+
+ this.handle = function(arg) {
+ body.add(body.toggle_button());
+ body.print();
+ }
+
+ this.refresh = function() {
+ body.fill_json("/json/blaha", tbl);
+ console.log("refreshing blaha");
+ }
+}
@@ -0,0 +1 @@
+[{enabled,"true"},{displayname,"Blaha"}].
Binary file not shown.
@@ -0,0 +1,7 @@
+/*#myTable tr {
+ border: 1px solid #000000;
+}*/
+
+#myTable tr.even {
+ background-color: #B7E68E;
+}
@@ -0,0 +1,9 @@
+-module(comp_table).
+-export([get_json/0]).
+
+%% Table data is on the format
+%% [{<<"table">>, [[row1col1, row1col2, ...], [row2col1, row2col2, ...], ... ]}]
+get_json() ->
+ TableData = [[<<"nicklas">>, X] || X <- lists:seq(1,20)],
+ {ok, jsfw_json:encode(TableData)}.
+
@@ -0,0 +1,27 @@
+var comp_table = new function() {
+
+ var body;
+
+ this.init = function() {
+ // console.log("table.init();");
+ // // User defined id and headers
+ // print_table("/json/comp_table", "myTable", ["Name", "Number"]);
+ body = new Body();
+
+ body.add(body.toggle_button());
+
+ var tbl = body.table(["Name", "Numbers"]);
+ body.fill_json("/json/comp_table", tbl);
+ body.add(tbl);
+ body.print();
+ // var table = body.table(["Name", "Number"]);
+ // table.attr("id", "myTable");
+ // body.add(table);
+ // body.print();
+
+ }
+
+ this.refresh = function() {
+ console.log("refreshing comp_table");
+ }
+}
@@ -0,0 +1 @@
+[{enabled,"true"},{displayname,"Table"}].
@@ -0,0 +1 @@
+[{enabled,"true"},{displayname,"SUPERNAME"}].
Binary file not shown.
No changes.
@@ -0,0 +1,5 @@
+-module(test).
+-export([get_json/0]).
+
+get_json() ->
+ {ok, jsfw_json:encode(<<"hello world from test!">>)}.
@@ -0,0 +1,11 @@
+var test = new function() {
+
+ this.init = function() {
+ body = new Body();
+ // Empty span to hold JSON from this component's Erl module
+ var span = body.span();
+ body.fill_json("/json/test", span);
+ body.add(span);
+ body.print();
+ }
+}
@@ -0,0 +1 @@
+[{enabled,"true"},{displayname,"Users"}].
Binary file not shown.
@@ -0,0 +1,4 @@
+/* Example of user defined styling on top of the default styling */
+#processTable tbody td:last-child {
+ font-family: 'Lucida Console';
+}
@@ -0,0 +1,61 @@
+-module(users).
+-export([get_json/0, get_json/1]).
+
+-record(user, {
+ id,
+ name,
+ job,
+ age
+}).
+
+add_user(ID, Name, Job, Age, Acc) ->
+ [{ID, #user{name=Name,job=Job,age=Age}}|Acc].
+
+users() ->
+
+ % Names = ["JOHNNY", "bill", "john", "eric", "kenneth", "mike"],
+ % IDs = lists:seq(1, length(Names)),
+ % Jobs = ["Carpenter", "Painter", "Bus driver", "Pilot", "Police", "Fire fighter"],
+ % Ages = lists:seq(20,20+length(Names), 3),
+ D1 = add_user(1, "Johnny", "Carpenter", 21, []),
+ D2 = add_user(2, "Mike", "Police", 23, D1),
+ D3 = add_user(3, "Nick", "Student", 25, D2),
+ D3.
+
+
+%% Table data is on the format
+%% [[row1col1, row1col2, ...], [row2col1, row2col2, ...], ... ]
+get_json() ->
+ % Processes = erlang:processes(),
+ % Fun = fun(PID, Key) ->
+ % KV = erlang:process_info(PID),
+ % proplists:get_value(Key, KV) end,
+ % % PID, LINK, regname, curfunc
+ % TableData = [
+ % [PID,
+ % Fun(PID,registered_name),
+ % Fun(PID, current_function)] || PID <- Processes],
+ % Table = [{<<"table">>, TableData}],
+ % application:start(sasl),
+ % application:start(os_mon),
+ % P = list_to_binary(integer_to_list(cpu_sup:avg1())),
+ % jsfw_json:encode(P).
+ Users = users(),
+ % Ints = [ list_to_binary(integer_to_list(I)) || I <- lists:seq(1,length(Users)) ],
+
+ Table = [ [list_to_binary(integer_to_list(ID)), list_to_binary(Rec#user.name)] || {ID, Rec} <- Users ],
+ % Table = lists:zipwith(fun(X,Y) -> [X,Y] end, Ints, Users),
+ {ok, jsfw_json:encode(Table)}.
+
+%% Here we are given a user id as argument
+get_json(Arg) ->
+ io:format("Arg: ~p~n", [Arg]),
+ {ok, jsfw_json:encode(<<"Haj">>)}.
+
+%% [[row1elem1, row1elem2], []]
+% get_json(Arg) ->
+% Pid = jsfw_utility:arg_to_pid(Arg),
+% Info = erlang:process_info(Pid),
+% TableData = [[Key, Value] || {Key, Value} <- Info],
+% Table = [{<<"table">>, TableData}],
+% jsfw_json:encode(Table).
@@ -0,0 +1,42 @@
+var users = new function() {
+
+ var body;
+ var table;
+ var options = new Object();
+
+ // Initializes the component, publish some elements etc
+ this.init = function() {
+
+ // Initialize a new body object for this component
+ body = new Body();
+
+ // Testing a toggle button for pause/resume
+ body.add(body.toggle_button());
+
+ // Create a table to hold the label and the data
+ table = body.table(["ID", "Username"]);
+
+ // Set options?
+ // options.linksIndex = 0;
+
+ // Fill this table with json from /json/users
+ body.fill_json("/json/users", table, options);
+
+ // Add the table to the body
+ body.add(table);
+
+ // Print the body
+ body.print();
+ }
+
+ // This is called when a link is clicked on the component's page
+ this.handle = function(arg) {
+ console.log("handle( " + arg + ") called!");
+ }
+
+ // This is called when this component is set to actively refresh
+ this.refresh = function() {
+ console.log("Called users.refresh()");
+ body.fill_json("/json/users", table, options);
+ }
+}

0 comments on commit cc93a4c

Please sign in to comment.