diff --git a/.DS_Store b/.DS_Store index 8a09867..6e1dea6 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/HealthcheckIntents/Info.plist b/HealthcheckIntents/Info.plist index ff3268a..8521c02 100644 --- a/HealthcheckIntents/Info.plist +++ b/HealthcheckIntents/Info.plist @@ -12,6 +12,7 @@ IntentsSupported + ConfigurationFourIntent ConfigurationIntent diff --git a/HealthcheckIntents/IntentHandler.swift b/HealthcheckIntents/IntentHandler.swift index 14d2e20..2fc6341 100644 --- a/HealthcheckIntents/IntentHandler.swift +++ b/HealthcheckIntents/IntentHandler.swift @@ -24,7 +24,7 @@ class IntentHandler: INExtension, ConfigurationIntentHandling { let shrinkedEventList = hcr.domain.sorted { $0.name > $1.name } shrinkedEventList.forEach { health in - var healthStatus = HealthcheckSymbol(identifier: health.healthtoken, display: health.name) + let healthStatus = HealthcheckSymbol(identifier: health.healthtoken, display: health.name) healthStatus.events = [] health.events.forEach { e in let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) @@ -54,7 +54,130 @@ class IntentHandler: INExtension, ConfigurationIntentHandling { let shrinkedEventList = hcr.domain.sorted { $0.name > $1.name } shrinkedEventList.forEach { health in - var healthStatus = HealthcheckSymbol(identifier: health.healthtoken, display: health.name) + let healthStatus = HealthcheckSymbol(identifier: health.healthtoken, display: health.name) + healthStatus.events = [] + health.events.forEach { e in + let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) + healthStatus.events?.append(event) + } + + symbols.append(healthStatus) + } + // Create a collection with the array of characters. + let collection = INObjectCollection(items: symbols) + print("Collection") + // Call the completion handler, passing the collection. + return collection + } + +} + +class IntentFourHandler: INExtension, ConfigurationFourIntentHandling { + + func resolveHealthcheckSymbol11(for intent: ConfigurationFourIntent) async -> HealthcheckSymbolResolutionResult { + return .success(with: HealthcheckSymbol(identifier: "", display: "")) + } + + func provideHealthcheckSymbol11OptionsCollection(for intent: ConfigurationFourIntent) async throws -> INObjectCollection { + var symbols:[HealthcheckSymbol] = [] + + let api = NetworkServices() + let hcd = DummyData.HealthcheckListCustom(customCount: 4) + let hcr = await api.GetHealthchecks() ?? HealthCheckResult(domain: hcd) + + let shrinkedEventList = hcr.domain.sorted { $0.name > $1.name } + shrinkedEventList.forEach { health in + let healthStatus = HealthcheckSymbol(identifier: health.healthtoken, display: health.name) + healthStatus.events = [] + health.events.forEach { e in + let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) + healthStatus.events?.append(event) + } + + symbols.append(healthStatus) + } + // Create a collection with the array of characters. + let collection = INObjectCollection(items: symbols) + print("Collection") + // Call the completion handler, passing the collection. + return collection + } + + func resolveHealthcheckSymbol12(for intent: ConfigurationFourIntent) async -> HealthcheckSymbolResolutionResult { + return .success(with: HealthcheckSymbol(identifier: "", display: "")) + } + + + func provideHealthcheckSymbol12OptionsCollection(for intent: ConfigurationFourIntent) async throws -> INObjectCollection { + var symbols:[HealthcheckSymbol] = [] + + let api = NetworkServices() + let hcd = DummyData.HealthcheckListCustom(customCount: 4) + let hcr = await api.GetHealthchecks() ?? HealthCheckResult(domain: hcd) + + let shrinkedEventList = hcr.domain.sorted { $0.name > $1.name } + shrinkedEventList.forEach { health in + let healthStatus = HealthcheckSymbol(identifier: health.healthtoken, display: health.name) + healthStatus.events = [] + health.events.forEach { e in + let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) + healthStatus.events?.append(event) + } + + symbols.append(healthStatus) + } + // Create a collection with the array of characters. + let collection = INObjectCollection(items: symbols) + print("Collection") + // Call the completion handler, passing the collection. + return collection + } + + func resolveHealthcheckSymbol21(for intent: ConfigurationFourIntent) async -> HealthcheckSymbolResolutionResult { + return .success(with: HealthcheckSymbol(identifier: "", display: "")) + } + + + func provideHealthcheckSymbol21OptionsCollection(for intent: ConfigurationFourIntent) async throws -> INObjectCollection { + var symbols:[HealthcheckSymbol] = [] + + let api = NetworkServices() + let hcd = DummyData.HealthcheckListCustom(customCount: 4) + let hcr = await api.GetHealthchecks() ?? HealthCheckResult(domain: hcd) + + let shrinkedEventList = hcr.domain.sorted { $0.name > $1.name } + shrinkedEventList.forEach { health in + let healthStatus = HealthcheckSymbol(identifier: health.healthtoken, display: health.name) + healthStatus.events = [] + health.events.forEach { e in + let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) + healthStatus.events?.append(event) + } + + symbols.append(healthStatus) + } + // Create a collection with the array of characters. + let collection = INObjectCollection(items: symbols) + print("Collection") + // Call the completion handler, passing the collection. + return collection + } + + func resolveHealthcheckSymbol22(for intent: ConfigurationFourIntent) async -> HealthcheckSymbolResolutionResult { + return .success(with: HealthcheckSymbol(identifier: "", display: "")) + } + + + func provideHealthcheckSymbol22OptionsCollection(for intent: ConfigurationFourIntent) async throws -> INObjectCollection { + var symbols:[HealthcheckSymbol] = [] + + let api = NetworkServices() + let hcd = DummyData.HealthcheckListCustom(customCount: 4) + let hcr = await api.GetHealthchecks() ?? HealthCheckResult(domain: hcd) + + let shrinkedEventList = hcr.domain.sorted { $0.name > $1.name } + shrinkedEventList.forEach { health in + let healthStatus = HealthcheckSymbol(identifier: health.healthtoken, display: health.name) healthStatus.events = [] health.events.forEach { e in let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) diff --git a/HealthcheckWidget/HealthcheckWidget.intentdefinition b/HealthcheckWidget/HealthcheckWidget.intentdefinition index 5f028a4..6ef7f0c 100644 --- a/HealthcheckWidget/HealthcheckWidget.intentdefinition +++ b/HealthcheckWidget/HealthcheckWidget.intentdefinition @@ -9,11 +9,11 @@ INIntentDefinitionNamespace 88xZPY INIntentDefinitionSystemVersion - 22D49 + 23C5030f INIntentDefinitionToolsBuildVersion - 14C18 + 15A507 INIntentDefinitionToolsVersion - 14.2 + 15.0.1 INIntents @@ -179,6 +179,291 @@ INIntentVerb View + + INIntentCategory + information + INIntentDescriptionID + 8wbr0p + INIntentEligibleForWidgets + + INIntentIneligibleForSuggestions + + INIntentLastParameterTag + 8 + INIntentName + ConfigurationFour + INIntentParameters + + + INIntentParameterConfigurable + + INIntentParameterCustomDisambiguation + + INIntentParameterDisplayName + Healthcheck 11 + INIntentParameterDisplayNameID + mHBNN8 + INIntentParameterDisplayPriority + 1 + INIntentParameterName + healthcheckSymbol11 + INIntentParameterObjectType + HealthcheckSymbol + INIntentParameterObjectTypeNamespace + 88xZPY + INIntentParameterPromptDialogs + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Configuration + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Primary + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + There are ${count} options matching ‘${healthcheckSymbol11}’. + INIntentParameterPromptDialogFormatStringID + wSoKH0 + INIntentParameterPromptDialogType + DisambiguationIntroduction + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + Just to confirm, you wanted ‘${healthcheckSymbol11}’? + INIntentParameterPromptDialogFormatStringID + VvCtzh + INIntentParameterPromptDialogType + Confirmation + + + INIntentParameterSupportsDynamicEnumeration + + INIntentParameterSupportsResolution + + INIntentParameterTag + 2 + INIntentParameterType + Object + + + INIntentParameterConfigurable + + INIntentParameterCustomDisambiguation + + INIntentParameterDisplayName + Healthcheck 12 + INIntentParameterDisplayNameID + Cglmh8 + INIntentParameterDisplayPriority + 2 + INIntentParameterName + healthcheckSymbol12 + INIntentParameterObjectType + HealthcheckSymbol + INIntentParameterObjectTypeNamespace + 88xZPY + INIntentParameterPromptDialogs + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Configuration + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Primary + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + There are ${count} options matching ‘${healthcheckSymbol12}’. + INIntentParameterPromptDialogFormatStringID + 4eRFjP + INIntentParameterPromptDialogType + DisambiguationIntroduction + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + Just to confirm, you wanted ‘${healthcheckSymbol12}’? + INIntentParameterPromptDialogFormatStringID + x74QSv + INIntentParameterPromptDialogType + Confirmation + + + INIntentParameterSupportsDynamicEnumeration + + INIntentParameterSupportsResolution + + INIntentParameterTag + 6 + INIntentParameterType + Object + + + INIntentParameterConfigurable + + INIntentParameterCustomDisambiguation + + INIntentParameterDisplayName + Healthcheck 21 + INIntentParameterDisplayNameID + dY84q6 + INIntentParameterDisplayPriority + 3 + INIntentParameterName + healthcheckSymbol21 + INIntentParameterObjectType + HealthcheckSymbol + INIntentParameterObjectTypeNamespace + 88xZPY + INIntentParameterPromptDialogs + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Configuration + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Primary + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + There are ${count} options matching ‘${healthcheckSymbol21}’. + INIntentParameterPromptDialogFormatStringID + 5644n8 + INIntentParameterPromptDialogType + DisambiguationIntroduction + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + Just to confirm, you wanted ‘${healthcheckSymbol21}’? + INIntentParameterPromptDialogFormatStringID + t3q63i + INIntentParameterPromptDialogType + Confirmation + + + INIntentParameterSupportsDynamicEnumeration + + INIntentParameterSupportsResolution + + INIntentParameterTag + 7 + INIntentParameterType + Object + + + INIntentParameterConfigurable + + INIntentParameterCustomDisambiguation + + INIntentParameterDisplayName + Healthcheck 22 + INIntentParameterDisplayNameID + 80skR6 + INIntentParameterDisplayPriority + 4 + INIntentParameterName + healthcheckSymbol22 + INIntentParameterObjectType + HealthcheckSymbol + INIntentParameterObjectTypeNamespace + 88xZPY + INIntentParameterPromptDialogs + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Configuration + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogType + Primary + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + There are ${count} options matching ‘${healthcheckSymbol22}’. + INIntentParameterPromptDialogFormatStringID + UMMJUm + INIntentParameterPromptDialogType + DisambiguationIntroduction + + + INIntentParameterPromptDialogCustom + + INIntentParameterPromptDialogFormatString + Just to confirm, you wanted ‘${healthcheckSymbol22}’? + INIntentParameterPromptDialogFormatStringID + MIqUFR + INIntentParameterPromptDialogType + Confirmation + + + INIntentParameterSupportsDynamicEnumeration + + INIntentParameterSupportsResolution + + INIntentParameterTag + 8 + INIntentParameterType + Object + + + INIntentResponse + + INIntentResponseCodes + + + INIntentResponseCodeName + success + INIntentResponseCodeSuccess + + + + INIntentResponseCodeName + failure + + + + INIntentTitle + Configuration Four + INIntentTitleID + sIO6Wf + INIntentType + Custom + INIntentVerb + View + INTypes diff --git a/HealthcheckWidget/HealthcheckWidget.swift b/HealthcheckWidget/HealthcheckWidget.swift index e05215b..e59c9c7 100644 --- a/HealthcheckWidget/HealthcheckWidget.swift +++ b/HealthcheckWidget/HealthcheckWidget.swift @@ -74,11 +74,11 @@ struct Provider: IntentTimelineProvider { let sorted = hcr.domain.sorted { $0.name > $1.name } let shrinkedEventList = Array(sorted) if (configuration.healthcheckSymbol1 != nil) { - var health = shrinkedEventList.first { $0.healthtoken == configuration.healthcheckSymbol1?.identifier } + let health = shrinkedEventList.first { $0.healthtoken == configuration.healthcheckSymbol1?.identifier } if (health == nil) { configuration.healthcheckSymbol1 = nil } else { - var healthStatus = HealthcheckSymbol(identifier: health!.healthtoken, display: health!.name) + let healthStatus = HealthcheckSymbol(identifier: health!.healthtoken, display: health!.name) healthStatus.events = [] health!.events.forEach { e in let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) @@ -88,11 +88,11 @@ struct Provider: IntentTimelineProvider { } } if (configuration.healthcheckSymbol2 != nil) { - var health = shrinkedEventList.first { $0.healthtoken == configuration.healthcheckSymbol2?.identifier } + let health = shrinkedEventList.first { $0.healthtoken == configuration.healthcheckSymbol2?.identifier } if (health == nil) { configuration.healthcheckSymbol2 = nil } else { - var healthStatus = HealthcheckSymbol(identifier: health!.healthtoken, display: health!.name) + let healthStatus = HealthcheckSymbol(identifier: health!.healthtoken, display: health!.name) healthStatus.events = [] health!.events.forEach { e in let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) @@ -108,6 +108,133 @@ struct Provider: IntentTimelineProvider { } } +struct ProviderFour: IntentTimelineProvider { + + @AppStorage("HealthcheckList") var healthCheckList: String = "" + + func placeholder(in context: Context) -> SimpleFourEntry { + var count = 2 + + if #available(iOSApplicationExtension 16.0, *) { + if context.family == .accessoryRectangular { + count = 1 + } else if context.family == .systemSmall { + count = 2 + } else if context.family == .systemMedium { + count = 4 + } else { + count = 9 + } + } else { + if context.family == .systemSmall { + count = 2 + } else if context.family == .systemMedium { + count = 4 + } else { + count = 9 + } + } + let hc = DummyData.HealthcheckListCustom(customCount: count) + return SimpleFourEntry(date: Date(), configuration: ConfigurationFourIntent(), healthcheck: hc) + } + + func getSnapshot(for configuration: ConfigurationFourIntent, in context: Context, completion: @escaping (SimpleFourEntry) -> ()) { + var count = 2 + if #available(iOSApplicationExtension 16.0, *) { + if context.family == .accessoryRectangular { + count = 1 + } else if context.family == .systemSmall { + count = 2 + } else if context.family == .systemMedium { + count = 4 + } else { + count = 9 + } + } else { + if context.family == .systemSmall { + count = 2 + } else if context.family == .systemMedium { + count = 4 + } else { + count = 9 + } + } + let hc = DummyData.HealthcheckListCustom(customCount: count) + let entry = SimpleFourEntry(date: Date(), configuration: configuration, healthcheck: hc) + completion(entry) + } + + func getTimeline(for configuration: ConfigurationFourIntent, in context: Context, completion: @escaping (Timeline) -> ()) { + Task { + let api = NetworkServices() + let hcd = DummyData.HealthcheckListCustom(customCount: 4) + let hcr = await api.GetHealthchecks() ?? HealthCheckResult(domain: hcd) + + let sorted = hcr.domain.sorted { $0.name > $1.name } + let shrinkedEventList = Array(sorted) + if (configuration.healthcheckSymbol11 != nil) { + let health = shrinkedEventList.first { $0.healthtoken == configuration.healthcheckSymbol11?.identifier } + if (health == nil) { + configuration.healthcheckSymbol11 = nil + } else { + let healthStatus = HealthcheckSymbol(identifier: health!.healthtoken, display: health!.name) + healthStatus.events = [] + health!.events.forEach { e in + let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) + healthStatus.events?.append(event) + } + configuration.healthcheckSymbol11 = healthStatus + } + } + if (configuration.healthcheckSymbol12 != nil) { + let health = shrinkedEventList.first { $0.healthtoken == configuration.healthcheckSymbol12?.identifier } + if (health == nil) { + configuration.healthcheckSymbol12 = nil + } else { + let healthStatus = HealthcheckSymbol(identifier: health!.healthtoken, display: health!.name) + healthStatus.events = [] + health!.events.forEach { e in + let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) + healthStatus.events?.append(event) + } + configuration.healthcheckSymbol12 = healthStatus + } + } + /*if (configuration.healthcheckSymbol21 != nil) { + let health = shrinkedEventList.first { $0.healthtoken == configuration.healthcheckSymbol21?.identifier } + if (health == nil) { + configuration.healthcheckSymbol21 = nil + } else { + let healthStatus = HealthcheckSymbol(identifier: health!.healthtoken, display: health!.name) + healthStatus.events = [] + health!.events.forEach { e in + let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) + healthStatus.events?.append(event) + } + configuration.healthcheckSymbol21 = healthStatus + } + } + if (configuration.healthcheckSymbol22 != nil) { + let health = shrinkedEventList.first { $0.healthtoken == configuration.healthcheckSymbol22?.identifier } + if (health == nil) { + configuration.healthcheckSymbol22 = nil + } else { + let healthStatus = HealthcheckSymbol(identifier: health!.healthtoken, display: health!.name) + healthStatus.events = [] + health!.events.forEach { e in + let event = EventSymbol(identifier: UUID().uuidString, display: e.status!.formatted()) + healthStatus.events?.append(event) + } + configuration.healthcheckSymbol22 = healthStatus + } + }*/ + let entry = SimpleFourEntry(date: .now, configuration: configuration, healthcheck: []) + let timeline = Timeline(entries: [entry], policy: .after(.now.advanced(by: 15 * 60))) + completion(timeline) + } + } +} + struct ProviderStatic: TimelineProvider { @AppStorage("HealthcheckList") var healthCheckList: String = "" @@ -203,6 +330,12 @@ struct SimpleEntry: TimelineEntry { let healthcheck: [HealthCheck] } +struct SimpleFourEntry: TimelineEntry { + let date: Date + let configuration: ConfigurationFourIntent + let healthcheck: [HealthCheck] +} + struct SimpleEntryStatic: TimelineEntry { let date: Date let healthcheck: [HealthCheck] @@ -238,6 +371,33 @@ struct HealthcheckWidgetEntryView : View { } } +//struct HealthcheckWidgetFourEntryView : View { +// @Environment(\.widgetFamily) var widgetFamily +// +// var entry: ProviderFour.Entry +// +// var body: some View { +// if #available(iOSApplicationExtension 16.0, *) { +// switch widgetFamily { +// case .systemMedium: +// MediumSizeView(entry: entry) +// .widgetURL(URL(string: "ipv64://tab/2")) +// default: +// Text("Not implemented!") +// } +// } else { +// // Fallback on earlier versions +// switch widgetFamily { +// case .systemMedium: +// MediumSizeView(entry: entry) +// .widgetURL(URL(string: "ipv64://tab/2")) +// default: +// Text("Not implemented!") +// } +// } +// } +//} + struct HealthcheckWidgetStaticEntryView : View { @Environment(\.widgetFamily) var widgetFamily @@ -305,6 +465,32 @@ struct HealthcheckWidgetStatic: Widget { } } +//struct HealthcheckWidgetFour: Widget { +// let kind: String = "HealthcheckWidgetFour" +// +// private var supportedFamilies: [WidgetFamily] { +// if #available(iOSApplicationExtension 16.0, *) { +// return [ +// .systemMedium +// ] +// } else { +// return [ +// .systemMedium +// ] +// } +// } +// +// var body: some WidgetConfiguration { +// IntentConfiguration(kind: kind, intent: ConfigurationFourIntent.self, provider: ProviderFour()) { entry in +// HealthcheckWidgetFourEntryView(entry: entry) +// } +// .supportedFamilies(supportedFamilies) +// .configurationDisplayName("Meine Healthchecks") +// .description("Hier werden dir deine Healthchecks angezeigt.") +// .contentMarginsDisabled() +// } +//} + extension View { func widgetBackground(backgroundView: some View) -> some View { if #available(iOSApplicationExtension 17.0, *) { @@ -319,8 +505,8 @@ extension View { struct HealthcheckWidget_Previews: PreviewProvider { static var previews: some View { - let hc = DummyData.HealthcheckListCustom(customCount: 2) + let hc = DummyData.HealthcheckListCustom(customCount: 4) HealthcheckWidgetEntryView(entry: SimpleEntry(date: Date(), configuration: ConfigurationIntent(), healthcheck: hc)) - .previewContext(WidgetPreviewContext(family: .systemSmall)) + .previewContext(WidgetPreviewContext(family: .systemMedium)) } } diff --git a/HealthcheckWidget/HealthcheckWidgetBundle.swift b/HealthcheckWidget/HealthcheckWidgetBundle.swift index 5c7ddae..c144550 100644 --- a/HealthcheckWidget/HealthcheckWidgetBundle.swift +++ b/HealthcheckWidget/HealthcheckWidgetBundle.swift @@ -12,6 +12,7 @@ import SwiftUI struct HealthcheckWidgetBundle: WidgetBundle { var body: some Widget { HealthcheckWidget() +// HealthcheckWidgetFour() HealthcheckWidgetStatic() } } diff --git a/HealthcheckWidget/WidgetSizes/MediumSizeView.swift b/HealthcheckWidget/WidgetSizes/MediumSizeView.swift index daa6947..e597a9d 100644 --- a/HealthcheckWidget/WidgetSizes/MediumSizeView.swift +++ b/HealthcheckWidget/WidgetSizes/MediumSizeView.swift @@ -13,6 +13,78 @@ struct MediumSizeView : View { @Environment(\.widgetFamily) var widgetFamily var entry: ProviderStatic.Entry + + /* + var body: some View { + ZStack { + if (entry.configuration.healthcheckSymbol11 == nil || entry.configuration.healthcheckSymbol12 == nil || entry.configuration.healthcheckSymbol21 == nil || entry.configuration.healthcheckSymbol22 == nil) { + VStack { + Text("Keine Healthchecks konfiguriert!") + .font(.system(.callout, design: .rounded)) + } + .padding() + } else { + /*HStack { + let firstColumn = GetColumn(start: 0, end: 1) + let secondColumn = GetColumn(start: 2, end: 3) + VStack { + ForEach(firstColumn, id: \.healthtoken) { it in + LazyVStack(alignment: .leading, spacing: 0) { + Text(it.name) + .font(.system(.title3, design: .rounded)) + .lineLimit(1) + Spacer() + HStack(spacing: 4) { + let lastXPills = GetLastXMonitorPills(count: 12, domain: it).reversed() + ForEach(lastXPills, id:\.self) { color in + RoundedRectangle(cornerRadius: 5).fill(color) + .frame(width: 7, height: 25) + } + } + .padding(.trailing, 5) + } + .frame(maxWidth: .infinity, alignment: .leading) + .id(UUID()) + .padding(.bottom, 5) + } + if (firstColumn.count == 1) { + Spacer() + } + } + .padding(.top, firstColumn.count == 1 ? 3 : 0) + VStack { + ForEach(secondColumn, id: \.healthtoken) { it in + LazyVStack(alignment: .leading, spacing: 0) { + Text(it.name) + .font(.system(.title3, design: .rounded)) + .lineLimit(1) + Spacer() + HStack(spacing: 4) { + let lastXPills = GetLastXMonitorPills(count: 12, domain: it).reversed() + ForEach(lastXPills, id:\.self) { color in + RoundedRectangle(cornerRadius: 5).fill(color) + .frame(width: 7, height: 25) + } + } + .padding(.trailing, 5) + } + .frame(maxWidth: .infinity, alignment: .leading) + .id(UUID()) + .padding(.bottom, 5) + } + if (secondColumn.count == 1) { + Spacer() + } + } + .padding(.top, secondColumn.count == 1 ? 0 : 0) + } + .padding()*/ + } + } + .frame(maxHeight: .infinity) + .widgetBackground(backgroundView: Color("circleBG")) + } + */ var body: some View { ZStack { diff --git a/IPv64.xcodeproj/project.pbxproj b/IPv64.xcodeproj/project.pbxproj index 5223313..d1fa6df 100644 --- a/IPv64.xcodeproj/project.pbxproj +++ b/IPv64.xcodeproj/project.pbxproj @@ -597,7 +597,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1420; - LastUpgradeCheck = 1410; + LastUpgradeCheck = 1500; TargetAttributes = { 9A10DBF4298C206D00285C0A = { CreatedOnToolsVersion = 14.2; @@ -932,6 +932,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -992,6 +993,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -1018,7 +1020,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = IPv64/IPv64.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 25; + CURRENT_PROJECT_VERSION = 26; DEVELOPMENT_ASSET_PATHS = "\"IPv64/Preview Content\""; DEVELOPMENT_TEAM = 3V2L6G4Y5X; ENABLE_PREVIEWS = YES; @@ -1039,7 +1041,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2; + MARKETING_VERSION = 1.2.1; PRODUCT_BUNDLE_IDENTIFIER = de.rpicloud.IPv64; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -1056,7 +1058,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = IPv64/IPv64.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 25; + CURRENT_PROJECT_VERSION = 26; DEVELOPMENT_ASSET_PATHS = "\"IPv64/Preview Content\""; DEVELOPMENT_TEAM = 3V2L6G4Y5X; ENABLE_PREVIEWS = YES; @@ -1077,7 +1079,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.2; + MARKETING_VERSION = 1.2.1; PRODUCT_BUNDLE_IDENTIFIER = de.rpicloud.IPv64; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/IPv64.xcodeproj/project.xcworkspace/xcuserdata/sebastianrank.xcuserdatad/UserInterfaceState.xcuserstate b/IPv64.xcodeproj/project.xcworkspace/xcuserdata/sebastianrank.xcuserdatad/UserInterfaceState.xcuserstate index 7d3a2b9..f707b35 100644 Binary files a/IPv64.xcodeproj/project.xcworkspace/xcuserdata/sebastianrank.xcuserdatad/UserInterfaceState.xcuserstate and b/IPv64.xcodeproj/project.xcworkspace/xcuserdata/sebastianrank.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/IPv64.xcodeproj/xcshareddata/xcschemes/HealthcheckWidgetExtension.xcscheme b/IPv64.xcodeproj/xcshareddata/xcschemes/HealthcheckWidgetExtension.xcscheme index 7eafd68..55a37fc 100644 --- a/IPv64.xcodeproj/xcshareddata/xcschemes/HealthcheckWidgetExtension.xcscheme +++ b/IPv64.xcodeproj/xcshareddata/xcschemes/HealthcheckWidgetExtension.xcscheme @@ -1,6 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/IPv64.xcodeproj/xcuserdata/sebastianrank.xcuserdatad/xcschemes/xcschememanagement.plist b/IPv64.xcodeproj/xcuserdata/sebastianrank.xcuserdatad/xcschemes/xcschememanagement.plist index 5f8f7c9..a5a992f 100644 --- a/IPv64.xcodeproj/xcuserdata/sebastianrank.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/IPv64.xcodeproj/xcuserdata/sebastianrank.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ HealthcheckIntents.xcscheme_^#shared#^_ orderHint - 3 + 2 HealthcheckWidgetExtension.xcscheme_^#shared#^_ @@ -22,7 +22,7 @@ NotificationService.xcscheme_^#shared#^_ orderHint - 2 + 3 Promises (Playground) 1.xcscheme diff --git a/IPv64/.DS_Store b/IPv64/.DS_Store index 1831f86..ed37ef9 100644 Binary files a/IPv64/.DS_Store and b/IPv64/.DS_Store differ diff --git a/IPv64/Info.plist b/IPv64/Info.plist index 4615181..38c511a 100644 --- a/IPv64/Info.plist +++ b/IPv64/Info.plist @@ -17,6 +17,7 @@ NSUserActivityTypes + ConfigurationFourIntent ConfigurationIntent UIBackgroundModes diff --git a/IPv64/Main/.DS_Store b/IPv64/Main/.DS_Store index 4576d3d..dcc7462 100644 Binary files a/IPv64/Main/.DS_Store and b/IPv64/Main/.DS_Store differ diff --git a/IPv64/Main/Account/AccountListView.swift b/IPv64/Main/Account/AccountListView.swift index 97e5132..a1913a3 100644 --- a/IPv64/Main/Account/AccountListView.swift +++ b/IPv64/Main/Account/AccountListView.swift @@ -18,6 +18,16 @@ struct AccountListView: View { @Binding var isBottomSheetVisible: Bool @Binding var accountList: [Account] @Binding var newAccountB: Bool + @State var activeSheet: ActiveSheet? = nil + @State var errorTyp: ErrorTyp? = .none + @State private var selectedAccount: Account? = nil + @State private var deleteAccount: Bool = false + + fileprivate func deleteAccountDialog() { + errorTyp = ErrorTypes.deleteAccount + activeSheet = .error + print(errorTyp) + } var body: some View { VStack { @@ -67,6 +77,18 @@ struct AccountListView: View { } } .listRowBackground(acc.Active! ? Color("AccountSelectionBG") : Color("SectionBG")) + .swipeActions(edge: .trailing) { + if (!acc.Active!) { + Button(role: .destructive, action: { + print("delete") + selectedAccount = acc + deleteAccountDialog() + }) { + Label("Löschen", systemImage: "trash") + } + .tint(.red) + } + } } } Button(action: { @@ -93,6 +115,44 @@ struct AccountListView: View { } } .scrollIndicators(.hidden) + .sheet(item: $activeSheet) { item in + showActiveSheet(item: item) + } + } + } + + @ViewBuilder + func showActiveSheet(item: ActiveSheet?) -> some View { + switch item { + case .error: + ErrorSheetView(errorTyp: $errorTyp, deleteThisDomain: $deleteAccount) + .interactiveDismissDisabled(errorTyp?.status == 202 ? false : true) + .onDisappear { + do { + let jsonDecoder = JSONDecoder() + let jsonData = accountListJson.data(using: .utf8) + var accountList = try jsonDecoder.decode([Account].self, from: jsonData!) + + if (deleteAccount) { + print(selectedAccount) + let indSel = accountList.firstIndex { $0.ApiKey == selectedAccount?.ApiKey } + print(indSel) + if indSel! > -1 { + accountList.remove(at: indSel!) + } + self.accountList = accountList + + let jsonEncoder = JSONEncoder() + let jsonData = try jsonEncoder.encode(accountList) + let json = String(data: jsonData, encoding: String.Encoding.utf8) + accountListJson = json! + } + } catch let error { + print(error) + } + } + default: + EmptyView() } } diff --git a/IPv64/Main/LoginView.swift b/IPv64/Main/LoginView.swift index ec7d749..981eac3 100644 --- a/IPv64/Main/LoginView.swift +++ b/IPv64/Main/LoginView.swift @@ -159,6 +159,7 @@ struct LoginView: View { actionSheet = nil newAccount = false showMainView.toggle() + apiKey = "" } } } @@ -168,36 +169,45 @@ struct LoginView: View { } private func addNewAccount() { - Task { - let accountInd = accountList.firstIndex { $0.ApiKey == apiKey } - if (accountInd != nil) { - withAnimation { - errorTyp = nil - actionSheet = nil - newAccount = false - showMainView.toggle() + if (apiKey.isEmpty) { + return; + } + + let accountInd = accountList.firstIndex { $0.ApiKey == apiKey } + if (accountInd != nil && accountInd != -1) { + errorTyp = ErrorTypes.accountFound + actionSheet = .error + } else { + Task { + do { + await getAccountInfos() + + if (accountInfos.api_key == nil) { + errorTyp = ErrorTypes.accountNotFound + actionSheet = .error + } else { + + let sdtoken = SetupPrefs.readPreference(mKey: "DEVICETOKEN", mDefaultValue: "") as! String + + let result = await api.PostAddIntegration(integrationType: "mobil", dtoken: sdtoken, dName: UIDevice().type.rawValue, apiKey: apiKey) + + print(result) + + let account = Account(ApiKey: apiKey, AccountName: accountInfos.email, DeviceToken: sdtoken, Since: accountInfos.reg_date, Active: false) + + accountList.append(account) + + let jsonEncoder = JSONEncoder() + let jsonData = try jsonEncoder.encode(accountList) + let json = String(data: jsonData, encoding: String.Encoding.utf8) + accountListJson = json! + + actionSheet = .error + errorTyp = ErrorTypes.accountSuccessfullyAdded + } + } catch let error { + print(error) } - return; - } - await getAccountInfos() - do { - let sdtoken = SetupPrefs.readPreference(mKey: "DEVICETOKEN", mDefaultValue: "") as! String - - let account = Account(ApiKey: apiKey, AccountName: accountInfos.email, DeviceToken: sdtoken, Since: accountInfos.reg_date, Active: false) - - accountList.append(account) - - let result = await api.PostAddIntegration(integrationType: "mobil", dtoken: sdtoken, dName: UIDevice().type.rawValue, apiKey: apiKey) - - let jsonEncoder = JSONEncoder() - let jsonData = try jsonEncoder.encode(accountList) - let json = String(data: jsonData, encoding: String.Encoding.utf8) - accountListJson = json! - - actionSheet = .error - errorTyp = ErrorTypes.accountSuccessfullyAdded - } catch let error { - print(error) } } } diff --git a/IPv64/Main/Sheets/ErrorSheetView.swift b/IPv64/Main/Sheets/ErrorSheetView.swift index 324f382..544eb5f 100644 --- a/IPv64/Main/Sheets/ErrorSheetView.swift +++ b/IPv64/Main/Sheets/ErrorSheetView.swift @@ -21,6 +21,7 @@ struct ErrorSheetView: View { VStack { Spacer() let icon = errorTyp!.icon! + if (icon.contains(";")) { let splittetIcons = icon.split(separator: ";") ZStack { diff --git a/IPv64/Main/WhatsNew/WhatsNewView.swift b/IPv64/Main/WhatsNew/WhatsNewView.swift index 94167f2..b83afe9 100644 --- a/IPv64/Main/WhatsNew/WhatsNewView.swift +++ b/IPv64/Main/WhatsNew/WhatsNewView.swift @@ -14,9 +14,7 @@ struct WhatsNewView: View { var whatsNewList = [ WhatsNewObj(imageName: "ant.circle", title: "Fehlerbehebung", subtitle: "Es wurden in diesem Update ein Paar Fehler behoben, die zur Steigerung der Performance und der Nutzbarkeit dienen"), - WhatsNewObj(imageName: "shield.lefthalf.filled", title: "Blocklist", subtitle: "Du kannst jetzt an deine Blocklist Node's bösartige IP - Adressen reporten"), - WhatsNewObj(imageName: "person.circle", title: "Profilseite", subtitle: "Profilseite wurde angepasst und es gibt erste Vorbereitungen für den Multi-User Support"), - WhatsNewObj(imageName: "speaker.wave.2", title: "Klick Sound", subtitle: "Beim drücken eines Tabs gibt es jetzt einen Klick Sound") + WhatsNewObj(imageName: "person.circle", title: "Multi-User Support", subtitle: "Ihr könnt jetzt mehr als 1 Account in der App hinterlegen um Private & Firmenaccount über ein Gerät zuverwalten!") ] var body: some View { diff --git a/IPv64/Models&Helpers/Models.swift b/IPv64/Models&Helpers/Models.swift index 7003581..50582a8 100644 --- a/IPv64/Models&Helpers/Models.swift +++ b/IPv64/Models&Helpers/Models.swift @@ -636,6 +636,7 @@ struct ErrorTypes { status: 429 ) } + static var updateCoolDown: ErrorTyp { ErrorTyp( icon: "bolt.horizontal.icloud.fill;exclamationmark.arrow.triangle.2.circlepath", @@ -646,6 +647,7 @@ struct ErrorTypes { status: 429 ) } + static var domainNotAvailable: ErrorTyp { ErrorTyp( icon: "xmark.icloud.fill", @@ -656,6 +658,7 @@ struct ErrorTypes { status: 403 ) } + static var domainCreatedSuccesfully: ErrorTyp { ErrorTyp( icon: "checkmark.icloud.fill", @@ -666,6 +669,7 @@ struct ErrorTypes { status: 201 ) } + static var poisonedIpSuccesfully: ErrorTyp { ErrorTyp( icon: "checkmark.icloud.fill", @@ -676,6 +680,7 @@ struct ErrorTypes { status: 201 ) } + static var poisonedIpError: ErrorTyp { ErrorTyp( icon: "xmark.icloud.fill", @@ -686,6 +691,7 @@ struct ErrorTypes { status: 403 ) } + static var delete: ErrorTyp { ErrorTyp( icon: "trash.fill", @@ -696,6 +702,7 @@ struct ErrorTypes { status: 202 ) } + static var deletehealth: ErrorTyp { ErrorTyp( icon: "trash.fill", @@ -706,6 +713,7 @@ struct ErrorTypes { status: 202 ) } + static var deleteIntegration: ErrorTyp { ErrorTyp( icon: "trash.fill", @@ -716,6 +724,7 @@ struct ErrorTypes { status: 202 ) } + static var dnsRecordSuccesfullyCreated: ErrorTyp { ErrorTyp( icon: "checkmark.icloud.fill", @@ -726,6 +735,7 @@ struct ErrorTypes { status: 201 ) } + static var deleteDNSRecord: ErrorTyp { ErrorTyp( icon: "trash.fill", @@ -736,6 +746,7 @@ struct ErrorTypes { status: 202 ) } + static var unauthorized: ErrorTyp { ErrorTyp( icon: "xmark.shield.fill", @@ -746,6 +757,7 @@ struct ErrorTypes { status: 401 ) } + static var websiteRequestError: ErrorTyp { ErrorTyp( icon: "bolt.horizontal.icloud.fill;exclamationmark.arrow.triangle.2.circlepath", @@ -756,6 +768,7 @@ struct ErrorTypes { status: 500 ) } + static var healthcheckCreatedSuccesfully: ErrorTyp { ErrorTyp( icon: "waveform.path.ecg", @@ -766,6 +779,7 @@ struct ErrorTypes { status: 201 ) } + static var healthcheckUpdatedSuccesfully: ErrorTyp { ErrorTyp( icon: "waveform.path.ecg", @@ -776,6 +790,7 @@ struct ErrorTypes { status: 201 ) } + static var accountSuccessfullyAdded: ErrorTyp { ErrorTyp( icon: "person.crop.circle.badge.checkmark", @@ -786,6 +801,39 @@ struct ErrorTypes { status: 201 ) } + + static var accountFound: ErrorTyp { + ErrorTyp( + icon: "person.crop.circle.badge.exclamationmark", + iconColor: .orange, + navigationTitle: "Achtung", + errorTitle: "Account wurde bereits hinzugefügt!", + errorDescription: "Dein API-Key ist bereits mit einem Account in der App verknüpft.", + status: 201 + ) + } + + static var accountNotFound: ErrorTyp { + ErrorTyp( + icon: "person.crop.circle.badge.questionmark", + iconColor: .red, + navigationTitle: "Fehler!", + errorTitle: "API-Key nicht gefunden!", + errorDescription: "Bist du dir sicher das der API-Key korrekt geschrieben ist?", + status: 401 + ) + } + + static var deleteAccount: ErrorTyp { + ErrorTyp( + icon: "trash.fill", + iconColor: .red, + navigationTitle: "Wirklick löschen?", + errorTitle: "Willst du wirklich den\nAccount löschen?", + errorDescription: "Dein Account wird mit sofortiger Wirkung aus der App gelöscht.", + status: 202 + ) + } } public var dynDomainList = [ @@ -1052,6 +1100,7 @@ public enum Model : String { iPad7 = "iPad 7", //iPad 2019 iPad8 = "iPad 8", //iPad 2020 iPad9 = "iPad 9", //iPad 2021 + iPad10 = "iPad 10", //iPad 2022 //iPad Mini iPadMini = "iPad Mini", @@ -1109,6 +1158,10 @@ public enum Model : String { iPhone14Plus = "iPhone 14 Plus", iPhone14Pro = "iPhone 14 Pro", iPhone14ProMax = "iPhone 14 Pro Max", + iPhone15 = "iPhone 15", + iPhone15Plus = "iPhone 15 Plus", + iPhone15Pro = "iPhone 15 Pro", + iPhone15ProMax = "iPhone 15 Pro Max", // Apple Watch AppleWatch1 = "Apple Watch 1gen", @@ -1152,7 +1205,6 @@ public extension UIDevice { //Simulator "i386" : .simulator, "x86_64" : .simulator, - "arm64" : .simulator, //iPod "iPod1,1" : .iPod1, @@ -1184,6 +1236,8 @@ public extension UIDevice { "iPad11,7" : .iPad8, "iPad12,1" : .iPad9, //iPad 2021 "iPad12,2" : .iPad9, + "iPad13,18" : .iPad10, + "iPad13,19" : .iPad10, //iPad Mini "iPad2,5" : .iPadMini, @@ -1292,6 +1346,10 @@ public extension UIDevice { "iPhone14,8" : .iPhone14Plus, "iPhone15,2" : .iPhone14Pro, "iPhone15,3" : .iPhone14ProMax, + "iPhone15,4" : .iPhone15, + "iPhone15,5" : .iPhone15Plus, + "iPhone16,1" : .iPhone15Pro, + "iPhone16,2" : .iPhone15ProMax, // Apple Watch "Watch1,1" : .AppleWatch1, @@ -1348,6 +1406,7 @@ public extension UIDevice { } + func GetUIImage(imageName: String, color: UIColor, hierarichal: Bool) -> UIImage { var image = UIImage(systemName: imageName)?.withTintColor(color) diff --git a/IPv64/Models&Helpers/NetworkServices.swift b/IPv64/Models&Helpers/NetworkServices.swift index b019487..8bba079 100644 --- a/IPv64/Models&Helpers/NetworkServices.swift +++ b/IPv64/Models&Helpers/NetworkServices.swift @@ -39,7 +39,7 @@ class NetworkServices: ObservableObject { request.setValue("Authorization: Bearer \(token)", forHTTPHeaderField: "Authorization") JsonEncoder.outputFormatting = .prettyPrinted - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(DomainResult.self, from: data) isLoading = false @@ -71,7 +71,7 @@ class NetworkServices: ObservableObject { request.setValue("Authorization: Bearer \(token)", forHTTPHeaderField: "Authorization") JsonEncoder.outputFormatting = .prettyPrinted - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(Logs.self, from: data) isLoading = false @@ -103,7 +103,7 @@ class NetworkServices: ObservableObject { request.setValue("Authorization: Bearer \(token)", forHTTPHeaderField: "Authorization") JsonEncoder.outputFormatting = .prettyPrinted - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AccountInfo.self, from: data) isLoading = false @@ -127,14 +127,14 @@ class NetworkServices: ObservableObject { } do { - let token = SetupPrefs.readPreference(mKey: "APIKEY", mDefaultValue: "") as! String + let _ = SetupPrefs.readPreference(mKey: "APIKEY", mDefaultValue: "") as! String var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData) request.httpMethod = "GET" //request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type") // the request is JSON request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Accept") // the expected response is also JSON JsonEncoder.outputFormatting = .prettyPrinted - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(MyIP.self, from: data) isLoading = false @@ -158,14 +158,14 @@ class NetworkServices: ObservableObject { } do { - let token = SetupPrefs.readPreference(mKey: "APIKEY", mDefaultValue: "") as! String + let _ = SetupPrefs.readPreference(mKey: "APIKEY", mDefaultValue: "") as! String var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData) request.httpMethod = "GET" //request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type") // the request is JSON request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Accept") // the expected response is also JSON JsonEncoder.outputFormatting = .prettyPrinted - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(MyIP.self, from: data) isLoading = false @@ -199,7 +199,7 @@ class NetworkServices: ObservableObject { request.httpBody = "add_domain=\(domain)".data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -233,7 +233,7 @@ class NetworkServices: ObservableObject { request.httpBody = "del_domain=\(domain)".data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -267,7 +267,7 @@ class NetworkServices: ObservableObject { request.httpBody = "add_record=\(domain)&praefix=\(praefix)&type=\(typ)&content=\(content)".data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -300,7 +300,7 @@ class NetworkServices: ObservableObject { request.httpBody = "del_record=\(recordId)".data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -333,7 +333,7 @@ class NetworkServices: ObservableObject { request.setValue("Authorization: Bearer \(token)", forHTTPHeaderField: "Authorization") JsonEncoder.outputFormatting = .prettyPrinted - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -366,9 +366,9 @@ class NetworkServices: ObservableObject { request.setValue("Authorization: Bearer \(token)", forHTTPHeaderField: "Authorization") JsonEncoder.outputFormatting = .prettyPrinted - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) - var result = try JsonDecoder.decode(HealthCheckResult.self, from: data) + let result = try JsonDecoder.decode(HealthCheckResult.self, from: data) isLoading = false return result } catch let error { @@ -399,7 +399,7 @@ class NetworkServices: ObservableObject { request.httpBody = "add_healthcheck=\(add_healthcheck)&alarm_count=\(alarm_count)&alarm_unit=\(alarm_unit)".data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -433,7 +433,7 @@ class NetworkServices: ObservableObject { request.httpBody = "pause_healthcheck=\(healthtoken)".data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -467,7 +467,7 @@ class NetworkServices: ObservableObject { request.httpBody = "start_healthcheck=\(healthtoken)".data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -502,7 +502,7 @@ class NetworkServices: ObservableObject { request.httpBody = "del_healthcheck=\(health)".data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -534,9 +534,9 @@ class NetworkServices: ObservableObject { request.setValue("Authorization: Bearer \(token)", forHTTPHeaderField: "Authorization") JsonEncoder.outputFormatting = .prettyPrinted - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) - var result = try JsonDecoder.decode(IntegrationResult.self, from: data) + let result = try JsonDecoder.decode(IntegrationResult.self, from: data) isLoading = false return result } catch let error { @@ -570,7 +570,7 @@ class NetworkServices: ObservableObject { request.httpBody = body.data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -606,7 +606,7 @@ class NetworkServices: ObservableObject { request.httpBody = body.data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -640,9 +640,9 @@ class NetworkServices: ObservableObject { request.setValue("Authorization: Bearer \(token)", forHTTPHeaderField: "Authorization") JsonEncoder.outputFormatting = .prettyPrinted - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) - var result = try JsonDecoder.decode(HealthcheckStatisticsResult.self, from: data) + let result = try JsonDecoder.decode(HealthcheckStatisticsResult.self, from: data) isLoading = false return result } catch let error { @@ -674,7 +674,7 @@ class NetworkServices: ObservableObject { request.httpBody = "del_integration=\(integration_id)".data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(AddDomainResult.self, from: data) isLoading = false @@ -706,7 +706,7 @@ class NetworkServices: ObservableObject { request.setValue("Authorization: Bearer \(token)", forHTTPHeaderField: "Authorization") JsonEncoder.outputFormatting = .prettyPrinted - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(BlockerNodeResults.self, from: data) isLoading = false @@ -742,7 +742,7 @@ class NetworkServices: ObservableObject { request.httpBody = body.data(using: .utf8) - let (data, response) = try await URLSession.shared.data(for: request) + let (data, _) = try await URLSession.shared.data(for: request) let result = try JsonDecoder.decode(PoisonedIPResult.self, from: data) isLoading = false