Revision 7fb14dbb

b/docs/quick-install-admin-guide.rst
931 931
.. code-block:: console
932 932

  
933 933
    CLOUDBAR_LOCATION = 'https://node1.example.com/static/im/cloudbar/'
934
    PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE = '3'
935 934
    CLOUDBAR_SERVICES_URL = 'https://node1.example.com/ui/get_services'
936 935
    CLOUDBAR_MENU_URL = 'https://node1.example.com/ui/get_menu'
937 936

  
938 937
The ``CLOUDBAR_LOCATION`` tells the client where to find the astakos common
939 938
cloudbar.
940 939

  
941
The ``PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE`` points to an already registered
942
Astakos service. You can see all :ref:`registered services <services-reg>` by
943
running on the Astakos node (node1):
944

  
945
.. code-block:: console
946

  
947
   # snf-manage service-list
948

  
949
The value of ``PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE`` should be the pithos
950
service's ``id`` as shown by the above command, in our case ``3``.
951

  
952 940
The ``CLOUDBAR_SERVICES_URL`` and ``CLOUDBAR_MENU_URL`` options are used by the
953 941
Pithos web client to get from astakos all the information needed to fill its
954 942
own cloudbar. So we put our astakos deployment urls there.
......
1738 1726
.. code-block:: console
1739 1727

  
1740 1728
   CLOUDBAR_LOCATION = 'https://node1.example.com/static/im/cloudbar/'
1741
   CLOUDBAR_ACTIVE_SERVICE = '2'
1742 1729
   CLOUDBAR_SERVICES_URL = 'https://node1.example.com/ui/get_services'
1743 1730
   CLOUDBAR_MENU_URL = 'https://account.node1.example.com/ui/get_menu'
1744 1731

  
......
1750 1737
``/etc/synnefo/20-snf-pithos-webclient-cloudbar.conf`` on the previous
1751 1738
:ref:`Pithos configuration <conf-pithos>` section.
1752 1739

  
1753
The ``CLOUDBAR_ACTIVE_SERVICE`` points to an already registered Astakos
1754
service. You can see all :ref:`registered services <services-reg>` by running
1755
on the Astakos node (node1):
1756

  
1757
.. code-block:: console
1758

  
1759
   # snf-manage service-list
1760

  
1761
The value of ``CLOUDBAR_ACTIVE_SERVICE`` should be the cyclades service's
1762
``id`` as shown by the above command, in our case ``2``.
1763

  
1764 1740
Edit ``/etc/synnefo/20-snf-cyclades-app-plankton.conf``:
1765 1741

  
1766 1742
.. code-block:: console
b/docs/scale/i-cyclades.rst
62 62

  
63 63
    GANETI_USE_HOTPLUG = True
64 64
    CLOUDBAR_LOCATION = 'https://accounts.example.com/static/im/cloudbar/'
65
    CLOUDBAR_ACTIVE_SERVICE = '2'
66 65
    CLOUDBAR_SERVICES_URL = 'https://accounts.example.com/ui/get_services'
67 66
    CLOUDBAR_MENU_URL = 'https://accounts.example.com/ui/get_menu'
68 67
    BACKEND_DB_CONNECTION = 'postgresql://synnefo:example_passw0rd@db.example.com:5432/snf_pithos'
b/docs/scale/i-pithos.rst
83 83
    CLOUDBAR_SERVICES_URL = 'https://accounts.example.com/ui/get_services'
84 84
    CLOUDBAR_MENU_URL = 'https://accounts.example.com/ui/get_menu'
85 85

  
86
    PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE = 'XXXXXXXX'
87

  
88 86
    PITHOS_UI_LOGIN_URL = "https://accounts.example.com/ui/login?next="
89 87

  
90 88
    PITHOS_UI_FEEDBACK_URL = "/feedback"
