Skip to content
This repository was archived by the owner on Mar 5, 2020. It is now read-only.

Commit 0b2f244

Browse files
committed
Profile page updated
1 parent b5d96e5 commit 0b2f244

File tree

6 files changed

+73
-34
lines changed

6 files changed

+73
-34
lines changed

src/main/java/pl/simplemethod/codebin/CodebinApplication.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@
33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.boot.autoconfigure.domain.EntityScan;
6-
import org.springframework.context.ConfigurableApplicationContext;
76
import org.springframework.context.annotation.Bean;
87
import pl.simplemethod.codebin.githubOauth.GithubClient;
9-
import pl.simplemethod.codebin.srv.SrvClient;
108
import pl.simplemethod.codebin.linkDeploy.LinkClient;
11-
12-
import java.security.Security;
9+
import pl.simplemethod.codebin.srv.SrvClient;
1310

1411
@SpringBootApplication
1512
@EntityScan("pl.simplemethod.codebin")

src/main/java/pl/simplemethod/codebin/githubOauth/GithubRestController.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package pl.simplemethod.codebin.githubOauth;
22

33

4+
import org.json.JSONObject;
45
import org.json.simple.parser.JSONParser;
56
import org.json.simple.parser.ParseException;
67
import org.springframework.beans.factory.annotation.Autowired;
@@ -295,4 +296,14 @@ ResponseEntity getPublicRepo(@CookieValue("token") String token, @PathVariable(v
295296

296297
}
297298
}
299+
300+
@GetMapping(path = "/user/subscription", produces = MediaType.APPLICATION_JSON_VALUE)
301+
public @ResponseBody ResponseEntity getSubscription(@CookieValue("id") Integer id) {
302+
if (id == null) {
303+
return new ResponseEntity<>("", null, HttpStatus.NOT_FOUND);
304+
}
305+
JSONObject json = new JSONObject();
306+
json.put("subscriber", usersRepository.getSubscription(id) != null);
307+
return new ResponseEntity<>(json.toString(), null, HttpStatus.valueOf(200));
308+
}
298309
}

src/main/java/pl/simplemethod/codebin/repository/UsersRepository.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.springframework.data.jpa.repository.JpaRepository;
44
import org.springframework.data.jpa.repository.Query;
5+
import org.springframework.data.repository.query.Param;
56
import org.springframework.stereotype.Repository;
67
import org.springframework.transaction.annotation.Transactional;
78

@@ -16,8 +17,11 @@ public interface UsersRepository extends JpaRepository<Users, Long> {
1617

1718
Users getFirstByToken(String token);
1819

19-
Users getFirstBySubscription(String subscription);
20+
Users getFirstBySubscription(String subscription);
2021

2122
@Query(value = "SELECT u FROM Users u INNER JOIN u.containers c WHERE c.idDocker = :id")
22-
Users findByContainersidDocker(String id);
23+
Users findByContainersidDocker(@Param("id") String id);
24+
25+
@Query(value = "SELECT u.subscription FROM Users u WHERE u.id = :id")
26+
String getSubscription(@Param("id") Integer id);
2327
}

src/main/resources/public/app.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ moduleA.config(function ($routeProvider) {
3535
})
3636

3737
.when('/profile', {
38-
templateUrl: 'dashboard/profile.html'
38+
templateUrl: 'dashboard/profile.html',
39+
controller: 'ProfileController'
3940
})
4041

