Skip to content

Commit 4b050f3

Browse files
committed
more AI panels
1 parent 9c96420 commit 4b050f3

File tree

13 files changed

+494
-27
lines changed

13 files changed

+494
-27
lines changed

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/ai/ModelsAndSamplersPanel.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import com.logicaldoc.gui.common.client.i18n.I18N;
44
import com.logicaldoc.gui.frontend.client.administration.AdminPanel;
5+
import com.logicaldoc.gui.frontend.client.ai.model.ModelsPanel;
56
import com.logicaldoc.gui.frontend.client.ai.sampler.SamplersPanel;
6-
import com.logicaldoc.gui.frontend.client.metadata.template.TemplatesPanel;
77
import com.smartgwt.client.widgets.tab.Tab;
88

99
/**
@@ -14,9 +14,9 @@
1414
*/
1515
public class ModelsAndSamplersPanel extends AdminPanel {
1616
public ModelsAndSamplersPanel() {
17-
super("templates");
17+
super("models");
1818

19-
body.setMembers(new TemplatesPanel());
19+
body.setMembers(new ModelsPanel());
2020

2121
Tab attributesTab = new Tab(I18N.message("samplers"));
2222
attributesTab.setPane(new SamplersPanel());

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/ai/model/GUIModel.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ public class GUIModel implements Serializable {
2222

2323
private String type = "neural";
2424

25+
private String features;
26+
27+
private String categories;
28+
29+
private String activation = "RELU";
30+
31+
private String weightInit = "XAVIER";
32+
33+
private String loss = "NEGATIVELOGLIKELIHOOD";
34+
2535
public GUIModel(long id, String name) {
2636
super();
2737
this.id = id;
@@ -71,4 +81,48 @@ public void setDescription(String description) {
7181
public void setType(String type) {
7282
this.type = type;
7383
}
84+
85+
public String getFeatures() {
86+
return features;
87+
}
88+
89+
public String getCategories() {
90+
return categories;
91+
}
92+
93+
public void setFeatures(String features) {
94+
this.features = features;
95+
}
96+
97+
public void setCategories(String categories) {
98+
this.categories = categories;
99+
}
100+
101+
public String getActivation() {
102+
return activation;
103+
}
104+
105+
public void setActivation(String activation) {
106+
this.activation = activation;
107+
}
108+
109+
public static long getSerialversionuid() {
110+
return serialVersionUID;
111+
}
112+
113+
public String getWeightInit() {
114+
return weightInit;
115+
}
116+
117+
public void setWeightInit(String weightInit) {
118+
this.weightInit = weightInit;
119+
}
120+
121+
public String getLoss() {
122+
return loss;
123+
}
124+
125+
public void setLoss(String loss) {
126+
this.loss = loss;
127+
}
74128
}

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/ai/model/ModelDS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ private void init(String url) {
3232
setFields(id, name, label, description, typeField);
3333
setClientOnly(true);
3434

35-
setDataURL("data/ai.xml?object=sampler");
35+
setDataURL("data/ai.xml?object=model");
3636
}
3737
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
package com.logicaldoc.gui.frontend.client.ai.model;
2+
3+
import com.logicaldoc.gui.common.client.DefaultAsyncCallback;
4+
import com.logicaldoc.gui.common.client.i18n.I18N;
5+
import com.logicaldoc.gui.common.client.widgets.EditingTabSet;
6+
import com.logicaldoc.gui.frontend.client.ai.AIService;
7+
import com.smartgwt.client.widgets.layout.HLayout;
8+
import com.smartgwt.client.widgets.layout.Layout;
9+
import com.smartgwt.client.widgets.layout.VLayout;
10+
import com.smartgwt.client.widgets.tab.Tab;
11+
12+
/**
13+
* This panel collects details about a model
14+
*
15+
* @author Marco Meschieri - LogicalDOC
16+
* @since 9.2
17+
*/
18+
public class ModelDetailsPanel extends VLayout {
19+
private GUIModel model;
20+
21+
private Layout standardTabPanel;
22+
23+
private ModelProperties standardPanel;
24+
25+
private EditingTabSet tabSet;
26+
27+
private ModelsPanel modelsPanel;
28+
29+
public ModelDetailsPanel(ModelsPanel samplersPanel) {
30+
super();
31+
32+
this.modelsPanel = samplersPanel;
33+
setHeight100();
34+
setWidth100();
35+
setMembersMargin(10);
36+
37+
tabSet = new EditingTabSet(saveEvent -> onSave(), cancelEvent -> {
38+
if (model.getId() != 0) {
39+
AIService.Instance.get().getModel(model.getId(), new DefaultAsyncCallback<>() {
40+
41+
@Override
42+
public void onSuccess(GUIModel sampler) {
43+
setModel(model);
44+
}
45+
46+
});
47+
} else {
48+
setModel(new GUIModel());
49+
}
50+
tabSet.hideSave();
51+
});
52+
53+
Tab propertiesTab = new Tab(I18N.message("properties"));
54+
standardTabPanel = new HLayout();
55+
standardTabPanel.setWidth100();
56+
standardTabPanel.setHeight100();
57+
propertiesTab.setPane(standardTabPanel);
58+
tabSet.addTab(propertiesTab);
59+
60+
addMember(tabSet);
61+
}
62+
63+
private void refresh() {
64+
tabSet.hideSave();
65+
66+
/*
67+
* Prepare the standard properties tab
68+
*/
69+
if (standardPanel != null) {
70+
standardPanel.destroy();
71+
if (Boolean.TRUE.equals(standardTabPanel.contains(standardPanel)))
72+
standardTabPanel.removeMember(standardPanel);
73+
}
74+
75+
standardPanel = new ModelProperties(model, event -> onModified());
76+
standardTabPanel.addMember(standardPanel);
77+
78+
}
79+
80+
public GUIModel getModel() {
81+
return model;
82+
}
83+
84+
public void setModel(GUIModel model) {
85+
this.model = model;
86+
refresh();
87+
}
88+
89+
public void onModified() {
90+
tabSet.displaySave();
91+
}
92+
93+
private boolean validate() {
94+
boolean stdValid = standardPanel.validate();
95+
if (!stdValid)
96+
tabSet.selectTab(0);
97+
return stdValid;
98+
}
99+
100+
public void onSave() {
101+
if (validate()) {
102+
AIService.Instance.get().saveModel(model, new DefaultAsyncCallback<>() {
103+
@Override
104+
public void onSuccess(GUIModel model) {
105+
tabSet.hideSave();
106+
if (model != null) {
107+
modelsPanel.updateRecord(model);
108+
modelsPanel.showModelDetails(model);
109+
}
110+
}
111+
});
112+
}
113+
}
114+
115+
@Override
116+
public boolean equals(Object other) {
117+
return super.equals(other);
118+
}
119+
120+
@Override
121+
public int hashCode() {
122+
return super.hashCode();
123+
}
124+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.logicaldoc.gui.frontend.client.ai.model;
2+
3+
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
4+
import com.smartgwt.client.widgets.layout.HLayout;
5+
6+
/**
7+
* Superclass for all tab panels in the model details area
8+
*
9+
* @author Marco Meschieri - LogicalDOC
10+
* @since 9.2
11+
*/
12+
public abstract class ModelDetailsTab extends HLayout {
13+
protected GUIModel model;
14+
15+
protected ChangedHandler changedHandler;
16+
17+
/**
18+
*
19+
* @param model The sampler this instance refers to
20+
* @param changedHandler The handler to be invoked in case of changes in the
21+
* syndication
22+
*/
23+
protected ModelDetailsTab(GUIModel model, ChangedHandler changedHandler) {
24+
super();
25+
this.model = model;
26+
this.changedHandler = changedHandler;
27+
}
28+
29+
public GUIModel getModel() {
30+
return model;
31+
}
32+
33+
public ChangedHandler getChangedHandler() {
34+
return changedHandler;
35+
}
36+
37+
@Override
38+
public boolean equals(Object other) {
39+
return super.equals(other);
40+
}
41+
42+
@Override
43+
public int hashCode() {
44+
return super.hashCode();
45+
}
46+
}

0 commit comments

Comments
 (0)