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

Feature/g drive #171

Merged
merged 178 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 159 commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
2aee336
implementing google sdk
May 9, 2024
4db1ebe
Move dissmiss views to resetApp function
dhekra-rouatbi May 10, 2024
1853d08
add selected type of drive connection view
May 20, 2024
851aa05
add SelectSharedDrive view
May 21, 2024
ed6658e
mock shared drives
May 21, 2024
d1c5418
create drive folder view
May 22, 2024
b2bff3e
basic implemantation of d-drive library
May 22, 2024
a5c20fb
re-use successLoginView
May 23, 2024
d4ef6a9
navigate from select shared drive to success
May 23, 2024
4dc3e10
final tweaks
May 23, 2024
82e3746
move google signIn to next button
May 28, 2024
4474e91
refactor buttonViews function in serverSelection class
May 28, 2024
38168f3
move gDrive login logic to separate function
May 28, 2024
c081b4a
create gDrive repository and update view models
May 28, 2024
05203a1
add gdrive url to TellaURL list
May 28, 2024
acb0400
add isValid constraint when creating a folder in gDrive
May 29, 2024
0cdb2d0
fix hardcoded strings, add space to VStacks and overall refactor
May 30, 2024
cfebc5d
add serverConnectinoType extension for successLoginView
May 30, 2024
5cc647e
add domain model for shared drives
May 30, 2024
8cfd528
add combine in gDriveRepository
Jun 3, 2024
1a6aa4a
add combine to the rest of the gDrive endpoints
Jun 4, 2024
28f6a06
remove toast if user is not authenticated
Jun 4, 2024
af3cab6
add async await for gDrive methods
Jun 5, 2024
1c4e420
implementing google sdk
May 9, 2024
8bdd46e
basic implemantation of d-drive library
May 22, 2024
49ce550
final tweaks
May 23, 2024
83df535
add isValid constraint when creating a folder in gDrive
May 29, 2024
c12a50e
implementing google sdk
May 9, 2024
5055d27
basic implemantation of d-drive library
May 22, 2024
8f77e2f
create folder in g-drive
May 24, 2024
f6d378a
save server connection
May 27, 2024
c0389d5
save shared drive connection and remove edit option from gDrive conne…
May 27, 2024
9562dde
some fixes after rebase
May 29, 2024
fc7be57
refactor folder creation logic
May 29, 2024
c834bb7
fix rebase conflicts
May 30, 2024
ed0bdea
disable gDrive connection if is already connected
May 30, 2024
4584df2
fix rebase conflicts
Jun 4, 2024
7bfd102
fix create folder and remove token if the user remove a gDrive connec…
Jun 4, 2024
f27e0ad
fix issues after rebase with develop
Jun 4, 2024
4eeb2cf
add navbar to gDrive views
Jun 5, 2024
4417cf8
add translations
Jun 5, 2024
e8bcb02
remove void from async auth function in gDrive repository
Jun 6, 2024
61ff31b
refactor sharedDriveView
Jun 6, 2024
e0882cc
move selected shared drive action to vm
Jun 7, 2024
cf7d920
add state manager to shared drive view model
Jun 10, 2024
500e936
add state management in create folder
Jun 10, 2024
752a24e
move viewModelState into a separate file
Jun 10, 2024
a2288b2
fix issue in server selection
Jun 10, 2024
4e7b508
move restoreSignIn to a private method inside the repository
Jun 11, 2024
2cbd7ff
add no token error localization
Jun 11, 2024
f5174e5
apply DI to gDriveRepository
Jun 11, 2024
da2a7ec
move mimeTypes to constants
Jun 11, 2024
3610273
some refactors on gDriveSeverViewModel and state management
Jun 12, 2024
defe989
change state management on gDriveAuthVM
Jun 12, 2024
49d6983
change onChange for onReceive
Jun 12, 2024
56601ef
Update Toast display
Rimktarii Jun 14, 2024
2bfaf6d
add drive to homeView
Jun 12, 2024
f7e5e0e
add pageView navigation inside gDriveView
Jun 13, 2024
382cded
add title and description to gDriveDraftView
Jun 13, 2024
9a0fdc2
create folder inside the root folder
Jun 14, 2024
42bfcd2
fix to supports all drives
Jun 14, 2024
efd833b
create report folder with title and description
Jun 18, 2024
cace5c0
add files to GDrive report
Jun 24, 2024
6aa05c3
create unify draft view
Jun 27, 2024
24c38e6
create a general baseReportsViewModel to handle list item navigation
Jun 27, 2024
b5333d6
add isValid constraint to GDriveDraftVM
Jun 28, 2024
ca4068f
save gDrive draft report
Jul 1, 2024
d868f89
Fix server subclassing (#165)
dhekra-rouatbi Jul 1, 2024
9873fbf
create base report class and get GDrive drafts
Jul 2, 2024
83d5a09
add gDriveList and show files saved in draft
Jul 3, 2024
8fc5839
Remove accessToken from Webserver
Rimktarii Jul 4, 2024
e0aa9e2
Create reusable report component
dhekra-rouatbi Jul 4, 2024
b8ffc11
update and delete draft report
Jul 4, 2024
52c46be
Merge branch 'g-drive/send-reports-ui' of https://github.com/Horizont…
Jul 4, 2024
8db93c4
save outbox and submitted report
Jul 4, 2024
9d47c2c
Merge branch 'g-drive/send-reports-ui' of https://github.com/Horizont…
Jul 4, 2024
628ab6b
fix UI bug on connection view and merge with latest draft changes
Jul 4, 2024
94aae5d
Fix PR comments
dhekra-rouatbi Jul 5, 2024
f3d7e23
Update report id
dhekra-rouatbi Jul 5, 2024
66dbb54
make report to conform with reusable report component
Jul 5, 2024
9ab2a72
merge conflicts
Jul 5, 2024
4367178
make gDriveViewModel to conform with reportMainViewModel
Jul 5, 2024
cda20de
Remove unused code
dhekra-rouatbi Jul 8, 2024
2041b8f
refactor tellaData and fix navigation between cells
Jul 8, 2024
562bff7
add DraftMainViewModel
Jul 8, 2024
173ed6d
add server list menu on draft view
Jul 8, 2024
2cd5833
Update Report classes
dhekra-rouatbi Jul 9, 2024
18a0678
Add serverId to BaseReport
dhekra-rouatbi Jul 9, 2024
7ab5ac4
create OutboxMainVM
Jul 10, 2024
18cf3f0
add GDriveOutboxVM
Jul 10, 2024
21b3365
add submitMainViewModel and implement it on tella reports and drive r…
Jul 11, 2024
56ec723
Update ReportFile class, Move redundant functions to DraftMainViewModel
dhekra-rouatbi Jul 11, 2024
f7e88f3
track progress update on gDrive
Jul 12, 2024
db35ecd
Merge branch 'feature/create-reusable-report-component' of https://gi…
Jul 12, 2024
4e03fe8
show proper status of uploading
Jul 12, 2024
e048eef
add folderId to gDriveReport
Jul 16, 2024
89c1414
implement pause and resume
Jul 17, 2024
448caf4
add queue to send files sequentially
Jul 18, 2024
154ccf5
persist outbox files progress
Jul 18, 2024
3e46adf
prevent duplicated files
Jul 18, 2024
245f454
fix no root folder error
Jul 18, 2024
a7bb1a9
show offline error when is not connected to internet
Jul 22, 2024
e3e9b09
Centralise updateProgressInfos in OutboxMainViewModel
dhekra-rouatbi Jul 23, 2024
a795694
fix drive encoding when adding and updating drive reports
Jul 23, 2024
c7b8296
fix merge conflicts
Jul 23, 2024
b1f63ba
only update files when tracking progress
Jul 23, 2024
2065762
Remove unused code
dhekra-rouatbi Jul 24, 2024
ab3b041
Centralise fillReportVM function in SubmittedMainViewModel class
dhekra-rouatbi Jul 24, 2024
a29d4d5
Refactor code to start uploading report from draft
dhekra-rouatbi Jul 24, 2024
ee69527
fix duplicated files issue in shared drive and fix some bugs
Jul 25, 2024
cf04bee
remove everything related to drive server after deleting the connection
Jul 25, 2024
bcf2792
fix UI errors
Jul 26, 2024
a783e96
Merge pull request #166 from Horizontal-org/feature/create-reusable-r…
ValbuenaG Jul 29, 2024
11d8222
Merge pull request #158 from Horizontal-org/g-drive/send-reports-ui
ValbuenaG Jul 29, 2024
5b18a81
Merge pull request #145 from Horizontal-org/g-drive/install-sdk
ValbuenaG Jul 29, 2024
2f976ba
change client id and add navigation fix
Jul 29, 2024
2f5d61a
organize files and folder structure
Jul 29, 2024
d6acf98
add remaining localizable strings
Jul 29, 2024
44bfdec
pause submission when app enter bg mode or user exit the app
Jul 29, 2024
d422373
fix localizable issues
Jul 31, 2024
85428f0
improve sign in state on GDriveAuthVM
Jul 31, 2024
839c286
remove environmentObjects for mainAppModel
Aug 2, 2024
e1c7c79
fix wording for page component
Aug 2, 2024
abb0fd2
remove BaseReportsVM
Aug 5, 2024
440ce77
rename reportMainViewModel to ReportsMainViewModel
Aug 5, 2024
af23571
remove EnvironmentObject from AddFilesToDraftView
Aug 5, 2024
24f55de
add debounceInterval to pause/resume to prevent app crashes
Aug 9, 2024
bd62d6a
fix design feedback
Aug 12, 2024
8b31cd6
fix localizableSettings format
Aug 14, 2024
9d229cf
Merge pull request #147 from Horizontal-org/g-drive/create-server-con…
ValbuenaG Aug 14, 2024
904b96c
remove unused error
Aug 14, 2024
f6d87dd
fix connection item title and change db version
Aug 15, 2024
58aa8c3
add some fixes to deleteServerTexts
Aug 15, 2024
b583038
fix localizable strings
Aug 15, 2024
65b7043
change disabling button to isValid in outbox details
Aug 15, 2024
2d14666
hotfix for large files
Aug 15, 2024
9803535
remove server protocol and replace print for debugLog
Aug 16, 2024
e10fb52
remove generic from draft report
Aug 16, 2024
06c6b56
remove drive report files when deleting a report
Aug 16, 2024
45707db
add missing localizable strings
Aug 16, 2024
59e4adc
move Components/connections to CommonConnectionReport
Aug 16, 2024
e550343
simplify serverArray logic in HomeView
Aug 16, 2024
b685476
add struct for simplifying upload file function params
Aug 16, 2024
376aac7
add new initializer to ReportFile class
Aug 19, 2024
715ee86
remove server from driveOutboxVM
Aug 19, 2024
d270ddc
move processing of vault files to parent method
Aug 19, 2024
cdaf1f0
refactor initializers in reportViewModel
Aug 19, 2024
6276ae5
fix thread issues in pause/resume
Aug 21, 2024
7058044
remove environmentObject
Aug 21, 2024
5edfda3
remove report initializaiton in submitReport method on tellaweb
Aug 21, 2024
f2df9f3
remove isUploading from drive repository
Aug 21, 2024
f942f94
small fix in submitReport method for google drive
Aug 21, 2024
330bbb1
convert fileURL method into an asynchronous operation
Aug 21, 2024
39f3732
check if drive upload queue is empty before removing an item
Aug 23, 2024
d3b80ad
refactor drive errors
Aug 23, 2024
e13091b
add rest of localizable errors
Aug 23, 2024
5dc437e
add folder name to driveserver
Aug 23, 2024
0fa19a3
change db version to apply folder name changes
Aug 23, 2024
a9f2fc1
preven duplicated folder name
Aug 23, 2024
0a8c355
Allow only one instace of Uwazi (#172)
Rimktarii Aug 26, 2024
3124106
rollback to db version 6
Aug 26, 2024
9c36fd8
remove hardcoded client id and fix logical error in server list
Aug 26, 2024
500664e
fix bug in uwazi card
Aug 26, 2024
5ca95d8
Add TellaConfig
dhekra-rouatbi Aug 27, 2024
89d18ef
Refactor APIError errorMessage, remove optionnal message
Rimktarii Aug 27, 2024
e8b155f
Remove unused code
Rimktarii Aug 27, 2024
b4d1b19
more fixes
Aug 27, 2024
4a641df
update g-drive server
Aug 27, 2024
bf32539
fix edge case in drive server connection
Aug 27, 2024
61190ce
refactor errors in gDrive
Aug 27, 2024
1f65fe0
Merge pull request #174 from Horizontal-org/feature/tella_config
ValbuenaG Aug 27, 2024
2262279
Merge branch 'feature/RefactorAPIErrorMessage' into feature/g-drive
dhekra-rouatbi Aug 27, 2024
ca15a12
refactor errors
Aug 27, 2024
9f2fe27
parse auth drive error as APIError
Aug 27, 2024
3cb37f1
remove TellaConfig
Aug 28, 2024
1f3bae9
re create tella config file
Aug 28, 2024
275780b
add tella config to project configuration
Aug 28, 2024
c6ebb37
Select server view : Fix next button action (#176)
dhekra-rouatbi Aug 28, 2024
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
4 changes: 3 additions & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ target 'Tella' do
pod 'SQLCipher', ">= 4.5.2"
pod 'ZIPFoundation'
pod 'Mantis', '~> 2.21.0'

pod 'GoogleSignIn'
pod 'GoogleAPIClientForREST/Drive'

target 'TellaTests' do
inherit! :search_paths
# Pods for testing
Expand Down
394 changes: 329 additions & 65 deletions Tella.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Tella/Application/TellaApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ struct TellaApp: App {
UIApplication.getTopViewController()?.dismiss(animated: false)
self.saveData(lockApptype: .enterInBackground)
case .active:
UIApplication.getTopViewController()?.dismiss(animated: false)
self.resetApp()
case .inactive:
appViewState.homeViewModel.shouldShowSecurityScreen = true
Expand Down Expand Up @@ -72,7 +71,8 @@ struct TellaApp: App {
let shouldResetApp = appViewState.homeViewModel.shouldResetApp()

if shouldResetApp && appEnterInBackground && !hasFileOnBackground {

UIApplication.getTopViewController()?.dismiss(animated: false)

DispatchQueue.main.async {
appViewState.shouldHidePresentedView = true
appViewState.resetApp()
Expand Down
12 changes: 8 additions & 4 deletions Tella/Components/NavigationHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@ import SwiftUI

enum NavigationType {
case save
case draft
case validate
case reload
case none
case delete

var imageName: String {
switch self {
case .save: return "reports.save"
case .draft: return "reports.save"
case .validate: return "report.select-files"
case .reload: return "arrow.clockwise"
case .delete: return "report.delete-outbox"
case .none: return ""
case .none, .save: return ""
}
}

var backButtonIcon: String {
switch self {
case .save: return "close"
case .save, .draft: return "close"
default: return "back"
}
}
Expand All @@ -40,13 +41,14 @@ struct NavigationHeaderView: View {
var rightButtonAction: (() -> Void)?
var title: String = ""
var type: NavigationType
var isRightButtonEnabled: Bool = true

var body: some View {
HStack(spacing: 0) {
backButton
headerTitleView
Spacer()
if(type != .none) {
if(!type.imageName.isEmpty) {
rightButton
}
}.frame(height: 56)
Expand Down Expand Up @@ -78,7 +80,9 @@ struct NavigationHeaderView: View {
Image(type.imageName)
.resizable()
.frame(width: 24, height: 24)
.opacity(isRightButtonEnabled ? 1 : 0.4)
}
.disabled(!isRightButtonEnabled)
}
}

Expand Down
32 changes: 32 additions & 0 deletions Tella/Components/ServerConnectionHeaderView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// ServerConnectionHeaderView.swift
// Tella
//
// Created by gus valbuena on 5/29/24.
// Copyright © 2024 HORIZONTAL. All rights reserved.
//

import SwiftUI

struct ServerConnectionHeaderView: View {
var title: String
var subtitle: String
var body: some View {
VStack(spacing: 8) {
Image("gdrive.icon")
.padding(.bottom, 16)
Text(title)
.font(.custom(Styles.Fonts.semiBoldFontName, size: 18))
.foregroundColor(.white)
.multilineTextAlignment(.center)
Text(subtitle)
.font(.custom(Styles.Fonts.regularFontName, size: 14))
.foregroundColor(.white)
.multilineTextAlignment(.center)
}.padding(.horizontal, 20)
}
}

#Preview {
ServerConnectionHeaderView(title: "title", subtitle: "subtitle")
}
6 changes: 3 additions & 3 deletions Tella/Components/Tabs/PageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import SwiftUI
class PageViewItem {

var title : String
var page : Pages
var page : Page
var number : Int

init(title: String, page: Pages, number: Int) {
init(title: String, page: Page, number: Int) {
self.title = title
self.page = page
self.number = number
Expand All @@ -19,7 +19,7 @@ class PageViewItem {

public struct PageView: View {

@Binding var selectedOption: Pages
@Binding var selectedOption: Page
var pageViewItems : [PageViewItem]

public var body: some View {
Expand Down
4 changes: 2 additions & 2 deletions Tella/Components/Tabs/PageViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ struct PageViewCell: View {
let title: String
let number: Int

let page: Pages
let page: Page

@Binding var selectedOption: Pages
@Binding var selectedOption: Page

public var body: some View {

Expand Down
2 changes: 1 addition & 1 deletion Tella/Components/Tabs/Pages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

public enum Pages: Hashable {
public enum Page: Hashable {

case draft
case outbox
Expand Down
46 changes: 26 additions & 20 deletions Tella/Components/ToastView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,37 @@
import SwiftUI

struct ToastView: View {

@State var isShowingView : Bool = true
var message : String
var width = CGFloat.infinity

var message: String
@State private var isShowing = true

var body: some View {

VStack {

Spacer()

Text(message)
.font(.custom(Styles.Fonts.regularFontName, size: 14))
.foregroundColor(.black)
.padding()
.frame(maxWidth: width)
.background(Color.white)
.cornerRadius(4)
.padding()
ZStack {
if isShowing {
Text(message)
.font(.custom(Styles.Fonts.regularFontName, size: 14))
.foregroundColor(.black)
.padding()
.frame(maxWidth: .infinity)
.background(Color.white)
.cornerRadius(4)
.padding()
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
withAnimation {
isShowing = false
}
}
}
}
}
.padding()
}
}

struct ToastView_Previews: PreviewProvider {
static var previews: some View {
ToastView( message: "Message")
ZStack {
Styles.Colors.backgroundMain
ToastView( message: "Message")
}
}
}
10 changes: 9 additions & 1 deletion Tella/Data/Database/Common/DatabaseConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct D {

/* DATABASE VERSION */

static let databaseVersion = 5
static let databaseVersion = 7
ValbuenaG marked this conversation as resolved.
Show resolved Hide resolved

/* DEFAULT TYPES FOR DATABASE */
// MARK: - DEFAULT TYPES FOR DATABASE
Expand All @@ -34,6 +34,9 @@ struct D {
static let tUwaziEntityInstanceVaultFile = "t_uwazi_entity_instance_vault_file"
static let tFeedback = "t_feedback"
static let tResource = "t_resource"
static let tGDriveServer = "t_drive_server"
ValbuenaG marked this conversation as resolved.
Show resolved Hide resolved
static let tGDriveReport = "t_drive_report_table"
static let tGDriveInstanceVaultFile = "t_drive_instance_vault_file"

/* DATABASE COLUMNS */
// MARK: - DATABASE COLUMNS
Expand Down Expand Up @@ -90,6 +93,11 @@ struct D {
static let cFilename = "c_filename"
static let cExternalId = "c_external_id"
static let cSize = "c_size"

//gDrive
static let cRootFolder = "c_root_folder"
ValbuenaG marked this conversation as resolved.
Show resolved Hide resolved
static let cFolderId = "c_folder_id"
static let cRootFolderName = "c_root_folder_name"

}

Expand Down
8 changes: 0 additions & 8 deletions Tella/Data/Database/Common/SQLStatementBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ class SQLiteStatementBuilder {
}
}

func addColumnToExistingTable(tableName: String, column: String) {
let sqlExpression = "ALTER TABLE " + tableName + " ADD COLUMN " + column
let ret = sqlite3_exec(dbPointer, sqlExpression, nil, nil, nil)

if (ret != SQLITE_OK) { // corrupt database.
logDbErr("Error altering db table - \(tableName)")
}
}
func setNewDatabaseVersion(version:Int) throws {

let sql = ("PRAGMA user_version = \(version)")
Expand Down
73 changes: 73 additions & 0 deletions Tella/Data/Database/GDriveData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// GDriveData.swift
// Tella
//
// Created by gus valbuena on 6/28/24.
// Copyright © 2024 HORIZONTAL. All rights reserved.
//

import Foundation

extension TellaData {
func addGDriveReport(report : GDriveReport) -> Result<Int, Error> {
let id = database.addGDriveReport(report: report)

shouldReloadGDriveReports.send(true)

return id
}

func getDraftGDriveReport() -> [GDriveReport] {
return self.database.getDriveReports(reportStatus: [ReportStatus.draft])
}

func getOutboxedGDriveReport() -> [GDriveReport] {
return self.database.getDriveReports(reportStatus: [.finalized,
.submissionError,
.submissionPending,
.submissionPaused,
.submissionInProgress,
.submissionAutoPaused,
.submissionScheduled])
}

func getSubmittedGDriveReport() -> [GDriveReport] {
return self.database.getDriveReports(reportStatus: [ReportStatus.submitted])
}

func getDriveReport(id: Int?) -> GDriveReport? {
guard let id else { return nil }
return self.database.getGDriveReport(id: id)
}

func updateDriveReport(report: GDriveReport) -> Result<Bool, Error> {
shouldReloadGDriveReports.send(true)
return self.database.updateDriveReport(report: report)
}

func deleteDriveReport(reportId: Int?) -> Result<Bool, Error> {
shouldReloadGDriveReports.send(true)
return self.database.deleteDriveReport(reportId: reportId)
}

@discardableResult
func updateDriveReportStatus(reportId: Int, status: ReportStatus) -> Result<Bool, Error> {
shouldReloadGDriveReports.send(true)

return self.database.updateDriveReportStatus(idReport: reportId, status: status)
}

@discardableResult
func updateDriveFolderId(reportId: Int, folderId: String) -> Result<Bool, Error> {
shouldReloadGDriveReports.send(true)

return self.database.updateDriveReportFolderId(idReport: reportId, folderId: folderId)
}

@discardableResult
func updateDriveFiles(reportId: Int, files: [ReportFile]) -> Result<Bool, Error> {
shouldReloadGDriveReports.send(true)

return self.database.updateDriveReportFiles(files: files, reportId: reportId)
}
}
Loading