<!-- Bread crumb is created dynamically -->
<!--
	The ID "widget-grid" will start to initialize all widgets below
	You do not need to use widgets if you dont want to. Simply remove
	the <section></section> and you can use wells or panels instead
	-->
<!-- widget grid -->
<section id="widget-grid" class="">

	<!-- row -->
	<div class="row">

		<!-- NEW WIDGET START -->
		<article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">

			<!-- Widget ID (each widget will need unique ID)-->
			<div class="jarviswidget" id="wid-id-4">
				<!-- widget options:
                usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

                data-widget-colorbutton="false"
                data-widget-editbutton="false"
                data-widget-togglebutton="false"
                data-widget-deletebutton="false"
                data-widget-fullscreenbutton="false"
                data-widget-custombutton="false"
                data-widget-collapsed="true"
                data-widget-sortable="false"

                -->
				<header>
					<span class="widget-icon"> <i class="fa fa-table"></i> </span>
					<h2>任务调度</h2>
				</header>
				<!-- widget div-->
				<div>
					<!-- widget edit box -->
					<div class="jarviswidget-editbox">
						<!-- This area used as dropdown edit box -->
					</div>
					<!-- end widget edit box -->
					<!-- widget content -->
					<div class="widget-body no-padding">
						<div class="dt-toolbar">
							<div class="col-xs-11 col-sm-10">
								<div class="dataTables_filter">
									<label>
										<span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
										<input type="search" placeholder="任务名称/任务属组/任务描述" data-ng-keyup="getScheduleList()" ng-model="queryParam.keyword" class="form-control" aria-controls="dt_basic"></label>
								</div>
							</div>
							<div class="col-xs-1 col-sm-2">
								<button class="btn btn-primary" type="button" data-ng-click="open()">
									<i class="fa fa-plus"></i>
									新增定时任务
								</button>
							</div>
						</div>
						<div class="table-responsive">
							<table class="table table-striped table-condensed table-hover smart-form has-tickbox">
								<thead>
									<tr>
										<th>
											<label class="checkbox">
												<input type="checkbox" name="checkbox-inline">
												<i></i>
											</label>
										</th>
										<th>任务属组</th>
										<th>任务名称</th>
										<th>状态</th>
										<th>触发器ID</th>
										<th>描述</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<tr ng-repeat="schedule in scheduleList"  ng-if="scheduleList.length > 0">
										<td>
											<label class="checkbox">
												<input type="checkbox" name="checkbox-inline">
												<i></i>
											</label>
										</td>
										<td ng-bind="schedule.jobGroup"></td>
										<td ng-bind="schedule.jobName"></td>
										<td ng-bind="schedule.jobStatusDesc"></td>
										<td ng-bind="schedule.triggerId"></td>
										<td ng-bind="schedule.jobDescription"></td>
										<td>
											<!-- Split button -->
											<div class="btn-group" dropdown>
												<button type="button" class="btn btn-primary" data-ng-click="openView($index, 'lg')">查看</button>
												<button type="button" class="btn btn-primary dropdown-toggle">
													<span class="caret"></span>
													<span class="sr-only">Split button!</span>
												</button>
												<ul class="dropdown-menu" role="menu">
													<li>
														<a href="javascript:void(0);" data-ng-click="restart($index)">重启</a>
													</li>
													<li>
														<a href="javascript:void(0);" data-ng-click="pause($index)">暂停</a>
													</li>
													<li>
														<a href="javascript:void(0);" data-ng-click="remove($index)">删除</a>
													</li>
													<li class="divider"></li>
													<li>
														<a href="javascript:void(0);" data-ng-click="openView($index)">查看</a>
													</li>
													<li>
														<a href="javascript:void(0);" data-ng-click="openUpdate($index)">编辑</a>
													</li>
												</ul>
											</div>
										</td>
									</tr>
									<tr ng-if="scheduleList == null || scheduleList.length == 0">
										<td colspan="8">
											<div>暂无消息数据</div>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
						<div class="dt-toolbar-footer">
							<div class="col-xs-12 col-sm-12">
								<ug-pagination page-info="pageInfoSetting" ></ug-pagination>
							</div>
						</div>
					</div>
					<!-- end widget content -->
				</div>
				<!-- end widget div -->
			</div>
			<!-- end widget -->
		</article>
		<!-- WIDGET END -->
	</div>
	<!-- end row -->
