Skip to content

Commit 1c48a7b

Browse files
authored
Merge pull request #13 from commit-live-admin/master
New Feature: Task List & Toolbar
2 parents 24075fa + 072ef83 commit 1c48a7b

File tree

6 files changed

+70
-62
lines changed

6 files changed

+70
-62
lines changed

lib/auth.coffee

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ _token = require './token'
77
localStorage = require './local-storage'
88
{BrowserWindow} = require 'remote'
99
{Notification} = require 'atom'
10+
{name} = require '../package.json'
1011

1112
confirmOauthToken = (token,userId) ->
1213
headers = new Headers(
1314
{'Authorization': token }
1415
)
15-
apiEndpoint = atom.config.get('greyatom-ide').apiEndpoint
16+
apiEndpoint = atom.config.get(name).apiEndpoint
1617
AUTH_URL = "#{apiEndpoint}/users/#{userId}"
1718
fetch(AUTH_URL, {headers}).then (response) ->
1819
console.log 'Get User Response'
@@ -101,7 +102,7 @@ commitLiveSignIn = () ->
101102
atom.notifications.addSuccess 'Commit Live IDE: You have successfully logged in.'
102103
resolve()
103104

104-
apiEndpoint = atom.config.get('greyatom-ide').apiEndpoint
105+
apiEndpoint = atom.config.get(name).apiEndpoint
105106
if not win.loadURL("#{apiEndpoint}/github/login")
106107
win.destroy()
107108

lib/commit-live.coffee

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ remote = require 'remote'
1616
BrowserWindow = remote.BrowserWindow
1717
localStorage = require './local-storage'
1818
{$} = require 'atom-space-pen-views'
19+
{name} = require '../package.json'
1920

2021
toolBar = null;
2122

@@ -33,6 +34,15 @@ module.exports =
3334
@activateIDE(state)
3435

3536
@authenticateUser()
37+
@subscriptions.add atom.commands.add 'atom-workspace',
38+
'commit-live:test-task': () =>
39+
@testTask()
40+
@subscriptions.add atom.commands.add 'atom-workspace',
41+
'commit-live:submit-task': () =>
42+
@submitTask()
43+
@subscriptions.add atom.commands.add 'atom-workspace',
44+
'commit-live:execute-task': () =>
45+
@executeTask()
3646
@subscriptions.add atom.commands.add 'atom-workspace',
3747
'commit-live:toggle-dashboard': () =>
3848
@showDashboard()
@@ -42,6 +52,8 @@ module.exports =
4252
@subscriptions.add atom.commands.add 'atom-workspace',
4353
'commit-live:connect-to-project': () =>
4454
atom.commands.dispatch(atom.views.getView(atom.workspace), 'commit-live-welcome:hide')
55+
atom.commands.dispatch(atom.views.getView(atom.workspace), 'commit-live:change-project-title')
56+
atom.commands.dispatch(atom.views.getView(atom.workspace), 'commit-live:refill-tasks')
4557
preReqPopup = new Notification("info", "Fetching Prerequisites...", {dismissable: true})
4658
atom.notifications.addNotification(preReqPopup)
4759
auth().then =>
@@ -57,7 +69,7 @@ module.exports =
5769
atom.notifications.addSuccess 'Your server is ready now!'
5870
setTimeout =>
5971
@studentServer = JSON.parse(localStorage.get('commit-live:user-info')).servers.student
60-
@connectToFileTreeInFiveSeconds()
72+
@waitAndConnectToServer()
6173
, 0
6274
.catch =>
6375
spinUpPopup.dismiss()
@@ -83,15 +95,12 @@ module.exports =
8395
if !dashboardView.length
8496
atom.commands.dispatch(atom.views.getView(atom.workspace), 'commit-live-welcome:show-dashboard')
8597
if atom.project.remoteftp.isConnected()
86-
atom.commands.dispatch(atom.views.getView(atom.workspace), 'commit-live-tree-view:toggle')
87-
atom.commands.dispatch(atom.views.getView(atom.workspace), 'commit-live:toggle-terminal')
98+
atom.project['remoteftp-main'].treeView.detach()
99+
@termView.panel.hide()
88100