b/snf-astakos-app/astakos/im/static/im/cloudbar/README.rst
9 9
The project consists of a javascript file which once imported in a
10 10
html page handles the automatic creation and styling of a bar that
11 11
is placed on top of the page (first body element absolutely
12
positioned on top). Since the addition of the bar may break the
13
current layout of the site once imported the script tries to load an
14
additional css located in the same url as the script itself named by
15
the ``CLOUDBAR_ACTIVE_SERVICE`` configuration and prefixed by *service_* so 
16
that css changes can be applied without touching the page native styles.
17

  
12
positioned on top). 
18 13
The bar contains links to the refered services application urls, and
19 14
depending on if the user is authenticated links to account pages
20 15
(login, change profile, logout etc.).
......
34 29
    - Include one of the latest jquery builds.
35 30
    - Set the ``CLOUDBAR_COOKIE_NAME`` variable containing info about the username
36 31
      and the authentication status of the current visitor of the page.
37
    - Set the ``CLOUDBAR_ACTIVE_SERVICE`` to the id of the service the current
38
      page refers to so that script cat set the appropriate active styles to
39
      the services menu for services ids see ``SERVICES_LINK`` object in 
40
      cloudbar.js. Use special **accounts** value to set account menu as the
41
      active link.
42 32
    - Set the ``CLOUDBAR_LOCATION`` to the url where bar files are served from.
43 33
    - Include the servicesbar.js script.
44 34

  
......
51 41
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
52 42
    <script>
53 43
        var CLOUDBAR_COOKIE_NAME = '_pithos2_a';
54
        var CLOUDBAR_ACTIVE_SERVICE = 'cloud';
55 44
        var CLOUDBAR_LOCATION = "https://accounts.cloud.grnet.gr/cloudbar/";
56 45

  
57 46
        $(document).ready(function(){
b/snf-astakos-app/astakos/im/static/im/cloudbar/cloudbar.js
17 17
    //  * Dual licensed under the MIT and GPL licenses
18 18
    var cookie=function(key,value,options){if(arguments.length>1&&(!/Object/.test(Object.prototype.toString.call(value))||value===null||value===undefined)){options=$.extend({},options);if(value===null||value===undefined){options.expires=-1}if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days)}value=String(value);return(document.cookie=[encodeURIComponent(key),'=',options.raw?value:encodeURIComponent(value),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''))}options=value||{};var decode=options.raw?function(s){return s}:decodeURIComponent;var pairs=document.cookie.split('; ');for(var i=0,pair;pair=pairs[i]&&pairs[i].split('=');i++){if(decode(pair[0])===key)return decode(pair[1]||'')}return null};
19 19

  
20
    var ACTIVE_MENU = window.CLOUDBAR_ACTIVE_SERVICE || 'cloud';
21 20
    var USER_DATA = window.CLOUDBAR_USER_DATA || {'user': 'Not logged in', 'logged_in': false};
22 21
    var COOKIE_NAME = window.CLOUDBAR_COOKIE_NAME || '_pithos2_a';
23 22

  
......
39 38

  
40 39
    if (!SKIP_ADDITIONAL_CSS) {
41 40
        var css = $("<link />");
42
        css.attr({rel:'stylesheet', type:'text/css', href:cssloc + 'service_' + ACTIVE_MENU + '.css'});
43 41
        $("head").append(css);
44 42
    }
45 43

  
......
52 50
    
53 51
    // create services links and set the active class to the current service
