This repository has been archived by the owner on Mar 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#49 implement recurring snapshot actions
- Loading branch information
Vladimir Shakhov
committed
Jul 17, 2017
1 parent
9242225
commit 44aac2b
Showing
27 changed files
with
537 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,4 +39,3 @@ | |
{{ 'SAVE' | translate }} | ||
</button> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 39 additions & 3 deletions
42
src/app/snapshot/recurring-snapshots/policy-list/policy-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,39 @@ | ||
<p> | ||
policy-list works! | ||
</p> | ||
<table class="mdl-data-table"> | ||
<thead> | ||
<tr> | ||
<th>{{ 'TIME' | translate }}</th> | ||
<th></th> | ||
<th>{{ 'TIME_ZONE' | translate }}</th> | ||
<th>{{ 'KEEP' | translate }}</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let p of policies"> | ||
<td> | ||
{{ p.timeToken | translate:{ value: p.timeValue } }} | ||
</td> | ||
<td> | ||
{{ p.periodToken | translate: { value: p.periodValue } }} | ||
</td> | ||
<td> | ||
{{ p.timeZone }} | ||
</td> | ||
<td> | ||
{{ p.keep }} | ||
</td> | ||
<td> | ||
<button | ||
(click)="deletePolicy(p)" | ||
[mdl-tooltip]="'DELETE' | translate" | ||
mdl-tooltip-position="bottom" | ||
mdl-button | ||
mdl-button-type="icon" | ||
mdl-ripple | ||
> | ||
<mdl-icon>delete</mdl-icon> | ||
</button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
table { | ||
width: 100%; | ||
} |
103 changes: 97 additions & 6 deletions
103
src/app/snapshot/recurring-snapshots/policy-list/policy-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,108 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { Policy } from '../policy-editor/policy-editor.component'; | ||
import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; | ||
import { DayOfWeek } from '../../../shared/types/day-of-week'; | ||
import { DailyPolicy } from '../policy-editor/daily/daily-policy.component'; | ||
import { HourlyPolicy } from '../policy-editor/hourly/hourly-policy.component'; | ||
import { MonthlyPolicy } from '../policy-editor/monthly/monthly-policy.component'; | ||
import { Policy, TimePolicy } from '../policy-editor/policy-editor.component'; | ||
import { WeeklyPolicy } from '../policy-editor/weekly/weekly-policy.component'; | ||
import { PolicyType } from '../recurring-snapshots.component'; | ||
import { Time } from '../time-picker/time-picker.component'; | ||
|
||
|
||
interface PolicyView { | ||
id: string; | ||
type: PolicyType; | ||
timeToken: string; | ||
timeValue: string; | ||
periodToken: string; | ||
periodValue: string; | ||
timeZone: string; | ||
keep: string; | ||
} | ||
|
||
@Component({ | ||
selector: 'cs-policy-list', | ||
templateUrl: 'policy-list.component.html', | ||
styleUrls: ['policy-list.component.scss'] | ||
}) | ||
export class PolicyListComponent implements OnInit { | ||
@Input() public policies: Array<Policy>; | ||
export class PolicyListComponent implements OnChanges { | ||
@Input() hourlyPolicy: Policy<HourlyPolicy>; | ||
@Input() dailyPolicy: Policy<DailyPolicy>; | ||
@Input() weeklyPolicy: Policy<WeeklyPolicy>; | ||
@Input() monthlyPolicy: Policy<MonthlyPolicy>; | ||
@Output() onPolicyDelete: EventEmitter<Policy<TimePolicy>>; | ||
|
||
public policies: Array<PolicyView>; | ||
|
||
constructor() { } | ||
constructor() { | ||
this.onPolicyDelete = new EventEmitter<Policy<TimePolicy>>(); | ||
} | ||
|
||
public ngOnChanges(): void { | ||
this.updatePolicies(); | ||
} | ||
|
||
public deletePolicy(policy: Policy<TimePolicy>): void { | ||
this.onPolicyDelete.next(policy); | ||
} | ||
|
||
public updatePolicies(): void { | ||
const daysOfWeek = [ | ||
{ value: DayOfWeek.Sunday, name: 'SUNDAY'}, | ||
{ value: DayOfWeek.Monday, name: 'MONDAY'}, | ||
{ value: DayOfWeek.Tuesday, name: 'TUESDAY'}, | ||
{ value: DayOfWeek.Wednesday, name: 'WEDNESDAY'}, | ||
{ value: DayOfWeek.Thursday, name: 'THURSDAY'}, | ||
{ value: DayOfWeek.Friday, name: 'FRIDAY'}, | ||
{ value: DayOfWeek.Saturday, name: 'SATURDAY'}, | ||
]; | ||
|
||
this.policies = [ | ||
...(this.hourlyPolicy ? [{ | ||
id: this.hourlyPolicy.id, | ||
type: PolicyType.Hourly, | ||
timeToken: 'POLICY_HOURLY_TIME', | ||
timeValue: this.hourlyPolicy.timePolicy.minute.toString(), | ||
periodToken: '', | ||
periodValue: '', | ||
timeZone: this.hourlyPolicy.timeZone.zone, | ||
keep: this.hourlyPolicy.storedSnapshots.toString() | ||
}] : []), | ||
...(this.dailyPolicy ? [{ | ||
id: this.dailyPolicy.id, | ||
type: PolicyType.Daily, | ||
timeToken: 'POLICY_DAILY_TIME', | ||
timeValue: this.getTimeString(this.dailyPolicy.timePolicy), | ||
periodToken: '', | ||
periodValue: '', | ||
timeZone: this.dailyPolicy.timeZone.zone, | ||
keep: this.dailyPolicy.storedSnapshots.toString() | ||
}] : []), | ||
...(this.weeklyPolicy ? [{ | ||
id: this.weeklyPolicy.id, | ||
type: PolicyType.Weekly, | ||
timeToken: 'POLICY_WEEKLY_TIME', | ||
timeValue: this.getTimeString(this.weeklyPolicy.timePolicy), | ||
periodToken: 'POLICY_WEEKLY_PERIOD', | ||
periodValue: daysOfWeek.find(_ => _.value === this.weeklyPolicy.timePolicy.dayOfWeek).name, | ||
timeZone: this.weeklyPolicy.timeZone.zone, | ||
keep: this.weeklyPolicy.storedSnapshots.toString() | ||
}] : []), | ||
...(this.monthlyPolicy ? [{ | ||
id: this.monthlyPolicy.id, | ||
type: PolicyType.Monthly, | ||
timeToken: 'POLICY_MONTHLY_TIME', | ||
timeValue: this.getTimeString(this.monthlyPolicy.timePolicy), | ||
periodToken: 'POLICY_MONTHLY_PERIOD', | ||
periodValue: this.monthlyPolicy.timePolicy.dayOfMonth.toString(), | ||
timeZone: this.monthlyPolicy.timeZone.zone, | ||
keep: this.monthlyPolicy.storedSnapshots.toString() | ||
}] : []) | ||
]; | ||
} | ||
|
||
public ngOnInit(): void { | ||
private getTimeString(time: Time): string { | ||
// todo am/pm | ||
return `${time.hour}:${time.minute} ${time.period}`; | ||
} | ||
} |
Empty file.
Empty file.
17 changes: 0 additions & 17 deletions
17
src/app/snapshot/recurring-snapshots/policy/policy.component.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.