| 1961 |
ankur.sing |
1 |
package in.shop2020.catalog.dashboard.client;
|
|
|
2 |
|
| 2359 |
ankur.sing |
3 |
import in.shop2020.catalog.dashboard.shared.Utils;
|
|
|
4 |
|
| 1961 |
ankur.sing |
5 |
import com.google.gwt.core.client.EntryPoint;
|
|
|
6 |
import com.google.gwt.core.client.GWT;
|
|
|
7 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
8 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
9 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
10 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
11 |
import com.google.gwt.uibinder.client.UiTemplate;
|
|
|
12 |
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
13 |
import com.google.gwt.user.client.ui.DockLayoutPanel;
|
|
|
14 |
import com.google.gwt.user.client.ui.RootLayoutPanel;
|
|
|
15 |
|
|
|
16 |
public class CatalogDashboard implements EntryPoint {
|
|
|
17 |
|
|
|
18 |
@UiTemplate("CatalogDashboard.ui.xml")
|
|
|
19 |
interface CatalogBinder extends UiBinder<DockLayoutPanel, CatalogDashboard> {
|
|
|
20 |
}
|
| 2066 |
ankur.sing |
21 |
|
| 1961 |
ankur.sing |
22 |
private static final CatalogBinder binder = GWT.create(CatalogBinder.class);
|
|
|
23 |
private final LoginServiceAsync loginService = GWT.create(LoginService.class);
|
| 2066 |
ankur.sing |
24 |
|
| 2105 |
ankur.sing |
25 |
@UiField TopPanel topPanel;
|
|
|
26 |
@UiField Shortcuts shortcuts;
|
|
|
27 |
//@UiField Filters filters;
|
|
|
28 |
@UiField ItemList itemList;
|
|
|
29 |
@UiField ItemDetails itemDetails;
|
|
|
30 |
@UiField ItemActions itemActions;
|
| 1961 |
ankur.sing |
31 |
|
|
|
32 |
RootLayoutPanel root;
|
|
|
33 |
LoginScreen login;
|
|
|
34 |
|
|
|
35 |
public void onModuleLoad() {
|
|
|
36 |
root = RootLayoutPanel.get();
|
| 2027 |
ankur.sing |
37 |
root.getElement().setScrollLeft(10);
|
| 1961 |
ankur.sing |
38 |
login = new LoginScreen();
|
| 2119 |
ankur.sing |
39 |
//initMainDB("Testing");
|
|
|
40 |
root.add(login);
|
| 1961 |
ankur.sing |
41 |
login.setLoginListener(new LoginScreen.LoginListener() {
|
|
|
42 |
@Override
|
|
|
43 |
public void onLoginPressed(String username, String password) {
|
| 2359 |
ankur.sing |
44 |
authenticateUser(username, password, Utils.ROLE_STAGING);
|
| 1961 |
ankur.sing |
45 |
}
|
| 2119 |
ankur.sing |
46 |
});
|
| 1961 |
ankur.sing |
47 |
}
|
|
|
48 |
|
| 2359 |
ankur.sing |
49 |
private void authenticateUser(String username, String password, int role) {
|
| 1961 |
ankur.sing |
50 |
final String uname = username;
|
| 2359 |
ankur.sing |
51 |
loginService.authenticateUser(username, password, role, new AsyncCallback<String>() {
|
| 1961 |
ankur.sing |
52 |
@Override
|
| 2027 |
ankur.sing |
53 |
public void onSuccess(String result) {
|
|
|
54 |
if (result != null) {
|
|
|
55 |
GWT.log(result + " logged in catalog dashboard");
|
| 1961 |
ankur.sing |
56 |
root.clear();
|
|
|
57 |
initMainDB(uname);
|
|
|
58 |
login.clearFields();
|
| 2027 |
ankur.sing |
59 |
} else {
|
|
|
60 |
login.setErrorText("Invalid username/password");
|
| 1961 |
ankur.sing |
61 |
}
|
|
|
62 |
}
|
|
|
63 |
@Override
|
|
|
64 |
public void onFailure(Throwable caught) {
|
| 2027 |
ankur.sing |
65 |
login.setErrorText("Error in authentication");
|
| 1961 |
ankur.sing |
66 |
}
|
|
|
67 |
});
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
private void initMainDB(String username) {
|
|
|
71 |
DockLayoutPanel dashboard = binder.createAndBindUi(this);
|
| 2126 |
ankur.sing |
72 |
itemActions.setItemDetails(itemDetails);
|
|
|
73 |
itemList.setItemDetails(itemDetails);
|
| 1961 |
ankur.sing |
74 |
topPanel.changeGreeting(username);
|
|
|
75 |
|
|
|
76 |
topPanel.getSignOutLink().addClickHandler(new ClickHandler() {
|
|
|
77 |
@Override
|
|
|
78 |
public void onClick(ClickEvent event) {
|
|
|
79 |
root.clear();
|
|
|
80 |
root.add(login);
|
|
|
81 |
}
|
|
|
82 |
});
|
|
|
83 |
root.clear();
|
|
|
84 |
root.add(dashboard);
|
| 1992 |
ankur.sing |
85 |
|
|
|
86 |
shortcuts.getCatalogTree().setTreeListener(new CatalogTree.TreeListener() {
|
|
|
87 |
@Override
|
| 2027 |
ankur.sing |
88 |
public void onTreeItemClicked(String itemsType) {
|
|
|
89 |
//showWaitCursor();
|
| 2119 |
ankur.sing |
90 |
if(CatalogTree.ALL_ITEMS.equals(itemsType)) {
|
| 2027 |
ankur.sing |
91 |
itemList.loadAllItems();
|
| 2208 |
ankur.sing |
92 |
} else if(CatalogTree.ALL_PHASED_OUT_ITEMS.equals(itemsType)) {
|
|
|
93 |
itemList.loadAllPhasedOutItems();
|
|
|
94 |
} else if(CatalogTree.ALL_PAUSED_ITEMS.equals(itemsType)) {
|
|
|
95 |
itemList.loadAllPausedItems();
|
| 2119 |
ankur.sing |
96 |
} else if(CatalogTree.ALL_ACTIVE_ITEMS.equals(itemsType)) {
|
|
|
97 |
itemList.loadAllActiveItems();
|
| 2359 |
ankur.sing |
98 |
} else if(CatalogTree.IN_PROCESS_ITEMS.equals(itemsType)) {
|
|
|
99 |
itemList.loadAllInProcessItems();
|
|
|
100 |
} else if(CatalogTree.CONTENT_COMPLETE_ITEMS.equals(itemsType)) {
|
|
|
101 |
itemList.loadAllContentCompleteItems();
|
|
|
102 |
} else if(CatalogTree.RISKY_ITEMS.equals(itemsType)) {
|
|
|
103 |
itemList.loadAllRiskyItems();
|
| 2119 |
ankur.sing |
104 |
} else if(CatalogTree.BEST_DEALS.equals(itemsType)) {
|
| 2027 |
ankur.sing |
105 |
itemList.loadBestDeals();
|
| 2119 |
ankur.sing |
106 |
} else if(CatalogTree.BEST_SELLERS.equals(itemsType)) {
|
| 2027 |
ankur.sing |
107 |
itemList.loadBestSellers();
|
| 2119 |
ankur.sing |
108 |
} else if(CatalogTree.LATEST_ARRIVALS.equals(itemsType)) {
|
| 2027 |
ankur.sing |
109 |
itemList.loadLatestArrivals();
|
|
|
110 |
}
|
| 1992 |
ankur.sing |
111 |
}
|
|
|
112 |
});
|
| 1961 |
ankur.sing |
113 |
}
|
|
|
114 |
}
|
| 2126 |
ankur.sing |
115 |
|