forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
876cf97
commit aad7338
Showing
13 changed files
with
702 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -772,6 +772,7 @@ | |
timeline_data | ||
groups | ||
guest_applications | ||
host_form_fields | ||
host_services | ||
index | ||
list | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
vmdb/app/assets/javascripts/controllers/host/host_form_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
miqAngularApplication.controller('hostFormController', ['$http', '$scope', 'hostFormId', 'miqService', function($http, $scope, hostFormId, miqService) { | ||
$scope.hostModel = { | ||
name: '', | ||
ipaddress: '', | ||
hostname: '', | ||
ipmi_address: '', | ||
custom_1: '', | ||
user_assigned_os: '', | ||
mac_address: '', | ||
default_userid: '', | ||
default_password: '', | ||
default_verify: '', | ||
remote_userid: '', | ||
remote_password: '', | ||
remote_verify: '', | ||
ws_userid: '', | ||
ws_password: '', | ||
ws_verify: '', | ||
ipmi_userid: '', | ||
ipmi_password: '', | ||
ipmi_verify: '' | ||
|
||
}; | ||
|
||
$scope.modelCopy = angular.copy( $scope.hostModel ); | ||
$scope.afterGet = false; | ||
$scope.formId = hostFormId; | ||
miqAngularApplication.$scope = $scope; | ||
|
||
if (hostFormId == 'new') { | ||
$scope.hostModel.name = ""; | ||
$scope.hostModel.ipaddress = ""; | ||
$scope.hostModel.hostname = ""; | ||
$scope.hostModel.ipmi_address = ""; | ||
$scope.hostModel.custom_1 = ""; | ||
$scope.hostModel.user_assigned_os = ""; | ||
$scope.hostModel.mac_address = ""; | ||
$scope.hostModel.default_userid = ""; | ||
$scope.hostModel.default_password = ""; | ||
$scope.hostModel.default_verify = ""; | ||
$scope.hostModel.remote_userid = ""; | ||
$scope.hostModel.remote_password = ""; | ||
$scope.hostModel.remote_verify = ""; | ||
$scope.hostModel.ws_userid = ""; | ||
$scope.hostModel.ws_password = ""; | ||
$scope.hostModel.ws_verify = ""; | ||
$scope.hostModel.ipmi_userid = ""; | ||
$scope.hostModel.ipmi_password = ""; | ||
$scope.hostModel.ipmi_verify = ""; | ||
|
||
} else { | ||
miqService.sparkleOn(); | ||
|
||
$http.get('/host/host_form_fields/' + hostFormId).success(function(data) { | ||
$scope.hostModel.name = data.name; | ||
$scope.hostModel.ipaddress = data.ipaddress; | ||
$scope.hostModel.hostname = data.hostname; | ||
$scope.hostModel.ipmi_address = data.ipmi_address; | ||
$scope.hostModel.custom_1 = data.custom_1; | ||
$scope.hostModel.user_assigned_os = data.user_assigned_os; | ||
$scope.hostModel.mac_address = data.mac_address; | ||
$scope.hostModel.default_userid = data.default_userid; | ||
$scope.hostModel.default_password = data.default_password; | ||
$scope.hostModel.default_verify = data.default_verify; | ||
$scope.hostModel.remote_userid = data.remote_userid; | ||
$scope.hostModel.remote_password = data.remote_password; | ||
$scope.hostModel.remote_verify = data.remote_verify; | ||
$scope.hostModel.ws_userid = data.ws_userid; | ||
$scope.hostModel.ws_password = data.ws_password; | ||
$scope.hostModel.ws_verify = data.ws_verify; | ||
$scope.hostModel.ipmi_userid = data.ipmi_userid; | ||
$scope.hostModel.ipmi_password = data.ipmi_password; | ||
$scope.hostModel.ipmi_verify = data.ipmi_verify; | ||
|
||
$scope.modelCopy = angular.copy( $scope.hostModel ); | ||
miqService.sparkleOff(); | ||
}); | ||
} | ||
|
||
$scope.$watch("hostModel.name", function() { | ||
$scope.form = $scope.hostForm; | ||
$scope.miqService = miqService; | ||
}); | ||
|
||
$scope.addClicked = function() { | ||
miqService.sparkleOn(); | ||
var url = 'create/new' + '?button=add'; | ||
miqService.miqAjaxButton(url, true); | ||
}; | ||
|
||
$scope.cancelClicked = function() { | ||
miqService.sparkleOn(); | ||
if (hostFormId == 'new') { | ||
var url = '/host/create/new' + '?button=cancel'; | ||
} | ||
else { | ||
var url = '/host/update/' + hostFormId + '?button=cancel'; | ||
} | ||
miqService.miqAjaxButton(url); | ||
}; | ||
|
||
$scope.saveClicked = function() { | ||
miqService.sparkleOn(); | ||
var url = '/host/update/' + hostFormId + '?button=save'; | ||
miqService.miqAjaxButton(url, true); | ||
}; | ||
|
||
$scope.resetClicked = function() { | ||
$scope.hostModel = angular.copy( $scope.modelCopy ); | ||
$scope.hostForm.$setPristine(true); | ||
setFormToValid(); | ||
miqService.miqFlash("warn", "All changes have been reset"); | ||
}; | ||
|
||
var setFormToValid = function() { | ||
for (var name in $scope.hostForm) { | ||
if($scope.hostForm[name].$name == name) | ||
$scope.hostForm[name].$setValidity('miqrequired', true); | ||
} | ||
} | ||
}]); |
37 changes: 37 additions & 0 deletions
37
vmdb/app/assets/javascripts/directives/host/multiple_tabs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
miqAngularApplication.directive('checkpath', function (){ | ||
return { | ||
require: 'ngModel', | ||
link: function (scope, elem, attrs, ctrl) { | ||
ctrl.$parsers.unshift(function() { | ||
if(validPath(scope, ctrl.$viewValue)) { | ||
ctrl.$setValidity('checkpath', true); | ||
} | ||
else { | ||
ctrl.$setValidity('checkpath', false); | ||
} | ||
}); | ||
|
||
validPath = function(scope, path) { | ||
modified_path = path.replace(/\\/g, "/"); | ||
if(new RegExp("^//[^/].*/.+$").test(modified_path)) { | ||
$j('#flash_msg_div').text(""); | ||
scope.path_type = "NAS"; | ||
return true; | ||
} | ||
else if(/^\[[^\]].+\].*$/.test(modified_path)) { | ||
$j('#flash_msg_div').text(""); | ||
scope.path_type = "VMFS"; | ||
return true; | ||
} | ||
else { | ||
if(scope.formId == "new") { | ||
scope.miqService.miqFlash("warn", "Need a valid UNC path"); | ||
} else { | ||
scope.miqService.miqFlash("error", "Incorrect UNC path"); | ||
} | ||
return false; | ||
} | ||
}; | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
%form#form_div(name="hostForm" ng-controller="hostFormController") | ||
= render :partial => "layouts/flash_msg" | ||
- if session[:host_items].nil? | ||
%p.legend=_('Basic Information') | ||
%table.style1 | ||
%tr | ||
%td.key=_('Name') | ||
%td.wide | ||
%input(type="text" name="host_name" ng-model="hostModel.host_name" ng-maxlength=10 miqrequired checkchange) | ||
|
||
- if false | ||
%tr | ||
%td.key=_('Host Name') | ||
%td.wide | ||
#= text_field_tag("hostname", | ||
@edit[:new][:hostname], | ||
:maxlength => MAX_HOSTNAME_LEN, | ||
"data-miq_observe" => observe) | ||
%tr | ||
%td.key=_('IP Address') | ||
%td.wide | ||
#= text_field_tag("ipaddress", | ||
@edit[:new][:ipaddress], | ||
:maxlength => 15, | ||
"data-miq_observe" => observe) | ||
%tr | ||
%td.key=_('Custom Identifier') | ||
%td.wide | ||
#= text_field_tag("custom_1", | ||
@edit[:new][:custom_1], | ||
:maxlength => 50, | ||
"data-miq_observe" => observe) | ||
- if @host.operating_system.nil? || @host.operating_system.product_name.nil? | ||
%tr | ||
%td.key=_('Host platform') | ||
%td.wide | ||
#= select_tag("user_assigned_os", | ||
options_for_select([["<#{_('not specified')}>", nil]] + Host.host_platforms.to_a, | ||
@edit[:new][:user_assigned_os]), | ||
"data-miq_observe" => { :url => url }.to_json) | ||
%tr | ||
%td.key=_('IPMI IP Address') | ||
%td.wide | ||
#= text_field_tag("ipmi_address", | ||
@edit[:new][:ipmi_address], | ||
:maxlength => 15, | ||
"data-miq_observe" => observe) | ||
%tr | ||
%td.key=_('MAC Address') | ||
%td.wide | ||
#= text_field_tag("mac_address", | ||
@edit[:new][:mac_address], | ||
:maxlength => MAX_NAME_LEN, | ||
"data-miq_observe" => observe) | ||
%hr | ||
|
||
#= render(:partial => "/layouts/multi_auth_credentials", :locals => {:record => @host}) | ||
%table{:width => '100%'} | ||
%tr | ||
%td{:align => 'right'} | ||
#buttons_on | ||
- if @host.id.nil? | ||
= button_tag("Add", :class => "btn btn-primary", "ng-class" => "{'btn-disabled': !hostForm.$valid}", "ng-click" => "addClicked()", "ng-disabled" => "!hostForm.$valid") | ||
- else | ||
= button_tag("Save", :class => "btn btn-primary", "ng-click" => "saveClicked()", "ng-disabled" => "hostForm.$pristine || hostForm.$invalid", "ng-class" => "{'btn-disabled': hostForm.$pristine || hostForm.$invalid}") | ||
= button_tag("Reset", :class => "btn btn-primary", "ng-click" => "resetClicked()", "ng-disabled" => "hostForm.$pristine", "ng-class" => "{'btn-disabled': hostForm.$pristine}") | ||
= button_tag("Cancel", :class => "btn btn-default", "ng-click" => "cancelClicked()") | ||
|
||
- unless session[:host_items].nil? | ||
%p.legend | ||
= pluralize(session[:host_items].length,Dictionary::gettext(Host.to_s, :type => :model, :notfound => :titleize)) | ||
| | ||
=_('Selected') | ||
| | ||
=_('Click on a Host to fetch its settings') | ||
%table.admittable{:height => '75'} | ||
%tbody | ||
%tr | ||
%td | ||
- if session[:host_items] | ||
- @embedded = true | ||
- @gtl_type = @settings[:views][:host] | ||
= render :partial => 'layouts/gtl' | ||
:javascript | ||
cfmeAngularApplication.value('hostFormId', '#{@host.id || "new"}'); | ||
angular.bootstrap(jQuery('#form_div'), ['cfmeAngularApplication']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
- validate_url ||= %w(new create).include?(controller.action_name) ? "create" : "update" | ||
- change_url ||= "form_field_changed" | ||
- pfx ||= "" | ||
- record ||= nil | ||
- rec_id = record && record.id ? "#{record.id}" : "new" | ||
- uid_label ||= "User ID" | ||
- pwd_label ||= "Password" | ||
|
||
%tr | ||
%td{:class => "key"} | ||
= uid_label | ||
%td | ||
%input(type="text" name="#{pfx}_userid" ng-model="hostModel.#{pfx}_userid" ng-maxlength=50 checkchange) | ||
|
||
%tr | ||
%td{:class => "key"} | ||
= pwd_label | ||
%td | ||
%input(type="password" name="#{pfx}_password" ng-model="hostModel.#{pfx}_password" ng-maxlength=50 checkchange) | ||
-#= password_field_tag("#{pfx}_password", '', | ||
:maxlength => 50, | ||
:placeholder => placeholder_if_present(@edit[:new]["#{pfx}_password".to_sym]), | ||
"data-miq_observe" => url_json) | ||
%tr | ||
%td{:class => "key"} | ||
Verify #{pwd_label} | ||
%td | ||
%input(type="password" name="#{pfx}_verify" ng-model="hostModel.#{pfx}_verify" ng-maxlength=50 checkchange) | ||
-#= password_field_tag("#{pfx}_verify", '', | ||
:maxlength => 50, | ||
:placeholder => placeholder_if_present(@edit[:new]["#{pfx}_verify".to_sym]), | ||
"data-miq_observe" => url_json) | ||
%tr | ||
%td | ||
%td | ||
= render(:partial => "/layouts/form_buttons_verify", | ||
:locals => {:validate_url => validate_url, | ||
:valtype => "#{pfx}", | ||
:record_hash => "test", | ||
:ujs_button => ujs_button, | ||
:record => record}) | ||
|
Oops, something went wrong.