4142
.when('/payment-accept', {
@@ -219,7 +220,7 @@ app.controller('ContainersController', ['$filter', '$routeParams', '$scope', '$h
219220
method: 'DELETE'
220221
}).then(
221222
function () {
222-
window.location = "/";
223+
window.location = "/dashboard.html";
223224
},
224225
function () {
225226
$scope.errors = "Problem with deleteing a container";
@@ -361,6 +362,18 @@ app.controller('dashboardGithub', function ($scope, $http, $cookies) {
361362
};
362363
});
363364

365+
app.controller('ProfileController', function ($scope, $http) {
366+
$http.get('http://127.0.0.1/github/user/subscription').then(
367+
function (response) {
368+
$scope.subscriber = response.data.subscriber;
369+
}, function () {
370+
console.error('Cookie not set');
371+
}
372+
)
373+
374+
});
375+
376+
364377
$('ul.nav > li > a.nav-link').click(function (e) {
365378
$('ul.nav > li > a.nav-link').removeClass('active');
366379
$(this).addClass('active');

src/main/resources/public/dashboard/home.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h3 class="page-title">Account Overview</h3>
1313
<div class="card-body p-0 d-flex">
1414
<div class="d-flex flex-column m-auto">
1515
<div class="stats-small__data text-center">
16-
<span class="stats-small__label text-uppercase">Privates repository</span>
16+
<span class="stats-small__label text-uppercase">Private repositories</span>
1717
<h6 class="stats-small__value count my-3">{{privateRepo}}</h6>
1818
</div>
1919
</div>
@@ -25,7 +25,7 @@ <h6 class="stats-small__value count my-3">{{privateRepo}}</h6>
2525
<div class="card-body p-0 d-flex">
2626
<div class="d-flex flex-column m-auto">
2727
<div class="stats-small__data text-center">
28-
<span class="stats-small__label text-uppercase">Public repository</span>
28+
<span class="stats-small__label text-uppercase">Public repositories</span>
2929
<h6 class="stats-small__value count my-3">{{publicRepo}}</h6>
3030
</div>
3131
</div>
@@ -37,7 +37,7 @@ <h6 class="stats-small__value count my-3">{{publicRepo}}</h6>
3737
<div class="card-body p-0 d-flex">
3838
<div class="d-flex flex-column m-auto">
3939
<div class="stats-small__data text-center">
40-
<span class="stats-small__label text-uppercase">Numbers of collaborators</span>
40+
<span class="stats-small__label text-uppercase">Number of collaborators</span>
4141
<h6 class="stats-small__value count my-3">{{numbersColl}}</h6>
4242
</div>
4343
</div>
Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,42 @@
1-
<!-- Page Header -->
2-
<div class="page-header row no-gutters py-4">
3-
<div class="col-12 col-sm-8 text-center text-sm-left mb-4">
4-
<span class="text-uppercase page-subtitle">Profile</span>
5-
<h3 class="page-title">Upgrade to Premium account</h3>
1+
<div ng-if="subscriber != true">
2+
<!-- Page Header -->
3+
<div class="page-header row no-gutters py-4">
4+
<div class="col-12 col-sm-8 text-center text-sm-left mb-4">
5+
<span class="text-uppercase page-subtitle">Profile</span>
6+
<h3 class="page-title">Upgrade to Premium account</h3>
7+
</div>
68
</div>
7-
</div>
89

9-
<div class="row">
10-
<div class="col-lg-5 md-6 mb-5 align-center">
11-
<img src="./img/bg-img/5.png" class="img-fluid" alt="Responsive image">
12-
</div>
13-
<div class="col-lg-6 md-6">
14-
<h3 class="page-title">Premium Plan</h3>
15-
<p>which contains features like:</p>
16-
<div>
17-
<p><i class="icon_check"></i> Unlimited number of repositories</p>
18-
<p><i class="icon_check"></i> Unlimited execution time</p>
19-
<p><i class="icon_check"></i> Full resolution</p>
20-
<p><i class="icon_check"></i> Sharing projects</p>
10+
<div class="row">
11+
<div class="col-lg-5 md-6 mb-5 align-center">
12+
<img src="./img/bg-img/5.png" class="img-fluid" alt="Responsive image">
2113
</div>
22-
<span>Do not wait and buy your access right now!</span>
23-
<h4 class="mb-4">Only for <span style="text-decoration: line-through;">$19.99</span> <b>$9.95</b>/month*</h4>
24-
<a href="/paypal/subscribe">
25-
<button type="button" class="mb-5 btn btn-primary mr-2 btn-block"><i class="fab fa-paypal p-1"></i> Buy with PayPal</button>
26-
</a>
14+
<div class="col-lg-6 md-6">
15+
<h3 class="page-title">Premium Plan</h3>
16+
<p>which contains features like:</p>
17+
<div>
18+
<p><i class="icon_check"></i> Unlimited number of repositories</p>
19+
<p><i class="icon_check"></i> Unlimited execution time</p>
20+
<p><i class="icon_check"></i> Full resolution</p>
21+
<p><i class="icon_check"></i> Sharing projects</p>
22+
</div>
23+
<span>Do not wait and buy your access right now!</span>
24+
<h4 class="mb-4">Only for <span style="text-decoration: line-through;">$19.99</span> <b>$9.95</b>/month*</h4>
25+
<a href="/paypal/subscribe">
26+
<button type="button" class="mb-5 btn btn-primary mr-2 btn-block"><i class="fab fa-paypal p-1"></i> Buy with PayPal</button>
27+
</a>
28+
</div>
29+
</div>
30+
</div>
31+
<div ng-if="subscriber == true">
32+
<div class="error">
33+
<div class="error__content">
34+
<h2 style="color: #55e023"><i class="far fa-check-circle"></i></h2>
35+
<h3>Premium Plan is active</h3>
36+
<p>Your Premium Plan is active!</p>
37+
<a href="#/!">
38+
<button type="button" class="btn btn-accent btn-pill"><i class="fas fa-long-arrow-alt-left p-1"></i> Go back to homepage!</button>
39+
</a>
40+
</div>
2741
</div>
2842
</div>

0 commit comments

Comments
 (0)