Skip to content

Commit 49b620e

Browse files
committed
UX fixes as well as api session timeout handling fix
1 parent ae5064b commit 49b620e

File tree

10 files changed

+889
-705
lines changed

10 files changed

+889
-705
lines changed

redhat-access/app/assets/javascripts/redhat_access/redhat_access.module.js

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,22 @@ angular.module('RedhatAccess', [
3232
$httpProvider.defaults.headers.common = {
3333
'X-CSRF-TOKEN': $('meta[name=csrf-token]').attr('content')
3434
};
35-
35+
var authInteceptor = ['$q',
36+
function ($q) {
37+
return {
38+
'response': function (response) {
39+
return response;
40+
},
41+
'responseError': function (rejection) {
42+
if (rejection.status === 401) {
43+
location.reload();
44+
}
45+
return $q.reject(rejection);
46+
}
47+
};
48+
}
49+
];
50+
$httpProvider.interceptors.push(authInteceptor);
3651
}
3752
]).run(['TITLE_VIEW_CONFIG',
3853
'$http', 'securityService', 'hideMachinesDropdown', 'NEW_DEFAULTS',
@@ -41,44 +56,43 @@ angular.module('RedhatAccess', [
4156
hideMachinesDropdown.value = true;
4257
NEW_DEFAULTS.product = "Red Hat Satellite or Proxy"; //TODO read from server config
4358
NEW_DEFAULTS.version = "6.0 Beta"; //TODO read from server config
44-
$http({
45-
method: 'GET',
46-
url: 'configuration'
47-
}).
48-
success(function (data, status, headers, config) {
49-
if (data) {
50-
if (data.strataHostName) {
51-
strata.setStrataHostname(data.strataHostName);
52-
} else {
53-
console.log("Invalid configuration object " + data);
54-
}
55-
if (data.strataClientId) {
56-
strata.setRedhatClientID(data.strataClientId);
57-
} else {
58-
strata.setRedhatClientID("foreman-strata-client");
59-
console.log("Invalid configuration object " + data);
60-
}
61-
}
62-
securityService.validateLogin(false).then(
63-
function (authedUser) {
64-
console.log("logged in user is " + authedUser)
65-
},
66-
function (error) {
67-
console.log("Unable to get user credentials");
68-
});
69-
}).
70-
error(function (data, status, headers, config) {
71-
console.log("Failed to read app configuration");
72-
strata.setRedhatClientID("foreman-strata-client");
73-
securityService.validateLogin(false).then(
74-
function (authedUser) {
75-
console.log("logged in user is " + authedUser)
76-
},
77-
function (error) {
78-
console.log("Unable to get user credentials");
79-
});
80-
});
81-
59+
// $http({
60+
// method: 'GET',
61+
// url: 'configuration'
62+
// }).
63+
// success(function (data, status, headers, config) {
64+
// if (data) {
65+
// if (data.strataHostName) {
66+
// strata.setStrataHostname(data.strataHostName);
67+
// } else {
68+
// console.log("Invalid configuration object " + data);
69+
// }
70+
// if (data.strataClientId) {
71+
// strata.setRedhatClientID(data.strataClientId);
72+
// } else {
73+
// strata.setRedhatClientID("foreman-strata-client");
74+
// console.log("Invalid configuration object " + data);
75+
// }
76+
// }
77+
// securityService.validateLogin(false).then(
78+
// function (authedUser) {
79+
// console.log("logged in user is " + authedUser)
80+
// },
81+
// function (error) {
82+
// console.log("Unable to get user credentials");
83+
// });
84+
// }).
85+
// error(function (data, status, headers, config) {
86+
// console.log("Failed to read app configuration");
87+
// strata.setRedhatClientID("foreman-strata-client");
88+
// securityService.validateLogin(false).then(
89+
// function (authedUser) {
90+
// console.log("logged in user is " + authedUser)
91+
// },
92+
// function (error) {
93+
// console.log("Unable to get user credentials");
94+
// });
95+
// });
8296
}
8397
]);
8498

redhat-access/app/controllers/redhat_access/attachments_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,9 @@ def create
3030
:status => 500
3131
end
3232
end
33+
34+
def api_request?
35+
true
36+
end
3337
end
3438
end

redhat-access/app/controllers/redhat_access/configuration_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@ def index
1212
render :json => { :strataHostName => strata_host,:strataClientId => client_id }.to_json,
1313
:layout => false
1414
end
15+
16+
def api_request?
17+
true
18+
end
19+
1520
end
1621
end

redhat-access/app/controllers/redhat_access/logs_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,9 @@ def get_available_logs
3535
def is_valid_file? file
3636
@@log_files.include?(file) && File.exist?(file) && File.readable?(file) && File.size(file) > 0
3737
end
38+
39+
def api_request?
40+
true
41+
end
3842
end
3943
end

redhat-access/app/views/redhat_access/redhat_access/index.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@
33
</div>
44
<%= stylesheet_link_tag 'redhat_access/application'%>
55
<%= javascript_include_tag 'redhat_access/application' %>
6+
<%= javascript_tag do %>
7+
strata.setStrataHostname('<%= REDHAT_ACCESS_CONFIG[:strata_host] %>');
8+
strata.setRedhatClientID('<%= "foreman_plugin_#{REDHAT_ACCESS_CONFIG[:deployment]}_#{RedhatAccess::VERSION}" %>');
9+
<% end %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module RedhatAccess
2-
VERSION = "0.0.3"
2+
VERSION = "0.0.4"
33
end

redhat-access/redhat_access.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ Gem::Specification.new do |s|
2525
# s.add_dependency "jquery-rails"
2626
#-------------s.add_dependency "angular-rails-templates", ">= 0.0.4"
2727
s.add_development_dependency "sqlite3"
28+
#s.add_development_dependency "redhat_access_lib"
2829
end

redhat-access/rubygem-foreman-redhat_access.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
%endif
1616

1717
Name: %{?scl_prefix}rubygem-foreman-%{gem_name}
18-
Version: 0.0.3
18+
Version: 0.0.4
1919
Release: 1%{?dist}
2020
Summary: Foreman engine to access Red Hat knowledge base
2121
Group: Development/Languages
@@ -111,6 +111,10 @@ cp -pa .%{rubygem_redhat_access_dir}/config/config.yml.example %{buildroot}/etc/
111111
/usr/bin
112112

113113
%changelog
114+
* Wed May 14 2014 Rex White <[email protected]> - 0.0.4-1
115+
- Resolves: bz1084590
116+
- Updated for UX comments
117+
114118
* Wed May 14 2014 Rex White <[email protected]> - 0.0.3-1
115119
- Resolves: bz1084590
116120

0 commit comments

Comments
 (0)