<!--

    Copyright © 2016-2017 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"
                            datakey-settings-schema="datakeySettingsSchema"
                            ng-required="model.type === types.datasourceType.function"
                            generate-data-key="generateDataKey({chip: chip, type: type})">
        </tb-datasource-func>
        <tb-datasource-device flex
                              ng-model="model"
                              datakey-settings-schema="datakeySettingsSchema"
                              ng-switch-when="device"
                              ng-required="model.type === types.datasourceType.device"
                              widget-type="widgetType"
                              device-aliases="deviceAliases"
                              generate-data-key="generateDataKey({chip: chip, type: type})"
                              fetch-device-keys="fetchDeviceKeys({deviceAliasId: deviceAliasId, query: query, type: type})"
                              on-create-device-alias="onCreateDeviceAlias({event: event, alias: alias})">
        </tb-datasource-device>
    </section>
</section>
