-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
204 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var Globals = (function () { | ||
function Globals() { | ||
} | ||
Globals.initEnv = function () { | ||
this.env = nunjucks.configure({}); | ||
this.env.addFilter('toFixed', function (num, digits) { | ||
return parseFloat(num).toFixed(digits || 2); | ||
}); | ||
this.env.addFilter('cut', function (str, digits) { | ||
return str.substring(0, digits || 8); | ||
}); | ||
this.env.addFilter('max', function (values) { | ||
return Math.max.apply(Math, values); | ||
}); | ||
this.env.addFilter('aslist', function (value) { | ||
var s = ''; | ||
value.split('/').forEach(function (element) { | ||
if (element) { | ||
s += '<li>' + element + '</li>'; | ||
} | ||
}); | ||
return '<ul>' + s + '</ul>'; | ||
}); | ||
}; | ||
return Globals; | ||
}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
interface CIHPCSimple { | ||
projectName: string; | ||
flaskApiUrl: string; | ||
} | ||
|
||
interface Window { | ||
cihpc: CIHPCSimple; | ||
moment: any; | ||
} | ||
|
||
interface ExtraData { | ||
_id: string[]; | ||
} | ||
|
||
|
||
class Globals { | ||
static env: nunjucks.Environment; | ||
|
||
static initEnv() { | ||
this.env = nunjucks.configure({}); | ||
this.env.addFilter('toFixed', (num, digits) => { | ||
return parseFloat(num).toFixed(digits || 2) | ||
}); | ||
this.env.addFilter('cut', (str, digits) => { | ||
return str.substring(0, digits || 8) | ||
}); | ||
this.env.addFilter('max', (values) => { | ||
return Math.max.apply(Math, values); | ||
}); | ||
this.env.addFilter('aslist', (value: string) => { | ||
var s = '' | ||
value.split('/').forEach((element: string) => { | ||
if (element) { | ||
s += '<li>' + element + '</li>'; | ||
} | ||
}) | ||
return '<ul>' + s + '</ul>'; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
$(document).ready(function () { | ||
Globals.initEnv(); | ||
Templates.loadTemplates(); | ||
Utils.extendJQuery(); | ||
CIHPC.url_base = window.cihpc.flaskApiUrl + '/' + window.cihpc.projectName; | ||
$.ajax({ | ||
url: CIHPC.url_base + '/config', | ||
error: function (result) { | ||
$('#configure-view').addClass('disabled'); | ||
$('#charts-sm').html(Templates.serverError.render({ | ||
title: 'Server error', | ||
shortDesc: 'Cannot connect to the server [500]', | ||
description: '<p>Could not connect to the server, make sure it is running ' + | ||
'and is accesible. The server should be running on this address: ' + | ||
'<code>' + CIHPC.url_base + '</code></p>' + | ||
'<p>This can be changed in <code>index.html</code> file, in ' + | ||
'section:</p><code><pre>' + | ||
'window.cihpc = {\n' + | ||
' projectName: "foobar",\n' + | ||
' flaskApiUrl: "http://foo.bar.com:5000",\n' + | ||
'}\n' + | ||
'</pre></code>' | ||
})); | ||
}, | ||
success: function (config) { | ||
console.log(config); | ||
CIHPC.init(config); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/// <reference path ="../typings/jquery/jquery.d.ts"/> | ||
/// <reference path ="../typings/nunjucks/nunjucks.d.ts"/> | ||
/// <reference path ="../typings/highcharts/index.d.ts"/> | ||
/// <reference path ="globals.ts"/> | ||
/// <reference path ="filters.ts"/> | ||
/// <reference path ="utils.ts"/> | ||
/// <reference path ="templates.ts"/> | ||
/// <reference path ="cihpc.ts"/> | ||
|
||
|
||
$(document).ready(() => { | ||
Globals.initEnv(); | ||
Templates.loadTemplates(); | ||
Utils.extendJQuery(); | ||
|
||
|
||
CIHPC.url_base = window.cihpc.flaskApiUrl + '/' + window.cihpc.projectName; | ||
|
||
$.ajax({ | ||
url: CIHPC.url_base + '/config', | ||
error: function (result) { | ||
$('#configure-view').addClass('disabled'); | ||
$('#charts-sm').html( | ||
Templates.serverError.render({ | ||
title: 'Server error', | ||
shortDesc: 'Cannot connect to the server [500]', | ||
description: '<p>Could not connect to the server, make sure it is running ' + | ||
'and is accesible. The server should be running on this address: ' + | ||
'<code>' + CIHPC.url_base + '</code></p>' + | ||
'<p>This can be changed in <code>index.html</code> file, in ' + | ||
'section:</p><code><pre>' + | ||
'window.cihpc = {\n' + | ||
' projectName: "foobar",\n' + | ||
' flaskApiUrl: "http://foo.bar.com:5000",\n' + | ||
'}\n' + | ||
'</pre></code>' | ||
}) | ||
); | ||
// alert(result); | ||
}, | ||
success: function(config) { | ||
console.log(config); | ||
CIHPC.init(config); | ||
// CIHPC.addFilters(config); | ||
// CIHPC.addTestList(config); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.