89101
showCodingScreen: () ->
90-
treeView = $('.greyatom-tree-view-view')
91-
terminalView = $('.commit-live-terminal-view')
92-
atom.commands.dispatch(atom.views.getView(atom.workspace), 'commit-live-tree-view:toggle') if !treeView.length
93-
if terminalView.length && terminalView.is(':hidden')
94-
atom.commands.dispatch(atom.views.getView(atom.workspace), 'commit-live:toggle-terminal')
102+
atom.project['remoteftp-main'].treeView.attach()
103+
@termView.panel.show()
95104
lastProject = JSON.parse(localStorage.get('commit-live:last-opened-project'))
96105
if lastProject
97106
@termView?.openLab(lastProject.id)
@@ -103,22 +112,16 @@ module.exports =
103112
});
104113
atom.notifications.addNotification(sessionExpiredNotify)
105114

106-
connectToFileTreeInFiveSeconds: () ->
115+
waitAndConnectToServer: () ->
107116
waitTime = 10 # seconds
108117
launchPopup = null
109-
intervalVar = setInterval ->
110-
if launchPopup
111-
launchPopup.dismiss()
112-
launchPopup = null
113-
if waitTime == 0
114-
if atom.project and atom.project.remoteftp
115-
atom.project.remoteftp.connectToStudentFTP()
116-
clearInterval(intervalVar)
117-
return
118-
launchPopup = new Notification("info", "Connecting in #{waitTime}...", {dismissable: true})
119-
atom.notifications.addNotification(launchPopup)
120-
waitTime = waitTime - 1
121-
, 1000
118+
launchPopup = new Notification("info", "Launching our services...", {dismissable: true})
119+
atom.notifications.addNotification(launchPopup)
120+
setTimeout ->
121+
launchPopup.dismiss()
122+
if atom.project and atom.project.remoteftp
123+
atom.project.remoteftp.connectToStudentFTP()
124+
, 1000 * waitTime
122125

123126
authenticateUser: () ->
124127
authPopup = new Notification("info", "Commit Live IDE: Authenticating...", {dismissable: true})
@@ -198,7 +201,7 @@ module.exports =
198201
'commit-live:reset': => @term.reset()
199202
# 'application:update-ile': -> (new Updater).checkForUpdate()
200203

201-
atom.config.onDidChange 'greyatom-ide.notifier', ({newValue}) =>
204+
atom.config.onDidChange "#{name}.notifier", ({newValue}) =>
202205
if newValue then @activateNotifier() else @notifier.deactivate()
203206

204207
openPath = localStorage.get('commitLiveOpenLabOnActivation')
@@ -207,7 +210,7 @@ module.exports =
207210
@termView.openLab(openPath)
208211

209212
activateNotifier: ->
210-
if atom.config.get('greyatom-ide.notifier')
213+
if atom.config.get("#{name}.notifier")
211214
@notifier = new Notifier(@token.get())
212215
@notifier.activate()
213216

@@ -222,9 +225,6 @@ module.exports =
222225
@statusView = null
223226
@subscriptions.dispose()
224227
@projectSearch.destroy()
225-
# if toolBar
226-
# toolBar.removeItems();
227-
# toolBar = null;
228228

229229
subscribeToLogin: ->
230230
@subscriptions.add atom.commands.add 'atom-workspace',
@@ -233,26 +233,32 @@ module.exports =
233233
cleanup: ->
234234
atomHelper.cleanup()
235235

236-
consumeToolBar: (getToolBar) ->
237-
# toolBar = getToolBar('greyatom-ide');
238-
# toolBar.addButton({
239-
# icon: 'play',
240-
# callback: 'application:about',
241-
# tooltip: 'Test',
242-
# iconset: 'fa'
243-
# })
244-
# toolBar.addButton({
245-
# icon: 'eject',
246-
# callback: 'application:about',
247-
# tooltip: 'Submit',
248-
# iconset: 'fa'
249-
# })
250-
# toolBar.addButton({
251-
# icon: 'exchange',
252-
# callback: 'commit-live:get-all-projects',
253-
# tooltip: 'Switch Project',
254-
# iconset: 'fa'
255-
# })
236+
testTask: ->
237+
@termView.showAndFocus()
238+
blob = localStorage.get('commit-live:current-track')
239+
if blob
240+
{titleSlug, titleSlugTestCase} = JSON.parse(blob)
241+
path = atom.project.remoteftp.getPathForTrack(titleSlug)
242+
command = "cd #{path} \r clear \rclive test #{titleSlugTestCase}"
243+
@termView.executeCommand(command)
244+
245+
submitTask: ->
246+
@termView.showAndFocus()
247+
blob = localStorage.get('commit-live:current-track')
248+
if blob
249+
{titleSlug, titleSlugTestCase} = JSON.parse(blob)
250+
path = atom.project.remoteftp.getPathForTrack(titleSlug)
251+
command = "cd #{path} \r clear \rclive submit #{titleSlugTestCase}"
252+
@termView.executeCommand(command)
253+
254+
executeTask: ->
255+
@termView.showAndFocus()
256+
blob = localStorage.get('commit-live:current-track')
257+
if blob
258+
{titleSlug, testCase} = JSON.parse(blob)
259+
path = atom.project.remoteftp.getPathForTrack(titleSlug)
260+
command = "cd #{path} \r clear \rpython #{testCase}/build.py"
261+
@termView.executeCommand(command)
256262

