| Line 20... |
Line 20... |
| 20 |
* This is the entry point of dashboard application.
|
20 |
* This is the entry point of dashboard application.
|
| 21 |
*
|
21 |
*
|
| 22 |
*/
|
22 |
*/
|
| 23 |
public class CatalogDashboard implements EntryPoint {
|
23 |
public class CatalogDashboard implements EntryPoint {
|
| 24 |
|
24 |
|
| 25 |
@UiTemplate("CatalogDashboard.ui.xml")
|
25 |
@UiTemplate("CatalogDashboard.ui.xml")
|
| 26 |
interface CatalogBinder extends UiBinder<DockLayoutPanel, CatalogDashboard> {
|
26 |
interface CatalogBinder extends UiBinder<DockLayoutPanel, CatalogDashboard> {
|
| 27 |
}
|
27 |
}
|
| 28 |
|
28 |
|
| 29 |
private static final CatalogBinder binder = GWT.create(CatalogBinder.class);
|
29 |
private static final CatalogBinder binder = GWT.create(CatalogBinder.class);
|
| 30 |
private final LoginServiceAsync loginService = GWT.create(LoginService.class);
|
30 |
private final LoginServiceAsync loginService = GWT.create(LoginService.class);
|
| 31 |
public String uname;
|
31 |
public String uname;
|
| 32 |
@UiField TopPanel topPanel; // logo, welcome message and sign out link
|
32 |
@UiField TopPanel topPanel; // logo, welcome message and sign out link
|
| 33 |
@UiField Shortcuts shortcuts; // anchors to filter item list based on status
|
33 |
@UiField Shortcuts shortcuts; // anchors to filter item list based on status
|
| 34 |
//TODO @UiField Filters filters;
|
34 |
//TODO @UiField Filters filters;
|
| 35 |
@UiField ItemList itemList; // list of items
|
35 |
@UiField ItemList itemList; // list of items
|
| 36 |
@UiField ItemDetails itemDetails; // details of an item selected in the list
|
36 |
@UiField ItemDetails itemDetails; // details of an item selected in the list
|
| 37 |
@UiField ItemActions itemActions; // action buttons to update, add item or change item status
|
37 |
@UiField ItemActions itemActions; // action buttons to update, add item or change item status
|
| 38 |
|
38 |
|
| 39 |
RootLayoutPanel root;
|
39 |
RootLayoutPanel root;
|
| 40 |
LoginScreen login;
|
40 |
LoginScreen login;
|
| 41 |
|
41 |
|
| 42 |
public void onModuleLoad() {
|
42 |
public void onModuleLoad() {
|
| 43 |
Map<Long, String> vendors = Utils.getAllVendors(); //do not delete this line it is done to prefetch the data
|
43 |
Map<Long, String> vendors = Utils.getAllVendors(); //do not delete this line it is done to prefetch the data
|
| 44 |
root = RootLayoutPanel.get();
|
44 |
root = RootLayoutPanel.get();
|
| 45 |
root.getElement().setScrollLeft(10);
|
45 |
root.getElement().setScrollLeft(10);
|
| 46 |
login = new LoginScreen();
|
46 |
login = new LoginScreen();
|
| 47 |
//initMainDB("Testing");
|
47 |
//initMainDB("Testing");
|
| 48 |
root.add(login);
|
48 |
root.add(login);
|
| 49 |
login.setLoginListener(new LoginScreen.LoginListener() {
|
49 |
login.setLoginListener(new LoginScreen.LoginListener() {
|
| 50 |
@Override
|
50 |
@Override
|
| 51 |
public void onLoginPressed(String username, String password) {
|
51 |
public void onLoginPressed(String username, String password) {
|
| 52 |
authenticateUser(username, password);
|
52 |
authenticateUser(username, password);
|
| 53 |
}
|
53 |
}
|
| 54 |
});
|
54 |
});
|
| 55 |
}
|
55 |
}
|
| 56 |
|
56 |
|
| 57 |
/**
|
57 |
/**
|
| 58 |
* Authenticates username and password and if successful, initialises
|
58 |
* Authenticates username and password and if successful, initialises
|
| 59 |
* main dashboard panel.
|
59 |
* main dashboard panel.
|
| 60 |
* @param username
|
60 |
* @param username
|
| 61 |
* @param password
|
61 |
* @param password
|
| 62 |
* @param role -- Utils.ROLE_STAGING (Login role for staging), another role
|
62 |
* @param role -- Utils.ROLE_STAGING (Login role for staging), another role
|
| 63 |
* is Utils.ROLE_PRODUCTION (for push to production username & password)
|
63 |
* is Utils.ROLE_PRODUCTION (for push to production username & password)
|
| 64 |
*/
|
64 |
*/
|
| 65 |
private void authenticateUser(String username, String password) {
|
65 |
private void authenticateUser(String username, String password) {
|
| 66 |
uname = username;
|
66 |
uname = username;
|
| 67 |
loginService.authenticateUser(username, password, new AsyncCallback<String>() {
|
67 |
loginService.authenticateUser(username, password, new AsyncCallback<String>() {
|
| 68 |
@Override
|
68 |
@Override
|
| 69 |
public void onSuccess(String result) {
|
69 |
public void onSuccess(String result) {
|
| 70 |
if (result != null) {
|
70 |
if (result != null) {
|
| 71 |
long role = Long.parseLong(result);
|
71 |
long role = Long.parseLong(result);
|
| 72 |
GWT.log(uname + " logged in catalog dashboard");
|
72 |
GWT.log(uname + " logged in catalog dashboard");
|
| 73 |
root.clear();
|
73 |
root.clear();
|
| 74 |
initMainDB(uname, role);
|
74 |
initMainDB(uname, role);
|
| 75 |
login.clearFields();
|
75 |
login.clearFields();
|
| 76 |
} else {
|
76 |
} else {
|
| 77 |
login.setErrorText("Invalid username/password");
|
77 |
login.setErrorText("Invalid username/password");
|
| 78 |
}
|
78 |
}
|
| 79 |
}
|
79 |
}
|
| 80 |
@Override
|
80 |
@Override
|
| 81 |
public void onFailure(Throwable caught) {
|
81 |
public void onFailure(Throwable caught) {
|
| 82 |
caught.printStackTrace();
|
82 |
caught.printStackTrace();
|
| 83 |
login.setErrorText("Error in authentication");
|
83 |
login.setErrorText("Error in authentication");
|
| 84 |
}
|
84 |
}
|
| 85 |
});
|
85 |
});
|
| 86 |
}
|
86 |
}
|
| 87 |
|
87 |
|
| 88 |
private void initMainDB(String username, long role) {
|
88 |
private void initMainDB(String username, long role) {
|
| 89 |
DockLayoutPanel dashboard = binder.createAndBindUi(this);
|
89 |
DockLayoutPanel dashboard = binder.createAndBindUi(this);
|
| 90 |
itemActions.setItemDetails(itemDetails);
|
90 |
itemActions.setItemDetails(itemDetails);
|
| 91 |
itemList.setItemDetails(itemDetails);
|
91 |
itemList.setItemDetails(itemDetails);
|
| 92 |
itemDetails.setCatalogDashboardPanel(this);
|
92 |
itemDetails.setCatalogDashboardPanel(this);
|
| 93 |
topPanel.changeGreeting(username);
|
93 |
topPanel.changeGreeting(username);
|
| 94 |
if(role == Utils.ROLE_READONLY){
|
94 |
if(role == Utils.ROLE_READONLY){
|
| 95 |
itemActions.disableAllActions();
|
95 |
itemActions.disableAllActions();
|
| 96 |
}
|
96 |
}
|
| 97 |
topPanel.getSignOutLink().addClickHandler(new ClickHandler() {
|
97 |
topPanel.getSignOutLink().addClickHandler(new ClickHandler() {
|
| 98 |
@Override
|
98 |
@Override
|
| 99 |
public void onClick(ClickEvent event) {
|
99 |
public void onClick(ClickEvent event) {
|
| 100 |
root.clear();
|
100 |
root.clear();
|
| 101 |
root.add(login);
|
101 |
root.add(login);
|
| 102 |
}
|
102 |
}
|
| 103 |
});
|
103 |
});
|
| 104 |
root.clear();
|
104 |
root.clear();
|
| 105 |
root.add(dashboard);
|
105 |
root.add(dashboard);
|
| 106 |
|
106 |
|
| 107 |
/**
|
107 |
/**
|
| 108 |
* listener for anchors to filter item list based on statuses and some other parameters.
|
108 |
* listener for anchors to filter item list based on statuses and some other parameters.
|
| 109 |
* On click event, string of the anchor is passed as argument and the same listener is
|
109 |
* On click event, string of the anchor is passed as argument and the same listener is
|
| 110 |
* taking different actions based on the different string arguments.
|
110 |
* taking different actions based on the different string arguments.
|
| 111 |
*/
|
111 |
*/
|
| 112 |
shortcuts.getCatalogTree().setTreeListener(new CatalogTree.TreeListener() {
|
112 |
shortcuts.getCatalogTree().setTreeListener(new CatalogTree.TreeListener() {
|
| 113 |
@Override
|
113 |
@Override
|
| 114 |
public void onTreeItemClicked(String itemsType) {
|
114 |
public void onTreeItemClicked(String itemsType) {
|
| 115 |
if(CatalogTree.ALL_ITEMS.equals(itemsType)) {
|
115 |
if(CatalogTree.ALL_ITEMS.equals(itemsType)) {
|
| 116 |
itemList.loadAllItems();
|
116 |
itemList.loadAllItems();
|
| 117 |
} else if(CatalogTree.ALL_PHASED_OUT_ITEMS.equals(itemsType)) {
|
117 |
} else if(CatalogTree.ALL_PHASED_OUT_ITEMS.equals(itemsType)) {
|
| 118 |
itemList.loadAllPhasedOutItems();
|
118 |
itemList.loadAllPhasedOutItems();
|
| 119 |
} else if(CatalogTree.ALL_PAUSED_ITEMS.equals(itemsType)) {
|
119 |
} else if(CatalogTree.ALL_PAUSED_ITEMS.equals(itemsType)) {
|
| 120 |
itemList.loadAllPausedItems();
|
120 |
itemList.loadAllPausedItems();
|
| 121 |
} else if(CatalogTree.ALL_ACTIVE_ITEMS.equals(itemsType)) {
|
121 |
} else if(CatalogTree.ALL_ACTIVE_ITEMS.equals(itemsType)) {
|
| 122 |
itemList.loadAllActiveItems();
|
122 |
itemList.loadAllActiveItems();
|
| 123 |
} else if(CatalogTree.IN_PROCESS_ITEMS.equals(itemsType)) {
|
123 |
} else if(CatalogTree.IN_PROCESS_ITEMS.equals(itemsType)) {
|
| 124 |
itemList.loadAllInProcessItems();
|
124 |
itemList.loadAllInProcessItems();
|
| 125 |
} else if(CatalogTree.CONTENT_COMPLETE_ITEMS.equals(itemsType)) {
|
125 |
} else if(CatalogTree.CONTENT_COMPLETE_ITEMS.equals(itemsType)) {
|
| 126 |
itemList.loadAllContentCompleteItems();
|
126 |
itemList.loadAllContentCompleteItems();
|
| 127 |
} else if(CatalogTree.RISKY_ITEMS.equals(itemsType)) {
|
127 |
} else if(CatalogTree.RISKY_ITEMS.equals(itemsType)) {
|
| 128 |
itemList.loadAllRiskyItems();
|
128 |
itemList.loadAllRiskyItems();
|
| 129 |
} else if(CatalogTree.BEST_DEALS.equals(itemsType)) {
|
129 |
} else if(CatalogTree.BEST_DEALS.equals(itemsType)) {
|
| 130 |
itemList.loadBestDeals();
|
130 |
itemList.loadBestDeals();
|
| 131 |
} else if(CatalogTree.BEST_SELLERS.equals(itemsType)) {
|
131 |
} else if(CatalogTree.BEST_SELLERS.equals(itemsType)) {
|
| 132 |
itemList.loadBestSellers();
|
132 |
itemList.loadBestSellers();
|
| 133 |
} else if(CatalogTree.LATEST_ARRIVALS.equals(itemsType)) {
|
133 |
} else if(CatalogTree.LATEST_ARRIVALS.equals(itemsType)) {
|
| 134 |
itemList.loadLatestArrivals();
|
134 |
itemList.loadLatestArrivals();
|
| 135 |
} else if(CatalogTree.SEARCH.equals(itemsType)) {
|
135 |
} else if(CatalogTree.SEARCH.equals(itemsType)) {
|
| 136 |
//Open the search dialog box
|
136 |
//Open the search dialog box
|
| 137 |
SearchItemBox box = new SearchItemBox(itemList);
|
137 |
SearchItemBox box = new SearchItemBox(itemList);
|
| 138 |
box.center();
|
138 |
box.center();
|
| 139 |
} else if (CatalogTree.INACTIVE_ITEMS_WITH_INVENTORY.equals(itemsType)) {
|
139 |
} else if (CatalogTree.INACTIVE_ITEMS_WITH_INVENTORY.equals(itemsType)) {
|
| 140 |
String link = GWT.getHostPageBaseURL() + "inactivewithinventory/download";
|
140 |
String link = GWT.getHostPageBaseURL() + "inactivewithinventory/download";
|
| 141 |
Window.open(link, "_blank", "Inactive Items with Inventory");
|
141 |
Window.open(link, "_blank", "Inactive Items with Inventory");
|
| 142 |
}else if (CatalogTree.BREAKEVEN_ITEMS.equals(itemsType)){
|
142 |
}else if (CatalogTree.BREAKEVEN_ITEMS.equals(itemsType)){
|
| 143 |
String link1 = GWT.getHostPageBaseURL() + "belowbreakeven/download";
|
143 |
String link1 = GWT.getHostPageBaseURL() + "belowbreakeven/download";
|
| 144 |
Window.open(link1, "_blank", "Item below break even price.");
|
144 |
Window.open(link1, "_blank", "Item below break even price.");
|
| 145 |
}else if (CatalogTree.INVENTORY_OUTOFSYNC_ITEM_LIST.equals(itemsType)){
|
145 |
}else if (CatalogTree.INVENTORY_OUTOFSYNC_ITEM_LIST.equals(itemsType)){
|
| 146 |
itemList.loadInventoryOutofSyncItems();
|
146 |
itemList.loadInventoryOutofSyncItems();
|
| 147 |
}
|
147 |
}
|
| 148 |
}
|
148 |
else if (CatalogTree.PRIVATE_DEALS.equals(itemsType)){
|
| 149 |
});
|
149 |
itemList.loadPrivateDealItems();
|
| 150 |
}
|
150 |
}
|
| 151 |
|
151 |
}
|
| 152 |
ItemList getItemListWidget() {
|
152 |
});
|
| 153 |
return this.itemList;
|
153 |
}
|
| 154 |
}
|
154 |
|
| 155 |
|
155 |
ItemList getItemListWidget() {
|
| 156 |
ItemDetails getItemDetailsWidget() {
|
156 |
return this.itemList;
|
| 157 |
return this.itemDetails;
|
157 |
}
|
| 158 |
}
|
158 |
|
| - |
|
159 |
ItemDetails getItemDetailsWidget() {
|
| - |
|
160 |
return this.itemDetails;
|
| - |
|
161 |
}
|
| 159 |
}
|
162 |
}
|
| 160 |
|
163 |
|