Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix admin reportform dateformat error #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"echarts": "^4.0.4",
"jquery": "^3.3.1",
"js-yaml": "^3.12.0",
"moment": "^2.22.2",
"mutationobserver-shim": "^0.3.2",
"ngx-markdown": "^6.3.0",
"particlesjs": "^2.2.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h2 class="header-title">上线次数统计</h2>
</clr-dg-column>
<clr-dg-row *ngFor="let data of datas;let i=index" [clrDgItem]="data">
<clr-dg-cell class="col-id">{{i}}</clr-dg-cell>
<clr-dg-cell class="col-time">{{data.date | date:'yyyy-MM-dd'}}</clr-dg-cell>
<clr-dg-cell class="col-time">{{data.date | date:'MM-dd-yyyy'}}</clr-dg-cell>
<clr-dg-cell>{{data.count}}</clr-dg-cell>
</clr-dg-row>
</clr-datagrid>
Expand Down
16 changes: 5 additions & 11 deletions src/frontend/src/app/admin/reportform/deploy/deploy.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {BreadcrumbService} from '../../../shared/client/v1/breadcrumb.service';
import {MessageHandlerService} from '../../../shared/message-handler/message-handler.service';
import {PublishService} from '../../../shared/client/v1/publish.service';
import {State} from '@clr/angular';
import * as moment from "moment";

@Component({
selector: 'wayne-deploy',
Expand All @@ -23,17 +24,10 @@ export class DeployComponent implements OnInit {

ngOnInit() {
const now = new Date();
this.startTime = this.formatDate(new Date(now.getTime() - 1000 * 3600 * 24 * 7));
this.endTime = this.formatDate(now);
}

formatDate(time: Date) {
const year: number = time.getFullYear();
const month: any = (time.getMonth() + 1) < 10 ? '0' + (time.getMonth() + 1) : (time.getMonth() + 1);
const day: any = time.getDate() < 10 ? '0' + time.getDate() : time.getDate();
return year + '-' + month + '-' + day;
};
this.startTime = moment(new Date(now.getTime() - 1000 * 3600 * 24 * 7)).format("MM/DD/YYYY");
this.endTime = moment(now).format("MM/DD/YYYY");

}

search() {
this.refresh();
Expand All @@ -43,7 +37,7 @@ export class DeployComponent implements OnInit {
}

refresh(state?: State) {
this.publishService.getDeployStatistics(this.startTime + 'T00:00:00Z', this.endTime + 'T00:00:00Z').subscribe(
this.publishService.getDeployStatistics(moment(this.startTime).format("YYYY-MM-DDTHH:mm:SS")+'Z', moment(this.endTime).format("YYYY-MM-DDTHH:mm:SS")+'Z').subscribe(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这种最好也提一个common func吧,影响不大

resp => {
this.datas = resp.data;
},
Expand Down