Просмотр исходного кода

load boot in desk.html #999

version-14
Anand Doshi 10 лет назад
Родитель
Сommit
2fc7741e9c
16 измененных файлов: 64 добавлений и 61 удалений
  1. +0
    -6
      frappe/boot.py
  2. +1
    -1
      frappe/core/page/desktop/all_applications_dialog.html
  3. +28
    -15
      frappe/core/page/desktop/desktop.js
  4. +1
    -1
      frappe/core/page/desktop/desktop_icon_grid.html
  5. +1
    -0
      frappe/desk/page/activity/activity.js
  6. +0
    -4
      frappe/handler.py
  7. +1
    -0
      frappe/public/css/desktop.css
  8. +5
    -24
      frappe/public/js/frappe/desk.js
  9. +2
    -2
      frappe/public/js/frappe/misc/user.js
  10. +1
    -0
      frappe/public/js/frappe/provide.js
  11. +1
    -1
      frappe/public/js/frappe/ui/toolbar/offcanvas_left_sidebar.html
  12. +1
    -1
      frappe/public/js/frappe/ui/toolbar/toolbar.js
  13. +1
    -0
      frappe/public/less/desktop.less
  14. +3
    -4
      frappe/sessions.py
  15. +6
    -0
      frappe/templates/pages/desk.html
  16. +12
    -2
      frappe/templates/pages/desk.py

+ 0
- 6
frappe/boot.py Просмотреть файл

@@ -114,12 +114,6 @@ def get_fullnames():

return d

def get_startup_js():
startup_js = []
for method in frappe.get_hooks().startup_js or []:
startup_js.append(frappe.get_attr(method)() or "")
return "\n".join(startup_js)

def get_user(bootinfo):
"""get user info"""
bootinfo.user = frappe.user.load_user()


+ 1
- 1
frappe/core/page/desktop/all_applications_dialog.html Просмотреть файл

@@ -4,8 +4,8 @@
<div class="list-group all-applications-list">
{% for(var i=0, l=all_modules.length; i < l; i++) {
var module_name = all_modules[i];
if (desktop_items.indexOf(module_name)===-1 || module_name==="All Applications") { continue; }
var module = frappe.get_module(module_name);
if (desktop_items.indexOf(module_name)===-1 || module.force_show) { continue; }
%}
<div class="list-group-item" data-label="{%= module.label %}" data-name="{%= module.name %}">
<div class="checkbox">


+ 28
- 15
frappe/core/page/desktop/desktop.js Просмотреть файл

@@ -23,7 +23,7 @@ $.extend(frappe.desktop, {

this.wrapper.html(frappe.render_template("desktop_icon_grid", {
// all visible icons
desktop_items: frappe.user.get_desktop_items(),
desktop_items: this.get_desktop_items(),

// user visible icons
user_desktop_items: this.get_user_desktop_items(),
@@ -40,6 +40,25 @@ $.extend(frappe.desktop, {
$(document).trigger("desktop-render");
},

get_desktop_items: function() {
var me = this;

frappe.modules["All Applications"] = {
icon: "octicon octicon-three-bars",
label: "All Applications",
_label: __("All Applications"),
_id: "all_applications",
color: "#4aa3df",
link: "",
force_show: true,
onclick: function() {
me.all_applications.show();
}
}

return frappe.user.get_desktop_items();
},

get_user_desktop_items: function() {
var me = this;

@@ -56,20 +75,13 @@ $.extend(frappe.desktop, {
user_desktop_items.push('Core');
}

frappe.modules["All Applications"] = {
icon: "octicon octicon-three-bars",
label: "All Applications",
_label: __("All Applications"),
_id: "all_applications",
color: "#4aa3df",
link: "",
onclick: function() {
me.all_applications.show();
for (var m in frappe.modules) {
var module = frappe.modules[m];
if (module.force_show && user_desktop_items.indexOf(m)===-1) {
user_desktop_items.push(m);
}
}

user_desktop_items.push("All Applications")

// filter valid icons
for (var i=0, l=user_desktop_items.length; i < l; i++) {
var m = user_desktop_items[i];
@@ -91,10 +103,11 @@ $.extend(frappe.desktop, {
var parent = $(this).parent();
var link = parent.attr("data-link");
if(link) {
if(link.substr(0, 1)==="/") {
window.open(link.substr(1))
if(link.substr(0, 1)==="/" || link.substr(0, 4)==="http") {
window.open(link, "_blank");
} else {
frappe.set_route(link);
}
frappe.set_route(link);
return false;
} else {
module = frappe.get_module(parent.attr("data-name"));


+ 1
- 1
frappe/core/page/desktop/desktop_icon_grid.html Просмотреть файл

@@ -2,7 +2,7 @@
<div id="icon-grid">
{% for (var i=0, l=desktop_items.length; i < l; i++) {
var module = frappe.get_module(desktop_items[i]);
if (user_desktop_items.indexOf(module.name)===-1) { continue; }
if (user_desktop_items.indexOf(module.name)===-1 && !module.force_show) { continue; }
%}
{%= frappe.render_template("desktop_module_icon", module) %}
{% } %}


+ 1
- 0
frappe/desk/page/activity/activity.js Просмотреть файл

@@ -6,6 +6,7 @@ frappe.provide("frappe.activity");
frappe.pages['activity'].on_page_load = function(wrapper) {
var me = this;

frappe.assets.views["List"]();
frappe.require('assets/frappe/js/lib/flot/jquery.flot.js');
frappe.require('assets/frappe/js/lib/flot/jquery.flot.downsample.js');



+ 0
- 4
frappe/handler.py Просмотреть файл

@@ -10,10 +10,6 @@ import frappe.utils.file_manager
import frappe.desk.form.run_method
from frappe.utils.response import build_response

@frappe.whitelist(allow_guest=True)
def startup():
frappe.response.update(frappe.sessions.get())

@frappe.whitelist()
def runserverobj(method, docs=None, dt=None, dn=None, arg=None, args=None):
frappe.desk.form.run_method.runserverobj(method, docs=docs, dt=dt, dn=dn, arg=arg, args=args)


+ 1
- 0
frappe/public/css/desktop.css Просмотреть файл

@@ -46,6 +46,7 @@ body[data-route="desktop"] .navbar-default {
display: inline-block;
transition: 0.2s;
-webkit-transition: 0.2s;
text-shadow: -1px 1px 5px rgba(0, 0, 0, 0.15);
}
.app-icon svg,
.app-icon img {


+ 5
- 24
frappe/public/js/frappe/desk.js Просмотреть файл

@@ -13,23 +13,7 @@ frappe.Application = Class.extend({
},

load_startup: function() {
var me = this;
if(window.app) {
return frappe.call({
method: 'startup',
callback: function(r, rt) {
frappe.provide('frappe.boot');
frappe.boot = r;
if(frappe.boot.user.name==='Guest' || frappe.boot.user.user_type==="Website User") {
window.location = 'index';
return;
}
me.startup();
}
});
} else {
this.startup();
}
this.startup();
},
startup: function() {
this.load_bootinfo();
@@ -37,7 +21,6 @@ frappe.Application = Class.extend({
this.make_nav_bar();
this.set_favicon();
this.setup_keyboard_shortcuts();
this.run_startup_js();

if(frappe.boot) {
if(localStorage.getItem("session_lost_route")) {
@@ -268,11 +251,6 @@ frappe.Application = Class.extend({
frappe.ui.toolbar.clear_cache();
});

},

run_startup_js: function() {
if(frappe.boot.startup_js)
eval(frappe.boot.startup_js);
}
});

@@ -288,10 +266,13 @@ frappe.get_module = function(m) {
module.link = "Module/" + m;
}

if(module.link) {
if (!module.link) module.link = "";

if (!module._id) {
module._id = module.link.toLowerCase().replace("/", "-");
}


if(!module.label) {
module.label = m;
}


+ 2
- 2
frappe/public/js/frappe/misc/user.js Просмотреть файл

@@ -80,7 +80,7 @@ $.extend(frappe.user, {
// add missing modules - they will be hidden anyways by the view
$.each(frappe.modules, function(m, module) {
var module = frappe.get_module(m);
if(module.link && modules_list.indexOf(m)==-1) {
if(modules_list.indexOf(m)==-1) {
modules_list.push(m);
}
});
@@ -96,7 +96,7 @@ $.extend(frappe.user, {
if(frappe.boot.hidden_modules && modules_list) {
var hidden_list = JSON.parse(frappe.boot.hidden_modules);
var modules_list = $.map(modules_list, function(m) {
if(hidden_list.indexOf(m)==-1) return m; else return null;
if(hidden_list.indexOf(m)==-1 || frappe.modules[m].force_show) return m; else return null;
});
}



+ 1
- 0
frappe/public/js/frappe/provide.js Просмотреть файл

@@ -4,6 +4,7 @@
// provide a namespace
if(!window.frappe)
window.frappe = {};

frappe.provide = function(namespace) {
// docs: create a namespace //
var nsl = namespace.split('.');


+ 1
- 1
frappe/public/js/frappe/ui/toolbar/offcanvas_left_sidebar.html Просмотреть файл

@@ -8,7 +8,7 @@
</form>
<ul class="list-unstyled sidebar-menu">
<li class="divider"></li>
<li><a href="#" class="all-applications strong">{%= __("All Applications") %}</a></li>
<li><a href="#" class="strong">{%= __("Home") %}</a></li>
</ul>
<div class="form-sidebar" style="display: none">



+ 1
- 1
frappe/public/js/frappe/ui/toolbar/toolbar.js Просмотреть файл

@@ -141,7 +141,7 @@ frappe.ui.toolbar.clear_cache = function() {
$c('frappe.sessions.clear',{},function(r,rt){
if(!r.exc) {
show_alert(r.message);
location.reload();
location.reload(true);
}
});
return false;


+ 1
- 0
frappe/public/less/desktop.less Просмотреть файл

@@ -55,6 +55,7 @@ body[data-route=""] .navbar-default, body[data-route="desktop"] .navbar-default
display: inline-block;
transition: 0.2s;
-webkit-transition: 0.2s;
text-shadow: -1px 1px 5px rgba(0, 0, 0, 0.15);
}

.app-icon svg, .app-icon img {


+ 3
- 4
frappe/sessions.py Просмотреть файл

@@ -73,7 +73,7 @@ def get():
"""get session boot info"""
from frappe.desk.notifications import \
get_notification_info_for_boot, get_notifications
from frappe.boot import get_bootinfo, get_startup_js
from frappe.boot import get_bootinfo

bootinfo = None
if not getattr(frappe.conf,'disable_session_cache', None):
@@ -81,9 +81,9 @@ def get():
bootinfo = frappe.cache().get_value("bootinfo", user=True)
if bootinfo:
bootinfo['from_cache'] = 1
bootinfo["user"]["recent"] = \
json.dumps(frappe.cache().get_value("recent", user=True))
bootinfo["notification_info"].update(get_notifications())
# bootinfo["user"]["recent"] = \
# json.dumps(frappe.cache().get_value("recent", user=True))

if not bootinfo:

@@ -96,7 +96,6 @@ def get():
if not bootinfo["metadata_version"]:
bootinfo["metadata_version"] = frappe.reset_metadata_version()

bootinfo["startup_js"] = get_startup_js()
for hook in frappe.get_hooks("extend_bootinfo"):
frappe.get_attr(hook)(bootinfo=bootinfo)



+ 6
- 0
frappe/templates/pages/desk.html Просмотреть файл

@@ -35,10 +35,16 @@
</div>

<script type="text/javascript" src="/assets/frappe/js/lib/jquery/jquery.min.js"></script>

<script type="text/javascript">
window._version_number = "{{ build_version }}";
// browser support
window.app = true;

if(!window.frappe) window.frappe = {};

frappe.boot = {{ boot }};

</script>

{% for include in include_js -%}


+ 12
- 2
frappe/templates/pages/desk.py Просмотреть файл

@@ -7,13 +7,23 @@ no_sitemap = 1
no_cache = 1
base_template_path = "templates/pages/desk.html"

import frappe, os
import os, json
import frappe
from frappe import _
import frappe.sessions
from frappe.utils.response import json_handler

def get_context(context):
if (frappe.session.user == "Guest" or
frappe.db.get_value("User", frappe.session.user, "user_type")=="Website User"):

frappe.throw(_("You are not permitted to access this page."), frappe.PermissionError)

hooks = frappe.get_hooks()
return {
"build_version": str(os.path.getmtime(os.path.join(frappe.local.sites_path, "assets", "js",
"frappe.min.js"))),
"include_js": hooks["app_include_js"],
"include_css": hooks["app_include_css"]
"include_css": hooks["app_include_css"],
"boot": json.dumps(frappe.sessions.get(), default=json_handler, indent=1, sort_keys=True)
}

Загрузка…
Отмена
Сохранить