| @@ -10,63 +10,62 @@ struct ScheduledReportsView: View { |
| 10 | var body: some View { |
10 | var body: some View { |
| 11 | List { |
11 | List { |
| 12 | Section("Overview") { |
12 | Section("Overview") { |
| 13 | VStack(alignment: .leading, spacing: 8) { |
13 | if !FeatureAccessService.hasAccess(to: .automatedMonitoring) { |
| 14 | if !FeatureAccessService.hasAccess(to: .automatedMonitoring) { |
14 | Text("Scheduled reports require Pro.") |
| 15 | Text("Scheduled reports require Pro.") |
15 | .font(appDensity.font(.caption)) |
| 16 | .font(appDensity.font(.caption)) |
16 | .foregroundStyle(.secondary) |
| 17 | .foregroundStyle(.secondary) |
17 | } |
| 18 | } |
| |
| 19 | |
18 | |
| 20 | Toggle("Scheduled Reports", isOn: Binding( |
19 | Toggle("Scheduled Reports", isOn: Binding( |
| 21 | get: { settings.isEnabled }, |
20 | get: { settings.isEnabled }, |
| 22 | set: { newValue in |
21 | set: { newValue in |
| 23 | settings.isEnabled = newValue |
22 | settings.isEnabled = newValue |
| 24 | saveSettings() |
23 | saveSettings() |
| 25 | } |
24 | } |
| 26 | )) |
25 | )) |
| 27 | .disabled(!FeatureAccessService.hasAccess(to: .automatedMonitoring)) |
26 | .disabled(!FeatureAccessService.hasAccess(to: .automatedMonitoring)) |
| 28 | |
27 | |
| 29 | Picker("Cadence", selection: Binding( |
28 | Picker("Cadence", selection: Binding( |
| 30 | get: { settings.cadence }, |
29 | get: { settings.cadence }, |
| 31 | set: { newValue in |
30 | set: { newValue in |
| 32 | settings.cadence = newValue |
31 | settings.cadence = newValue |
| 33 | saveSettings() |
32 | saveSettings() |
| 34 | } |
| |
| 35 | )) { |
| |
| 36 | ForEach(ScheduledReportCadence.allCases) { cadence in |
| |
| 37 | Text(cadence.title).tag(cadence) |
| |
| 38 | } |
| |
| 39 | } |
33 | } |
| |
34 | )) { |
| |
35 | ForEach(ScheduledReportCadence.allCases) { cadence in |
| |
36 | Text(cadence.title).tag(cadence) |
| |
37 | } |
| |
38 | } |
| |
39 | .disabled(!FeatureAccessService.hasAccess(to: .automatedMonitoring)) |
| 40 | |
40 | |
| 41 | Picker("Format", selection: Binding( |
41 | Picker("Format", selection: Binding( |
| 42 | get: { settings.format }, |
42 | get: { settings.format }, |
| 43 | set: { newValue in |
43 | set: { newValue in |
| 44 | settings.format = newValue |
44 | settings.format = newValue |
| 45 | saveSettings() |
45 | saveSettings() |
| 46 | } |
| |
| 47 | )) { |
| |
| 48 | ForEach([DomainExportFormat.markdown, .pdf, .json]) { format in |
| |
| 49 | Text(format.title).tag(format) |
| |
| 50 | } |
| |
| 51 | } |
46 | } |
| |
47 | )) { |
| |
48 | ForEach([DomainExportFormat.markdown, .pdf, .json]) { format in |
| |
49 | Text(format.title).tag(format) |
| |
50 | } |
| |
51 | } |
| |
52 | .disabled(!FeatureAccessService.hasAccess(to: .automatedMonitoring)) |
| 52 | |
53 | |
| 53 | LabeledContent( |
54 | LabeledContent( |
| 54 | "Last Generated", |
55 | "Last Generated", |
| 55 | value: settings.lastGeneratedAt?.formatted(date: .abbreviated, time: .shortened) ?? "Never" |
56 | value: settings.lastGeneratedAt?.formatted(date: .abbreviated, time: .shortened) ?? "Never" |
| 56 | ) |
57 | ) |
| 57 | |
58 | |
| 58 | if let statusMessage { |
59 | if let statusMessage { |
| 59 | Text(statusMessage) |
60 | Text(statusMessage) |
| 60 | .font(appDensity.font(.caption)) |
61 | .font(appDensity.font(.caption)) |
| 61 | .foregroundStyle(.secondary) |
62 | .foregroundStyle(.secondary) |
| 62 | } |
63 | } |
| 63 | |
64 | |
| 64 | Button(isGenerating ? "Generating…" : "Generate Now") { |
65 | Button(isGenerating ? "Generating…" : "Generate Now") { |
| 65 | Task { await generateNow() } |
66 | Task { await generateNow() } |
| 66 | } |
| |
| 67 | .disabled(isGenerating) |
| |
| 68 | } |
67 | } |
| 69 | .padding(.vertical, 4) |
68 | .disabled(isGenerating || !FeatureAccessService.hasAccess(to: .automatedMonitoring)) |
| 70 | } |
69 | } |
| 71 | .listRowBackground(Color(.systemGray6).opacity(0.5)) |
70 | .listRowBackground(Color(.systemGray6).opacity(0.5)) |
| 72 | |
71 | |