<!--

    Copyright © 2016-2020 The Thingsboard Authors

    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.

-->
<section flex layout='column' layout-align="center" layout-gt-sm='row' layout-align-gt-sm="start center" class="tb-datasource">
    <md-input-container style="min-width: 110px;">
        <md-select placeholder="{{ 'datasource.type' | translate }}" required id="datasourceType" ng-model="model.type">
            <md-option ng-repeat="datasourceType in datasourceTypes" value="{{datasourceType}}">
                {{ datasourceType | translate }}
            </md-option>
        </md-select>
    </md-input-container>
    <section flex class="datasource" ng-switch on="model.type">
        <tb-datasource-func flex
                            ng-switch-default
                            ng-model="model"
                            max-data-keys="maxDataKeys"
                            opt-data-keys="optDataKeys"
                            datakey-settings-schema="datakeySettingsSchema"
                            ng-required="model.type === types.datasourceType.function"
                            widget-type="widgetType"
                            generate-data-key="generateDataKey({chip: chip, type: type})">
        </tb-datasource-func>
        <tb-datasource-entity flex
                              ng-model="model"
                              max-data-keys="maxDataKeys"
                              opt-data-keys="optDataKeys"
                              datakey-settings-schema="datakeySettingsSchema"
                              ng-switch-when="entity"
                              ng-required="model.type === types.datasourceType.entity"
                              widget-type="widgetType"
                              alias-controller="aliasController"
                              generate-data-key="generateDataKey({chip: chip, type: type})"
                              fetch-entity-keys="fetchEntityKeys({entityAliasId: entityAliasId, query: query, type: type})"
                              on-create-entity-alias="onCreateEntityAlias({event: event, alias: alias})">
        </tb-datasource-entity>
    </section>
</section>
