forked from CodewarsClone/Codewars
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainService.js
More file actions
114 lines (95 loc) · 2.46 KB
/
Copy pathmainService.js
File metadata and controls
114 lines (95 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/************* MAIN SERVICE ***************/
angular.module('app').service('mainService', function($http, $q, $sce) {
// $sce.trustAsResourceUrl('/s');
// Dumby information so I don't have to mess with the server all the time.
// this.user = {id: 4, github_id: "20197415", name: "Steven", email: null, picture_url: "https://avatars.githubusercontent.com/u/20197415?v=3", username: "Steven-Nagie"};
this.user = {};
// POST
this.testExamples = (solution, examples) => {
return $http({
method: 'POST',
url: `http://192.168.0.186:3030/api/test/examples`,
data: {
script: solution,
examples: examples
}
});
};
this.testSuite = (solution, kataid) => {
return $http({
method: 'POST',
url: `/api/test/suite/${kataid}`,
data: {
script: solution
}
});
};
this.setSolution = (solution, kataid) => {
return $http({
method: 'POST',
url: `/api/solution/` + kataid,
data: {
script: solution
}
});
};
//kata_listCtrl
this.searchKatasByName = (input) => {
return $http({
method: 'POST',
url: `/api/kata-by-name`,
data: {
userInput: input
}
})
}
// GET
this.getUser = () => {
return $http({
method: 'GET',
url: `/api/me`
})
}
// trainingCtrl
this.getKataById = (kataid) => {
return $http({
method: 'GET',
url: `/api/kata/` + kataid
});
};
// homeCtrl - displaying one kata withing range
// kata_listCtrl = displays a plethora of katas based on user ability
this.getRandomKata = (userid) => { // eventually we will want it to return a random kata based on the users experience. THAT IS WHY THERE IS AN ID PARAM
return $http({
method: 'GET',
url: `/api/random-kata`
});
};
this.getRandomKataList = (userid) => {
return $http({
method: 'GET',
url: `/api/random-kata-list`
});
}
// kata_listCtrl
this.getKatasByKyu = (kyu) => {
return $http({
method: 'GET',
url: `/api/katas-by-kyu/` + kyu
});
};
// solutionsCtrl
this.getKataSolutions = (kataid) => {
return $http({
method: 'GET',
url: `/api/solutions/` + kataid
});
};
// profileCtrl - brings back a specific users kata information (script, name, kyu, description) - use on kata tab soltion tab
this.getUserKatas = () => {
return $http({
method: 'GET',
url: `/api/get-user-katas`
});
};
});