Project

General

Profile

1
package eu.dnetlib.repo.manager.client;
2

    
3
import com.google.gwt.dev.protobuf.ServiceException;
4
import com.google.gwt.dom.client.Document;
5
import com.google.gwt.dom.client.Style;
6
import com.google.gwt.user.client.History;
7
import com.google.gwt.user.client.Window;
8
import eu.dnetlib.domain.functionality.UserProfile;
9
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
10
import org.springframework.security.core.context.SecurityContextHolder;
11

    
12
/**
13
 * Created by stefania on 12/2/15.
14
 */
15
public class NavigationManager {
16

    
17
    private static NavigationManager instance = null;
18

    
19
    private NavigationManager() {
20

    
21
    }
22

    
23
    public static final NavigationManager getInstance() {
24

    
25
        if(instance==null)
26
            instance = new NavigationManager();
27

    
28
        return instance;
29
    }
30

    
31
    public void navigate(String token) {
32

    
33
        //TODO use role instead of email
34
        if(RepositoryManager.currentUserRole.equals("admin")) {
35
            Document.get().getElementById("admin1").getStyle().setDisplay(Style.Display.BLOCK);
36
            Document.get().getElementById("admin2").getStyle().setDisplay(Style.Display.BLOCK);
37
        } else {
38
            Document.get().getElementById("admin1").getStyle().setDisplay(Style.Display.NONE);
39
            Document.get().getElementById("admin2").getStyle().setDisplay(Style.Display.NONE);
40
        }
41

    
42
        RepositoryManager.previousToken = RepositoryManager.currentToken;
43
        RepositoryManager.currentToken = token;
44

    
45
        if (token.equals("landing")) {
46

    
47
            LandingPage.getInstance().showLandingPage();
48

    
49
        } else if (token.equals("login")) {
50

    
51
           /* LoginPage.getInstance().showLoginPage();
52
            LoginPage.LoginListener loginListener = new LoginPage.LoginListener() {
53
                @Override
54
                public void loginSucceeded(UserProfile userProfile) {
55

    
56
                    if (RepositoryManager.currentUser != null) {
57

    
58
                        String content = "<span class=\"uk-margin-small-right uk-icon\"><svg height=\"20\" ratio=\"1\" " +
59
                                "viewBox=\"0 0 20 20\" width=\"20\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"9.9\" " +
60
                                "cy=\"6.4\" fill=\"none\" r=\"4.4\" stroke=\"#000\" stroke-width=\"1.1\"></circle>" +
61
                                "<path d=\"M1.5,19 C2.3,14.5 5.8,11.2 10,11.2 C14.2,11.2 17.7,14.6 18.5,19.2\" fill=\"none\" " +
62
                                "stroke=\"#000\" stroke-width=\"1.1\"></path></svg></span>" +
63
                                RepositoryManager.currentUser.getFirstname() + " " + RepositoryManager.currentUser.getLastname();
64
                        Document.get().getElementById("currentUser").setInnerHTML(content);
65
                    }
66
                    History.newItem("dashboard");
67
                }
68
            };
69
            LoginPage.getInstance().setLoginListener(loginListener);*/
70

    
71
        } else if (token.equals("register")) {
72

    
73
//            RegisterPage.getInstance().showRegisterPage();
74

    
75
        } else {
76

    
77
            RepositoryManagerPage.getInstance().showRepositoryManagerPage();
78

    
79
            //TODO add catch page not found exception
80
            RepositoryManagerController.getInstance().showWidget(token);
81
        }
82
    }
83
}
(6-6/12)