54 52
    $.getJSON(get_services_url + "?callback=?", function(data) {
53
            var active_found = false;
55 54
            $.each(data, function(i, el){
56 55
            var sli = $("<li class='service-"+el.name+"'>");
57 56
            var slink = $("<a>");
......
72 71
            slink.attr('title', el.name);
73 72
            sli.append(slink);
74 73
            services.append(sli);
75
            if (el.id == ACTIVE_MENU || el.name == ACTIVE_MENU) {
76
                sli.addClass("active");
74
            var urlReg = new RegExp('^'+el.url+'.*');
75
            if (urlReg.test(window.location.toString())) {
76
              active_found = true;   
77
              sli.addClass("active");
77 78
            }
78 79
        });
80
        // no active service found, activate accounts
81
        if (!active_found) {
82
            $('.cloudbar .user').addClass("hover active");
83
        }
79 84
      });
80 85
    
81 86
    // create profile links
82 87
    var user = $('<div class="user"></div>');    
83
    if (ACTIVE_MENU == "accounts") { user.addClass("hover active")}
84 88
    var username = $('<a href="#"></a>');
85 89
    var usermenu = $("<ul>");
86 90
    var get_menu_url = (window.GET_MENU_URL || window.CLOUDBAR_MENU) + '?callback=?&location=' + window.location.toString().split("?")[0];
b/snf-common/synnefo/lib/context_processors.py
33 33
    CB_LOCATION = getattr(settings, 'CLOUDBAR_LOCATION')
34 34
    CB_COOKIE_NAME = getattr(settings, 'CLOUDBAR_COOKIE_NAME',
35 35
            'okeanos_account')
36
    CB_ACTIVE_SERVICE = getattr(settings, 'CLOUDBAR_ACTIVE_SERVICE',
37
            'cloud')
38 36
    CB_SERVICES_URL = getattr(settings, 'CLOUDBAR_SERVICES_URL')
39 37
    CB_MENU_URL = getattr(settings, 'CLOUDBAR_MENU_URL')
40 38
    CB_HEIGHT = getattr(settings, 'CLOUDBAR_HEIGHT',
......
46 44
    <script type="text/javascript">
47 45
        var CLOUDBAR_LOCATION = "%(location)s";
48 46
        var CLOUDBAR_COOKIE_NAME = "%(cookie_name)s";
49
        var CLOUDBAR_ACTIVE_SERVICE = "%(active_service)s";
50 47
        var GET_SERVICES_URL = "%(services_url)s";
51 48
        var GET_MENU_URL = "%(menu_url)s";
52 49
        var CLOUDBAR_HEIGHT = '%(height)s';
......
65 62
        }
66 63
    </style>
67 64
""" % {'location': CB_LOCATION,
68
       'active_service': CB_ACTIVE_SERVICE,
69 65
       'cookie_name': CB_COOKIE_NAME,
70 66
       'services_url': CB_SERVICES_URL,
71 67
       'menu_url': CB_MENU_URL,
......
78 74
        'CLOUDBAR_ACTIVE': CB_ACTIVE,
79 75
        'CLOUDBAR_LOCATION': CB_LOCATION,
80 76
        'CLOUDBAR_COOKIE_NAME': CB_COOKIE_NAME,
81
        'CLOUDBAR_ACTIVE_SERVICE': CB_ACTIVE_SERVICE,
82 77
        'CLOUDBAR_SERVICES_URL': CB_SERVICES_URL,
83 78
        'CLOUDBAR_MENU_URL': CB_MENU_URL,
84 79
        'CLOUDBAR_CODE': CB_CODE
b/snf-cyclades-app/conf/20-snf-cyclades-app-cloudbar.conf
1 1
#CLOUDBAR_ACTIVE = True
2 2
#CLOUDBAR_LOCATION = 'https://accounts.synnefo.org/static/im/cloudbar/'
3 3
#CLOUDBAR_COOKIE_NAME = '_pithos2_a'
4
#CLOUDBAR_ACTIVE_SERVICE = 'cloud'
5 4
#CLOUDBAR_SERVICES_URL = 'https://accounts.okeanos.grnet.gr/ui/get_services'
6 5
#CLOUDBAR_MENU_URL = 'https://accounts.okeanos.grnet.gr/ui/get_menu'
7 6
#
b/snf-cyclades-app/synnefo/app_settings/default/cloudbar.py
1 1
CLOUDBAR_ACTIVE = True
2 2
CLOUDBAR_LOCATION = 'https://accounts.synnefo.org/static/im/cloudbar/'
3 3
CLOUDBAR_COOKIE_NAME = '_pithos2_a'
4
CLOUDBAR_ACTIVE_SERVICE = 'cloud'
5 4
CLOUDBAR_SERVICES_URL = 'https://accounts.synnefo.org/ui/get_services'
6 5
CLOUDBAR_MENU_URL = 'https://accounts.synnefo.org/ui/get_menu'

Also available in: Unified diff