Alireza Hassani 4 years ago
commit a4cefefcc5

@ -19,6 +19,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\TrimStrings::class, \App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class, \App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\FindLanguage::class,
]; ];
/** /**

@ -0,0 +1,24 @@
<?php
namespace App\Http\Middleware;
use Closure;
use WM\Core\Infrastructures\Enumerations\Language;
class FindLanguage
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($language = $request->header('accept-language')) {
app()->setLocale($language);
}
return $next($request);
}
}

@ -45,7 +45,7 @@ return [
'local' => [ 'local' => [
'driver' => 'local', 'driver' => 'local',
'root' => storage_path('app'), 'root' => base_path('/'),
], ],
'public' => [ 'public' => [

@ -0,0 +1,19 @@
import Pie from "./apexhart/type/pie";
import Bar from "./apexhart/type/bar";
import Linear from "./apexhart/type/linear";
export default class {
constructor(typeChart, options) {
switch (typeChart) {
case 'pie':
return new Pie(options);
case 'bar':
return new Bar(options);
case 'linear':
return new Linear(options);
default:
throw new Error("The Type Chart is Not Support!");
}
}
}

@ -0,0 +1,23 @@
import axios from 'axios';
export default class {
constructor({url, params}) {
this.url = url;
this.params = params;
this.isLoadRequest = false;
this.responseChart = null;
}
async request() {
if (!this.isLoadRequest) {
let response = await axios.get(this.url, {params: this.params});
if (response && response.status === 200) {
this.responseChart = response.data;
this.isLoadRequest = true;
}
}
return this.responseChart;
}
}

@ -0,0 +1,71 @@
import chart from "../chart";
export default class extends chart {
constructor(options) {
super(options);
this.type = options.type ? options.type : 'daily';
this.options = {
fill: {
colors: ["#e6e6e6"]
},
chart: {
id: "lineChart",
fontFamily: '"iranyekan-regular-en-num", "Montserrat-Regular"'
},
xaxis: {
categories: []
},
dataLabels: {
style: {
colors: ["#000", "#000", "#000"]
}
},
series: [
{
name: "bar chart",
data: []
}
]
};
}
async getOptions() {
await this.request();
this.setOptions();
return this.options;
}
setOptions() {
switch (this.type) {
case 'weekly':
case 'cost-weekly':
return this.setWeekly();
case 'monthly':
case 'cost-monthly':
return this.setMonthly();
case 'daily':
case 'cost-daily':
return this.setDaily();
}
}
setWeekly() {
this.options.series[0].data = this.responseChart.map(x => x.count);
this.options.xaxis.categories = this.responseChart.map(x => x.week);
}
setMonthly() {
this.options.series[0].data = this.responseChart.map(x => x.count);
this.options.xaxis.categories = this.responseChart.map(x => x.month + ' ' + x.year.substring(2) );
}
setDaily() {
this.options.series[0].data = this.responseChart.map(x => x.count);
this.options.xaxis.categories = this.responseChart.map(x => x.persian_date);
}
}

@ -0,0 +1,20 @@
import chart from "../chart";
export default class extends chart {
constructor(options) {
super(options);
}
async getOptions() {
await this.request(this.setOptions);
return this.options;
}
setOptions(self) {
self.options.series[0].data = self.responseChart.map(x => x.user_count);
self.options.xaxis.categories = self.responseChart.map(x => x.week);
}
}

@ -0,0 +1,47 @@
import chart from "../chart";
import color from "@Global/utils/colors/index"
export default class extends chart {
constructor(options) {
super(options);
this.options = {
chart: {
type: "donut",
id: "pieChart",
fontFamily: '"iranyekan-regular-en-num", "Montserrat-Regular"'
},
fill: {
label: [],
},
dataLabels: {
enabled: true,
formatter: function (val, opt) {
return Math.round(val * 10) / 10 + '% ' + opt.w.globals.labels[opt.seriesIndex]
},
},
series: [],
labels: [],
legend: {
fontSize: "16px"
}
};
}
async getOptions() {
await this.request();
this.setOptions();
return this.options;
}
setOptions() {
this.options.series = this.responseChart.map(x => x.count);
this.options.labels = this.responseChart.map(x => x.category);
this.options.labels = this.responseChart.map(x => x.category.name);
this.options.fill.label = this.responseChart.map(x => x.category.name);
this.options['colors'] = this.responseChart.map( x =>{
let colorText = x.category.color ? x.category.color : color[parseInt((Math.random() * 100) % 14)].color;
return color.find(x => x.color == colorText).hex;
} );
}
}

@ -9,7 +9,7 @@ const ApiService = {
} else if (process.env.MIX_PUSHER_APP_API) { } else if (process.env.MIX_PUSHER_APP_API) {
axios.defaults.baseURL = process.env.MIX_PUSHER_APP_API; axios.defaults.baseURL = process.env.MIX_PUSHER_APP_API;
} }
this.setHeader();
axios.interceptors.request.use((config) => { axios.interceptors.request.use((config) => {
config.headers = this.setModuleHeader(config.headers); config.headers = this.setModuleHeader(config.headers);
return config; return config;
@ -17,10 +17,9 @@ const ApiService = {
}, },
setHeader() { setHeader() {
axios.defaults.headers.common["Accept"] = `application/json`; axios.defaults.headers.common["Accept-Language"] = `fa`;
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
}, },
setModuleHeader(headers = axios.defaults.headers.common) { setModuleHeader(headers = axios.defaults.headers.common) {
headers['Module'] = commonState.current_module; headers['Module'] = commonState.current_module;
return headers; return headers;

@ -1,17 +1,17 @@
export default [ export default [
{ name: 'قرمز', color:'red'}, { name: 'قرمز', color:'red', hex: '#ee3552'},
{ name: 'نارنجی', color:'orange'}, { name: 'نارنجی', color:'orange', hex: '#ff6b57'},
{ name: 'زرد', color:'yellow'}, { name: 'زرد', color:'yellow', hex: '#ffc107'},
{ name: 'صورتی', color:'pink'}, { name: 'صورتی', color:'pink', hex: '#e94c8f'},
{ name: 'طلایی', color:'gold'}, { name: 'طلایی', color:'gold', hex: '#ddcfbb'},
{ name: 'بنفش', color:'purple'}, { name: 'بنفش', color:'purple', hex: '#ac3773'},
{ name: 'آبی', color:'blue'}, { name: 'آبی', color:'blue', hex: '#1875BB'},
{ name: 'آبی تیره', color:'dark-blue'}, { name: 'آبی تیره', color:'dark-blue', hex: '#04314B'},
{ name: 'سبز', color:'green'}, { name: 'سبز', color:'green', hex: '#0d7e00'},
{ name: 'سبز پاستیلی', color:'teal'}, { name: 'سبز پاستیلی', color:'teal', hex: '#00897b'},
{ name: 'فیروزه ای', color:'cyan'}, { name: 'فیروزه ای', color:'cyan', hex: '#32c5d2'},
{ name: 'قهوه ای', color:'brown'}, { name: 'قهوه ای', color:'brown', hex: '#915117'},
{ name: 'خاکستری', color:'gray'}, { name: 'خاکستری', color:'gray', hex: '#828282'},
{ name: 'مشکی', color:'black'}, { name: 'مشکی', color:'black', hex: '#000'},
{ name: 'سفید', color:'white'}, { name: 'سفید', color:'white', hex: '#fff'},
]; ];

Loading…
Cancel
Save