-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service integration > Nodes Repo Checks page #58
Service integration > Nodes Repo Checks page #58
Conversation
santiph
commented
Oct 5, 2016
•
edited
Loading
edited
- Update repositories checks based on service response
- Update static API responses (nodejs)
- Refactor Data module
- Integrate with /api/crowbar to get the list of installed Add Ons
- Display repositories list based on available Add Ons
…' of github.com:crowbar/crowbar-ui into features/upgrade7/nodes-repo-checks/service-integration
…upgrade7/nodes-repo-checks/service-integration
bard.mockService(upgradeBackupFactory, { | ||
create: $q.reject(mockedErrorResponse) | ||
bard.mockService(crowbarBackupFactory, { | ||
create: $q.reject(mockedErrorResponse), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comma at the end of the line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should have failed the lints. Good catch, Richa
Looks good :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good to me, some minor nitpicks
/* @ngInject */ | ||
function upgradeBackupFactory($q, $http, $filter, COMMON_API_V2_HEADERS) { | ||
function crowbarBackupFactory($q, $http, $filter, COMMON_API_V2_HEADERS) { | ||
var factory = { | ||
create: createBackup, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create -> createBackup for consistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end it would be used like: crowbarBackupFactory().createBackup()
. Don't you think it's redundant, considering we're already operating over a backup factory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, a bit redundant but as the var+function below changed their names to include backup, I was thinking more about consistency between both methods crowbarBackupFactory().createBackup()
and crowbarBackupFactory().getBackup()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @Itxaka here. It should be either create
& download
or createBackup
& getBackup
or downloadBackup
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be updated
* @param {Number} Backup Id to be downloaded | ||
* @return {Promise} | ||
*/ | ||
function getBackup(id) { | ||
// this should never happen, caller should make sure 'id' is set | ||
if (angular.isUndefined(id)) { | ||
throw Error('downloadBackup() called without id.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
downloadBackup -> getBackup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be fixed
var requestOptions = { | ||
method: 'GET', | ||
url: '/api/crowbar', | ||
headers: COMMON_API_V2_HEADERS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cant we set $http.defaults.headers to avoid adding the headers on each function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be isolated to crowbar endpoints only, so we allow different headers for different endpoints in the future (OpenStack, for instance)
Maybe as part of suseData.crowbar
specific configuration... What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, anything to avoid repetition 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skazi0 Would Restangular help us here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would simplify things a bit. We could use "decoupled service" (https://github.com/mgonto/restangular#decoupled-restangular-service) for the /api/ prefix and pre-configure it with required headers and other options if needed like I did here: https://github.com/skazi0/yaia/blob/master/app/static/js/invoices.js#L22-L27
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could do it, but current implementation works fine so I'd leave migration to Restangular for the future or when we're blocked by some problem with direct $http usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've created #61 to track it in the future
Thanks for the input
c842ab8
to
272b9de
Compare
/* @ngInject */ | ||
function upgradeBackupFactory($q, $http, $filter, COMMON_API_V2_HEADERS) { | ||
function crowbarBackupFactory($q, $http, $filter, COMMON_API_V2_HEADERS) { | ||
var factory = { | ||
create: createBackup, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @Itxaka here. It should be either create
& download
or createBackup
& getBackup
or downloadBackup
.
bard.appModule('crowbarData.upgrade'); | ||
bard.inject('upgradeBackupFactory', '$q', '$httpBackend'); | ||
bard.appModule('suseData.crowbar'); | ||
bard.inject('crowbarBackupFactory', '$q', '$httpBackend', 'COMMON_API_V2_HEADERS'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to inject COMMON_API_V2_HEADERS
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the API documentation, we do