<!-- Faraday Penetration Test IDE -->
<!-- Copyright (C) 2013  Infobyte LLC (http://www.infobytesec.com/) -->
<!-- See the file 'doc/LICENSE' for the license information -->

<form name="form" novalidate>
    <div class="modal-header">
        <div class="modal-button btn-toolbar">
            <button class="btn btn-success" ng-disabled="form.$invalid || date.$invalid || workspace.end_date< workspace.start_date" ng-click="okNew()">Save</button>
            <button class="btn btn-danger" ng-click="cancel()">Cancel</button>
        </div>
        <h3 class="modal-title">New Workspace</h3>
    </div>
    <div class="modal-body">
        <div class="form-horizontal">
                <div class="form-group" ng-class="{'has-error': form.name.$invalid && form.name.$dirty}">
                    <div class="col-md-12">
                        <ng-form name="form" novalidate>
                            <label class="sr-only" for="wsp-name">Workspace Name</label>
                            <input type="text" class="form-control"
                                               ng-pattern=/^[a-z0-9][a-z0-9\_\$\(\)\+\-\/]*$/ id="vuln-name" name="name" placeholder="Workspace Name"
                                                                                  ng-model="workspace.name" required/>
                            <div ng-if="form.$invalid && form.name.$dirty">
                                <div class="alert alert-danger target_not_selected" role="alert" ng-hide="">
                                    <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                                    <span class="sr-only">Error:</span>
                                    <button type="button" class="close" data-dismiss="alert"><span area-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                    Workspace name can not contain white spaces or start with uppercase.
                                </div>
                            </div>
                        </ng-form>
                    </div>
                </div><!-- .form-group -->
                <div class="form-group">
                    <div class="col-md-12">
                        <label class="sr-only" for="vuln-desc">Workspace Description</label>
                        <textarea class="form-control" id="vuln-desc"
                                                       placeholder="Description" ng-model="workspace.description"
                                                                                 >
                        </textarea>
                    </div>
            </div><!-- .form-group -->
            <div class="form-group">
                <ng-form name="date" novalidate>
                <div class="col-md-6 datepicker">
                    <label class="sr-only" for="work-start">Start Date</label>
                    <p class="input-group">
                      <input type="text" class="form-control" uib-datepicker-popup="MM/dd/yyyy" ng-model="workspace.start_date" is-open="openedStart" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" close-text="Close" placeholder="Start Date"  />
                      <span class="input-group-btn">
                        <button type="button" class="btn btn-default" ng-click="open($event,true)"><i class="glyphicon glyphicon-calendar"></i></button>
                      </span>
                    </p>
                </div>
                <div class="col-md-6 datepicker">
                    <label class="sr-only" for="work-end">End Date</label>
                    <p class="input-group">
                      <input type="text" class="form-control" uib-datepicker-popup="MM/dd/yyyy" ng-model="workspace.end_date" is-open="openedEnd" datepicker-options="dateOptions" date-disabled="disabled(date, mode)" close-text="Close" placeholder="End Date"  />
                      <span class="input-group-btn">
                        <button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
                      </span>
                    </p>
                </div>
                <div ng-if="date.$invalid || workspace.end_date< workspace.start_date" class="col-md-12">
                    <div class="alert alert-danger target_not_selected" role="alert" ng-hide="">
                        <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                        <span class="sr-only">Error:</span>
                        <button type="button" class="close" data-dismiss="alert"><span area-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                        Invalid Date
                    </div>
                </div>
            </ng-form>
            </div><!-- .form-group -->
            <div class="form-group">
                <div class="col-md-12">
                    <h5>Scope</h5>
                    <span class="input-group-addon button-radius" ng-click="newScope($event)">Add scope target</span>
                </div>
                <div class="col-md-12 input-margin" ng-repeat="scope in workspace.scope">
                    <div class="input-group margin-bottom-sm col-md-12">
                        <input type="text" class="form-control" placeholder="Scope target" ng-model="scope.key"/>
                        <span class="input-group-addon" ng-click="workspace.scope.splice($index, 1)" ng-hide="workspace.scope.length == 1"><i class="fa fa-minus-circle"></i></span>
                    </div>
                </div>
            </div><!-- .form-group -->
        </div><!-- .form-horizontal -->
    </div><!-- .modal-body -->
</form>
