mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
[sso] save and restore field data mapping
This commit is contained in:
parent
ee333df53f
commit
13f416a101
@ -85,7 +85,7 @@ class AuthenticationController
|
||||
$scope.datatype = datatype
|
||||
## data transformation rules
|
||||
$scope.transformation =
|
||||
rules: {} #TODO get from resolve
|
||||
rules: field.transformation || {}
|
||||
## available transformation formats
|
||||
$scope.formats =
|
||||
date: [
|
||||
@ -103,15 +103,22 @@ class AuthenticationController
|
||||
}
|
||||
]
|
||||
|
||||
## Create a new mapping between anything and an expected integer
|
||||
$scope.addIntegerMapping = ->
|
||||
unless angular.isArray $scope.transformation.rules.mapping
|
||||
$scope.transformation.rules.mapping = []
|
||||
$scope.transformation.rules.mapping.push({from:'', to:0})
|
||||
|
||||
## close and save the modifications
|
||||
$scope.ok = ->
|
||||
console.log('TODO')
|
||||
$uibModalInstance.close()
|
||||
$uibModalInstance.close($scope.transformation.rules)
|
||||
|
||||
## do not save the modifications
|
||||
$scope.cancel = ->
|
||||
$uibModalInstance.dismiss()
|
||||
]
|
||||
.result['finally'](null).then (transfo_rules) ->
|
||||
mapping.transformation = transfo_rules
|
||||
|
||||
|
||||
|
||||
|
@ -125,6 +125,7 @@ p, .widget p {
|
||||
.pull-in{margin-left: -15px;margin-right: -15px;}
|
||||
.pull-out{margin:-10px -15px;}
|
||||
|
||||
.width-35 { width: 35% !important; }
|
||||
.width-70 { width: 70%; }
|
||||
|
||||
.b{border: 1px solid rgba(0, 0, 0, 0.05)}
|
||||
|
@ -35,10 +35,23 @@
|
||||
ng-options="format.value as format.label for format in formats.date">
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- INTEGER -->
|
||||
<div ng-switch-when="integer">
|
||||
<label for="add_mapping" translate>{{ 'mappings' }}</label>
|
||||
<button class="btn btn-default pull-right" ng-click="addIntegerMapping()"><i class="fa fa-plus"></i></button>
|
||||
<ul>
|
||||
<li ng-repeat="map in transformation.rules.mapping" class="m-t-sm">
|
||||
<input type="text" class="form-control inline width-35" ng-model="map.from">
|
||||
<i class="fa fa-arrows-h"></i>
|
||||
<input type="number" class="form-control inline width-35" ng-model="map.to">
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</ng-switch>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<!--<button class="btn btn-primary" ng-click="ok()" ng-disabled="!mappingForm.$valid" translate>{{ 'confirm' }}</button>-->
|
||||
<button class="btn btn-primary" ng-click="ok()" ng-disabled="!mappingForm.$valid" ng-if="datatype != 'string' && datatype != 'text'" translate>{{ 'confirm' }}</button>
|
||||
<button class="btn btn-warning" ng-click="cancel()" translate>{{ 'cancel' }}</button>
|
||||
</div>
|
@ -58,7 +58,8 @@ class API::AuthProvidersController < API::ApiController
|
||||
params.require(:auth_provider).permit(:name, :providable_type, providable_attributes: [
|
||||
:id, :base_url, :token_endpoint, :authorization_endpoint, :profile_url, :client_id, :client_secret,
|
||||
o_auth2_mappings_attributes: [
|
||||
:id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type, :_destroy
|
||||
:id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type, :_destroy,
|
||||
transformation: [:format, :true_value, :false_value, mapping: [:from, :to]]
|
||||
]
|
||||
])
|
||||
end
|
||||
|
@ -6,7 +6,7 @@ if @provider.providable_type == OAuth2Provider.name
|
||||
json.providable_attributes do
|
||||
json.extract! @provider.providable, :id, :base_url, :token_endpoint, :authorization_endpoint, :profile_url, :client_id, :client_secret
|
||||
json.o_auth2_mappings_attributes @provider.providable.o_auth2_mappings do |m|
|
||||
json.extract! m, :id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type
|
||||
json.extract! m, :id, :local_model, :local_field, :api_field, :api_endpoint, :api_data_type, :transformation
|
||||
end
|
||||
end
|
||||
end
|
@ -251,6 +251,7 @@ en:
|
||||
data_mapping: "Data mapping"
|
||||
expected_data_type: "Expected data type"
|
||||
input_format: "Input format"
|
||||
mappings: "Mappings"
|
||||
|
||||
oauth2:
|
||||
# edition/creation form of an OAuth2 authentication provider
|
||||
|
@ -251,6 +251,7 @@ fr:
|
||||
data_mapping: "Correspondance des données"
|
||||
expected_data_type: "Type de données attendues"
|
||||
input_format: "Format d'entrée"
|
||||
mappings: "Correspondances"
|
||||
|
||||
oauth2:
|
||||
# formulaire d'édition/création d'un fournisseur d'authentification de type OAuth2
|
||||
|
@ -0,0 +1,5 @@
|
||||
class AddTransformationToOAuth2Mapping < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :o_auth2_mappings, :transformation, :jsonb
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160906145713) do
|
||||
ActiveRecord::Schema.define(version: 20160915105234) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@ -305,6 +305,7 @@ ActiveRecord::Schema.define(version: 20160906145713) do
|
||||
t.string "local_model"
|
||||
t.string "api_endpoint"
|
||||
t.string "api_data_type"
|
||||
t.jsonb "transformation"
|
||||
end
|
||||
|
||||
add_index "o_auth2_mappings", ["o_auth2_provider_id"], name: "index_o_auth2_mappings_on_o_auth2_provider_id", using: :btree
|
||||
|
Loading…
x
Reference in New Issue
Block a user