diff --git a/flow/sunstone/public/js/apptools-appflow-services.js b/flow/sunstone/public/js/apptools-appflow-services.js index c972eff2c9..62d42089ce 100644 --- a/flow/sunstone/public/js/apptools-appflow-services.js +++ b/flow/sunstone/public/js/apptools-appflow-services.js @@ -137,107 +137,8 @@ var service_tab_content = '\ \ '; -/*+++++++++++++++++++++++++++++++ -var create_service_tmpl = '\ -
\ -
\ - ' + tr("Flowironment") + '\ -
\ - \ -
\ -
\ - \ -
\ -
\ - \ - \ -
\ -
\ - \ -
\ -
\ -\ -
\ -
\ - \ -
\ - \ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
'; -*/ - - -var update_service_tmpl = - '
\ -

'+tr("Please, choose and modify the service")+':

\ -
\ - \ - \ -
\ -
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+tr("Permissions")+':'+tr("Use")+''+tr("Manage")+''+tr("Admin")+'
'+tr("Owner")+'
'+tr("Group")+'
'+tr("Other")+'
\ -
\ -
\ -
\ -
\ - \ -
\ -
\ -
'; var dataTable_services; -//var $create_service_dialog; var service_actions = { "Service.list" : { @@ -314,17 +215,6 @@ var service_actions = { notify: true }, - "Service.fetch_permissions" : { - type : "single", - call : Service.show, - callback : function(request, json){ - var dialog = $('#service_update_dialog form'); - var tmpl = json.DOCUMENT; - setPermissionsTable(tmpl, dialog); - }, - error: onError - }, - "Service.shutdown" : { type: "multiple", call: Service.shutdown, @@ -332,27 +222,6 @@ var service_actions = { error: onError, notify: true }, - -/* - "Service.clone_dialog" : { - type: "custom", - call: popUpServiceCloneDialog - }, - "Service.clone" : { - type: "single", - call: Service.clone, - error: onError, - notify: true - }, -*/ - - "Service.help" : { - type: "custom", - call: function() { - hideDialog(); - $('div#services_tab div.legend_div').slideToggle(); - } - } }; @@ -379,12 +248,6 @@ var service_buttons = { layout: "user_select", condition: mustBeAdmin }, -/* - "Service.clone_dialog" : { - type: "action", - text: tr("Clone") - }, -*/ "Service.shutdown" : { type: "action", layout: "main", @@ -425,10 +288,7 @@ function serviceElements() { // Returns an array containing the values of the service_json and ready // to be inserted in the dataTable function serviceElementArray(service_json){ - //Changing this? It may affect to the is_persistent() functions. var service = service_json.DOCUMENT; - //var body = JSON.parse(service.TEMPLATE.BODY); - //var description = body.description; return [ '', @@ -486,41 +346,46 @@ function updateServiceVMInfo(vmachine_list){ function updateServiceInfo(request,elem){ var elem_info = elem.DOCUMENT; - /* - elem_info.TEMPLATE.BODY = JSON.parse(elem_info.TEMPLATE.BODY); - // Form trs for variables - var vars = ''; - var defaults = elem_info.TEMPLATE.BODY.defaults; - if (!$.isEmptyObject(defaults)){ - for (key in defaults){ - vars += '\ - '+ key +'\ - \ - \ - '; - }; - } + var roles_info = '\ + \ + \ + ' - // Form options of compatible templates - var compat_templates = ''; - var templates = elem_info.TEMPLATE.BODY.templates; - if (templates) - for (var i = 0; i < templates.length; i++) - compat_templates += ''; -*/ + var roles = elem_info.TEMPLATE.BODY.roles + if (roles && roles.length) + for (var i = 0; i < roles.length; i++) { + roles_info += '\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + ' + if (roles[i].parents) + roles_info += '\ + \ + \ + ' + } + roles_info += '
'+tr("Roles")+'
'+roles[i].name+'
     '+tr("State")+''+Role.state(roles[i].state)+'
     '+tr("Cardinality")+''+roles[i].cardinality+'
     '+tr("VM Template")+''+roles[i].vm_template+'
     '+tr("Parents")+''+roles[i].parents.join(', ')+'
