batch init this batches together the calls to json_metadata, i18n_messages, and user-find [whoami] tostreamline the init process, and also allow us to add a call to enumerate the plugins.

This commit is contained in:
Adam Young 2010-11-17 22:15:09 -05:00 committed by Endi Sukma Dewata
parent 5da8313b66
commit 775fc23738
6 changed files with 4533 additions and 587 deletions

View File

@ -21,7 +21,6 @@
/*global $:true, location:true */
/*Forward defined due to circular dependency with IPA.*/
var IPA = ( function () {
var that = {
@ -34,8 +33,6 @@ var IPA = ( function () {
that.json_url = 'test/data'
}
that.ajax_options = {
type: 'POST',
contentType: 'application/json',
@ -46,6 +43,8 @@ var IPA = ( function () {
that.messages = {};
that.metadata = {};
that.whoami = {};
that.entities = [];
that.entities_by_name = {};
@ -76,10 +75,21 @@ var IPA = ( function () {
$.ajaxSetup(that.ajax_options);
ipa_cmd('json_metadata', [], {},
var startup_batch =
[
{"method":"json_metadata","params":[[],{}]},
{"method":"i18n_messages","params":[[],{}]},
{"method":"user_find","params":[[],{
"whoami":"true","all":"true"}]}
];
ipa_cmd('batch', startup_batch, {},
function (data, text_status, xhr) {
that.metadata = data.result.metadata;
that.messages = data.result.messages;
that.metadata = data.result.results[0].metadata;
that.messages = data.result.results[1].messages;
that.whoami = data.result.results[2].result[0];
if (on_success) {
on_success(data, text_status, xhr);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
{
"error": null,
"id": 0,
"result": {
"messages": {
"ajax": {
"401": "Your kerberos ticket no longer valid.Please run KInit and then click 'retry'If this is your first time running the IPA Web UI<a href='/ipa/errors/ssbrowser.html'> Follow these directions</a> to configure your browser."
},
"button": {
"add": "Add",
"enroll": "Enroll",
"find": "Find",
"remove": "Delete",
"reset": "Reset",
"update": "Update"
},
"details": {
"account": "Account Details",
"contact": "Contact Details",
"employee": " Employee Information",
"identity": "Identity Details",
"mailing": "Mailing Address",
"misc": "Misc. Information",
"to_top": "Back to Top"
},
"login": {
"header": "Logged In As"
},
"search": {
"delete_confirm": "Do you really want to delete the selected entries?",
"quick_links": "Quick Links",
"select_all": "Select All",
"unselect_all": "Unselect All"
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -53,20 +53,20 @@ var self_serv_tab_set =
{name:'user', label:'Users', setup:ipa_entity_setup}]}];
var ipa_whoami_pkey;
/* main (document onready event handler) */
$(function() {
function whoami_on_win(data, text_status, xhr) {
function init_on_win(data, text_status, xhr) {
$(window).bind('hashchange', window_hashchange);
var whoami = data.result.result[0];
ipa_whoami_pkey=whoami.uid[0];
var whoami = IPA.whoami;
IPA.whoami_pkey=whoami.uid[0];
$('#loggedinas').find('strong').text(whoami.krbprincipalname[0]);
$('#loggedinas a').fragment(
{'user-facet':'details', 'user-pkey':ipa_whoami_pkey},2);
{'user-facet':'details', 'user-pkey':IPA.whoami_pkey},2);
for (var i=0; i<IPA.entities.length; i++) {
var entity = IPA.entities[i];
@ -82,7 +82,7 @@ $(function() {
} else {
nav_create(self_serv_tab_set, navigation, 'tabs');
var state = {'user-pkey':ipa_whoami_pkey ,
var state = {'user-pkey':IPA.whoami_pkey ,
'user-facet': jQuery.bbq.getState('user-facet') ||
'details'};
$.bbq.pushState(state);
@ -92,9 +92,6 @@ $(function() {
$('#login_header').html(IPA.messages.login.header);
}
function init_on_win(data, text_status, xhr) {
ipa_cmd('user_find', [], {"whoami":"true","all":"true"}, whoami_on_win, init_on_error, null);
}
function init_on_error(xhr, text_status, error_thrown) {
var navigation = $('#navigation').empty();

View File

@ -1,5 +1,6 @@
# Authors:
# Pavel Zuna <pzuna@redhat.com>
# Adam YOung <ayoung@redhat.com>
#
# Copyright (c) 2010 Red Hat
# See file 'copying' for use and warranty information
@ -35,6 +36,43 @@ class json_metadata(Command):
"""
INTERNAL = False
takes_args = (
Str('objname?',
doc=_('Name of object to export'),
),
)
has_output = (
Output('metadata', dict, doc=_('Dict of JSON encoded IPA Objects')),
)
def execute(self, objname):
if objname and objname in self.api.Object:
meta = dict(
result=dict(
((objname, json_serialize(self.api.Object[objname])), )
)
)
retval= dict([("metadata",meta), ("messages",dict())])
else:
meta=dict(
(o.name, json_serialize(o)) for o in self.api.Object()
)
retval= dict([("metadata",meta)])
return retval
def output_for_cli(self, textui, result, *args, **options):
print json.dumps(result, default=json_serialize)
api.register(json_metadata)
class i18n_messages(Command):
messages={
"login": {"header" :_("Logged In As")},
"button":{
@ -67,41 +105,14 @@ class json_metadata(Command):
"Follow these directions</a> to configure your browser.")
}
}
takes_args = (
Str('objname?',
doc=_('Name of object to export'),
),
)
has_output = (
Output('metadata', dict, doc=_('Dict of JSON encoded IPA Objects')),
Output('messages', dict, doc=_('Dict of I18N messages')),
)
def execute(self, objname):
if objname and objname in self.api.Object:
meta = dict(
result=dict(
((objname, json_serialize(self.api.Object[objname])), )
)
)
retval= dict([("metadata",meta), ("messages",dict())])
else:
meta=dict(
(o.name, json_serialize(o)) for o in self.api.Object()
)
retval= dict([("metadata",meta),
("messages",json_serialize(self.messages))])
return retval
def execute(self):
return dict([("messages",json_serialize(self.messages))])
def output_for_cli(self, textui, result, *args, **options):
print json.dumps(result, default=json_serialize)
api.register(json_metadata)
api.register(i18n_messages)