<!--
  ~
  ~ Headwind MDM: Open Source Android MDM Software
  ~ https://h-mdm.com
  ~
  ~ Copyright (C) 2019 Headwind Solutions LLC (http://h-sms.com)
  ~
  ~ 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.
  ~
  -->

<!-- Localization completed -->
<div ng-show='errorMessage' class='modal-header'>
    <div ng-show='errorMessage' class='error'><span>{{errorMessage}}</span></div>
</div>
<div class='modal-body'>
    <form class='form-horizontal'>

        <div class='form-group'>
            <label class='col-sm-3 control-label' localized>form.application.configurations.app</label>
            <div class='col-sm-9'>
                <input type="text" disabled="disabled" class="form-control"
                       value="{{application.name}} ({{application.version}})"/>
            </div>
        </div>

        <div class='form-group'>
            <label class='col-sm-3 control-label' localized>form.application.configurations.configs</label>
            <div class='col-sm-9'>
                <div class='configurations-videos panel panel-default'>
                    <div class='panel-body'>

                        <div class="form-group">
                            <div class="col-sm-1">
                                <input type="checkbox" style="margin-top: 12px" ng-model="toggleSelectAll" ng-change="selectAllChanged()">
                            </div>
                            <div class="col-sm-5">
                                <select id='actionGroup'
                                        ng-change="actionGroupChanged()"
                                        ng-model="actionGroup" name="actionGroup"
                                        class="form-control col-sm-4">
                                    <option ng-value="-1" ng-selected="actionGroup == -1" localized>form.configuration.apps.action.select</option>
                                    <option ng-value="1" ng-selected="actionGroup == 1"
                                            ng-if="!isInstallOptionAvailable(application)"
                                            localized>form.configuration.apps.action.permit</option>
                                    <option ng-value="1" ng-selected="actionGroup == 1"
                                            ng-if="isInstallOptionAvailable(application)"
                                            localized>form.configuration.apps.action.install</option>
                                    <option ng-value="0" ng-selected="actionGroup == 0"
                                            ng-if="!isInstallOptionAvailable(application)"
                                            localized>form.configuration.apps.action.prohibit</option>
                                    <option ng-value="0" ng-selected="actionGroup == 0"
                                            ng-if="isInstallOptionAvailable(application)"
                                            localized>form.configuration.apps.action.not.install</option>
                                    <option ng-value="2" ng-selected="actionGroup == 2"
                                            ng-if="isRemoveOptionAvailable(application)"
                                            localized>form.configuration.apps.action.delete</option>
                                </select>
                            </div>
                            <div class='col-sm-6'></div>
                        </div>

                        <hr style="margin-top: 0; margin-bottom: 15px">

                        <div ng-repeat='configuration in configurations | orderBy: "name"' class="form-group">
                            <div class="col-sm-1">
                                <input type="checkbox" style="margin-top: 12px" ng-model="configuration.selected"
                                       ng-change="selectionChanged(configuration)">
                            </div>
                            <div class="col-sm-5">
                                <select id='action{{configuration.configurationId}}'
                                        ng-change="actionChanged(configuration)"
                                        ng-model="configuration.action" name="action{{configuration.configurationId}}"
                                        class="form-control col-sm-4">
                                    <option ng-value="1" ng-selected="configuration.action == 1"
                                            ng-if="!isInstallOptionAvailable(application)"
                                            localized>form.configuration.apps.action.permit</option>
                                    <option ng-value="1" ng-selected="configuration.action == 1"
                                            ng-if="isInstallOptionAvailable(application)"
                                            localized>form.configuration.apps.action.install</option>
                                    <option ng-value="0" ng-selected="configuration.action == 0"
                                            ng-if="!isInstallOptionAvailable(application)"
                                            localized>form.configuration.apps.action.prohibit</option>
                                    <option ng-value="0" ng-selected="configuration.action == 0"
                                            ng-if="isInstallOptionAvailable(application)"
                                            localized>form.configuration.apps.action.not.install</option>
                                    <option ng-value="2" ng-selected="configuration.action == 2"
                                            ng-if="isRemoveOptionAvailable(application)"
                                            localized>form.configuration.apps.action.delete</option>
                                </select>
                            </div>
                            <label style="display:flex; align-items:center; height:34px;" class='col-sm-6' for='action{{configuration.configurationId}}'>{{configuration.configurationName}}</label>
                            <!--<div class="col-sm-2">
                                <button class="btn btn-default" ng-if="configuration.outdated && configuration.action != 2"
                                        ng-click="upgradeApp(configuration)"
                                        title="{{localizeRenewVersionTitle(configuration)}}">
                                    <span class="glyphicon glyphicon-refresh"></span>
                                </button>
                            </div> -->
                        </div>

                    </div>
                </div>
            </div>
        </div>

        <div class='form-group'>
            <div class='col-sm-offset-3 col-sm-8'>
                <button type='submit' class='btn btn-default' ng-click='save()' ng-disabled="loading" localized>button.save</button>
                <button type='button' class='btn btn-default' ng-click='closeModal()' localized>button.cancel</button>
            </div>
        </div>
    </form>
</div>
