2 * Copyright 2016-2017 Huawei Technologies Co., Ltd.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 Table.create = function(data, id, columns) {
\r
18 $('#' + id).DataTable({
\r
21 "sDom": "<t<'left'li><'right'p>>",
\r
26 * update the table data, the cloumns must be same with the create one.
\r
27 * data: the update data. as the create structure
\r
30 Table.updata = function(data, id) {
\r
31 var datatable = $('#' + id).dataTable().api();
\r
33 datatable.rows.add(data);
\r
37 Table.enableToolTips = function(id) {
\r
38 $("#" + id + " tr th").each(function(index, sdom){
\r
39 sdom.title = sdom.textContent;
\r
41 $("#" + id + " tbody tr td").each(function(index, sdom){
\r
42 sdom.title = sdom.textContent;
\r
48 Rest.http = function(setting) {
\r
49 var ret = $.ajax(setting);
\r
50 ret.fail(function(data) {
\r
52 if (data.responseText.indexOf("login") != -1) {
\r
53 top.window.document.location.reload()
\r
55 var result = JSON.parse(data.responseText);
\r
56 if (result.error && result.error.message) {
\r
57 top.bootbox.alert(result.error.message, function() {});
\r
66 Rest.turn2URI = function(url) {
\r
67 var cookies = document.cookie.split(";");
\r
69 for (var i = 0; i < cookies.length; i++) {
\r
70 if (cookies[i].split("=")[0] == "X-Auth-Token") {
\r
71 cookie = cookies[i].split("=")[1];
\r
76 url: "/openoapi/auth/v1/tokens",
\r
79 "X-Auth-Token": cookie
\r
81 success: function(data) {
\r
82 window.document.location = url;
\r
84 error: function(data) {
\r
85 top.window.document.location.reload();
\r