-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Native support of Airtable #2
Comments
@milanvarady We now have Airlift! https://github.com/TheAcharya/Airlift We can use the pre-complied binary. |
@milanvarady For Airtable it is little more involved due to the integration of Dropbox for temporary image hosting provider. I believe it would work elegantly once it is implement correctly. I have designed the mock-up ui for the Airtable tab within the Database panel. You can follow the UI layout. Tweak it a little if needed.9:
For the Dropbox Token's location, we can fix it at -
Here is the workflow.
{
"app_key": "VALUE"
}
TOOL_PATH="/Applications/Marker Data.app/Contents/Resources/airlift"
DROPBOX_TOKEN="/Users/UserID/Library/Application Support/Marker Data/Database/dropbox-token.json"
UPLOAD_LOG="/Users/UserID/Library/Application Support/Marker Data/Logs/airlift_log.txt"
$TOOL_PATH --dropbox-token $DROPBOX_TOKEN --dropbox-refresh-token --log $UPLOAD_LOG --verbose
1. Go to: https://www.dropbox.com/oauth2/authorize?response_type=code&client_id=6zh18qgnw37ifpp&token_access_type=offline&code_challenge=TphrwcwmRtkGawgxFvWQcROFMbjsTeba9BGv0Lgi0nw&code_challenge_method=S256
2. Click "Allow" (you might have to log in first).
3. Copy the authorization code.
Enter the authorization code here: We need to take this URL and direct to the
{
"app_key": "VALUE",
"refresh_token": "VALUE"
}
User would always use the same Hope the workflow makes sense to you. Thank you. |
@milanvarady I forgot to include one more field for the Airtable Tab. With this field users are given more customisation to their database. They are not confined to just "Marker ID" as their main Key Column. TOOL_PATH="/Applications/Marker Data.app/Contents/Resources/airlift"
AIRTABLE_TOKEN="REPLACE"
AIRTABLE_BASE="REPLACE"
AIRTABLE_TABLE="REPLACE"
DROPBOX_TOKEN="Users/UserID/Library/Application Support/Marker Data/Database/dropbox-token.json"
UPLOAD_PAYLOAD="REPLACE"
UPLOAD_LOG="/Users/UserID/Library/Application Support/Marker Data/Logs/airlift_log.txt"
$TOOL_PATH --token $AIRTABLE_TOKEN --base $AIRTABLE_BASE --table $AIRTABLE_TABLE --dropbox-token $DROPBOX_TOKEN --attachment-columns-map "Image Filename" "Attachments" --md --rename-key-column "Marker ID" "VALUE" --log $UPLOAD_LOG --verbose "$UPLOAD_PAYLOAD"
We now have an additional switch If the field is empty, we don't use this Hope it makes sense. |
@milanvarady I believe we can remove
|
@IAmVigneswaran I've started the Airtable implementation, however, there are two problems. 1. Airlift is not recognizing the command line arguments when trying to get the authorization URL. I used the ones you described:
The output is:
Edit: I was testing this with Airlift v1.0.6. 2. In step 9 you mention:
I can't pass data into the running shell like a user would. I can only call a command with arguments. So could the process be modified so there is a separate command to get the auth URL and to submit the authorization code? |
@milanvarady Apparently there is a bug in the latest build of Airlift creating dropbox refresh token. Hopefully we can fix this asap. TheAcharya/Airlift#31
@arjunprakash027 Can we add this additional switch? Maybe once we have fixed this, we would have a clearer picture on the workflow. |
@milanvarady We have now fixed this. You can use this test build binary for now. That should solve the first problem.
For this issue. what do you have in mind? Right now using this,
Would show this in terminal -
Proposed -
So we need to have something like After users have obtained their authorization code, they would paste into the form, Marker Data would take the value and trigger the shell script to update the |
@IAmVigneswaran Exactly. I need two additional options. One for just returning the auth URL. So like |
Creating 2 seperate processes one for getting the url and one for entering the code is possible, but the caveat here is, to get the code one must go to the url and press on "allow" button, so dropbox knows it is you who wants to get the code and give you the code. How are you planning to automate that (if you are planning) @milanvarady |
@arjunprakash027 There is no "automation". The idea is Once they have copied the code, they would paste it in the our Marker Data's I believe we can also do this. Step 1
Airlift would basically RESET and Create a new JSON File. {
"app_key": "VALUE"
}
Step 2
{
"app_key": "VALUE"
"refresh_token": "VALUE"
}
|
@milanvarady After experimenting, @arjunprakash027 has discovered that we can't able to split the process of the getting the URL first and then entering the authorization code separately. The first step is getting the authorization URL from the Dropbox server and 2nd step is to send the auth code again to the server to get the refresh token. The catch here is, we have to create a SINGLE session to get the url and send the authorization code to get the refresh token. Every session is unique and authorization code received from one session cannot be passed to another session. When we splitting our refresh-token step into 2 step process, we have to create 2 sessions because we cannot persists the session between 2 runs of the Airlift binary and therefore the code received from the first session of first step cannot be passed to the session created in 2nd step both must be done in the same step. One possible solution, we do this obtaining of Not sure if you can take ideas from our Airlift code. https://www.dropbox.com/developers/documentation/swift#overview Or find a way to pass the https://stackoverflow.com/questions/74501866/how-to-launch-terminal-and-pass-it-a-command-using-swift |
@milanvarady Not sure if this approach can solve our problem. We basically have a expose small terminal window within our Airtable form. When users click on the
https://stackoverflow.com/questions/59227688/swift-view-and-use-terminal-inside-another-application Not entirely sleek, but I believe it would work? I have seen Apps that has Terminal Emulator embedded into their UI. You need not have to add any additional swift code for dropbox swift SDK. From Chat GPT import SwiftUI
struct TerminalView: View {
@State private var terminalOutput = ""
@State private var command = ""
var body: some View {
VStack {
Text("Simple Terminal Emulator")
ScrollView {
TextEditor(text: $terminalOutput)
.frame(minWidth: 200, minHeight: 100)
.background(Color.black)
.foregroundColor(Color.green)
.font(.system(size: 12))
.disabled(true)
}
TextField("Enter command", text: $command, onCommit: executeCommand)
.padding()
.textFieldStyle(RoundedBorderTextFieldStyle())
}
.padding()
}
func executeCommand() {
// Execute the command and update terminal output
terminalOutput += "> \(command)\n"
// Add logic to execute the command and get output
let commandOutput = executeShellCommand(command)
terminalOutput += "\(commandOutput)\n"
command = ""
}
func executeShellCommand(_ command: String) -> String {
// Add logic to execute the shell command and get output
// This is just a placeholder, replace it with actual command execution code
return "Output for command: \(command)"
}
} In this example: NSTextView is used to display the terminal output. |
@IAmVigneswaran This is getting overly complicated. I don't know of any way to include a terminal inside the app, and the code you provided is not a real implementation. I think we have two reasonable options: 1. Replace Dropbox entirelyThe best would be to replace Dropbox entirely. Dropbox is not really meant for public HTTP access. The workflow to achieve this is very convoluted. Amazon's S3 file storage service IS meant for public access. It's inexpensive. We could either use an S3 bucket that all clients would use - as long as you don't have thousands of users, this should cost on the order of a few dollars per month maximum. Or, users could register their own S3 (or compatible) account and provide their own access keys, then you wouldn't need to worry about the storage costs. 2. Setup outside of the appAnother solution is to keep Dropbox but set it up outside of Marker Data in the terminal. In the documentation, you can provide the steps users can follow to set up Dropbox. |
@milanvarady Thanks for input. Option 1 - Is not possible. After heavy review of all the alternative storage providers, Dropbox is still best free option. There is no cost involved for the end user. Option 2 - Yes. It is possible but as a FINAL last resort. When all else fails. We have spent so much of effort and energy on our Application, asking users to up terminal and type commands is still not the best approach. |
@milanvarady While we agreed on opening a terminal as a separate window would be the best approach. (Last Resort) I was wondering if we can just attempt on embedding the terminal? Just a couple of tries. 🙏 From ChatGPT import SwiftUI
struct TerminalView: NSViewControllerRepresentable {
@Binding var terminalText: String
var width: CGFloat
var height: CGFloat
func makeNSViewController(context: Context) -> NSViewController {
let viewController = NSViewController()
let textView = NSTextView()
textView.isEditable = true // Allow user input
textView.backgroundColor = NSColor.black
textView.textColor = NSColor.green
viewController.view = textView
return viewController
}
func updateNSViewController(_ nsViewController: NSViewController, context: Context) {
guard let textView = nsViewController.view as? NSTextView else { return }
textView.string = terminalText
}
}
struct ContentView: View {
@State private var terminalText: String = ""
var body: some View {
VStack {
Text("Your App Content Here")
TerminalView(terminalText: $terminalText, width: 400, height: 200)
Button("Run Script") {
executeScript()
}.padding()
}
}
func executeScript() {
let scriptPath = "/Applications/Marker Data.app/Contents/Resources/dropbox-rehresh-token.sh"
terminalText.append(">> \(scriptPath)\n")
let task = Process()
task.launchPath = "/bin/bash"
task.arguments = ["-c", "sh \(scriptPath)"] // Add "sh" command here
let pipe = Pipe()
task.standardOutput = pipe
task.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()
if let output = String(data: data, encoding: .utf8) {
terminalText.append(output)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
|
@IAmVigneswaran ChatGPT won't be able to help in this regard. Building a fully functional terminal emulator is a very complicated task, it's kind of like building a web browser. We might be able to find some package that does this, but I don't know how easy would it be to interact with it, especially from Swift. Like pasting in the command and so on. |
@milanvarady Thanks for the test build! We need to tweak to the behaviour of how The It should only appear when {
"refresh_token" : "",
} |
@IAmVigneswaran I have merged the changes. Also, the checking logic has been fixed. |
@milanvarady The behaviour works correctly now. Thanks for the update! For convince, Line 19 in 976c1ec
Can the |
@milanvarady I notice that Rename Key Column is not working. But when I tested it directly with Airlift Binary. I am able to update the Data set to Airtable. I have share the Airtable Template with you. #!/bin/sh
TOOL_PATH="/Volumes/Ancestral Recall/App Projects/Airlift/airlift"
AIRTABLE_TOKEN="REPLACE"
AIRTABLE_BASE="REPLACE"
AIRTABLE_TABLE="REPLACE"
DROPBOX_TOKEN="REPLACE"
UPLOAD_PAYLOAD="REPLACE"
UPLOAD_LOG="REPLACE"
"$TOOL_PATH" --token $AIRTABLE_TOKEN --base $AIRTABLE_BASE --table $AIRTABLE_TABLE --dropbox-token "$DROPBOX_TOKEN" --attachment-columns-map "Image Filename" "Attachments" --md --rename-key-column "Marker ID" "Shot Name" --log "$UPLOAD_LOG" --verbose "$UPLOAD_PAYLOAD" |
I added a link below instead. Making the title a link doesn't make sense to me. |
I was passing in the wrong argument. Should be working now, although I get warnings like:
And the data is not uploaded. Check if it works for you. |
Perfect! |
Just tested
It is normal behaviour. When any |
@milanvarady Airlift is now updated to 1.0.7. Could you add Is it possible to Kill and Close both of Terminal windows once the Thank you. |
We already have the
It is possible, but we don't know if Marker Data opened the terminal or if the user had it already open. Because if they did, quitting the app just like that wouldn't be good. What if they have some other important process running there? |
👍
Noted! |
https://github.com/academypoa/AirtableKit
TheAcharya/MarkersExtractor#44
The text was updated successfully, but these errors were encountered: