Rift.IO OSM R1 Initial Submission
[osm/UI.git] / skyquake / plugins / about / src / aboutSource.js
1
2 /*
3 *
4 * Copyright 2016 RIFT.IO Inc
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19 var rw = require('utils/rw.js');
20 var API_SERVER = rw.getSearchParams(window.location).api_server;
21 var aboutActions = require('./aboutActions.js');
22 var Utils = require('utils/utils.js');
23 import $ from 'jquery';
24 var aboutSource = {
25 get: function() {
26 return {
27 remote: function(state) {
28 return new Promise(function(resolve, reject) {
29 $.ajax({
30 url: 'api/?api_server=' + API_SERVER,
31 type:'GET',
32 beforeSend: Utils.addAuthorizationStub,
33 contentType: "application/json",
34 success: function(data) {
35 resolve(data);
36 },
37 error: function(error) {
38 console.log("There was an error getting the crash details: ", error);
39 reject(error);
40 }
41 }).fail(function(xhr){
42 console.log(xhr)
43 //Authentication and the handling of fail states should be wrapped up into a connection class.
44 Utils.checkAuthentication(xhr.status);
45 });
46
47 }).catch(function(){});
48 },
49 success: aboutActions.getAboutSuccess,
50 loading: aboutActions.getAboutLoading,
51 error: aboutActions.getAboutFail
52 }
53 },
54 createTime: function() {
55 return {
56 remote: function(state) {
57 return new Promise(function(resolve, reject) {
58 $.ajax({
59 url: 'api/create-time?api_server=' + API_SERVER,
60 type:'GET',
61 beforeSend: Utils.addAuthorizationStub,
62 contentType: "application/json",
63 success: function(data) {
64 resolve(data);
65 },
66 error: function(error) {
67 console.log("There was an error getting the uptime : ", error);
68 reject(error);
69 }
70 })
71
72 }).catch(function(){});;
73 },
74 success: aboutActions.getCreateTimeSuccess,
75 loading: aboutActions.getCreateTimeLoading,
76 error: aboutActions.getCreateTimeFail
77 }
78 }
79 }
80 module.exports = aboutSource;