A small menubar app that allows you to switch between R versions quickly (if you have multiple versions of R framework installed). https://rud.is/rswitch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

104 lines
2.4 KiB

//
// exportPopupViewController.swift
// RSwitch
//
// Created by hrbrmstr on 5/24/20.
// Copyright © 2020 Bob Rudis. All rights reserved.
//
import Cocoa
import WebKit
// EXPORT
class exportPopupViewController: NSViewController {
var webView: WKWebView!
var urlPath: String = ""
open override func viewDidLoad() {
super.viewDidLoad()
}
func setupWebView(configuration: WKWebViewConfiguration) {
webView = WKWebView(frame: view.bounds, configuration: configuration)
webView.autoresizingMask = [.width, .height]
webView.uiDelegate = self
webView.navigationDelegate = self
view.addSubview(webView)
}
func loadWebView(urlIn: String) {
urlPath = urlIn
NSLog("loadWebView: " + urlPath)
// Check for "/export/"
// If export, then get bring up a Save Panel and then download the file to that location
if let url = URL(string: urlPath) {
NSLog("URL path: " + url.path)
if (url.path.starts(with: "/export")) {
NSLog(" Name: " + url.queryParameters["name"]!)
let savePanel = NSSavePanel()
savePanel.canCreateDirectories = true
savePanel.nameFieldStringValue = url.queryParameters["name"]!
savePanel.beginSheetModal(for:self.view.window!) { (response) in
if (response == NSApplication.ModalResponse.OK) {
//completionHandler([savePanel.url!])
NSLog("SP OK RESP")
NSLog("From here " + url.absoluteString)
NSLog("To here " + savePanel.url!.absoluteString)
download_from_studio_server(fromRS: url.absoluteString, toFS: savePanel.url!.absoluteString)
} else {
//completionHandler(nil)
NSLog("Don't do anything!")
}
savePanel.close()
}
}
}
}
override func viewDidAppear() {
super.viewDidAppear()
}
}
extension exportPopupViewController: WKUIDelegate {
func webViewDidClose(_ webView: WKWebView) {
self.view.window?.close()
}
}
extension exportPopupViewController: WKNavigationDelegate {
open func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
print("Export DID START")
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
print("Export DID FINISH")
}
}