Skip to content
This repository has been archived by the owner on Apr 2, 2021. It is now read-only.

Commit

Permalink
Use Tazkrtak API instead of Counterfeit
Browse files Browse the repository at this point in the history
  • Loading branch information
yousinix committed Oct 30, 2019
1 parent dc355fe commit 6a8bd0e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Site settings
title : تذكرتك
description : متابعة برامج تذكرتك عن طريق متصفح الإنترنت
url : "https://tazkrtak-admin.web.app"
root-endpoint : "https://my-json-server.typicode.com/tazkrtak/counterfeit"
url : https://tazkrtak-admin.web.app
root-endpoint : https://tazkrtak-api.web.app

# Build settings
markdown : kramdown
Expand Down
10 changes: 5 additions & 5 deletions _data/counters.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
- name: المستخدمون
id: users
endpoint: "/users-count"
endpoint: "/users/total"

- name: الدخل
id: income
endpoint: "/users-count"
endpoint: "/transactions/income"

- name: الحافلات
id: buses
endpoint: "/buses-count"
endpoint: "/buses/total"

- name: المفتشون
- name: الموظفون
id: collectors
endpoint: "/buses-count"
endpoint: "/staff/total"
2 changes: 1 addition & 1 deletion _data/usage-charts.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
title: الاستخدام
endpoint: ""
endpoint: "/transactions"
intervals:
- name: شهر
id: months
Expand Down
2 changes: 1 addition & 1 deletion assets/js/buses-charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fetchBusesData().then(data => {
});

async function fetchBusesData() {
const root = "{{ site.root-endpoint }}";
const root = "https://my-json-server.typicode.com/tazkrtak/counterfeit";
const endpoint = "{{ site.data.buses-charts.endpoint }}";
const response = await fetch(`${root}${endpoint}`);
return await response.json();
Expand Down
2 changes: 1 addition & 1 deletion assets/js/counters.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{% for counter in site.data.counters %}
fetchCounterData("{{ counter.endpoint }}").then(data => {
new CountUp("{{ counter.id }}-counter", 0, data.value, 0, 1).start();
new CountUp("{{ counter.id }}-counter", 0, data.total, 0, 1).start();
});
{% endfor %}

Expand Down
6 changes: 3 additions & 3 deletions assets/js/usage-charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

{% for interval in site.data.usage-charts.intervals %}
fetchUsageData("{{ interval.endpoint }}").then(data => {
const x = data.map(month => month.number);
const y = data.map(month => month.usage);
const x = data.map(interval => interval.name);
const y = data.map(interval => interval.transactions);
createUsageChart("{{ interval.id }}-chart", x, y);
});
{% endfor %}

async function fetchUsageData(interval) {
const root = "{{ site.root-endpoint }}";
const endpoint = "{{ site.data.usage-charts.endpoint }}";
const response = await fetch(`${root}${endpoint}/${interval}`);
const response = await fetch(`${root}${endpoint}${interval}`);
return await response.json();
}

Expand Down

0 comments on commit 6a8bd0e

Please sign in to comment.