forked from denrytech/flask-argon-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a secure RESTfull node - consumed by the dashboard charts
- Loading branch information
Adi Chirilov
committed
Jun 18, 2019
1 parent
4e50263
commit 9e07faa
Showing
11 changed files
with
259 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Argon Dashboard - coded in Flask | ||
Author : AppSeed App Generator | ||
Design : Creative-Tim.com | ||
License : MIT | ||
Support : https://appseed.us/support | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
Argon Dashboard - coded in Flask | ||
Author : AppSeed App Generator | ||
Design : Creative-Tim.com | ||
License : MIT | ||
Support : https://appseed.us/support | ||
""" | ||
|
||
from flask_restful import Resource | ||
from flask_login import current_user | ||
|
||
from app.models import Stats | ||
|
||
class ApiStats(Resource): | ||
|
||
def get(self,segment): | ||
|
||
if not current_user.is_authenticated: | ||
return {'err': 'auth'}, 401 | ||
|
||
# See the model for details | ||
val = Stats( segment ).val | ||
|
||
if 'traffic' == segment: | ||
return { segment : val }, 200 | ||
|
||
elif 'users' == segment: | ||
return { segment : val }, 200 | ||
|
||
elif 'sales' == segment: | ||
return { segment : val }, 200 | ||
|
||
elif 'perf' == segment: | ||
return { segment : val }, 200 | ||
|
||
else: | ||
return {'err': 'unknown'}, 404 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
'use strict'; | ||
|
||
$(function() { | ||
|
||
// Update the Traffic cell | ||
$.getJSON('/api/stats/traffic', function( data ) { | ||
//console.log( ' -> ' + data['traffic'] ) | ||
$('#stats_traffic').html( data['traffic'] ); | ||
}); | ||
|
||
// Update the Users cell | ||
$.getJSON('/api/stats/users', function( data ) { | ||
//console.log( ' -> ' + data['traffic'] ) | ||
$('#stats_users').html( data['users'] ); | ||
}); | ||
|
||
// Update the Sales cell | ||
$.getJSON('/api/stats/sales', function( data ) { | ||
//console.log( ' -> ' + data['traffic'] ) | ||
$('#stats_sales').html( data['sales'] ); | ||
}); | ||
|
||
// Update the Perf cell | ||
$.getJSON('/api/stats/perf', function( data ) { | ||
//console.log( ' -> ' + data['traffic'] ) | ||
$('#stats_perf').html( data['perf'] ); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
|
||
<div class="header bg-gradient-primary pb-8 pt-5 pt-md-8"> | ||
<div class="container-fluid"> | ||
<div class="header-body"> | ||
<!-- Card stats --> | ||
<div class="row"> | ||
<div class="col-xl-3 col-lg-6"> | ||
<div class="card card-stats mb-4 mb-xl-0"> | ||
<div class="card-body"> | ||
<div class="row"> | ||
<div class="col"> | ||
<h5 class="card-title text-uppercase text-muted mb-0">Traffic</h5> | ||
|
||
<span id="stats_traffic" class="h2 font-weight-bold mb-0">N/A</span> | ||
|
||
</div> | ||
<div class="col-auto"> | ||
<div class="icon icon-shape bg-danger text-white rounded-circle shadow"> | ||
<i class="fas fa-chart-bar"></i> | ||
</div> | ||
</div> | ||
</div> | ||
<p class="mt-3 mb-0 text-muted text-sm"> | ||
<span class="text-success mr-2"><i class="fa fa-arrow-up"></i> 3.48%</span> | ||
<span class="text-nowrap">Since last month</span> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-xl-3 col-lg-6"> | ||
<div class="card card-stats mb-4 mb-xl-0"> | ||
<div class="card-body"> | ||
<div class="row"> | ||
<div class="col"> | ||
<h5 class="card-title text-uppercase text-muted mb-0">New users</h5> | ||
|
||
<span id="stats_users" class="h2 font-weight-bold mb-0">N/A</span> | ||
|
||
</div> | ||
<div class="col-auto"> | ||
<div class="icon icon-shape bg-warning text-white rounded-circle shadow"> | ||
<i class="fas fa-chart-pie"></i> | ||
</div> | ||
</div> | ||
</div> | ||
<p class="mt-3 mb-0 text-muted text-sm"> | ||
<span class="text-danger mr-2"><i class="fas fa-arrow-down"></i> 3.48%</span> | ||
<span class="text-nowrap">Since last week</span> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-xl-3 col-lg-6"> | ||
<div class="card card-stats mb-4 mb-xl-0"> | ||
<div class="card-body"> | ||
<div class="row"> | ||
<div class="col"> | ||
<h5 class="card-title text-uppercase text-muted mb-0">Sales</h5> | ||
|
||
<span id="stats_sales" class="h2 font-weight-bold mb-0">N/A</span> | ||
|
||
</div> | ||
<div class="col-auto"> | ||
<div class="icon icon-shape bg-yellow text-white rounded-circle shadow"> | ||
<i class="fas fa-users"></i> | ||
</div> | ||
</div> | ||
</div> | ||
<p class="mt-3 mb-0 text-muted text-sm"> | ||
<span class="text-warning mr-2"><i class="fas fa-arrow-down"></i> 1.10%</span> | ||
<span class="text-nowrap">Since yesterday</span> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-xl-3 col-lg-6"> | ||
<div class="card card-stats mb-4 mb-xl-0"> | ||
<div class="card-body"> | ||
<div class="row"> | ||
<div class="col"> | ||
<h5 class="card-title text-uppercase text-muted mb-0">Performance</h5> | ||
|
||
<span id="stats_perf" class="h2 font-weight-bold mb-0">N/A</span> | ||
|
||
</div> | ||
<div class="col-auto"> | ||
<div class="icon icon-shape bg-info text-white rounded-circle shadow"> | ||
<i class="fas fa-percent"></i> | ||
</div> | ||
</div> | ||
</div> | ||
<p class="mt-3 mb-0 text-muted text-sm"> | ||
<span class="text-success mr-2"><i class="fas fa-arrow-up"></i> 12%</span> | ||
<span class="text-nowrap">Since last month</span> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
Oops, something went wrong.