No known key found for this signature in database
GPG Key ID: 1D7529BE14E2BBA9
8 changed files with
91 additions and
14 deletions
-
RSwitch/Data/RStudioServerSess+CoreDataClass.swift
-
RSwitch/Data/RStudioServerSess+CoreDataProperties.swift
-
RSwitch/RSwitch.xcdatamodeld/RSwitch.xcdatamodel/contents
-
RSwitch/Swift/AppDelegate.swift
-
RSwitch/Swift/MenuActions/RStudioServerAction.swift
-
RSwitch/Swift/Sessions/RStudioServerSession.swift
-
RSwitch/Swift/Sessions/RStudioServerSessionManager.swift
-
RSwitch/Swift/WebViewController.swift
|
|
@ -0,0 +1,15 @@ |
|
|
|
// |
|
|
|
// RStudioServerSess+CoreDataClass.swift |
|
|
|
// |
|
|
|
// |
|
|
|
// Created by hrbrmstr on 9/5/19. |
|
|
|
// |
|
|
|
// |
|
|
|
|
|
|
|
import Foundation |
|
|
|
import CoreData |
|
|
|
|
|
|
|
|
|
|
|
public class RStudioServerSess: NSManagedObject { |
|
|
|
|
|
|
|
} |
|
|
@ -0,0 +1,22 @@ |
|
|
|
// |
|
|
|
// RStudioServerSess+CoreDataProperties.swift |
|
|
|
// |
|
|
|
// |
|
|
|
// Created by hrbrmstr on 9/5/19. |
|
|
|
// |
|
|
|
// |
|
|
|
|
|
|
|
import Foundation |
|
|
|
import CoreData |
|
|
|
|
|
|
|
|
|
|
|
extension RStudioServerSess { |
|
|
|
|
|
|
|
@nonobjc public class func fetchRequest() -> NSFetchRequest<RStudioServerSess> { |
|
|
|
return NSFetchRequest<RStudioServerSess>(entityName: "RStudioServerSess") |
|
|
|
} |
|
|
|
|
|
|
|
@NSManaged public var menuTitle: String? |
|
|
|
@NSManaged public var url: String? |
|
|
|
|
|
|
|
} |
|
|
@ -0,0 +1,10 @@ |
|
|
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
|
|
|
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="14897.2" systemVersion="19A546d" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> |
|
|
|
<entity name="RStudioServerSess" representedClassName=".RStudioServerSess" syncable="YES"> |
|
|
|
<attribute name="menuTitle" attributeType="String"/> |
|
|
|
<attribute name="url" attributeType="String"/> |
|
|
|
</entity> |
|
|
|
<elements> |
|
|
|
<element name="RStudioServerSess" positionX="-63" positionY="-18" width="128" height="73"/> |
|
|
|
</elements> |
|
|
|
</model> |
|
|
@ -40,13 +40,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { |
|
|
|
|
|
|
|
rdevel_enabled = true |
|
|
|
rstudio_enabled = true |
|
|
|
|
|
|
|
sess = RStudioServerSessionManager() |
|
|
|
sess.newSession(url: "https://rstudio.hrbrmstr.de", title: "One") |
|
|
|
sess.newSession(url: "https://rud.is/b", title: "Two") |
|
|
|
|
|
|
|
sess.debugSessions() |
|
|
|
|
|
|
|
|
|
|
|
URLCache.shared = URLCache(memoryCapacity: 0, diskCapacity: 0, diskPath: nil) |
|
|
|
|
|
|
|
} |
|
|
@ -71,6 +65,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { |
|
|
|
mainStoryboard = NSStoryboard(name: "Main", bundle: nil) |
|
|
|
|
|
|
|
abtController = (mainStoryboard.instantiateController(withIdentifier: "aboutPanelController") as! NSWindowController) |
|
|
|
|
|
|
|
sess = RStudioServerSessionManager() |
|
|
|
// sess.newSession(url: "https://rstudio.hrbrmstr.de", title: "One") |
|
|
|
// sess.newSession(url: "https://rud.is/b", title: "Two") |
|
|
|
|
|
|
|
sess.debugSessions() |
|
|
|
|
|
|
|
timer = Timer.scheduledTimer( |
|
|
|
timeInterval: 3600, |
|
|
@ -81,7 +81,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { |
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) { |
|
|
|
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) { } |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
@ -44,7 +44,7 @@ class RStudioServerMenuAction { |
|
|
|
rsSub.addItem(newRStudioSessItem) |
|
|
|
rsSub.addItem(NSMenuItem.separator()) |
|
|
|
|
|
|
|
for sess in manager.sessions { |
|
|
|
for sess in manager.sessions! { |
|
|
|
|
|
|
|
let sessItem = NSMenuItem(title: sess.menuTitle, action: Selector(("activateServerSession:")), keyEquivalent: "") |
|
|
|
sessItem.representedObject = sess |
|
|
|
|
|
@ -9,16 +9,23 @@ |
|
|
|
import Foundation |
|
|
|
import Cocoa |
|
|
|
|
|
|
|
class RStudioServerSession { |
|
|
|
class RStudioServerSession : Codable { |
|
|
|
|
|
|
|
var url : String |
|
|
|
var menuTitle : String |
|
|
|
var wk : NSWindowController? |
|
|
|
var wv : WebViewController? |
|
|
|
|
|
|
|
private enum CodingKeys: String, CodingKey { |
|
|
|
case url |
|
|
|
case menuTitle |
|
|
|
} |
|
|
|
|
|
|
|
init(url: String, title: String) { |
|
|
|
self.url = url |
|
|
|
self.menuTitle = title |
|
|
|
self.wk = nil |
|
|
|
self.wv = nil |
|
|
|
} |
|
|
|
|
|
|
|
func show() { |
|
|
@ -27,6 +34,7 @@ class RStudioServerSession { |
|
|
|
let mainStoryboard = appDelegate.mainStoryboard! |
|
|
|
|
|
|
|
if (wk == nil) { |
|
|
|
print("wk was nil") |
|
|
|
wk = (mainStoryboard.instantiateController(withIdentifier: "wkPanelController") as! NSWindowController) |
|
|
|
wv = wk!.window?.contentViewController as? WebViewController |
|
|
|
wv!.url = url |
|
|
@ -34,7 +42,6 @@ class RStudioServerSession { |
|
|
|
|
|
|
|
wk?.window?.orderFront(appDelegate) |
|
|
|
wk?.showWindow(appDelegate) |
|
|
|
wk?.window?.orderFront(appDelegate) |
|
|
|
|
|
|
|
NSApp.activate(ignoringOtherApps: true) |
|
|
|
|
|
|
|
|
|
@ -12,15 +12,30 @@ import WebKit |
|
|
|
|
|
|
|
class RStudioServerSessionManager { |
|
|
|
|
|
|
|
var sessions = [ RStudioServerSession ]() |
|
|
|
var sessions : [ RStudioServerSession ]? |
|
|
|
|
|
|
|
init() { |
|
|
|
loadSessions() |
|
|
|
} |
|
|
|
|
|
|
|
func newSession(url: String, title: String) { |
|
|
|
sessions.append(RStudioServerSession(url: url, title: title)) |
|
|
|
sessions!.append(RStudioServerSession(url: url, title: title)) |
|
|
|
let sessionsData = try! JSONEncoder().encode(sessions) |
|
|
|
UserDefaults.standard.set(sessionsData, forKey: "rstudioServerSessions") |
|
|
|
} |
|
|
|
|
|
|
|
func loadSessions() { |
|
|
|
let sessionsData = UserDefaults.standard.data(forKey: "rstudioServerSessions") |
|
|
|
if (sessionsData != nil) { |
|
|
|
sessions = try! JSONDecoder().decode([RStudioServerSession].self, from: sessionsData!) |
|
|
|
} else { |
|
|
|
sessions = [ RStudioServerSession ]() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func debugSessions() { |
|
|
|
|
|
|
|
for s in sessions { |
|
|
|
for s in sessions! { |
|
|
|
print(s.menuTitle) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -25,5 +25,11 @@ class WebViewController: NSViewController { |
|
|
|
let request = URLRequest(url: URL(string: url)!) |
|
|
|
rstudioServerView.load(request) |
|
|
|
} |
|
|
|
|
|
|
|
override var representedObject: Any? { |
|
|
|
didSet { |
|
|
|
// Update the view, if already loaded. |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|