NCCreateFormUploadRichdocuments.swift 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. //
  2. // CCCreateCloud.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 14/11/18.
  6. // Copyright © 2017 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <m.faggiana@twsweb.it>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import Foundation
  24. // MARK: -
  25. class NCCreateFormUploadRichdocuments: UIViewController, NCSelectDelegate {
  26. var typeTemplate = ""
  27. var serverUrl = ""
  28. var fileNameFolder = ""
  29. var fileName = ""
  30. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  31. @objc convenience init(typeTemplate : String) {
  32. self.init()
  33. self.typeTemplate = typeTemplate
  34. serverUrl = appDelegate.activeMain.serverUrl
  35. if serverUrl == CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl) {
  36. fileNameFolder = "/"
  37. } else {
  38. fileNameFolder = (serverUrl as NSString).lastPathComponent
  39. }
  40. }
  41. /*
  42. func initializeForm() {
  43. let form : XLFormDescriptor = XLFormDescriptor(title: NSLocalizedString("_upload_photos_videos_", comment: "")) as XLFormDescriptor
  44. form.rowNavigationOptions = XLFormRowNavigationOptions.stopDisableRow
  45. var section : XLFormSectionDescriptor
  46. var row : XLFormRowDescriptor
  47. // Section: Destination Folder
  48. section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_save_path_", comment: ""))
  49. form.addFormSection(section)
  50. row = XLFormRowDescriptor(tag: "ButtonDestinationFolder", rowType: XLFormRowDescriptorTypeButton, title: fileNameFolder)
  51. row.action.formSelector = #selector(changeDestinationFolder(_:))
  52. let imageFolder = CCGraphics.changeThemingColorImage(UIImage(named: "folder")!, multiplier:1, color: NCBrandColor.sharedInstance.brandElement) as UIImage
  53. row.cellConfig["imageView.image"] = imageFolder
  54. row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.right.rawValue
  55. row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
  56. section.addFormRow(row)
  57. // Section: File Name
  58. section = XLFormSectionDescriptor.formSection(withTitle: NSLocalizedString("_filename_", comment: ""))
  59. form.addFormSection(section)
  60. row = XLFormRowDescriptor(tag: "fileName", rowType: XLFormRowDescriptorTypeAccount, title: NSLocalizedString("_filename_", comment: ""))
  61. row.value = self.fileName
  62. row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 15.0)
  63. row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
  64. row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 15.0)
  65. section.addFormRow(row)
  66. self.form = form
  67. }
  68. */
  69. // MARK: - View Life Cycle
  70. override func viewDidLoad() {
  71. super.viewDidLoad()
  72. let ocNetworking = OCnetworking.init(delegate: nil, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
  73. ocNetworking?.createTemplateRichdocuments(withTemplate: typeTemplate, success: { (listOfTemplate) in
  74. //
  75. }, failure: { (message, errorCode) in
  76. //
  77. })
  78. let cancelButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(cancel))
  79. let saveButton : UIBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_save_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(save))
  80. self.navigationItem.leftBarButtonItem = cancelButton
  81. self.navigationItem.rightBarButtonItem = saveButton
  82. self.navigationController?.navigationBar.isTranslucent = false
  83. self.navigationController?.navigationBar.barTintColor = NCBrandColor.sharedInstance.brand
  84. self.navigationController?.navigationBar.tintColor = NCBrandColor.sharedInstance.brandText
  85. self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: NCBrandColor.sharedInstance.brandText]
  86. }
  87. // MARK: - Action
  88. func dismissSelect(serverUrl: String?, metadata: tableMetadata?, type: String) {
  89. guard let serverUrl = serverUrl else {
  90. return
  91. }
  92. self.serverUrl = serverUrl
  93. if serverUrl == CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl) {
  94. fileNameFolder = "/"
  95. } else {
  96. fileNameFolder = (serverUrl as NSString).lastPathComponent
  97. }
  98. }
  99. @objc func changeDestinationFolder(_ sender: XLFormRowDescriptor) {
  100. let storyboard = UIStoryboard(name: "NCSelect", bundle: nil)
  101. let navigationController = storyboard.instantiateInitialViewController() as! UINavigationController
  102. let viewController = navigationController.topViewController as! NCSelect
  103. viewController.delegate = self
  104. viewController.hideButtonCreateFolder = false
  105. viewController.includeDirectoryE2EEncryption = false
  106. viewController.includeImages = false
  107. viewController.layoutViewSelect = k_layout_view_move
  108. viewController.selectFile = false
  109. viewController.titleButtonDone = NSLocalizedString("_select_", comment: "")
  110. viewController.type = ""
  111. navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
  112. self.present(navigationController, animated: true, completion: nil)
  113. }
  114. @objc func save() {
  115. self.dismiss(animated: true, completion: {
  116. //self.appDelegate.activeMain.uploadFileAsset(self.assets, serverUrl: self.serverUrl, useSubFolder: useSubFolder, session: self.session)
  117. })
  118. }
  119. @objc func cancel() {
  120. self.dismiss(animated: true, completion: nil)
  121. }
  122. }
  123. // MARK: -
  124. // MARK: -
  125. //MARK: -