1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- @{
- Layout = null;
- }
- <script src="~/js/jquery-3.4.1.min.js"></script>
- <script>
- $(document).ready(function() {
- //document.location = '@Url.Action("Index","SmartFuel")';
- //document.location = "http://localhost:8384/SmartFuel";
- getWebConsoleAPI(["webapi", ["WebConsole"]], function (apiPath) {
- //console.log("Joy home page index ready api path" + apiPath);
- if (apiPath === null || apiPath === undefined || apiPath === "") {
- document.location = '@Url.Action("Index","SmartFuel")';
- return;
- }
- var href = window.location.href;
- var path = window.location.pathname;
- let basicUrl = href.slice(0, href.indexOf(path));
- var serviceUrl = basicUrl + apiPath;
- $.ajax({
- url: serviceUrl,
- datatype: "application/json",
- type: 'post',
- contentType: "application/json;charset=utf-8;",
- beforeSend: function () {
- },
- success: function (data) {
- console.log(data);
- //alert("success get config:" + data.LayoutConfig.IndexPageUrl);
- if (data !== null && data.LayoutConfig && data.LayoutConfig.IndexPageUrl) {
- document.location = data.LayoutConfig.IndexPageUrl;
-
- } else {
- document.location = '@Url.Action("Index","SmartFuel")';
- }
- },
- error: function (err) {
- console.log(err);
- //alert("error happens");
- document.location = '@Url.Action("Index","SmartFuel")';
- }
- });
- });
- });
- function getWebConsoleAPI(parameter, callBack) {
- var href = window.location.href;
- var path = window.location.pathname;
- let basicUrl = href.slice(0, href.indexOf(path));
- var serviceUrl = basicUrl + "/u/?apitype=service&an=ShowMeApi&pn=ProcessorsDispatcher&en=Edge.Core.Processor.Dispatcher.DefaultDispatcher";
- $.ajax({
- url: serviceUrl,
- datatype: "application/json",
- type: 'post',
- contentType: "application/json;charset=utf-8;",
- data: JSON.stringify(parameter),
- beforeSend: function () {
- },
- success: function (data) {
- console.log(data);
- if (data !== null && Array.isArray(data) && data.length > 0) {
- if (callBack !== null) callBack(data[0].Path);
- } else {
- if (callBack !== null) callBack(null);
- }
- },
- error: function (err) {
- console.log(err);
- if (callBack !== null) callBack(null);
- }
- });
- }
- </script>
|