257263
consumeStatusBar: (statusBar) ->
258264
@addStatusBar = statusBar.addRightTile
@@ -268,7 +274,7 @@ module.exports =
268274
localStorage.delete('commit-live:last-opened-project')
269275
@token.unset()
270276
@token.unsetID()
271-
atom.reload()
277+
atom.restartApplication()
272278

273279
checkForV1WindowsInstall: ->
274280
require('./windows')

lib/instance.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
fetch = require './fetch'
22
_token = require './token'
33
localStorage = require './local-storage'
4+
{name} = require '../package.json'
45

56
callStart = (token, instanceId) ->
67
headers = new Headers(
78
{'Authorization': token }
89
)
9-
apiEndpoint = atom.config.get('greyatom-ide').apiEndpoint
10+
apiEndpoint = atom.config.get(name).apiEndpoint
1011
AUTH_URL = "#{apiEndpoint}/aws/toggleServer/#{instanceId}?action=start"
1112
fetch(AUTH_URL, {method:'PUT',headers}).then (response) ->
1213
console.log 'Start Instance Response'

lib/project-search.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import fuzzaldrinPlus from 'fuzzaldrin-plus'
99
import _token from './token'
1010
import localStorage from './local-storage'
1111
import fetch from './fetch'
12+
import {name} from '../package.json'
1213

1314
function highlight (path, matches, offsetIndex) {
1415
let lastIndex = 0
@@ -159,7 +160,7 @@ export default class RemoteFileSearchView {
159160
Authorization: token,
160161
});
161162
const courseId = JSON.parse(localStorage.get('commit-live:user-info')).courseId;
162-
const apiEndpoint = atom.config.get('greyatom-ide').apiEndpoint
163+
const apiEndpoint = atom.config.get(name).apiEndpoint
163164
const getAllProjectApi = `${apiEndpoint}/user/course/${courseId}/program`;
164165
fetch(getAllProjectApi, {
165166
headers,

lib/views/terminal.coffee

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class TerminalView extends View
109109
'commit-live:reset-font-size': => @resetFontSize()
110110

111111
sendClear: ->
112-
console.log 'm at sendClear'
112+
# console.log 'm at sendClear'
113113
if !@isOpenLabActive
114114
@terminal.send('clear \r')
115115

@@ -120,10 +120,14 @@ class TerminalView extends View
120120
if path
121121
@isOpenLabActive = true
122122
setTimeout (=>
123-
@terminal.send('clive open ' + path.toString() + '\r')
123+
@terminal.send('clear \rclive open ' + path.toString() + '\r')
124124
), 2000
125125
@openPath = null
126126

127+
executeCommand: (command)->
128+
# console.log command
129+
@terminal.send(command + '\r')
130+
127131
onBlur: (e) ->
128132
{relatedTarget} = e
129133
@unfocus() if relatedTarget? and relatedTarget isnt @terminalWrapper.element

package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
"versions": {
2424
"^1.0.0": "consumeStatusBar"
2525
}
26-
},
27-
"tool-bar": {
28-
"versions": {
29-
"^0 || ^1": "consumeToolBar"
30-
}
3126
}
3227
},
3328
"dependencies": {
@@ -46,10 +41,10 @@
4641
"utf8": "2.1.1"
4742
},
4843
"packageDependencies": {
49-
"greyatom-tree-view": "1.3.13",
44+
"greyatom-tree-view": "1.3.24",
5045
"tablr": "1.8.3",
51-
"tool-bar": "1.1.0",
52-
"greyatom-ide-welcome": "0.0.7",
46+
"tool-bar": "1.1.1",
47+
"greyatom-ide-welcome": "0.0.9",
5348
"greyatom-ide-background-tips": "0.0.3"
5449
},
5550
"configSchema": {

0 commit comments

Comments
 (0)