Skip to content
Snippets Groups Projects
Commit d0638adf authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[ivette] fix in state items

parent 147b3588
No related branches found
No related tags found
No related merge requests found
...@@ -272,7 +272,7 @@ class SyncArray ...@@ -272,7 +272,7 @@ class SyncArray
getItems() { getItems() {
if (!this.insync && Server.isRunning()) this.fetch(); if (!this.insync && Server.isRunning()) this.fetch();
return this.items; return this.index;
} }
isEmpty() { isEmpty() {
...@@ -290,16 +290,15 @@ class SyncArray ...@@ -290,16 +290,15 @@ class SyncArray
reloaded = this.isEmpty(); reloaded = this.isEmpty();
this.index = {}; this.index = {};
} }
removed.forEach((id) => { removed.forEach((key) => {
delete this.index[id]; delete this.index[key];
}); });
updated.forEach((item) => { updated.forEach((item) => {
this.index[item.id] = item; this.index[item.key] = item;
}); });
if (reloaded || removed.length || updated.length) if (reloaded || removed.length || updated.length)
Dome.emit( this.UPDATE ); Dome.emit( this.UPDATE );
if (pending>0) { if (pending>0) {
console.log('PENDING');
this.fetch(); this.fetch();
} }
}); });
......
...@@ -2,22 +2,25 @@ ...@@ -2,22 +2,25 @@
// --- Properties // --- Properties
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
import _ from 'lodash' ;
import React from 'react' ; import React from 'react' ;
import Dome from 'dome' ; import Dome from 'dome' ;
import States from 'frama-c/states' ; import States from 'frama-c/states' ;
import { ArrayModel } from 'dome/table/arrays' ; import { ArrayModel } from 'dome/table/arrays' ;
import { Table, Column, DefineColumn } from 'dome/table/views' ;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// --- Properties Array // --- Properties Array
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
const Table = () => { const PropTable = () => {
const model = React.useMemo( () => new ArrayModel() ); const model = React.useMemo( () => new ArrayModel() );
const items = States.useSyncArray('kernel.properties'); const items = _.toArray( States.useSyncArray('kernel.properties') );
console.log(items);
if (items) if (items)
return ( return (
<ul> <ul>
{items.map((item) => (<li key={item.id}><tt>{item.id}</tt></li>))} {items.map((item) => (<li key={item.key}><tt>{item.key}</tt></li>))}
</ul> </ul>
); );
else else
...@@ -28,6 +31,6 @@ const Table = () => { ...@@ -28,6 +31,6 @@ const Table = () => {
// --- Exports // --- Exports
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
export default { Table }; export default { PropTable };
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -96,7 +96,7 @@ let model () = ref [] ...@@ -96,7 +96,7 @@ let model () = ref []
let column (type a b) ~(model : a model) ~name ~descr let column (type a b) ~(model : a model) ~name ~descr
~(data: b Request.output) ~(get : a -> b) () = ~(data: b Request.output) ~(get : a -> b) () =
let module D = (val data) in let module D = (val data) in
if name = "id" || name = "_index" then if name = "key" || name = "index" then
raise (Invalid_argument "Server.States.column: invalid name") ; raise (Invalid_argument "Server.States.column: invalid name") ;
if List.exists (fun (fd,_) -> fd.Syntax.name = name) !model then if List.exists (fun (fd,_) -> fd.Syntax.name = name) !model then
raise (Invalid_argument "Server.States.column: duplicate name") ; raise (Invalid_argument "Server.States.column: duplicate name") ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment