Skip to content
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
7 changes: 7 additions & 0 deletions iOSClient/Account Settings/NCAccountSettingsModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ class NCAccountSettingsModel: ObservableObject, ViewOnAppearHandling {
return (nil, "", "")
}

/// Is the user an Admin
func isAdminGroup() -> Bool {
guard let activeAccount else { return false }
let groups = NCManageDatabase.shared.getAccountGroups(account: activeAccount.account)
return groups.contains(NCGlobal.shared.groupAdmin)
}

/// Function to know the height of "account" data
func getTableViewHeight() -> CGFloat {
guard let activeAccount else { return 0 }
Expand Down
92 changes: 47 additions & 45 deletions iOSClient/Account Settings/NCAccountSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,52 +181,54 @@ struct NCAccountSettingsView: View {
}
///
/// Certificate server
Button(action: {
showServerCertificate.toggle()
}, label: {
HStack {
Image(systemName: "lock")
.resizable()
.scaledToFit()
.font(Font.system(.body).weight(.light))
.frame(width: 20, height: 20)
.foregroundStyle(Color(NCBrandColor.shared.iconImageColor))
Text(NSLocalizedString("_certificate_details_", comment: ""))
.lineLimit(1)
.truncationMode(.middle)
.foregroundStyle(Color(NCBrandColor.shared.textColor))
.padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 20))
}
.font(.system(size: 14))
})
.sheet(isPresented: $showServerCertificate) {
if let url = URL(string: model.activeAccount?.urlBase), let host = url.host {
certificateDetailsView(host: host, title: NSLocalizedString("_certificate_view_", comment: ""))
}
}
///
/// Certificate push
Button(action: {
showPushCertificate.toggle()
}, label: {
HStack {
Image(systemName: "lock")
.resizable()
.scaledToFit()
.font(Font.system(.body).weight(.light))
.frame(width: 20, height: 20)
.foregroundStyle(Color(NCBrandColor.shared.iconImageColor))
Text(NSLocalizedString("_certificate_pn_details_", comment: ""))
.lineLimit(1)
.truncationMode(.middle)
.foregroundStyle(Color(NCBrandColor.shared.textColor))
.padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 20))
if model.isAdminGroup() {
Button(action: {
showServerCertificate.toggle()
}, label: {
HStack {
Image(systemName: "lock")
.resizable()
.scaledToFit()
.font(Font.system(.body).weight(.light))
.frame(width: 20, height: 20)
.foregroundStyle(Color(NCBrandColor.shared.iconImageColor))
Text(NSLocalizedString("_certificate_details_", comment: ""))
.lineLimit(1)
.truncationMode(.middle)
.foregroundStyle(Color(NCBrandColor.shared.textColor))
.padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 20))
}
.font(.system(size: 14))
})
.sheet(isPresented: $showServerCertificate) {
if let url = URL(string: model.activeAccount?.urlBase), let host = url.host {
certificateDetailsView(host: host, title: NSLocalizedString("_certificate_view_", comment: ""))
}
}
.font(.system(size: 14))
})
.sheet(isPresented: $showPushCertificate) {
if let url = URL(string: NCBrandOptions.shared.pushNotificationServerProxy), let host = url.host {
certificateDetailsView(host: host, title: NSLocalizedString("_certificate_pn_view_", comment: ""))
///
/// Certificate push
Button(action: {
showPushCertificate.toggle()
}, label: {
HStack {
Image(systemName: "lock")
.resizable()
.scaledToFit()
.font(Font.system(.body).weight(.light))
.frame(width: 20, height: 20)
.foregroundStyle(Color(NCBrandColor.shared.iconImageColor))
Text(NSLocalizedString("_certificate_pn_details_", comment: ""))
.lineLimit(1)
.truncationMode(.middle)
.foregroundStyle(Color(NCBrandColor.shared.textColor))
.padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 20))
}
.font(.system(size: 14))
})
.sheet(isPresented: $showPushCertificate) {
if let url = URL(string: NCBrandOptions.shared.pushNotificationServerProxy), let host = url.host {
certificateDetailsView(host: host, title: NSLocalizedString("_certificate_pn_view_", comment: ""))
}
}
}
})
Expand Down
12 changes: 12 additions & 0 deletions iOSClient/Data/NCManageDatabase+Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,16 @@ extension NCManageDatabase {
NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Could not write to database: \(error)")
}
}

func getAccountGroups(account: String) -> [String] {
do {
let realm = try Realm()
if let result = realm.objects(tableAccount.self).filter("account == %@", account).first {
return result.groups.components(separatedBy: ",")
}
} catch let error as NSError {
NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] Could not access database: \(error)")
}
return []
}
}
4 changes: 4 additions & 0 deletions iOSClient/NCGlobal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -485,4 +485,8 @@ class NCGlobal: NSObject {
// DRAG & DROP
//
let metadataOcIdDataRepresentation = "text/com.nextcloud.ocId"

// GROUP AMIN
//
let groupAdmin = "admin"
}
5 changes: 5 additions & 0 deletions iOSClient/Settings/Advanced/NCSettingsAdvancedModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class NCSettingsAdvancedModel: ObservableObject, ViewOnAppearHandling {
let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
/// Keychain access
var keychain = NCKeychain()
/// State variable for indicating if the user is in Admin group
@Published var isAdminGroup: Bool = false
/// State variable for indicating whether hidden files are shown.
@Published var showHiddenFiles: Bool = false
/// State variable for indicating the most compatible format.
Expand Down Expand Up @@ -65,6 +67,8 @@ class NCSettingsAdvancedModel: ObservableObject, ViewOnAppearHandling {

/// Triggered when the view appears.
func onViewAppear() {
let groups = NCManageDatabase.shared.getAccountGroups(account: appDelegate.account)
isAdminGroup = groups.contains(NCGlobal.shared.groupAdmin)
showHiddenFiles = keychain.showHiddenFiles
mostCompatible = keychain.formatCompatibility
livePhoto = keychain.livePhoto
Expand All @@ -73,6 +77,7 @@ class NCSettingsAdvancedModel: ObservableObject, ViewOnAppearHandling {
crashReporter = keychain.disableCrashservice
selectedLogLevel = LogLevel(rawValue: keychain.logLevel) ?? .standard
selectedInterval = CacheDeletionInterval(rawValue: keychain.cleanUpDay) ?? .never

DispatchQueue.global().async {
self.calculateSize()
}
Expand Down
40 changes: 21 additions & 19 deletions iOSClient/Settings/Advanced/NCSettingsAdvancedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,28 @@ struct NCSettingsAdvancedView: View {
Text(NSLocalizedString("_diagnostics_", comment: ""))
}, footer: { })
/// Set Log Level() & Capabilities
Section(content: {
NavigationLink(destination: LazyView {
NCCapabilitiesView(model: NCCapabilitiesModel())
}) {
HStack {
Image(systemName: "list.bullet")
.resizable()
.scaledToFit()
.font(Font.system(.body).weight(.light))
.frame(width: 25, height: 25)
.foregroundColor(Color(NCBrandColor.shared.iconImageColor))
Text(NSLocalizedString("_capabilities_", comment: ""))
if model.isAdminGroup {
Section(content: {
NavigationLink(destination: LazyView {
NCCapabilitiesView(model: NCCapabilitiesModel())
}) {
HStack {
Image(systemName: "list.bullet")
.resizable()
.scaledToFit()
.font(Font.system(.body).weight(.light))
.frame(width: 25, height: 25)
.foregroundColor(Color(NCBrandColor.shared.iconImageColor))
Text(NSLocalizedString("_capabilities_", comment: ""))
}
.font(.system(size: 16))
}
.font(.system(size: 16))
}
}, header: {
Text(NSLocalizedString("_capabilities_", comment: ""))
}, footer: {
Text(NSLocalizedString("_capabilities_footer_", comment: ""))
})
}, header: {
Text(NSLocalizedString("_capabilities_", comment: ""))
}, footer: {
Text(NSLocalizedString("_capabilities_footer_", comment: ""))
})
}
}
/// Delete in Cache & Clear Cache
Section(content: {
Expand Down