@@ -16,6 +16,7 @@ remote = require 'remote'
1616BrowserWindow = remote .BrowserWindow
1717localStorage = require ' ./local-storage'
1818{$ } = require ' atom-space-pen-views'
19+ {name } = require ' ../package.json'
1920
2021toolBar = 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 \r clive 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 \r clive 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 \r python #{ 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' )
0 commit comments