</section>
<!-- end widget grid -->

<script type="text/ng-template" id="addScheduleJob.html">
	<div class="modal-header">
		<h3 class="modal-title">添加定时任务</h3>
	</div>
	<div class="modal-body">
		<form class="form-horizontal" ug-validate="addScheduleForm" name="addScheduleForm" novalidate="">

			<fieldset>
				<div class="form-group">
					<label class="col-md-2 control-label">任务属组</label>
					<div class="col-md-10 input-group">
						<input class="form-control" required="true" data-rule-maxlength="20" ng-model="schedule.jobGroup" name="jobGroup" placeholder="任务属组" type="text">
					</div>
				</div>

				<div class="form-group">
					<label class="col-md-2 control-label">任务名称</label>
					<div class="col-md-10 input-group">
						<input class="form-control" required="true" data-rule-maxlength="20" ng-model="schedule.jobName" name="jobName" placeholder="任务名称" type="text">
					</div>
				</div>

				<div class="form-group">
					<label class="col-md-2 control-label">任务描述</label>
					<div class="col-md-10 input-group">
						<input class="form-control" required="true" data-rule-maxlength="200" ng-model="schedule.description" name="description" placeholder="任务描述" type="text" >
					</div>
				</div>

				<div class="form-group">
					<label class="col-md-2 control-label">cron规则</label>
					<div class="col-md-10 input-group">
						<input class="form-control" required="true" data-rule-maxlength="200" ng-model="schedule.cronExpression" name="cronExpression" placeholder="请输入cron表达式" type="text">
						<div class="input-group-btn open">
							<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" tabindex="-1" title="点击查看cron表达式示例">
								<i class="icon-append fa fa-question-circle"></i>
								<!--<span class="caret"></span>-->
							</button>
							<ul class="dropdown-menu pull-right" role="menu">
								<li>
									<div>
										每隔5秒执行一次：*/5 * * * * ?<br>
										每隔1分钟执行一次：0 */1 * * * ?<br>
										每天23点执行一次：0 0 23 * * ?<br>
										每天凌晨1点执行一次：0 0 1 * * ?<br>
										每月1号凌晨1点执行一次：0 0 1 1 * ?<br>
										每月最后一天23点执行一次：0 0 23 L * ?<br>
										每周星期天凌晨1点实行一次：0 0 1 ? * L<br>
										在26分、29分、33分执行一次：0 26,29,33 * * * ?<br>
										每天的0点、13点、18点、21点都执行一次：0 0 0,13,18,21 * * ?<br>
									</div>
								</li>
							</ul>
						</div>
					</div>
				</div>

				<div class="form-group">
					<label class="col-md-2 control-label">触发器模板</label>
					<div class="col-md-10 input-group">
						<select class="form-control" required="true" ng-options="item.triggerKey as item.triggerName for item in scheduleTemplates" ng-model="schedule.jobTriggerId" name="jobTriggerId">
							<option value="">请选择</option>
						</select>
					</div>
				</div>

				<div class="form-group">
					<label class="col-md-2 control-label">是否运行</label>
					<div class="col-md-10 input-group">
						<div class="checkbox">
							<label>
								<input type="checkbox" ng-model="schedule.started" ng-init="schedule.started=false" class="checkbox style-0" name="started" checked="checked" ng-true-value="true" ng-false-value="false">
								<span>勾选开启任务</span>
							</label>
						</div>
					</div>
				</div>
				<div class="form-group" ng-if="errors">
					<label class="col-md-2 control-label"></label>
					<div class="col-md-10" style="color: red;" >
						{{errors}}
					</div>
				</div>
			</fieldset>
		</form>
	</div>
	<div class="modal-footer">
		<button class="btn btn-primary" type="button" data-ng-click="addSchedule()">
			<i class="fa fa-save"></i>
			保存
		</button>
		<button class="btn btn-warning" ng-click="cancel()">关闭</button>
	</div>
</script>

<script type="text/ng-template" id="updateScheduleJob.html">
	<div class="modal-header">
		<h3 class="modal-title">编辑定时任务</h3>
	</div>
	<div class="modal-body">
		<form class="form-horizontal" ug-validate="updateScheduleForm" name="updateScheduleForm" novalidate="">

			<fieldset>
				<div class="form-group">
					<label class="col-md-2 control-label">任务属组</label>
					<div class="col-md-10 input-group">
						<input ng-model="schedule.id" name="id" type="hidden">
						<input class="form-control" required="true" data-rule-maxlength="20" ng-model="schedule.jobGroup" name="jobGroup" placeholder="任务属组" type="text" ng-disabled="setting.disabled">
					</div>
				</div>

				<div class="form-group">
					<label class="col-md-2 control-label">任务名称</label>
					<div class="col-md-10 input-group">
						<input class="form-control" required="true" data-rule-maxlength="20" ng-model="schedule.jobName" name="jobName" placeholder="任务名称" type="text" ng-disabled="setting.disabled">
					</div>
				</div>

				<div class="form-group">
					<label class="col-md-2 control-label">任务描述</label>
					<div class="col-md-10 input-group">
						<input class="form-control" required="true" data-rule-maxlength="200" ng-model="schedule.jobDescription" name="description" placeholder="任务描述" type="text"  ng-disabled="setting.disabled">
					</div>
				</div>

				<div class="form-group">
					<label class="col-md-2 control-label">cron规则</label>
					<div class="col-md-10 input-group">
						<input class="form-control" required="true" data-rule-maxlength="200" ng-model="schedule.cronExpression" name="cronExpression" placeholder="请输入cron表达式" type="text" ng-disabled="setting.disabled">
						<div class="input-group-btn open">
							<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" tabindex="-1" title="点击查看cron表达式示例">
								<i class="icon-append fa fa-question-circle"></i>
								<!--<span class="caret"></span>-->
							</button>
							<ul class="dropdown-menu pull-right" role="menu">
								<li>
									<div>
										每隔5秒执行一次：*/5 * * * * ?<br>
										每隔1分钟执行一次：0 */1 * * * ?<br>
										每天23点执行一次：0 0 23 * * ?<br>
										每天凌晨1点执行一次：0 0 1 * * ?<br>
										每月1号凌晨1点执行一次：0 0 1 1 * ?<br>
										每月最后一天23点执行一次：0 0 23 L * ?<br>
										每周星期天凌晨1点实行一次：0 0 1 ? * L<br>
										在26分、29分、33分执行一次：0 26,29,33 * * * ?<br>
										每天的0点、13点、18点、21点都执行一次：0 0 0,13,18,21 * * ?<br>
									</div>
								</li>
							</ul>
						</div>
					</div>
				</div>

				<div class="form-group">
					<label class="col-md-2 control-label">触发器模板</label>
					<div class="col-md-10 input-group">
						<select class="form-control" required="true" ng-options="item.triggerKey as item.triggerName for item in scheduleTemplates" ng-model="schedule.triggerId" name="triggerId" ng-disabled="setting.disabled">
							<option value="">请选择</option>
						</select>
					</div>
				</div>

				<div class="form-group" ng-if="errors">
					<label class="col-md-2 control-label"></label>
					<div class="col-md-10" style="color: red;" >
						{{errors}}
					</div>
				</div>
			</fieldset>
		</form>
	</div>
	<div class="modal-footer">
		<button class="btn btn-primary" type="button" data-ng-click="updateSchedule()" ng-hide="setting.disabled">
			<i class="fa fa-save"></i>
			保存
		</button>
		<button class="btn btn-warning" ng-click="cancel()">关闭</button>
	</div>
</script>