Changed Host delete dialog to reflect when a host is being removed from a group vs. permanent removal from All hosts.

This commit is contained in:
chouseknecht 2013-07-09 14:48:58 -04:00
parent a82edf0e4a
commit 2438bdd698
2 changed files with 14 additions and 7 deletions

View File

@ -4,7 +4,7 @@
*
* awx-min.js
*
* master-18c53bb, Mon Jul 8 15:33:44 2013 -0400
* master-09cebfc, Tue Jul 9 00:09:37 2013 -0400
*
*/
var urlPrefix="/static/";
@ -215,9 +215,9 @@ m.formModalHeader="Edit Host";m.formModalCancelShow=!0;m.parseType="yaml";z(m);m
b,d,c){$.isEmptyObject(a)?m.variables="---":m.variables=jsyaml.safeDump(a)}).error(function(b,d,c,e){m.variables=null;a(m,b,d,f,{hdr:"Error!",msg:"Failed to retrieve host variables. GET returned status: "+d})})):m.variables="---";s.variables=m.variables});c.setUrl(k);c.get().success(function(a,b,d,c){for(var e in f.fields)a[e]&&(m[e]=a[e],s[e]=m[e]);for(var l in f.related);m.variable_url=a.related.variable_data;m.$emit("hostLoaded")}).error(function(b,d,c,e){a(m,b,d,f,{hdr:"Error!",msg:"Failed to retrieve host: "+
id+". GET returned status: "+d})});m.$$phase||m.$digest();m.formModalAction=function(){try{if("json"==m.parseType){JSON.parse(m.variables);var b=m.variables}else b=jsyaml.load(m.variables);var e={},l;for(l in f.fields)e[l]=m[l];e.inventory=h;c.setUrl(k);c.put(e).success(function(e,l,g,h){m.variables?(c.setUrl(d("hosts")+e.id+"/variable_data/"),c.put(b).success(function(a,b,d,c){$("#form-modal").modal("hide")}).error(function(b,d,c,e){a(m,b,d,f,{hdr:"Error!",msg:"Failed to update host varaibles. PUT returned status: "+
d})})):$("#form-modal").modal("hide")}).error(function(b,d,c,e){a(m,b,d,f,{hdr:"Error!",msg:"Failed to update host: "+g+". PUT returned status: "+d})})}catch(z){p("Error","Error parsing host variables. Parser returned: "+z)}};m.formReset=function(){e.reset();for(var a in s)m[a]=s[a];m.parseType="yaml"}}}]).factory("HostsDelete",["$rootScope","$location","$log","$routeParams","Rest","Alert","Prompt","ProcessErrors","GetBasePath","HostsReload",function(h,m,k,g,c,p,f,e,l,a){return function(d){var b=
d.scope,f=d.group_id,g=d.inventory_id,h=d.host_id,k=d.host_name,m=null!==f?l("groups")+f+"/hosts/":l("inventory")+g+"/hosts/";$("#prompt-header").text("Delete Host");$("#prompt-body").text("Are you sure you want to delete host "+k+"?");$("#prompt-action-btn").addClass("btn-danger");b.promptAction=function(){b.removeHostsReload&&b.removeHostsReload();b.removeHostsReload=b.$on("hostsReload",function(){a(d)});c.setUrl(m);c.post({id:h,disassociate:1}).success(function(a,d,c,e){$("#prompt-modal").modal("hide");
b.$emit("hostsReload")}).error(function(a,d,c,f){$("#prompt-modal").modal("hide");b.$emit("hostsReload");e(b,a,d,null,{hdr:"Error!",msg:"Call to "+m+" failed. DELETE returned status: "+d})})};$("#prompt-modal").modal({backdrop:"static",keyboard:!0,show:!0})}}]).factory("HostsReload",["RelatedSearchInit","RelatedPaginateInit","InventoryForm","GetBasePath",function(h,m,k,g){return function(c){scope=c.scope;var p={hosts:{url:null!==scope.group_id?g("groups")+scope.group_id+"/hosts/":g("inventory")+c.inventory_id+
"/hosts/",iterator:"host"}};h({scope:c.scope,form:k,relatedSets:p});m({scope:c.scope,relatedSets:p});c.scope.search("host");c.scope.$$phase||c.scope.$digest()}}]);angular.module("InventoryHelper","RestServices Utilities OrganizationListDefinition SearchHelper PaginateHelper ListGenerator AuthService InventoryHelper RelatedSearchHelper RelatedPaginateHelper InventoryFormDefinition".split(" ")).factory("LoadTreeData",["Alert","Rest","Authorization","$http",function(h,m,k,g){return function(c){var g=c.scope,f=c.inventory,e=f.related.root_groups,l=f.related.hosts,a=f.name,d=f.url,b=f.id,k=f.description,w=0,B=[];g.HostLoadedRemove&&g.HostLoadedRemove();g.HostLoadedRemove=
d.scope,f=d.inventory_id,g=d.host_id,h=d.host_name,k=null!==b.group_id?l("groups")+b.group_id+"/hosts/":l("inventory")+f+"/hosts/";null!==b.group_id?($("#prompt-header").text("Remove Host from Group"),$("#prompt-body").text("Are you sure you want to remove host "+h+" from the group?")):($("#prompt-header").text("Delete Host"),$("#prompt-body").text("Are you sure you want to permenantly remove host "+h+"?"));$("#prompt-action-btn").addClass("btn-danger");b.promptAction=function(){b.removeHostsReload&&
b.removeHostsReload();b.removeHostsReload=b.$on("hostsReload",function(){a(d)});c.setUrl(k);c.post({id:g,disassociate:1}).success(function(a,d,c,e){$("#prompt-modal").modal("hide");b.$emit("hostsReload")}).error(function(a,d,c,f){$("#prompt-modal").modal("hide");b.$emit("hostsReload");e(b,a,d,null,{hdr:"Error!",msg:"Call to "+k+" failed. DELETE returned status: "+d})})};$("#prompt-modal").modal({backdrop:"static",keyboard:!0,show:!0})}}]).factory("HostsReload",["RelatedSearchInit","RelatedPaginateInit",
"InventoryForm","GetBasePath",function(h,m,k,g){return function(c){scope=c.scope;var p={hosts:{url:null!==scope.group_id?g("groups")+scope.group_id+"/hosts/":g("inventory")+c.inventory_id+"/hosts/",iterator:"host"}};h({scope:c.scope,form:k,relatedSets:p});m({scope:c.scope,relatedSets:p});c.scope.search("host");c.scope.$$phase||c.scope.$digest()}}]);angular.module("InventoryHelper","RestServices Utilities OrganizationListDefinition SearchHelper PaginateHelper ListGenerator AuthService InventoryHelper RelatedSearchHelper RelatedPaginateHelper InventoryFormDefinition".split(" ")).factory("LoadTreeData",["Alert","Rest","Authorization","$http",function(h,m,k,g){return function(c){var g=c.scope,f=c.inventory,e=f.related.root_groups,l=f.related.hosts,a=f.name,d=f.url,b=f.id,k=f.description,w=0,B=[];g.HostLoadedRemove&&g.HostLoadedRemove();g.HostLoadedRemove=
g.$on("hostsLoaded",function(){m.setUrl(e+"?"+(g.inventoryFailureFilter?"has_active_failures__int=1&":"")+"order_by=name");m.get().success(function(a,b,d,c){for(b=0;b<a.results.length;b++)B[0].children.push({data:{title:a.results[b].name},attr:{id:w,group_id:a.results[b].id,type:"group",name:a.results[b].name,description:a.results[b].description,inventory:a.results[b].inventory,all:a.results[b].related.all_hosts,children:a.results[b].related.children,hosts:a.results[b].related.hosts,variable:a.results[b].related.variable_data,
"data-failures":a.results[b].has_active_failures},state:"closed"}),w++;g.$emit("buildTree",B,w)}).error(function(a,b,d,c){h("Error","Failed to laod tree data. Url: "+e+" GET status: "+b)})});m.setUrl(l+"?order_by=name");m.get().success(function(c,e,h,m){B=[{data:{title:a},attr:{type:"inventory",id:"inventory-node",url:d,inventory_id:b,hosts:l,name:a,description:k,"data-failures":f.has_active_failures},state:"open",children:[]}];g.$emit("hostsLoaded")}).error(function(a,b,d,c){h("Error","Failed to laod tree data. Url: "+
l+" GET status: "+b)})}}]).factory("TreeInit",["Alert","Rest","Authorization","$http","LoadTreeData",function(h,m,k,g,c){return function(g){var f=g.scope;f.buildTreeRemove&&f.buildTreeRemove();f.buildTreeRemove=f.$on("buildTree",function(c,l,a){var d=a;$("#tree-view").jstree({core:{initially_open:["inventory-node"]},plugins:["themes","json_data","ui","contextmenu"],themes:{theme:"ansible",dots:!1,icons:!0},ui:{initially_select:["inventory-node"]},json_data:{data:l,ajax:{url:function(a){f.selected_node=

View File

@ -413,7 +413,8 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
var inventory_id = params.inventory_id;
var host_id = params.host_id;
var host_name = params.host_name;
var url = (group_id !== null) ? GetBasePath('groups') + group_id + '/hosts/' : GetBasePath('inventory') + inventory_id + '/hosts/';
var url = (scope.group_id !== null) ? GetBasePath('groups') + scope.group_id + '/hosts/' :
GetBasePath('inventory') + inventory_id + '/hosts/';
var action_to_take = function() {
if (scope.removeHostsReload) {
@ -437,8 +438,14 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
};
//Force binds to work. Not working usual way.
$('#prompt-header').text('Delete Host');
$('#prompt-body').text('Are you sure you want to delete host ' + host_name + '?');
if (scope.group_id !== null) {
$('#prompt-header').text('Remove Host from Group');
$('#prompt-body').text('Are you sure you want to remove host ' + host_name + ' from the group?');
}
else {
$('#prompt-header').text('Delete Host');
$('#prompt-body').text('Are you sure you want to permenantly remove host ' + host_name + '?');
}
$('#prompt-action-btn').addClass('btn-danger');
scope.promptAction = action_to_take; // for some reason this binds?
$('#prompt-modal').modal({