moved category before fdd_code of rule in admin UI and API

pull/24/head
13621160019@163.com 2021-03-23 10:51:34 +08:00
parent c9aa2a1f23
commit cee412557a
4 changed files with 31 additions and 33 deletions

View File

@ -3,12 +3,10 @@
app.controller('RuleController', function($scope, $common, $uibModal, $translate, RuleService, toaster, SweetAlert) {
$scope.initExpression = [{
"spaceid": 1,
"sample_object_id": 1,
"limit": 1000.000,
"recipients": [{
"user_id": "1"
}, {
"user_id": "2"
}]
}];

View File

@ -11,8 +11,8 @@
<tr>
<th >{{'SETTING.ID' | translate}}</th>
<th >{{'SETTING.NAME' | translate}}</th>
<th >{{'FDD.FDD_CODE' | translate}}</th>
<th >{{'FDD.CATEGORY' | translate}}</th>
<th >{{'FDD.FDD_CODE' | translate}}</th>
<th >{{'FDD.PRIORITY' | translate}}</th>
<th >{{'FDD.CHANNEL' | translate}}</th>
<th >{{'FDD.IS_ENABLED' | translate}}</th>
@ -28,8 +28,8 @@
<tr ng-repeat="rule in rules">
<td >{{ rule.id }}</td>
<td >{{ rule.name }}</td>
<td >{{ rule.fdd_code }}</td>
<td >{{ rule.category }}</td>
<td >{{ rule.fdd_code }}</td>
<td >{{ rule.priority }}</td>
<td >{{ rule.channel }}</td>
<td >{{ rule.is_enabled==true?'SETTING.ON':'SETTING.OFF' | translate}}</td>

View File

@ -6,15 +6,33 @@
<form role="form" name="form_rule" novalidate class="form-horizontal">
<div class="form-group"><label class="col-sm-2 control-label">{{'SETTING.NAME' | translate}}</label>
<div class="col-sm-10"><input ng-model="rule.name" type="text" name="rulename" class="form-control" required="">
<div class="col-sm-5"><input ng-model="rule.name" type="text" name="rulename" class="form-control" required="">
<div class="m-t-xs" ng-show="form_rule.rulename.$invalid && form_rule.rulename.$dirty">
<small class="text-danger" ng-show="form_rule.rulename.$error.required">{{'SETTING.INPUT_NAME' | translate}}</small>
</div>
</div>
</div>
<div class="hr-line-dashed"></div>
<div class="form-group"><label class="col-sm-2 control-label">{{'FDD.CATEGORY' | translate}}</label>
<div class="col-sm-5">
<select name="category" ng-model="rule.category" class="form-control m-b">
<option value="SYSTEM">SYSTEM</option>
<option value="REALTIME">REALTIME</option>
<option value="SPACE">SPACE</option>
<option value="METER">METER</option>
<option value="TENANT">TENANT</option>
<option value="STORE">STORE</option>
<option value="SHOPFLOOR">SHOPFLOOR</option>
<option value="EQUIPMENT">EQUIPMENT</option>
<option value="COMBINEDEQUIPMENT">COMBINEDEQUIPMENT</option>
</select>
<div class="m-t-xs" ng-show="form_rule.category.$invalid && form_rule.category.$dirty">
<small class="text-danger" ng-show="form_rule.category.$error.required">-</small>
</div>
</div>
</div>
<div class="form-group"><label class="col-sm-2 control-label">{{'FDD.FDD_CODE' | translate}}</label>
<div class="col-sm-10">
<div class="col-sm-5">
<select name="fdd_code" ng-model="rule.fdd_code" class="form-control m-b">
<option value="SYSTEM01">SYSTEM01</option>
<option value="SYSTEM02">SYSTEM02</option>
@ -54,26 +72,8 @@
</div>
</div>
</div>
<div class="form-group"><label class="col-sm-2 control-label">{{'FDD.CATEGORY' | translate}}</label>
<div class="col-sm-10">
<select name="category" ng-model="rule.category" class="form-control m-b">
<option value="SYSTEM">SYSTEM</option>
<option value="REALTIME">REALTIME</option>
<option value="SPACE">SPACE</option>
<option value="METER">METER</option>
<option value="TENANT">TENANT</option>
<option value="STORE">STORE</option>
<option value="SHOPFLOOR">SHOPFLOOR</option>
<option value="EQUIPMENT">EQUIPMENT</option>
<option value="COMBINEDEQUIPMENT">COMBINEDEQUIPMENT</option>
</select>
<div class="m-t-xs" ng-show="form_rule.category.$invalid && form_rule.category.$dirty">
<small class="text-danger" ng-show="form_rule.category.$error.required">-</small>
</div>
</div>
</div>
<div class="form-group"><label class="col-sm-2 control-label">{{'FDD.PRIORITY' | translate}}</label>
<div class="col-sm-10">
<div class="col-sm-5">
<select name="priority" ng-model="rule.priority" class="form-control m-b">
<option value="CRITICAL">CRITICAL</option>
<option value="HIGH">HIGH</option>
@ -86,7 +86,7 @@
</div>
</div>
<div class="form-group"><label class="col-sm-2 control-label">{{'FDD.CHANNEL' | translate}}</label>
<div class="col-sm-10">
<div class="col-sm-5">
<select name="channel" ng-model="rule.channel" class="form-control m-b">
<option value="WEB">WEB</option>
<option value="SMS">SMS</option>

View File

@ -143,13 +143,13 @@ class RuleCollection:
description='API.RULE_NAME_IS_ALREADY_IN_USE')
add_row = (" INSERT INTO tbl_rules "
" (name, uuid, fdd_code, category, priority, "
" (name, uuid, category, fdd_code, priority, "
" channel, expression, message_template, is_enabled) "
" VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) ")
cursor.execute(add_row, (name,
str(uuid.uuid4()),
fdd_code,
category,
fdd_code,
priority,
channel,
expression,
@ -183,7 +183,7 @@ class RuleItem:
cursor = cnx.cursor(dictionary=True)
query = (" SELECT id, name, uuid, "
" fdd_code, category, priority, "
" category, fdd_code, priority, "
" channel, expression, message_template, "
" is_enabled, last_run_datetime_utc, next_run_datetime_utc "
" FROM tbl_rules "
@ -204,7 +204,7 @@ class RuleItem:
next_run_datetime = row['next_run_datetime_utc'].replace(tzinfo=timezone.utc).timestamp() * 1000
result = {"id": row['id'], "name": row['name'], "uuid": row['uuid'],
"fdd_code": row['fdd_code'], "category": row['category'], "priority": row['priority'],
"category": row['category'], "fdd_code": row['fdd_code'], "priority": row['priority'],
"channel": row['channel'], "expression": row['expression'],
"message_template": row['message_template'].replace("<br>", ""),
"is_enabled": bool(row['is_enabled']),
@ -342,13 +342,13 @@ class RuleItem:
description='API.RULE_NAME_IS_ALREADY_IN_USE')
update_row = (" UPDATE tbl_rules "
" SET name = %s, fdd_code = %s, category = %s, priority = %s, "
" SET name = %s, category = %s, fdd_code = %s, priority = %s, "
" channel = %s, expression = %s, message_template = %s, "
" is_enabled = %s "
" WHERE id = %s ")
cursor.execute(update_row, (name,
fdd_code,
category,
fdd_code,
priority,
channel,
expression,