• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

compassinformatics / cpsi-mapview / 15022980938

14 May 2025 02:11PM UTC coverage: 26.333% (+0.04%) from 26.29%
15022980938

push

github

geographika
Move describe to test globals

492 of 2344 branches covered (20.99%)

Branch coverage included in aggregate %.

1464 of 5084 relevant lines covered (28.8%)

1.17 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.31
/app/controller/button/LoginButtonController.js
1
/**
2
 * This class is the controller for the {@link CpsiMapview.view.button.LoginButton}
3
 */
4
Ext.define('CpsiMapview.controller.button.LoginButtonController', {
1✔
5
    extend: 'Ext.app.ViewController',
6

7
    requires: ['CpsiMapview.view.form.Login'],
8

9
    alias: 'controller.cmv_login_button',
10

11
    /**
12
     * The prefix used in the cookie for any browser-based
13
     * user roles
14
     * */
15
    displayRolePrefixes: ['Browser_'],
16

17
    /**
18
     * Logout, clear the login cookie, and show
19
     * the login form
20
     * */
21
    onClick: function () {
22
        const app = Ext.getApplication
1!
23
            ? Ext.getApplication()
24
            : Ext.app.Application.instance;
25
        let loginWin;
26

27
        if (app && app.loginWindow) {
1!
28
            loginWin = app.loginWindow;
×
29
        } else {
30
            let viewModel = {};
1✔
31
            if (app) {
1!
32
                viewModel = {
1✔
33
                    tokenName: app.tokenName,
34
                    serviceUrl: app.authenticationUrl,
35
                    validateUrl: app.tokenValidationUrl,
36
                    minimumRequiredRole: app.minimumRequiredRole
37
                };
38
            }
39
            loginWin = Ext.create('CpsiMapview.view.form.Login', {
1✔
40
                viewModel: viewModel
41
            });
42
            if (app) {
1!
43
                app.loginWindow = loginWin;
1✔
44
            }
45
        }
46
        loginWin.getController().logout();
1✔
47
        loginWin.show();
1✔
48
    },
49

50
    /**
51
     * Get the user name and roles from the login cookie
52
     * and return as a formatted string
53
     * */
54
    getLoginDetails: function () {
55
        const me = this;
2✔
56
        const app = Ext.getApplication
2!
57
            ? Ext.getApplication()
58
            : Ext.app.Application.instance;
59
        const userName = Ext.util.Cookies.get('username');
2✔
60
        let roles = Ext.util.Cookies.get('roles');
2✔
61
        const displayRolePrefixes =
62
            (app && app.displayRolePrefixes) || me.displayRolePrefixes;
2✔
63
        if (roles) {
2!
64
            roles = roles.split(',');
2✔
65
            const displayRoles = [];
2✔
66

67
            Ext.Array.each(roles, function (r) {
2✔
68
                Ext.Array.each(displayRolePrefixes, function (prefix) {
4✔
69
                    if (r.startsWith(prefix)) {
6✔
70
                        displayRoles.push(r.replace(prefix, ''));
4✔
71
                    }
72
                });
73
            });
74

75
            displayRoles.sort();
2✔
76
            roles = displayRoles.join('<br />');
2✔
77
        }
78
        return Ext.String.format(
2✔
79
            'Username: <b>{0}</b><br />User Roles: <br /><br />{1}',
80
            userName,
81
            roles
82
        );
83
    },
84

85
    /**
86
     * Init the controller and add listeners to the global
87
     * login and logout events fired by {@link CpsiMapview.controller.form.Login#login}
88
     * and {@link CpsiMapview.controller.form.Login#logout}
89
     * */
90
    init: function () {
91
        const me = this;
3✔
92

93
        Ext.GlobalEvents.on('login', function () {
3✔
94
            me.getViewModel().set('loggedIn', true);
3✔
95
        });
96

97
        Ext.GlobalEvents.on('logout', function () {
3✔
98
            me.getViewModel().set('loggedIn', false);
×
99
        });
100
    }
101
});
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc