Skip to content

Commit 5fc2bcd

Browse files
committed
update versions
1 parent 51967d7 commit 5fc2bcd

6 files changed

Lines changed: 64 additions & 16 deletions

File tree

data.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@
4646
}
4747
],
4848
"versions": [
49+
{
50+
"npm": "6.5.0",
51+
"url": {
52+
"linux": "https://nodejs.org/download/release/v11.8.0/node-v11.8.0-linux-x64.tar.xz",
53+
"darwin": "https://nodejs.org/download/release/v11.8.0/node-v11.8.0-darwin-x64.tar.xz",
54+
"shasum256": "https://nodejs.org/download/release/v11.8.0/SHASUMS256.txt",
55+
"win": "https://nodejs.org/download/release/v11.8.0/node-v11.8.0-win-x64.7z"
56+
},
57+
"v8": "7.0.276.38",
58+
"version": "11.8.0",
59+
"date": "2019-01-24",
60+
"node-module-version": "67"
61+
},
4962
{
5063
"npm": "6.5.0",
5164
"url": {

mac/Base.lproj/Main.storyboard

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -711,19 +711,19 @@
711711
</connections>
712712
</segmentedControl>
713713
</toolbarItem>
714-
<toolbarItem implicitItemIdentifier="383DBE9B-7B43-4574-BC60-B642A3E4B8F8" label="Current Version" paletteLabel="Current Version" id="mYe-hx-4aL">
714+
<toolbarItem implicitItemIdentifier="507EBD12-4645-4D32-A77E-DB5215F3C491" label="Refresh" paletteLabel="Refresh" image="NSRefreshTemplate" sizingBehavior="auto" id="NDs-Eu-f3z">
715715
<nil key="toolTip"/>
716-
<size key="minSize" width="38" height="17"/>
717-
<size key="maxSize" width="204" height="17"/>
718-
<textField key="view" horizontalHuggingPriority="251" verticalHuggingPriority="750" id="sma-bh-gC0">
719-
<rect key="frame" x="0.0" y="14" width="204" height="17"/>
716+
<button key="view" verticalHuggingPriority="750" id="y8A-lY-io1">
717+
<rect key="frame" x="2" y="14" width="44" height="43"/>
720718
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
721-
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Current Version" id="5Fm-KL-l2e">
719+
<buttonCell key="cell" type="push" bezelStyle="rounded" image="NSRefreshTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Jrw-5R-20b">
720+
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
722721
<font key="font" metaFont="system"/>
723-
<color key="textColor" name="controlDarkShadowColor" catalog="System" colorSpace="catalog"/>
724-
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
725-
</textFieldCell>
726-
</textField>
722+
</buttonCell>
723+
<connections>
724+
<action selector="refresh:" target="B8D-0N-5wS" id="8yW-ai-qWn"/>
725+
</connections>
726+
</button>
727727
</toolbarItem>
728728
<toolbarItem implicitItemIdentifier="B43759D6-47A5-4A0E-9292-1D720BC75B53" label="Loading Indicator" paletteLabel="Loading Indicator" tag="-1" id="b4L-wM-Ge9" userLabel="Loading Indicator">
729729
<nil key="toolTip"/>
@@ -739,7 +739,7 @@
739739
<toolbarItem reference="H3u-9J-tuD"/>
740740
<toolbarItem reference="b4L-wM-Ge9"/>
741741
<toolbarItem reference="VUM-zR-QcG"/>
742-
<toolbarItem reference="mYe-hx-4aL"/>
742+
<toolbarItem reference="NDs-Eu-f3z"/>
743743
</defaultToolbarItems>
744744
</toolbar>
745745
<connections>
@@ -748,6 +748,7 @@
748748
</window>
749749
<connections>
750750
<outlet property="loadingIndicator" destination="LVL-Jd-J81" id="gx8-GL-GVl"/>
751+
<outlet property="refreshButton" destination="y8A-lY-io1" id="9Ab-dR-loR"/>
751752
<outlet property="tabControl" destination="DSK-0o-KEh" id="5Cl-Qf-beu"/>
752753
<segue destination="6NC-pZ-gSe" kind="relationship" relationship="window.shadowedContentViewController" id="KNi-gb-cfu"/>
753754
</connections>
@@ -1229,6 +1230,7 @@
12291230
<resources>
12301231
<image name="NSActionTemplate" width="14" height="14"/>
12311232
<image name="NSListViewTemplate" width="14" height="10"/>
1233+
<image name="NSRefreshTemplate" width="11" height="15"/>
12321234
<image name="NSRevealFreestandingTemplate" width="14" height="14"/>
12331235
</resources>
12341236
</document>

mac/DownloadViewController.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ class DownloadViewController: NSSplitViewController,
3030

3131
override func viewDidLoad() {
3232
super.viewDidLoad()
33+
NotificationCenter.default.addObserver(self, selector: #selector(self.refresh(notification:)), name: Notification.Name("refresh-list"), object: nil)
34+
3335
sidebarView.expandItem(rootElement)
3436
self.initStore()
35-
3637
}
3738

3839
/**
@@ -170,4 +171,14 @@ class DownloadViewController: NSSplitViewController,
170171
print("no row clicked")
171172
}
172173
}
174+
175+
/* ---------- Refresh ---------- */
176+
177+
@objc func refresh(notification: Notification) {
178+
NotificationCenter.default.post(name: NSNotification.Name("show-loading"), object: nil)
179+
self.store?.refresh {
180+
NotificationCenter.default.post(name: NSNotification.Name("hide-loading"), object: nil)
181+
self.tableView.reloadData()
182+
}
183+
}
173184
}

mac/Store.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ let VERSION_URL = "https://raw.githubusercontent.com/learning/node-box/master/da
1414
class Store {
1515
static private var store:Store? = nil;
1616

17-
var branches:Array<Branch>;
18-
var versions:Array<Version>;
17+
var branches:Array<Branch> = [];
18+
var versions:Array<Version> = [];
19+
20+
init (data: Dictionary<String, Any>) {
21+
self.updateWith(data: data)
22+
}
1923

20-
init(data: Dictionary<String, Any>) {
24+
func updateWith(data: Dictionary<String, Any>) {
2125
self.branches = (data["branches"] as! Array<Dictionary<String, String>>).map { Branch(data: $0) }
2226
self.versions = (data["versions"] as! Array<Dictionary<String, Any>>).map { Version(data: $0) }
2327
do {
@@ -62,6 +66,15 @@ class Store {
6266

6367
public func refresh(onSuccess success: @escaping () -> Void) {
6468
// TODO: refresh version list
69+
Store.updateDownloadList {
70+
let data = Store.getData()
71+
if data != nil {
72+
self.updateWith(data: data!)
73+
success()
74+
} else {
75+
NotificationCenter.default.post(name: Notification.Name("alert"), object: "Download error, please try again.")
76+
}
77+
}
6578
}
6679

6780
/**

mac/WindowController.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ class WindowController: NSWindowController {
1212

1313
@IBOutlet weak var loadingIndicator: NSProgressIndicator!
1414
@IBOutlet weak var tabControl: NSSegmentedControl!
15-
15+
@IBOutlet weak var refreshButton: NSButton!
16+
1617
override func windowDidLoad() {
1718
super.windowDidLoad()
1819
NotificationCenter.default.addObserver(self, selector: #selector(self.reopen(notification:)), name: Notification.Name("reopen"), object: nil)
@@ -23,6 +24,7 @@ class WindowController: NSWindowController {
2324

2425
var frame = self.window?.frame
2526
frame?.size = NSSize(width: 620, height: 350)
27+
refreshButton.isHidden = true
2628
self.window?.setFrame(frame!, display: true)
2729
}
2830

@@ -32,6 +34,7 @@ class WindowController: NSWindowController {
3234

3335
@objc func changeTab(notification: Notification) {
3436
tabControl.setSelected(true, forSegment: notification.object as! Int)
37+
refreshButton.isHidden = (notification.object as! Int == 0)
3538
}
3639

3740
@objc func reopen(notification: Notification) {
@@ -42,9 +45,11 @@ class WindowController: NSWindowController {
4245
if notification.name.rawValue == "show-loading" {
4346
self.loadingIndicator.isHidden = false
4447
self.loadingIndicator.startAnimation(self)
48+
self.refreshButton.isEnabled = false
4549
} else {
4650
self.loadingIndicator.isHidden = true
4751
self.loadingIndicator.stopAnimation(self)
52+
self.refreshButton.isEnabled = true
4853
}
4954
}
5055

@@ -59,4 +64,8 @@ class WindowController: NSWindowController {
5964
print(response)
6065
})
6166
}
67+
68+
@IBAction func refresh(_ sender: Any) {
69+
NotificationCenter.default.post(name: NSNotification.Name("refresh-list"), object: nil)
70+
}
6271
}
Binary file not shown.

0 commit comments

Comments
 (0)