' var info_tab = { title: tr("Information"), content: - '\ + '
\ +
\ +
\ \ - \ + \ \ \ \ @@ -530,111 +395,70 @@ function updateServiceInfo(request,elem){ \ \ \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ \ \ \ \ -
'+tr("Service")+' \"'+elem_info.NAME+'\" '+ - tr("information")+'
'+tr("Service Template")+' \"'+elem_info.NAME+'\"'+'
'+tr("ID")+''+tr("Name")+''+elem_info.NAME+'
'+tr("State")+''+ Service.state(elem_info.TEMPLATE.BODY.state) +'
'+tr("Owner")+''+elem_info.UNAME+'
'+tr("Group")+''+elem_info.GNAME+'
'+tr("Permissions")+'
     '+tr("Owner")+''+ownerPermStr(elem_info)+'
     '+tr("Group")+''+groupPermStr(elem_info)+'
     '+tr("Other")+''+otherPermStr(elem_info)+'
'+tr("Strategy")+''+elem_info.TEMPLATE.BODY.deployment+'
' - } - - var roles_info = '\ - ' - - var roles = elem_info.TEMPLATE.BODY.roles - if (roles && roles.length) - for (var i = 0; i < roles.length; i++) { - roles_info += '\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - ' - - if (roles[i].parents) - roles_info += '\ - \ - \ - ' - } - - roles_info += '
'+tr("Role")+' '+roles[i].name+'
     '+tr("State")+''+Role.state(roles[i].state)+'
     '+tr("Cardinality")+''+roles[i].cardinality+'
     '+tr("VM Template")+''+roles[i].vm_template+'
     '+tr("Parents")+''+roles[i].parents.join(', ')+'
' - - var roles_tab = { - title: tr("Roles"), - content: roles_info + \ + '+tr("State")+'\ + '+ Service.state(elem_info.TEMPLATE.BODY.state) +'\ + \ + ' + + roles_info + + '\ +
' + insert_permissions_table('apptools-appflow-services', + "Service", + elem_info.ID, + elem_info.UNAME, + elem_info.GNAME, + elem_info.UID, + elem_info.GID) + + '
\ + ' } var vms_tab = { title : "Virtual Machines", - content : '\ -
\ -\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+tr("Role")+''+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("Status")+''+tr("Used CPU")+''+tr("Used Memory")+''+tr("Host")+''+tr("IPs")+''+tr("Start Time")+''+tr("VNC Access")+'
' + content : '
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
'+tr("Role")+''+tr("ID")+''+tr("Owner")+''+tr("Group")+''+tr("Name")+''+tr("Status")+''+tr("Used CPU")+''+tr("Used Memory")+''+tr("Host")+''+tr("IPs")+''+tr("Start Time")+''+tr("VNC")+'
\ +
' }; var logs = elem_info.TEMPLATE.BODY.log var log_info = '' if (logs) { - log_info += '\ - ' + log_info += '
' for (var i = 0; i < logs.length; i++) { - log_info += '
\ - \ - ' + var line = pretty_time(logs[i].timestamp)+' ['+logs[i].severity + '] ' + logs[i].message+ '
'; + if (logs[i].severity == 'E'){ + line = ''+line+''; + } + + log_info += line; } - log_info += '
'+pretty_time(logs[i].timestamp)+' ['+logs[i].severity + '] ' + logs[i].message+ '
' + log_info += '
' } var logs_tab = { @@ -648,14 +472,10 @@ function updateServiceInfo(request,elem){ Sunstone.updateInfoPanelTab("service_info_panel", "service_info_tab",info_tab); if (roles.length){ - Sunstone.addInfoPanelTab("service_info_panel", - "service_role_tab",roles_tab); Sunstone.updateInfoPanelTab("service_info_panel", "service_vms_tab",vms_tab); } else { - Sunstone.removeInfoPanelTab("service_info_panel", - "service_role_tab"); Sunstone.removeInfoPanelTab("service_info_panel", "service_vms_tab"); }; @@ -664,7 +484,13 @@ function updateServiceInfo(request,elem){ "service_log_tab",logs_tab); // Popup panel - Sunstone.popUpInfoPanel("service_info_panel"); + Sunstone.popUpInfoPanel("service_info_panel", "apptools-appflow-services"); + setPermissionsTable(elem_info,''); + + $("#service_info_panel_refresh", $("#service_info_panel")).click(function(){ + $(this).html(spinner); + Sunstone.runAction('Service.showinfo', elem_info.ID); + }) if (!roles.length) return; @@ -683,11 +509,9 @@ function updateServiceInfo(request,elem){ }; var servicevmsDataTable = $('#datatable_service_vms').dataTable({ - "bJQueryUI": true, "bSortClasses": false, - "sPaginationType": "full_numbers", "bAutoWidth":false, - "sDom" : '<"H"lfrC>t<"F"ip>', + "sDom" : '<"H">t<"F"p>', "aoColumnDefs": [ { "sWidth": "60px", "aTargets": [6,7] }, { "sWidth": "35px", "aTargets": [1, 11] }, @@ -700,206 +524,39 @@ function updateServiceInfo(request,elem){ updateView(vms, servicevmsDataTable); - $('tbody tr',servicevmsDataTable).click(function(e){ - var aData = servicevmsDataTable.fnGetData(this); - var id = aData[1]; - if (!id) return true; - if ($(e.target).is('img')) return true; + //$('tbody tr',servicevmsDataTable).click(function(e){ + // var aData = servicevmsDataTable.fnGetData(this); + // var id = aData[1]; + // if (!id) return true; + // if ($(e.target).is('img')) return true; +// + // //open the Vresources submenu in case it was closed + // var vres_menu = $('div#menu li#li_vres_tab') + // $('li.vres_tab', vres_menu.parent()).fadeIn('fast'); + // $('span', vres_menu).removeClass('ui-icon-circle-plus'); + // $('span', vres_menu).addClass('ui-icon-circle-minus'); +// + // showTab('vms_tab'); +// + // popDialogLoading(); + // Sunstone.runAction("VM.showinfo", id) + // return false; + //}); - //open the Vresources submenu in case it was closed - var vres_menu = $('div#menu li#li_vres_tab') - $('li.vres_tab', vres_menu.parent()).fadeIn('fast'); - $('span', vres_menu).removeClass('ui-icon-circle-plus'); - $('span', vres_menu).addClass('ui-icon-circle-minus'); - showTab('vms_tab'); - - popDialogLoading(); - Sunstone.runAction("VM.showinfo", id) - return false; - }); } - -function setupServiceUpdateDialog(){ - //Append to DOM - dialogs_context.append('
'); - var dialog = $('#service_update_dialog', dialogs_context); - - //Put HTML in place - dialog.html(update_service_tmpl); - - var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window - - //Convert into jQuery - dialog.addClass("reveal-modal xlarge"); - - - $('#service_update_select',dialog).change(function(){ - var id = $(this).val(); - $('.permissions_table input', dialog).removeAttr('checked'); - $('.permissions_table', dialog).removeAttr('update'); - if (id && id.length){ - Sunstone.runAction("Service.fetch_permissions", id); - }; - }); - - $('.permissions_table input',dialog).change(function(){ - $(this).parents('table').attr('update','update'); - }); - - $('form',dialog).submit(function(){ - var dialog = $(this); - var id = $('#service_update_select',dialog).val(); - if (!id || !id.length) { - $(this).parents('#service_update_dialog').trigger("reveal:close") - return false; - }; - - var permissions = $('.permissions_table',dialog); - if (permissions.attr('update')){ - var perms = { - octet : buildOctet(permissions) - }; - Sunstone.runAction("Service.chmod", id, perms); - }; - - $(this).parents('#service_update_dialog').trigger("reveal:close") - return false; - }); -}; - - -function popUpServiceUpdateDialog(){ - var select = makeSelectOptions(dataTable_services, - 1,//id_col - 4,//name_col - [], - [] - ); - var sel_elems = getSelectedNodes(dataTable_services); - - - var dialog = $('#service_update_dialog'); - $('#service_update_select', dialog).html(select); -// $('#service_update_textarea',dialog).val(""); - $('.permissions_table input', dialog).removeAttr('checked'); - $('.permissions_table', dialog).removeAttr('update'); - - if (sel_elems.length >= 1){ //several items in the list are selected - //grep them - var new_select= sel_elems.length > 1? '' : ""; - $('option','').each(function(){ - var val = $(this).val(); - if ($.inArray(val,sel_elems) >= 0){ - new_select+=''; - }; - }); - $('#service_update_select', dialog).html(new_select); - if (sel_elems.length == 1) { - $('#service_update_select option', - dialog).attr('selected','selected'); - $('#service_update_select', dialog).trigger("change"); - }; - }; - - dialog.reveal(); - return false; -} - - // Set the autorefresh interval for the datatable function setServiceAutorefresh() { setInterval(function(){ var checked = $('input.check_item:checked',dataTable_services); - var filter = $("#datatable_services_filter input", - dataTable_services.parents("#datatable_services_wrapper")).attr('value'); - if (!checked.length && !filter.length){ + var filter = $("#services_search").attr('value'); + if ((checked.length==0) && !filter){ Sunstone.runAction("Service.autorefresh"); } },INTERVAL+someTime()); }; -/* -function setupServiceCloneDialog(){ - //Append to DOM - dialogs_context.append('
'); - var dialog = $('#service_clone_dialog',dialogs_context); - - //Put HTML in place - - var html = '
\ -
'+tr("Choose a new name for the flowironment")+':
\ -
'+tr("Several flowironments are selected, please choose prefix to name the new copies")+':
\ -
\ -\ -\ -\ -
\ - \ -
\ -'; - - dialog.html(html); - - //Convert into jQuery - dialog.dialog({ - autoOpen:false, - width:375, - modal:true, - resizable:false - }); - - $('button',dialog).button(); - - $('form',dialog).submit(function(){ - var name = $('input', this).val(); - var sel_elems = serviceElements(); - if (!name || !sel_elems.length) - notifyError('A name or prefix is needed!'); - if (sel_elems.length > 1){ - for (var i=0; i< sel_elems.length; i++) - //If we are cloning several items we - //use the name as prefix - Sunstone.runAction('Service.clone', - sel_elems[i], - name + getName(sel_elems[i], - dataTable_services, - 4)); - } else { - Sunstone.runAction('Service.clone',sel_elems[0],name) - }; - dialog.dialog('close'); - setTimeout(function(){ - Sunstone.runAction('Service.refresh'); - }, 1500); - return false; - }); -} - -function popUpServiceCloneDialog(){ - var dialog = $('#service_clone_dialog'); - var sel_elems = serviceElements(); - //show different text depending on how many elements are selected - if (sel_elems.length > 1){ - $('.clone_one',dialog).hide(); - $('.clone_several',dialog).show(); - $('input',dialog).val('Copy of '); - } - else { - $('.clone_one',dialog).show(); - $('.clone_several',dialog).hide(); - $('input',dialog).val('Copy of '+getName(sel_elems[0], - dataTable_services, 4)); - }; - - $(dialog).dialog('open'); -} - -*/ - //The DOM is ready at this point $(document).ready(function(){ @@ -923,14 +580,9 @@ $(document).ready(function(){ Sunstone.runAction("Service.list"); - setupServiceUpdateDialog(); - -// setupImageCloneDialog(); setServiceAutorefresh(); initCheckAllBoxes(dataTable_services); tableCheckboxesListener(dataTable_services); infoListener(dataTable_services,'Service.showinfo'); - - $('div#services_tab div.legend_div').hide(); }); diff --git a/flow/sunstone/public/js/apptools-appflow-templates.js b/flow/sunstone/public/js/apptools-appflow-templates.js index f37344c3e6..3db9df228b 100644 --- a/flow/sunstone/public/js/apptools-appflow-templates.js +++ b/flow/sunstone/public/js/apptools-appflow-templates.js @@ -225,50 +225,6 @@ var create_service_template_tmpl = '\ '; -var update_service_template_tmpl = - '
\ -

'+tr("Please, choose and modify the service template")+':

\ -
\ - \ - \ -
\ -
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
'+tr("Permissions")+':'+tr("Use")+''+tr("Manage")+''+tr("Admin")+'
'+tr("Owner")+'
'+tr("Group")+'
'+tr("Other")+'
\ -
\ -
\ -
\ -
\ - \ -
\ -
\ -
'; - var dataTable_service_templates; var $create_service_template_dialog; @@ -293,11 +249,6 @@ var service_template_actions = { call: popUpCreateServiceTemplateDialog }, - "ServiceTemplate.update_dialog" : { - type : "custom", - call : popUpServiceTemplateUpdateDialog - }, - "ServiceTemplate.list" : { type: "list", call: ServiceTemplate.list, @@ -380,28 +331,6 @@ var service_template_actions = { notify: true }, - "ServiceTemplate.fetch_permissions" : { - type : "single", - call : ServiceTemplate.show, - callback : function(request, json){ - var dialog = $('#service_template_update_dialog form'); - var tmpl = json.DOCUMENT; - setPermissionsTable(tmpl, dialog); - }, - error: onError - }, -/* - "ServiceTemplate.clone_dialog" : { - type: "custom", - call: popUpServiceTemplateCloneDialog - }, - "ServiceTemplate.clone" : { - type: "single", - call: ServiceTemplate.clone, - error: onError, - notify: true - }, -*/ "ServiceTemplate.help" : { type: "custom", call: function() { @@ -423,13 +352,6 @@ var service_template_buttons = { layout: "create" }, - "ServiceTemplate.update_dialog" : { - type: "action", - text: tr("Update"), - layout: "main", - alwaysActive: true - }, - "ServiceTemplate.instantiate" : { type: "action", layout: "main", @@ -451,12 +373,7 @@ var service_template_buttons = { tip: tr("Select the new group")+":", condition: mustBeAdmin }, -/* - "ServiceTemplate.clone_dialog" : { - type: "action", - text: tr("Clone") - }, -*/ + "ServiceTemplate.delete" : { type: "confirm", text: tr("Delete"), @@ -492,10 +409,7 @@ function serviceTemplateElements() { // Returns an array containing the values of the service_template_json and ready // to be inserted in the dataTable function serviceTemplateElementArray(service_template_json){ - //Changing this? It may affect to the is_persistent() functions. var service_template = service_template_json.DOCUMENT; - //var body = JSON.parse(service_template.TEMPLATE.BODY); - //var description = body.description; return [ '', @@ -503,7 +417,6 @@ function serviceTemplateElementArray(service_template_json){ service_template.UNAME, service_template.GNAME, service_template.NAME -// description ? description : tr("None") ]; } @@ -541,39 +454,42 @@ function updateServiceTemplatesView(request, service_templates_list){ // Callback to update the information panel tabs and pop it up function updateServiceTemplateInfo(request,elem){ var elem_info = elem.DOCUMENT; -/* - // Form trs for variables - var vars = ''; - var defaults = elem_info.TEMPLATE.BODY.defaults; - if (!$.isEmptyObject(defaults)){ - for (key in defaults){ - vars += '\ - '+ key +'\ - \ - \ - '; - }; - } - // Form options of compatible templates - var compat_templates = ''; - var templates = elem_info.TEMPLATE.BODY.templates; - if (templates) - for (var i = 0; i < templates.length; i++) - compat_templates += ''; + var roles_info = '\ + \ + \ + ' + var roles = elem_info.TEMPLATE.BODY.roles + if (roles && roles.length > 0) + for (var i = 0; i < roles.length; i++) { + roles_info += '\ + \ + \ + \ + \ + \ + \ + \ + ' -*/ + if (roles[i].parents) + roles_info += '\ + \ + \ + ' + } + + roles_info += '
'+tr("Roles")+'
'+roles[i].name+'
     '+tr("Cardinality")+''+roles[i].cardinality+'
     '+tr("VM Template")+''+roles[i].vm_template+'
     '+tr("Parents")+''+roles[i].parents.join(', ')+'
' var info_tab = { title: tr("Information"), content: - '\ + '
\ +
\ +
\ \ - \ + \ \ \ \ @@ -583,81 +499,33 @@ function updateServiceTemplateInfo(request,elem){ \ \ \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ \ \ \ \ -
'+tr("Service Template")+' \"'+elem_info.NAME+'\" '+ - tr("information")+'
'+tr("Service Template")+' \"'+elem_info.NAME+'\"'+'
'+tr("ID")+''+tr("Name")+''+elem_info.NAME+'
'+tr("Owner")+''+elem_info.UNAME+'
'+tr("Group")+''+elem_info.GNAME+'
'+tr("Permissions")+'
     '+tr("Owner")+''+ownerPermStr(elem_info)+'
     '+tr("Group")+''+groupPermStr(elem_info)+'
     '+tr("Other")+''+otherPermStr(elem_info)+'
'+tr("Strategy")+''+elem_info.TEMPLATE.BODY.deployment+'
' + ' + + roles_info + + '\ +
' + insert_permissions_table('apptools-appflow-templates', + "ServiceTemplate", + elem_info.ID, + elem_info.UNAME, + elem_info.GNAME, + elem_info.UID, + elem_info.GID) + + '
\ + ' }; - var roles_info = '\ - ' - - var roles = elem_info.TEMPLATE.BODY.roles - if (roles && roles.length > 0) - for (var i = 0; i < roles.length; i++) { - roles_info += '\ - \ - \ - \ - \ - \ - \ - \ - ' - - if (roles[i].parents) - roles_info += '\ - \ - \ - ' - } - - roles_info += '
'+tr("Role")+' '+roles[i].name+'
     '+tr("Cardinality")+''+roles[i].cardinality+'
     '+tr("VM Template")+''+roles[i].vm_template+'
     '+tr("Parents")+''+roles[i].parents.join(', ')+'
' - - var roles_tab = { - title: tr("Roles"), - content: roles_info - } - -/* - var roles_tab = { - title: tr("Roles"), - content: '\ - '+ - (elem_info.TEMPLATE.BODY ? prettyPrintJSON(elem_info.TEMPLATE.BODY) : "" )+ - '
'+tr("Node")+'
' - } -*/ Sunstone.updateInfoPanelTab("service_template_info_panel","service_template_info_tab",info_tab); - if (roles && roles.length > 0) - Sunstone.addInfoPanelTab("service_template_info_panel","service_template_roles_tab",roles_tab); - else - Sunstone.removeInfoPanelTab("service_template_info_panel","service_template_roles_tab"); - Sunstone.popUpInfoPanel("service_template_info_panel", "apptools-appflow-templates"); + setPermissionsTable(elem_info,''); + + $("#service_template_info_panel_refresh", $("#service_template_info_panel")).click(function(){ + $(this).html(spinner); + Sunstone.runAction('ServiceTemplate.showinfo', elem_info.ID); + }) } @@ -793,121 +661,17 @@ function popUpCreateServiceTemplateDialog(){ var dialog = $create_service_template_dialog; var tpl_select = makeSelectOptions(dataTable_templates, 1, 4, [], [], true); $('select[name="vm_template"]', dialog).html(tpl_select); - // $('select[name="templates"] option', dialog).each(function(){ - // $(this).text('☐ '+$(this).text()); - // }); - - // //Somehow this needs to go here. Live() doesn't respond in setup function - // $('select[name="templates"] option', dialog).click(function(){ - // var clicked = $(this).attr('clicked'); - // if (clicked){//unbold, unmark - // $(this).text($(this).text().replace(/☒/g,'☐')); - // $(this).removeAttr('clicked'); - // } - // else {//bold,mark - // $(this).text($(this).text().replace(/☐/g,'☒')); - // $(this).attr('clicked','clicked'); - // } - // return false; - // }); - dialog.reveal(); } -function setupServiceTemplateUpdateDialog(){ - //Append to DOM - dialogs_context.append('
'); - var dialog = $('#service_template_update_dialog',dialogs_context); - - //Put HTML in place - dialog.html(update_service_template_tmpl); - - var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window - - //Convert into jQuery - dialog.addClass("reveal-modal xlarge"); - - - $('#service_template_update_select',dialog).change(function(){ - var id = $(this).val(); - $('.permissions_table input', dialog).removeAttr('checked'); - $('.permissions_table', dialog).removeAttr('update'); - if (id && id.length){ - Sunstone.runAction("ServiceTemplate.fetch_permissions", id); - }; - }); - - $('.permissions_table input',dialog).change(function(){ - $(this).parents('table').attr('update','update'); - }); - - $('form',dialog).submit(function(){ - var dialog = $(this); - var id = $('#service_template_update_select',dialog).val(); - if (!id || !id.length) { - $(this).parents('#service_template_update_dialog').trigger("reveal:close"); - return false; - }; - - var permissions = $('.permissions_table',dialog); - if (permissions.attr('update')){ - var perms = { - octet : buildOctet(permissions) - }; - Sunstone.runAction("ServiceTemplate.chmod", id, perms); - }; - - $(this).parents('#service_template_update_dialog').trigger("reveal:close"); - return false; - }); -}; - - -function popUpServiceTemplateUpdateDialog(){ - var select = makeSelectOptions(dataTable_service_templates, - 1,//id_col - 4,//name_col - [], - [] - ); - var sel_elems = getSelectedNodes(dataTable_service_templates); - - - var dialog = $('#service_template_update_dialog'); - $('#service_template_update_select', dialog).html(select); -// $('#service_template_update_textarea',dialog).val(""); - $('.permissions_table input', dialog).removeAttr('checked'); - $('.permissions_table', dialog).removeAttr('update'); - - if (sel_elems.length >= 1){ //several items in the list are selected - //grep them - var new_select= sel_elems.length > 1? '' : ""; - $('option','').each(function(){ - var val = $(this).val(); - if ($.inArray(val,sel_elems) >= 0){ - new_select+=''; - }; - }); - $('#service_template_update_select', dialog).html(new_select); - if (sel_elems.length == 1) { - $('#service_template_update_select option', - dialog).attr('selected','selected'); - $('#service_template_update_select', dialog).trigger("change"); - }; - }; - - dialog.reveal(); - return false; -} // Set the autorefresh interval for the datatable function setServiceTemplateAutorefresh() { setInterval(function(){ var checked = $('input.check_item:checked',dataTable_service_templates); - var filter = $("#datatable_service_templates_filter input", - dataTable_service_templates.parents("#datatable_service_templates_wrapper")).attr('value'); - if (!checked.length && !filter.length){ + var filter = $("#service_template_search").attr('value'); + if ((checked.length==0) && !filter){ Sunstone.runAction("ServiceTemplate.autorefresh"); } },INTERVAL+someTime()); @@ -936,13 +700,9 @@ $(document).ready(function(){ Sunstone.runAction("ServiceTemplate.list"); - setupCreateServiceTemplateDialog(); - setupServiceTemplateUpdateDialog(); setupTips($create_service_template_dialog); - $('.st_man .man_icon', - $create_service_template_dialog).css('display', 'inline-block'); -// setupImageCloneDialog(); + setServiceTemplateAutorefresh(); initCheckAllBoxes(dataTable_service_templates);