Merge branch 'PR' into develop
commit
1d1775a7aa
|
@ -11,14 +11,14 @@ app.controller('EmailMessageOptionController', function(
|
||||||
endDate: moment()
|
endDate: moment()
|
||||||
};
|
};
|
||||||
$scope.dtOptions = {
|
$scope.dtOptions = {
|
||||||
timePicker: false,
|
timePicker: true,
|
||||||
timePicker24Hour: true,
|
timePicker24Hour: true,
|
||||||
timePickerIncrement: 1,
|
timePickerIncrement: 1,
|
||||||
timePickerSeconds: true,
|
timePickerSeconds: true,
|
||||||
startView:2,
|
startView:2,
|
||||||
autoApply: true,
|
autoApply: true,
|
||||||
locale:{
|
locale:{
|
||||||
format: 'YYYY-MM-DD',
|
format: 'YYYY-MM-DDTHH:mm:ss',
|
||||||
applyLabel: "OK",
|
applyLabel: "OK",
|
||||||
cancelLabel: "Cancel",
|
cancelLabel: "Cancel",
|
||||||
},
|
},
|
||||||
|
@ -30,11 +30,12 @@ app.controller('EmailMessageOptionController', function(
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.execute = function() {
|
$scope.execute = function() {
|
||||||
var datestart, dateend;
|
var startdatetime, enddatetime;
|
||||||
var query = {
|
var query = {
|
||||||
datestart: $scope.daterange.startDate.format().slice(0, 10),
|
startdatetime: $scope.daterange.startDate.format().slice(0, 19),
|
||||||
dateend: $scope.daterange.endDate.format().slice(0, 10)
|
enddatetime: $scope.daterange.endDate.format().slice(0, 19)
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$emit('handleEmitEmailMessageOptionChanged', {
|
$scope.$emit('handleEmitEmailMessageOptionChanged', {
|
||||||
load: true,
|
load: true,
|
||||||
period:$scope.currentPeriod
|
period:$scope.currentPeriod
|
||||||
|
|
|
@ -3,7 +3,7 @@ app.factory('EmailMessageAnalysisService', function($http) {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
getAnalysisResult: function(query, headers, callback) {
|
getAnalysisResult: function(query, headers, callback) {
|
||||||
$http.get(getAPI()+"emailmessages"+"/from/"+query.datestart+"/to/"+query.dateend, {headers})
|
$http.get(getAPI()+"emailmessages?" + 'startdatetime=' + query.startdatetime + '&enddatetime=' + query.enddatetime, {headers})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
callback(response);
|
callback(response);
|
||||||
}, function (response) {
|
}, function (response) {
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
<form role="form">
|
<form role="form">
|
||||||
<div class="form-group no-margin">
|
<div class="form-group no-margin">
|
||||||
<label>{{'COMMON.DATE' | translate}}</label>
|
<label>{{'COMMON.DATE' | translate}}</label>
|
||||||
<textarea rows="1" date-range-picker class="form-control date-picker" type="text"
|
<textarea rows="2" date-range-picker class="form-control date-picker" type="text"
|
||||||
ng-model="daterange" options="dtOptions" readonly="" placeholder="请选择日期" />
|
ng-model="daterange" options="dtOptions" readonly="" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -170,7 +170,7 @@ api.add_route('/distributionsystems/{id_}',
|
||||||
api.add_route('/distributionsystems/{id_}/distributioncircuits',
|
api.add_route('/distributionsystems/{id_}/distributioncircuits',
|
||||||
distributionsystem.DistributionSystemDistributionCircuitCollection())
|
distributionsystem.DistributionSystemDistributionCircuitCollection())
|
||||||
|
|
||||||
api.add_route('/emailmessages/from/{startdate}/to/{enddate}',
|
api.add_route('/emailmessages',
|
||||||
emailmessage.EmailMessageCollection())
|
emailmessage.EmailMessageCollection())
|
||||||
api.add_route('/emailmessages/{id_}',
|
api.add_route('/emailmessages/{id_}',
|
||||||
emailmessage.EmailMessageItem())
|
emailmessage.EmailMessageItem())
|
||||||
|
|
|
@ -13,35 +13,45 @@ class EmailMessageCollection:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def on_options(req, resp, startdate, enddate):
|
def on_options(req, resp):
|
||||||
resp.status = falcon.HTTP_200
|
resp.status = falcon.HTTP_200
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def on_get(req, resp, startdate, enddate):
|
def on_get(req, resp):
|
||||||
access_control(req)
|
access_control(req)
|
||||||
try:
|
print(req.params)
|
||||||
start_datetime_local = datetime.strptime(startdate, '%Y-%m-%d')
|
start_datetime_local = req.params.get('startdatetime')
|
||||||
except Exception:
|
end_datetime_local = req.params.get('enddatetime')
|
||||||
raise falcon.HTTPError(falcon.HTTP_400,
|
|
||||||
title='API.BAD_REQUEST',
|
|
||||||
description='API.INVALID_START_DATE_FORMAT')
|
|
||||||
try:
|
|
||||||
end_datetime_local = datetime.strptime(enddate, '%Y-%m-%d')
|
|
||||||
except Exception:
|
|
||||||
raise falcon.HTTPError(falcon.HTTP_400,
|
|
||||||
title='API.BAD_REQUEST',
|
|
||||||
description='API.INVALID_END_DATE_FORMAT')
|
|
||||||
|
|
||||||
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
|
timezone_offset = int(config.utc_offset[1:3]) * 60 + int(config.utc_offset[4:6])
|
||||||
if config.utc_offset[0] == '-':
|
if config.utc_offset[0] == '-':
|
||||||
timezone_offset = -timezone_offset
|
timezone_offset = -timezone_offset
|
||||||
|
|
||||||
start_datetime_utc = start_datetime_local.replace(tzinfo=timezone.utc)
|
if start_datetime_local is None:
|
||||||
start_datetime_utc -= timedelta(minutes=timezone_offset)
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
|
description="API.INVALID_START_DATETIME_FORMAT")
|
||||||
|
else:
|
||||||
|
start_datetime_local = str.strip(start_datetime_local)
|
||||||
|
try:
|
||||||
|
start_datetime_utc = datetime.strptime(start_datetime_local,
|
||||||
|
'%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
|
||||||
|
timedelta(minutes=timezone_offset)
|
||||||
|
except ValueError:
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
|
description="API.INVALID_START_DATETIME_FORMAT")
|
||||||
|
|
||||||
end_datetime_utc = end_datetime_local.replace(tzinfo=timezone.utc)
|
if end_datetime_local is None:
|
||||||
end_datetime_utc -= timedelta(minutes=timezone_offset)
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
end_datetime_utc += timedelta(days=1)
|
description="API.INVALID_END_DATETIME_FORMAT")
|
||||||
|
else:
|
||||||
|
end_datetime_local = str.strip(end_datetime_local)
|
||||||
|
try:
|
||||||
|
end_datetime_utc = datetime.strptime(end_datetime_local,
|
||||||
|
'%Y-%m-%dT%H:%M:%S').replace(tzinfo=timezone.utc) - \
|
||||||
|
timedelta(minutes=timezone_offset)
|
||||||
|
except ValueError:
|
||||||
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
|
description="API.INVALID_END_DATETIME_FORMAT")
|
||||||
|
|
||||||
if start_datetime_utc >= end_datetime_utc:
|
if start_datetime_utc >= end_datetime_utc:
|
||||||
raise falcon.HTTPError(falcon.HTTP_400,
|
raise falcon.HTTPError(falcon.HTTP_400,
|
||||||
|
|
Loading…
Reference in New Issue