fix(api): dashboard restarts api
parent
8b4054fef5
commit
d39bb23829
|
@ -4,7 +4,7 @@ from pprint import pprint
|
|||
|
||||
import os, shutil
|
||||
|
||||
from requests import get, post
|
||||
import requests
|
||||
|
||||
from schema import And, Optional, Schema, SchemaError, Use
|
||||
import yaml
|
||||
|
@ -83,6 +83,7 @@ class Dashboard:
|
|||
return self.apply_updates()
|
||||
|
||||
def apply_updates(self):
|
||||
# Keycloak
|
||||
# Api
|
||||
resp = requests.get(
|
||||
"http://isard-sso-api:7039/restart"
|
||||
)
|
||||
return True
|
||||
|
|
|
@ -35,11 +35,11 @@ $(document).ready(function() {
|
|||
init_background_cropper()
|
||||
|
||||
$('#save-colors').click(function () {
|
||||
console.log({
|
||||
'background': $('#colorpicker-background-input').val(),
|
||||
'primary': $('#colorpicker-primary-input').val(),
|
||||
'secondary': $('#colorpicker-secondary-input').val()
|
||||
})
|
||||
// console.log({
|
||||
// 'background': $('#colorpicker-background-input').val(),
|
||||
// 'primary': $('#colorpicker-primary-input').val(),
|
||||
// 'secondary': $('#colorpicker-secondary-input').val()
|
||||
// })
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url:"/api/dashboard/colours",
|
||||
|
@ -104,7 +104,7 @@ function init_logo_cropper() {
|
|||
|
||||
|
||||
if (typeof ($.fn.cropper) === 'undefined') { return; }
|
||||
console.log('init_logo_cropper');
|
||||
// console.log('init_logo_cropper');
|
||||
|
||||
var $image = $('#image_logo');
|
||||
var $dataX = $('#dataX');
|
||||
|
@ -139,25 +139,25 @@ function init_logo_cropper() {
|
|||
// Cropper
|
||||
$image.on({
|
||||
'build.cropper': function (e) {
|
||||
console.log(e.type);
|
||||
// console.log(e.type);
|
||||
},
|
||||
'built.cropper': function (e) {
|
||||
console.log(e.type);
|
||||
// console.log(e.type);
|
||||
},
|
||||
'cropstart.cropper': function (e) {
|
||||
console.log(e.type, e.action);
|
||||
// console.log(e.type, e.action);
|
||||
},
|
||||
'cropmove.cropper': function (e) {
|
||||
console.log(e.type, e.action);
|
||||
// console.log(e.type, e.action);
|
||||
},
|
||||
'cropend.cropper': function (e) {
|
||||
console.log(e.type, e.action);
|
||||
// console.log(e.type, e.action);
|
||||
},
|
||||
'crop.cropper': function (e) {
|
||||
console.log(e.type, e.x, e.y, e.width, e.height, e.rotate, e.scaleX, e.scaleY);
|
||||
// console.log(e.type, e.x, e.y, e.width, e.height, e.rotate, e.scaleX, e.scaleY);
|
||||
},
|
||||
'zoom.cropper': function (e) {
|
||||
console.log(e.type, e.ratio);
|
||||
// console.log(e.type, e.ratio);
|
||||
}
|
||||
}).cropper(options);
|
||||
|
||||
|
@ -277,7 +277,7 @@ function init_background_cropper() {
|
|||
|
||||
|
||||
if (typeof ($.fn.cropper) === 'undefined') { return; }
|
||||
console.log('init_background_cropper');
|
||||
// console.log('init_background_cropper');
|
||||
|
||||
var $image = $('#image_background');
|
||||
var $dataX = $('#dataX');
|
||||
|
@ -312,25 +312,25 @@ function init_background_cropper() {
|
|||
// Cropper
|
||||
$image.on({
|
||||
'build.cropper': function (e) {
|
||||
console.log(e.type);
|
||||
// console.log(e.type);
|
||||
},
|
||||
'built.cropper': function (e) {
|
||||
console.log(e.type);
|
||||
// console.log(e.type);
|
||||
},
|
||||
'cropstart.cropper': function (e) {
|
||||
console.log(e.type, e.action);
|
||||
// console.log(e.type, e.action);
|
||||
},
|
||||
'cropmove.cropper': function (e) {
|
||||
console.log(e.type, e.action);
|
||||
// console.log(e.type, e.action);
|
||||
},
|
||||
'cropend.cropper': function (e) {
|
||||
console.log(e.type, e.action);
|
||||
// console.log(e.type, e.action);
|
||||
},
|
||||
'crop.cropper': function (e) {
|
||||
console.log(e.type, e.x, e.y, e.width, e.height, e.rotate, e.scaleX, e.scaleY);
|
||||
// console.log(e.type, e.x, e.y, e.width, e.height, e.rotate, e.scaleX, e.scaleY);
|
||||
},
|
||||
'zoom.cropper': function (e) {
|
||||
console.log(e.type, e.ratio);
|
||||
// console.log(e.type, e.ratio);
|
||||
}
|
||||
}).cropper(options);
|
||||
|
||||
|
@ -350,10 +350,10 @@ function init_background_cropper() {
|
|||
contentType: false,
|
||||
success: function () {
|
||||
// Update background image
|
||||
console.log('Upload success');
|
||||
// console.log('Upload success');
|
||||
},
|
||||
error: function () {
|
||||
console.log('Upload error');
|
||||
// console.log('Upload error');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,6 +20,13 @@ server {
|
|||
access_log off;
|
||||
}
|
||||
|
||||
location /restart {
|
||||
proxy_pass http://127.0.0.1:7039/restart;
|
||||
expires max;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location /user_menu/json {
|
||||
alias /api/api/static/templates/user_menu_header.json;
|
||||
default_type application/json;
|
||||
|
|
|
@ -50,4 +50,4 @@ def send_templates(path):
|
|||
"""
|
||||
Import all views
|
||||
"""
|
||||
from .views import AvatarsViews, MenuViews
|
||||
from .views import AvatarsViews, MenuViews, InternalViews
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# coding=utf-8
|
||||
|
||||
import os
|
||||
|
||||
from flask import Response, jsonify, redirect, render_template, request, url_for
|
||||
|
||||
from .decorators import is_internal
|
||||
|
||||
from api import app
|
||||
|
||||
@app.route("/restart", methods=["GET"])
|
||||
@is_internal
|
||||
def api_restart():
|
||||
os.system("kill 1")
|
||||
|
||||
|
||||
# @app.route('/user_menu/<format>', methods=['GET'])
|
||||
# @app.route('/user_menu/<format>/<application>', methods=['GET'])
|
||||
# def api_v2_user_menu(format,application=False):
|
||||
# if application == False:
|
||||
# if format == 'json':
|
||||
# if application == False:
|
||||
# return json.dumps(menu.get_user_nenu()), 200, {'Content-Type': 'application/json'}
|
|
@ -36,7 +36,6 @@ def api_v2_header(format, application=False):
|
|||
if application == "wordpress":
|
||||
return render_template("header_wordpress.html")
|
||||
|
||||
|
||||
# @app.route('/user_menu/<format>', methods=['GET'])
|
||||
# @app.route('/user_menu/<format>/<application>', methods=['GET'])
|
||||
# def api_v2_user_menu(format,application=False):
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#!flask/bin/python
|
||||
# coding=utf-8
|
||||
|
||||
import socket
|
||||
from functools import wraps
|
||||
|
||||
from flask import redirect, request, url_for
|
||||
|
||||
def is_internal(fn):
|
||||
@wraps(fn)
|
||||
def decorated_view(*args, **kwargs):
|
||||
remote_addr = (
|
||||
request.headers["X-Forwarded-For"].split(",")[0]
|
||||
if "X-Forwarded-For" in request.headers
|
||||
else request.remote_addr.split(",")[0]
|
||||
)
|
||||
if socket.gethostbyname("isard-sso-admin") == remote_addr:
|
||||
return fn(*args, **kwargs)
|
||||
return ""
|
||||
|
||||
return decorated_view
|
Loading…
Reference in New Issue