add loading indicator

This commit is contained in:
Géry Debongnie
2019-02-06 21:20:26 +01:00
parent 971b798803
commit 8d94c69223
4 changed files with 24 additions and 1 deletions
+12
View File
@@ -187,3 +187,15 @@ body {
padding: 5px; padding: 5px;
} }
} }
/***** Loading indicator *****/
.o_loading {
position: fixed;
bottom: 0;
right: 0;
z-index: 1051; // lol...
background-color: $main-color;
color: white;
padding: 4px;
font-size: 14px;
}
+8 -1
View File
@@ -41,6 +41,7 @@ interface State {
stack: ActionStack; stack: ActionStack;
inHome: boolean; inHome: boolean;
currentApp: MenuItem | null; currentApp: MenuItem | null;
isLoading: boolean;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -55,7 +56,8 @@ export class Root extends Widget<Props, State> {
notifications: [], notifications: [],
stack: [], stack: [],
inHome: false, inHome: false,
currentApp: null currentApp: null,
isLoading: false
}; };
constructor(env: Env, props: Props) { constructor(env: Env, props: Props) {
@@ -73,6 +75,11 @@ export class Root extends Widget<Props, State> {
this.updateState({ notifications: notifs }) this.updateState({ notifications: notifs })
); );
// loading indicator
this.env.ajax.on("rpc_status", this, status => {
this.updateState({ isLoading: status === "loading" });
});
// actions // actions
this.env.actionManager.on("action_stack_updated", this, stack => this.env.actionManager.on("action_stack_updated", this, stack =>
this.updateState({ stack, inHome: false }) this.updateState({ stack, inHome: false })
+1
View File
@@ -14,6 +14,7 @@
<t t-widget="Notification" t-props="notif"/> <t t-widget="Notification" t-props="notif"/>
</t> </t>
</div> </div>
<div class="o_loading" t-if="state.isLoading">Loading</div>
</div> </div>
<div t-name="web.navbar" class="o_navbar" t-att-class="props.inHome ? 'o_navbar o_in_home' : 'o_navbar'"> <div t-name="web.navbar" class="o_navbar" t-att-class="props.inHome ? 'o_navbar o_in_home' : 'o_navbar'">
@@ -31,6 +31,7 @@ exports[`can be rendered (in home menu) 1`] = `
<div class=\\"o_notification_container\\"> <div class=\\"o_notification_container\\">
</div> </div>
</div>" </div>"
`; `;
@@ -106,6 +107,7 @@ exports[`if url has action_id, will render action and navigate to proper menu_id
<div class=\\"o_notification_container\\"> <div class=\\"o_notification_container\\">
</div> </div>
</div>" </div>"
`; `;
@@ -172,5 +174,6 @@ exports[`start with no action => clicks on client action => discuss is rendered
<div class=\\"o_notification_container\\"> <div class=\\"o_notification_container\\">
</div> </div>
</div>" </div>"
`; `;