Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sfcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush
sfcode
Commits
5f0b478d
Commit
5f0b478d
authored
Dec 06, 2020
by
Ayush
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reconfigure routing
parent
0c9724c7
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
29 additions
and
19 deletions
+29
-19
backend/filesave.php
backend/filesave.php
+4
-4
src/app/app-routing.module.ts
src/app/app-routing.module.ts
+4
-3
src/app/arena/arena.component.ts
src/app/arena/arena.component.ts
+1
-1
src/app/file.service.ts
src/app/file.service.ts
+2
-1
src/app/file.ts
src/app/file.ts
+1
-0
src/app/file/file.component.html
src/app/file/file.component.html
+1
-1
src/app/header/header.component.html
src/app/header/header.component.html
+2
-2
src/app/home/home.component.html
src/app/home/home.component.html
+1
-1
src/app/ide/ide.component.ts
src/app/ide/ide.component.ts
+5
-2
src/app/save-file/save-file.component.ts
src/app/save-file/save-file.component.ts
+8
-3
src/app/user/user.component.ts
src/app/user/user.component.ts
+0
-1
No files found.
backend/filesave.php
View file @
5f0b478d
<?php
<?php
include_once
(
"database.php"
)
include_once
(
"database.php"
)
;
$postData
=
file_get_contents
(
"php://input"
);
$postData
=
file_get_contents
(
"php://input"
);
if
(
isset
(
$postData
)
&&
!
empty
(
$postData
))
{
if
(
isset
(
$postData
)
&&
!
empty
(
$postData
))
{
...
...
src/app/app-routing.module.ts
View file @
5f0b478d
...
@@ -11,8 +11,9 @@ import { FileComponent } from './file/file.component';
...
@@ -11,8 +11,9 @@ import { FileComponent } from './file/file.component';
const
routes
:
Routes
=
[
const
routes
:
Routes
=
[
{
path
:
'
home
'
,
component
:
HomeComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
home
'
,
component
:
HomeComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
arena/:id
'
,
component
:
ArenaComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
arena/problem/:id
'
,
component
:
ArenaComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
arena
'
,
component
:
IdeComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
arena/file/:id
'
,
component
:
IdeComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
arena/file/new
'
,
component
:
IdeComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
user
'
,
component
:
UserComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
user
'
,
component
:
UserComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
files
'
,
component
:
FileComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
files
'
,
component
:
FileComponent
,
canActivate
:
[
AuthGuard
]
},
{
path
:
'
login
'
,
component
:
LoginComponent
},
{
path
:
'
login
'
,
component
:
LoginComponent
},
...
...
src/app/arena/arena.component.ts
View file @
5f0b478d
...
@@ -19,7 +19,7 @@ export class ArenaComponent implements OnInit {
...
@@ -19,7 +19,7 @@ export class ArenaComponent implements OnInit {
}
}
ngOnInit
():
void
{
ngOnInit
():
void
{
this
.
id
=
parseInt
(
this
.
router
.
url
.
split
(
'
/
'
)[
2
],
10
);
this
.
id
=
parseInt
(
this
.
router
.
url
.
split
(
'
/
'
)[
3
],
10
);
this
.
getProblem
();
this
.
getProblem
();
const
editorArea
=
document
.
getElementById
(
'
editor
'
);
const
editorArea
=
document
.
getElementById
(
'
editor
'
);
const
editor
=
CodeMirror
.
fromTextArea
(
editorArea
as
HTMLTextAreaElement
,
{
const
editor
=
CodeMirror
.
fromTextArea
(
editorArea
as
HTMLTextAreaElement
,
{
...
...
src/app/file.service.ts
View file @
5f0b478d
...
@@ -21,10 +21,11 @@ export class FileService {
...
@@ -21,10 +21,11 @@ export class FileService {
for
(
const
item
of
arr
)
{
for
(
const
item
of
arr
)
{
ret
.
push
({
ret
.
push
({
username
:
''
,
id
:
item
,
id
:
item
,
filename
:
'
lambda
'
,
filename
:
'
lambda
'
,
language
:
'
.cpp
'
,
language
:
'
.cpp
'
,
text
:
'
Random Shit
'
,
text
:
'
Random Shit
'
});
});
}
}
...
...
src/app/file.ts
View file @
5f0b478d
export
interface
File
{
export
interface
File
{
id
:
number
;
id
:
number
;
username
:
string
;
filename
:
string
;
filename
:
string
;
language
:
string
;
language
:
string
;
text
:
string
;
text
:
string
;
...
...
src/app/file/file.component.html
View file @
5f0b478d
<div
id=
"tray"
>
<div
id=
"tray"
>
<button
style=
"margin-right: 10px;"
routerLink=
"/arena"
routerLinkActive=
"active"
>
Create A File
</button>
<button
style=
"margin-right: 10px;"
routerLink=
"/arena
/file/new
"
routerLinkActive=
"active"
>
Create A File
</button>
<button
(click)=
"onClick()"
id=
"myBtn"
style=
"margin-left: 10px;"
>
Upload A File
</button>
<button
(click)=
"onClick()"
id=
"myBtn"
style=
"margin-left: 10px;"
>
Upload A File
</button>
</div>
</div>
...
...
src/app/header/header.component.html
View file @
5f0b478d
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<a
*ngIf=
"!loggedIn"
routerLink=
"/register"
routerLinkActive=
"active"
>
Register
</a>
<a
*ngIf=
"!loggedIn"
routerLink=
"/register"
routerLinkActive=
"active"
>
Register
</a>
<a
*ngIf=
"!loggedIn"
routerLink=
"/login"
routerLinkActive=
"active"
>
Login
</a>
<a
*ngIf=
"!loggedIn"
routerLink=
"/login"
routerLinkActive=
"active"
>
Login
</a>
<a
*ngIf=
"loggedIn"
routerLink=
"/home"
routerLinkActive=
"active"
>
Home
</a>
<a
*ngIf=
"loggedIn"
routerLink=
"/home"
routerLinkActive=
"active"
>
Home
</a>
<a
*ngIf=
"loggedIn"
routerLink=
"/arena"
routerLinkActive=
"active"
>
Arena
</a>
<a
*ngIf=
"loggedIn"
routerLink=
"/arena
/file/new
"
routerLinkActive=
"active"
>
Arena
</a>
<a
*ngIf=
"loggedIn"
routerLink=
"/files"
routerLinkActive=
"active"
>
Files
</a>
<a
*ngIf=
"loggedIn"
routerLink=
"/files"
routerLinkActive=
"active"
>
Files
</a>
<a
*ngIf=
"loggedIn"
routerLink=
"/user"
routerLinkActive=
"active"
>
User
</a>
<a
*ngIf=
"loggedIn"
routerLink=
"/user"
routerLinkActive=
"active"
>
User
</a>
</nav>
</nav>
src/app/home/home.component.html
View file @
5f0b478d
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<div
*ngFor=
"let problem of problems"
class=
"card"
>
<div
*ngFor=
"let problem of problems"
class=
"card"
>
<div
class=
"title"
>
{{problem.title}}
</div>
<div
class=
"title"
>
{{problem.title}}
</div>
<div
class=
"details"
>
{{problem.details}}
</div>
<div
class=
"details"
>
{{problem.details}}
</div>
<button
[routerLink]=
"['/arena', problem.id]"
class=
"attempt"
>
Attempt
</button>
<button
[routerLink]=
"['/arena
/problem
', problem.id]"
class=
"attempt"
>
Attempt
</button>
<span
class=
"stats"
><span
*ngIf=
"problem.n_attempts != 0"
>
{{problem.n_correct}} accepted out of
<span
class=
"stats"
><span
*ngIf=
"problem.n_attempts != 0"
>
{{problem.n_correct}} accepted out of
{{problem.n_attempts}}
{{problem.n_attempts}}
({{problem.n_correct / problem.n_attempts * 100}}%)
</span><span
*ngIf=
"problem.n_attempts === 0"
>
No attempt
({{problem.n_correct / problem.n_attempts * 100}}%)
</span><span
*ngIf=
"problem.n_attempts === 0"
>
No attempt
...
...
src/app/ide/ide.component.ts
View file @
5f0b478d
...
@@ -6,6 +6,7 @@ import {RunCodeService} from '../run-code.service';
...
@@ -6,6 +6,7 @@ import {RunCodeService} from '../run-code.service';
import
{
SaveFileComponent
}
from
'
../save-file/save-file.component
'
;
import
{
SaveFileComponent
}
from
'
../save-file/save-file.component
'
;
import
{
File
}
from
'
../file
'
;
import
{
File
}
from
'
../file
'
;
import
{
FileService
}
from
'
../file.service
'
;
import
{
FileService
}
from
'
../file.service
'
;
import
{
ApiService
}
from
'
../api.service
'
;
declare
const
CodeMirror
:
any
;
declare
const
CodeMirror
:
any
;
...
@@ -25,13 +26,15 @@ export class IdeComponent implements OnInit {
...
@@ -25,13 +26,15 @@ export class IdeComponent implements OnInit {
id
:
null
,
id
:
null
,
filename
:
'
Untitled
'
,
filename
:
'
Untitled
'
,
language
:
'
.cpp
'
,
language
:
'
.cpp
'
,
text
:
''
text
:
''
,
username
:
JSON
.
parse
(
this
.
apiService
.
getToken
()).
username
,
};
};
@
ViewChild
(
InputComponent
)
inputField
;
@
ViewChild
(
InputComponent
)
inputField
;
@
ViewChild
(
IdeCompileComponent
)
runField
;
@
ViewChild
(
IdeCompileComponent
)
runField
;
@
ViewChild
(
SaveFileComponent
)
saveField
;
@
ViewChild
(
SaveFileComponent
)
saveField
;
constructor
(
public
router
:
Router
,
public
runCodeService
:
RunCodeService
,
private
fileService
:
FileService
)
{
constructor
(
public
router
:
Router
,
public
runCodeService
:
RunCodeService
,
private
fileService
:
FileService
,
private
apiService
:
ApiService
)
{
}
}
ngOnInit
():
void
{
ngOnInit
():
void
{
...
...
src/app/save-file/save-file.component.ts
View file @
5f0b478d
import
{
Component
,
OnInit
,
Output
,
EventEmitter
,
Input
}
from
'
@angular/core
'
;
import
{
Component
,
OnInit
,
Output
,
EventEmitter
,
Input
}
from
'
@angular/core
'
;
import
{
FileService
}
from
'
../file.service
'
;
import
{
FileService
}
from
'
../file.service
'
;
import
{
File
}
from
'
../file
'
;
import
{
File
}
from
'
../file
'
;
import
{
Location
}
from
'
@angular/common
'
;
@
Component
({
@
Component
({
selector
:
'
app-save-file
'
,
selector
:
'
app-save-file
'
,
...
@@ -14,9 +15,11 @@ export class SaveFileComponent implements OnInit {
...
@@ -14,9 +15,11 @@ export class SaveFileComponent implements OnInit {
@
Input
()
file
:
File
;
@
Input
()
file
:
File
;
isUploading
=
false
;
isUploading
=
false
;
constructor
(
public
fileService
:
FileService
)
{
}
constructor
(
public
fileService
:
FileService
,
private
location
:
Location
)
{
}
ngOnInit
():
void
{
}
ngOnInit
():
void
{
}
setState
(
value
:
boolean
):
void
{
setState
(
value
:
boolean
):
void
{
const
text
=
document
.
getElementById
(
'
filenameInput
'
)
as
HTMLTextAreaElement
;
const
text
=
document
.
getElementById
(
'
filenameInput
'
)
as
HTMLTextAreaElement
;
...
@@ -33,6 +36,8 @@ export class SaveFileComponent implements OnInit {
...
@@ -33,6 +36,8 @@ export class SaveFileComponent implements OnInit {
this
.
isUploading
=
false
;
this
.
isUploading
=
false
;
this
.
savedFile
.
emit
(
true
);
this
.
savedFile
.
emit
(
true
);
this
.
isActive
=
false
;
this
.
isActive
=
false
;
this
.
location
.
replaceState
(
'
/arena/file/
'
+
response
.
key
);
console
.
log
(
response
);
},
(
error
)
=>
{
},
(
error
)
=>
{
console
.
log
(
error
);
console
.
log
(
error
);
this
.
isUploading
=
false
;
this
.
isUploading
=
false
;
...
...
src/app/user/user.component.ts
View file @
5f0b478d
...
@@ -22,7 +22,6 @@ export class UserComponent implements OnInit {
...
@@ -22,7 +22,6 @@ export class UserComponent implements OnInit {
ngOnInit
():
void
{
ngOnInit
():
void
{
this
.
dataService
.
getLoggedInState
.
subscribe
(
state
=>
this
.
changeState
(
state
));
this
.
dataService
.
getLoggedInState
.
subscribe
(
state
=>
this
.
changeState
(
state
));
this
.
loggedIn
=
this
.
dataService
.
isLoggedIn
();
this
.
loggedIn
=
this
.
dataService
.
isLoggedIn
();
console
.
log
(
this
.
dataService
.
getToken
());
this
.
user
=
JSON
.
parse
(
this
.
dataService
.
getToken
());
this
.
user
=
JSON
.
parse
(
this
.
dataService
.
getToken
());
(()
=>
{
(()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment