-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
settings for toolbar and provider is fetched from server, rather than from Json file. Provider states are fetched as well from server, so creating new provider can be as generic as possible
- Loading branch information
Showing
6 changed files
with
246 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
///<reference path="../tsd.d.ts"/> | ||
export interface IProviderState { | ||
addProviderStates(states, statePrefix?): void; | ||
getProviderTypes(statePrefix): ng.IPromise<any[]>; | ||
} | ||
|
||
export default class NewProviderState implements ng.IServiceProvider { | ||
private $http: ng.IHttpService; | ||
private MiQDataAccessService: any; | ||
private $state: any; | ||
public $stateProvider: any; | ||
public endpoints = { | ||
types : '/types' | ||
}; | ||
|
||
public addProviderStates(states) { | ||
_.each(states, (oneState: any) => { | ||
if (!this.$state.get(oneState.stateId)) { | ||
this.$stateProvider.state(oneState.stateId, { | ||
views: _.mapValues(oneState.views, (value) => { | ||
return {'templateUrl': value}; | ||
}) | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
public getProviderTypes(statePrefix): ng.IPromise<any[]> { | ||
return this.httpGet(this.MiQDataAccessService.getUrlPrefix() + this.endpoints.types).then((typesData: any) => { | ||
_.each(typesData, (type) => { | ||
type.stateId = statePrefix + '.' + type.id; | ||
}); | ||
return typesData; | ||
}); | ||
} | ||
|
||
private httpGet(url, requestData?) { | ||
return this.$http.get(url, requestData).then((responseData) => { | ||
return responseData.data; | ||
}); | ||
} | ||
|
||
/*@ngInject*/ | ||
public $get($http: any, $state: any, MiQDataAccessService: any) : IProviderState { | ||
this.$http = $http; | ||
this.$state = $state; | ||
this.MiQDataAccessService = MiQDataAccessService; | ||
return { | ||
addProviderStates: (states) => this.addProviderStates(states), | ||
getProviderTypes: (statePrefix) => this.getProviderTypes(statePrefix) | ||
}; | ||
} | ||
} |
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
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 @@ | ||
/// | ||
/// Copyright 2015-2016 Red Hat, Inc. and/or its affiliates | ||
/// and other contributors as indicated by the @author tags. | ||
/// | ||
/// Licensed under the Apache License, Version 2.0 (the "License"); | ||
/// you may not use this file except in compliance with the License. | ||
/// You may obtain a copy of the License at | ||
/// | ||
/// http://www.apache.org/licenses/LICENSE-2.0 | ||
/// | ||
/// Unless required by applicable law or agreed to in writing, software | ||
/// distributed under the License is distributed on an "AS IS" BASIS, | ||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
/// See the License for the specific language governing permissions and | ||
/// limitations under the License. | ||
/// | ||
|
||
///<reference path="../tsd.d.ts"/> | ||
export default class ProvidersSettingsService { | ||
private $http: any; | ||
private MiQDataAccessService: any; | ||
public endpoints = { | ||
settings : '/list_providers_settings' | ||
}; | ||
|
||
public getSettings() { | ||
return this.httpGet(this.MiQDataAccessService.getUrlPrefix() + this.endpoints.settings); | ||
} | ||
|
||
private httpGet(url: string): any { | ||
return this.$http.get(url) | ||
.then(dataResponse => dataResponse.data); | ||
} | ||
/*@ngInject*/ | ||
public $get($http: any, MiQDataAccessService: any): any { | ||
this.$http = $http; | ||
this.MiQDataAccessService = MiQDataAccessService; | ||
return { | ||
getSettings: () => this.getSettings() | ||
}; | ||
} | ||
} |