Skip to content
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

Merged

Conversation

santiph
Copy link
Contributor

@santiph santiph commented Oct 5, 2016

  • 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

Santiago Petrone added 2 commits October 5, 2016 19:46
…' of github.com:crowbar/crowbar-ui into features/upgrade7/nodes-repo-checks/service-integration
…upgrade7/nodes-repo-checks/service-integration
@santiph
Copy link
Contributor Author

santiph commented Oct 7, 2016

@santiph santiph changed the title Nodes Repo Checks > Service integration Service integration > Nodes Repo Checks page Oct 9, 2016
bard.mockService(upgradeBackupFactory, {
create: $q.reject(mockedErrorResponse)
bard.mockService(crowbarBackupFactory, {
create: $q.reject(mockedErrorResponse),
Copy link
Contributor

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

Copy link
Contributor Author

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

@bisht-richa
Copy link
Contributor

Looks good :)

Copy link
Member

@Itxaka Itxaka left a 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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create -> createBackup for consistency?

Copy link
Contributor Author

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?

Copy link
Member

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()

Copy link
Member

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.

Copy link
Contributor Author

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.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

downloadBackup -> getBackup

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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 👍

Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

Copy link
Contributor Author

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

@santiph santiph force-pushed the features/upgrade7/nodes-repo-checks/service-integration branch from c842ab8 to 272b9de Compare October 11, 2016 14:22
/* @ngInject */
function upgradeBackupFactory($q, $http, $filter, COMMON_API_V2_HEADERS) {
function crowbarBackupFactory($q, $http, $filter, COMMON_API_V2_HEADERS) {
var factory = {
create: createBackup,
Copy link
Member

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');
Copy link
Member

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?

Copy link
Contributor Author

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

@santiph santiph merged commit 7cc632f into master Oct 12, 2016
@skazi0 skazi0 deleted the features/upgrade7/nodes-repo-checks/service-integration branch June 16, 2017 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants