Saiku ui-settings接口404错误避免

自己手动编译的saiku ,不知道为什么前端总是报错   /saiku/rest/saiku/info/ui-settings  404NotFound

于是我就去查了查后台接口 ,确实没有此请求对应的接口呀 ui-settings

因为不是特别清楚接口做了什么,所以就从前端处理此问题啦

ui-settings 解析

>>获取动态CSS的接口 URL:/saiku/rest/saiku/info/ui-settings

>>接下来当然还是要访问这个接口啦

 |——这么说吧,我如果成功success了,我要做以下的事:
|——加载所有的JS[plugins.size次异步请求]
|——加载所有的CSS[css.size次异步请求]
|——如果我不小心失败error
|——我就只能加载所有的JS[plugins.size次异步请求]啦,你总不能要求我加载获取失败的CSS吧

  

解决方案

在js文件 Saiku.js (/saiku-ui/js/saiku/Saiku.js)中,我们每次请求 ui-settings接口都是失败,为了避免页上报错,我们就直接加载所有的js了,就不去加在所有的css啦

更改 if (!Settings.BIPLUGIN) { .. } 代码段如下:

/**
* Dynamically load plugins!
*
* @type {PluginCollection}
*/
if (!Settings.BIPLUGIN) {
$(document).ready(function() {
var plugins = new PluginCollection(); plugins.fetch({
success: function() {
var i = plugins.size();
var j = 0; plugins.each(function(log) {
j = j + 1; if (log.attributes.path !== 'js/saiku/plugins/I18n/plugin.js') {
jQuery.ajax({
async: false,
type: 'GET',
url: log.attributes.path,
data: null,
success: function() {
if (j === i) {
if (Settings.CSS !== undefined) {
Saiku.loadCSS(Settings.CSS, null);
} Saiku.session = new Session({}, {
username: Settings.USERNAME,
password: Settings.PASSWORD
}); Saiku.toolbar = new Toolbar();
}
},
dataType: 'script'
});
}
else {
if (j === i) {
if (Settings.CSS !== undefined) {
Saiku.loadCSS(Settings.CSS, null);
} Saiku.session = new Session({}, {
username: Settings.USERNAME,
password: Settings.PASSWORD
}); Saiku.toolbar = new Toolbar();
}
}
});
}
});
});
}

  

完整的saiku.js文件如下:(修改后的)

/*
* Copyright 2012 OSBI Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ /**
* Central object for handling global application state
*/
var Saiku = {
/**
* View which manages toolbar interactions
*/
toolbar: {}, /**
* View which handles tabs
*/
tabs: new TabSet(), /**
* Stop the intro plugin when it finishes
*/
introDone: false, /**
* Saiku SplashScreen
*/
splash: new SplashScreen({ toolbar: this.toolbar }), /**
* Model which handles session and authentication
*/
session: null, /**
* Global event bus
*/
events: _.extend({}, Backbone.Events), /**
* Collection of routers for page fragments
*/
routers: [], /**
* Create a new variable for Leaflet interactive maps
*/
leaflet: (typeof L !== 'undefined') ? L : {}, /**
* Convenience functions for blocking the UI
*/
ui: {
block: function(message) {
$('.processing_message').html(message);
$('.processing_message').removeClass('i18n_translated').addClass('i18n'); Saiku.i18n.translate(); $('.processing, .processing_container').show();
}, unblock: function() {
$('.processing, .processing_container, .blockOverlay').hide(); // Fix for Internet Explorer 10 UIBlock issue
$('.blockUI').fadeOut('slow');
}
}, /**
* Outputs a message to the Web Console
*/
log: function(channel, item) {
if (console && console.log) {
console.log('Logging for: ' + channel); if (item) {
console.log(item);
}
}
}, /**
* Outputs an error message to the Web Console
*/
error: function(channel, item) {
if (console && console.error) {
console.error('Logging for: ' + channel);
console.error(item);
}
}, /**
* Defines utility methods to work with the query string of a URL
*
* @example:
*
* Put in your URL:
* http://<YOUR_MACHINE_IP>:8080/?splash=false
*
* var paramsURI = Saiku.URLParams.paramsURI();
*
* if (Saiku.URLParams.contains({ splash: paramsURI.splash })) {
* // Do something...
* }
*/
URLParams: {
buildValue: function(value) {
if (/^\s*$/.test(value)) { return null; }
if (/^(true|false)$/i.test(value)) { return value.toLowerCase() === 'true'; }
if (isFinite(value)) { return parseFloat(value); } return value;
}, joinArrayValues: function(values) {
if (values.length === 2) {
return values[1];
}
else {
return values[1] + '=' + values[2];
}
}, paramsURI: function() {
var paramsURI = {};
var couples = window.location.search.substr(1).split('&');
var lenCouples = couples.length;
var keyId;
var keyValue; if (window.location.search.length > 1) {
for (keyId = 0; keyId < lenCouples; keyId++) {
keyValue = couples[keyId].split('=');
paramsURI[decodeURIComponent(keyValue[0])] = keyValue.length > 1
// ? this.buildValue(decodeURIComponent(keyValue[1]))
? this.buildValue(decodeURIComponent(this.joinArrayValues(keyValue)))
: null;
}
} return paramsURI;
}, equals: function() {
var params = Array.prototype.slice.call(arguments);
var paramsURI = this.paramsURI(); if (_.isEqual(paramsURI, params[0])) {
return true;
}
else {
return false;
}
}, contains: function() {
var params = Array.prototype.slice.call(arguments);
var paramsURI = this.paramsURI();
var common = {}; for (var key in paramsURI) {
if (paramsURI.hasOwnProperty(key)) {
if (params[0][key] && paramsURI[key] === params[0][key]) {
common[key] = params[0][key];
}
}
} if (_.isEqual(common, params[0])) {
return true;
}
else {
return false;
}
}
}, /**
* A function for loading CSS asynchronously
*
* @example:
*
* Saiku.loadCSS('PATH_OF_YOUR_CSS');
*/
loadCSS: function(href, media) {
var cssNode = window.document.createElement('link');
var ref = window.document.getElementsByTagName('script')[0]; cssNode.rel = 'stylesheet';
cssNode.href = href; // Temporarily, set media to something non-matching to
// ensure it'll fetch without blocking render
cssNode.media = 'only x'; // Inject link
ref.parentNode.insertBefore(cssNode, ref); // Set media back to `all` so that the
// stylesheet applies once it loads
setTimeout(function() {
cssNode.media = media || 'all';
}); return cssNode;
}, /**
* A function for asynchronously loading JavaScript files
*
* @example:
*
* Saiku.loadJS('PATH_OF_YOUR_JS');
*/
loadJS: function(src, callback) {
var scriptNode = window.document.createElement('script');
var ref = window.document.getElementsByTagName('script')[0]; scriptNode.src = src;
scriptNode.async = true; // Inject script
ref.parentNode.insertBefore(scriptNode, ref); // if callback...
if (callback && typeof(callback) === 'function') {
scriptNode.onload = callback;
} return scriptNode;
}, /**
* Converts value using a mask
*
* @example:
*
* Saiku.toPattern(1099911111, '(99) 9999-9999'); // -> (10) 9991-1111
* Saiku.toPattern(12122000, '99/99/9999'); // -> 12/12/2000
* Saiku.toPattern(99911111101, '999.999.999-99'); // -> 999.111.111-01
* Saiku.toPattern('ABC1234', 'AAA-9999'); // -> ABC-1234
*/
toPattern: function(value, opts) {
var DIGIT = '9';
var ALPHA = 'A';
var ALPHANUM = 'S';
var output = (typeof opts === 'object' ? opts.pattern : opts).split('');
var values = value ? value.toString().replace(/[^0-9a-zA-Z]/g, '') : '';
var index = 0;
var len = output.length; for (var i = 0; i < len; i++) {
if (index >= values.length) {
break;
}
if ((output[i] === DIGIT && values[index].match(/[0-9]/)) ||
(output[i] === ALPHA && values[index].match(/[a-zA-Z]/)) ||
(output[i] === ALPHANUM && values[index].match(/[0-9a-zA-Z]/))) {
output[i] = values[index++];
}
else if (output[i] === DIGIT ||
output[i] === ALPHA ||
output[i] === ALPHANUM) {
output = output.slice(0, i);
}
} return output.join('').substr(0, i);
}, /**
* Converts value using a mask
*
* @example:
*
* Saiku.replaceString('World', 'Web', 'Saiku Analytics World'); // -> Saiku Analytics Web
*/
replaceString: function(oldS, newS, fullS) {
var len = fullS.length; for (var i = 0; i < len; i++) {
if (fullS.substring(i, i + oldS.length) === oldS) {
fullS = fullS.substring(0, i) + newS + fullS.substring(i + oldS.length, fullS.length);
}
} return fullS;
}, /**
* Remove brackets
*
* @example:
*
* Saiku.removeBrackets('[Time].[Time].[Year]'); // -> Time.Time.Year
*/
removeBrackets: function(value) {
var str = value.toString(); return str.replace(/[\[\]]/gi, '');
}, /**
* Trim first or last char or both
*
* @example:
*
* Saiku.trimFirstLastChar('Saiku Analytics', 'first'); // -> aiku Analytics
* Saiku.trimFirstLastChar('Saiku Analytics', 'last'); // -> Saiku Analytic
* Saiku.trimFirstLastChar('Saiku Analytics'); // -> aiku Analytic
*/
trimFirstLastChar: function(value, trimPosChar) {
var str = value.toString(); if (trimPosChar === 'first') {
return str.substring(1, (str.length));
}
else if (trimPosChar === 'last') {
return str.substring(0, (str.length - 1));
}
else {
// Trim first and last char
return str.substring(1, (str.length - 1));
}
}
}; /**
* Saiku Singleton pattern
*/
Saiku.singleton = (function() {
'use strict'; var instance; Saiku.singleton = function() {
if (instance) {
return instance;
} instance = this; this.set = function(data) {
this.data = data;
}; this.get = function() {
return this.data;
};
}; return Saiku.singleton;
}()); /**
* Setting this option to true will fake PUT and DELETE requests
* with a HTTP POST, and pass them under the _method parameter.
* Setting this option will also set an X-HTTP-Method-Override header
* with the true method. This is required for BI server integration
*/
Backbone.emulateHTTP = false; /**
* Dynamically load plugins!
*
* @type {PluginCollection}
*/
/**
if (!Settings.BIPLUGIN) {
$(document).ready(function() {
var plugins = new PluginCollection(); plugins.fetch({
success: function() {
var settingsoverride = new SettingsOverrideCollection(); settingsoverride.fetch({
success: function() {
var i = plugins.size();
var j = 0; plugins.each(function(log) {
j = j + 1; if (log.attributes.path !== 'js/saiku/plugins/I18n/plugin.js') {
jQuery.ajax({
async: false,
type: 'GET',
url: log.attributes.path,
data: null,
success: function() {
if (j === i) {
var k = settingsoverride.size();
var l = 0; settingsoverride.each(function(log) {
l = l + 1; for (var key in log.attributes) {
if (log.attributes.hasOwnProperty(key)) {
Settings[key] = log.attributes[key];
}
} if (Settings.CSS !== undefined) {
Saiku.loadCSS(Settings.CSS, null);
} if (k === l) {
Saiku.session = new Session({}, {
username: Settings.USERNAME,
password: Settings.PASSWORD
}); Saiku.toolbar = new Toolbar();
}
});
}
},
dataType: 'script'
});
}
else {
if (j === i) {
var k = settingsoverride.size();
var l = 0; settingsoverride.each(function(log) {
l = l + 1; for (var key in log.attributes) {
if (log.attributes.hasOwnProperty(key)) {
Settings[key] = log.attributes[key];
}
} if (Settings.CSS !== undefined) {
Saiku.loadCSS(Settings.CSS, null);
} if (k === l) {
Saiku.session = new Session({}, {
username: Settings.USERNAME,
password: Settings.PASSWORD
}); Saiku.toolbar = new Toolbar();
}
});
}
}
});
},
error: function() {
var i = plugins.size();
var j = 0; plugins.each(function(log) {
j = j + 1; if (log.attributes.path !== 'js/saiku/plugins/I18n/plugin.js') {
jQuery.ajax({
async: false,
type: 'GET',
url: log.attributes.path,
data: null,
success: function() {
if (j === i) {
if (Settings.CSS !== undefined) {
Saiku.loadCSS(Settings.CSS, null);
} Saiku.session = new Session({}, {
username: Settings.USERNAME,
password: Settings.PASSWORD
}); Saiku.toolbar = new Toolbar();
}
},
dataType: 'script'
});
}
else {
if (j === i) {
if (Settings.CSS !== undefined) {
Saiku.loadCSS(Settings.CSS, null);
} Saiku.session = new Session({}, {
username: Settings.USERNAME,
password: Settings.PASSWORD
}); Saiku.toolbar = new Toolbar();
}
}
});
}
});
}
});
});
}
*/ /**
* Dynamically load plugins!
*
* @type {PluginCollection}
*/
if (!Settings.BIPLUGIN) {
$(document).ready(function() {
var plugins = new PluginCollection(); plugins.fetch({
success: function() {
var i = plugins.size();
var j = 0; plugins.each(function(log) {
j = j + 1; if (log.attributes.path !== 'js/saiku/plugins/I18n/plugin.js') {
jQuery.ajax({
async: false,
type: 'GET',
url: log.attributes.path,
data: null,
success: function() {
if (j === i) {
if (Settings.CSS !== undefined) {
Saiku.loadCSS(Settings.CSS, null);
} Saiku.session = new Session({}, {
username: Settings.USERNAME,
password: Settings.PASSWORD
}); Saiku.toolbar = new Toolbar();
}
},
dataType: 'script'
});
}
else {
if (j === i) {
if (Settings.CSS !== undefined) {
Saiku.loadCSS(Settings.CSS, null);
} Saiku.session = new Session({}, {
username: Settings.USERNAME,
password: Settings.PASSWORD
}); Saiku.toolbar = new Toolbar();
}
}
});
}
});
});
} var SaikuTimeLogger = function(element) {
this._element = $(element);
this._timestamps = [];
this._events = [];
}; SaikuTimeLogger.prototype.log = function(eventname) {
var time = (new Date()).getTime(); if (!eventname) {
eventname = 'Unknown';
} if (this._timestamps.length > 0) {
var lastTime = this._timestamps[this._timestamps.length -1]; if ((time - lastTime) > 1) {
this._element.append('<div>' + (time - lastTime) + ' ms ' + eventname + ' (previous: ' + this._events[this._events.length -1] + ' )</div>');
}
} this._timestamps.push(time);
this._events.push(eventname);
};

  

Saiku ui-settings接口404错误避免(二十九)的更多相关文章

  1. 第三百二十九节,web爬虫讲解2—urllib库爬虫—ip代理—用户代理和ip代理结合应用

    第三百二十九节,web爬虫讲解2—urllib库爬虫—ip代理 使用IP代理 ProxyHandler()格式化IP,第一个参数,请求目标可能是http或者https,对应设置build_opener ...

  2. WCF技术剖析之二十九:换种不同的方式调用WCF服务[提供源代码下载]

    原文:WCF技术剖析之二十九:换种不同的方式调用WCF服务[提供源代码下载] 我们有两种典型的WCF调用方式:通过SvcUtil.exe(或者添加Web引用)导入发布的服务元数据生成服务代理相关的代码 ...

  3. 《条目二十九:对于逐个字符的输入请考虑istreambuf_iterator》

    <条目二十九:对于逐个字符的输入请考虑istreambuf_iterator> 1.使用: ifstream inputfile("xxxx"); string fil ...

  4. 微信小程序把玩(二十九)video组件

    原文:微信小程序把玩(二十九)video组件 视频播放组件与图片加载组件也没啥差别,使用起来也没啥注意的 重要属性: wxml <!--监听button点击事件--> <button ...

  5. FreeSql (二十九)Lambda 表达式

    FreeSql 支持功能丰富的表达式函数解析,方便程序员在不了解数据库函数的情况下编写代码.这是 FreeSql 非常特色的功能之一,深入细化函数解析尽量做到满意,所支持的类型基本都可以使用对应的表达 ...

  6. 使用Typescript重构axios(二十九)——添加baseURL

    0. 系列文章 1.使用Typescript重构axios(一)--写在最前面 2.使用Typescript重构axios(二)--项目起手,跑通流程 3.使用Typescript重构axios(三) ...

  7. 《手把手教你》系列技巧篇(二十九)-java+ selenium自动化测试- Actions的相关操作上篇(详解教程)

    1.简介 有些测试场景或者事件,Selenium根本就没有直接提供方法去操作,而且也不可能把各种测试场景都全面覆盖提供方法去操作.比如:就像鼠标悬停,一般测试场景鼠标悬停分两种常见,一种是鼠标悬停在某 ...

  8. Bootstrap <基础二十九>面板(Panels)

    Bootstrap 面板(Panels).面板组件用于把 DOM 组件插入到一个盒子中.创建一个基本的面板,只需要向 <div> 元素添加 class .panel 和 class .pa ...

  9. Web 开发人员和设计师必读文章推荐【系列二十九】

    <Web 前端开发精华文章推荐>2014年第8期(总第29期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各类能够提升网站用户体验的优秀 jQuery 插件,展示前沿的 HTML5 ...

随机推荐

  1. 11 K-Means 原理及案例

    11 K-Means 原理及案例 非监督学习 unsupervised learning (非监督学习) ,只有特征值,没有目标值 聚类: 主要方法 - k-means (K - 需要分成的类别数) ...

  2. 剑指Offer-39.把数组排成最小的数(C++/Java)

    题目: 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个.例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323. 分析: 将数组 ...

  3. [译]Vulkan教程(19)渲染和呈现

    [译]Vulkan教程(19)渲染和呈现 Rendering and presentation 渲染和呈现 Setup 设置 This is the chapter where everything ...

  4. JS获取url请求参数

    JS获取url请求参数,代码如下: // 获取url请求参数 function getQueryParams() { var query = location.search.substring(1) ...

  5. MongoDB自学------(4)MongoDB主从搭建

    MongoDB复制原理 mongodb的复制至少需要两个节点.其中一个是主节点,负责处理客户端请求,其余的都是从节点,负责复制主节点上的数据. mongodb各个节点常见的搭配方式为:一主一从.一主多 ...

  6. 【朝花夕拾】Android自定义View篇之(二)Canvas常用功能

    前言 转在请申明,转自[https://www.cnblogs.com/andy-songwei/p/10960012.html],谢谢! 上一篇讲View的绘制流程中讲到过,最后一步是draw流程, ...

  7. PAT 1011 World Cup Betting 查找元素

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  8. MVC过滤器:过滤器执行顺序

    如果某个Action过滤器运用了多种过滤器,那么过滤器的执行顺序是如何呢? 规则一:不同类型的过滤器有一个先后顺序 即执行顺序是:授权过滤器->动作过滤器->结果过滤器->异常过滤器 ...

  9. Angular中使用bootstrap样式

    Angular中使用bootstrap样式 Angular中引入bootstrap的方法   方法1:在Angular.json中的styles数组中添加bootstrap路径 如下所示: " ...

  10. Spring Boot 2 使用自定义配置

    在application.yml定义配置后,可以使用Environment来读取配置,也可以使用@Value注解让业务代码去读取配置.如果属性较多,可以定义属性映射对象. 开发环境:IntelliJ ...