Uploaded Test files

This commit is contained in:
Batuhan Berk Başoğlu 2020-11-12 11:05:57 -05:00
parent f584ad9d97
commit 2e81cb7d99
16627 changed files with 2065359 additions and 102444 deletions

View file

@ -0,0 +1,105 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/namespace',
'tree/js/notebooklist',
'base/js/i18n'
], function($, IPython, notebooklist, i18n) {
"use strict";
var KernelList = function (selector, options) {
/**
* Constructor
*
* Parameters:
* selector: string
* options: dictionary
* Dictionary of keyword arguments.
* session_list: SessionList instance
* base_url: string
* notebook_path: string
*/
notebooklist.NotebookList.call(this, selector, $.extend({
element_name: 'running'},
options));
this.kernelspecs = this.sessions = null;
this.events.on('kernelspecs_loaded.KernelSpec', $.proxy(this._kernelspecs_loaded, this));
};
KernelList.prototype = Object.create(notebooklist.NotebookList.prototype);
KernelList.prototype.add_duplicate_button = function () {
/**
* do nothing
*/
};
KernelList.prototype._kernelspecs_loaded = function (event, kernelspecs) {
this.kernelspecs = kernelspecs;
if (this.sessions) {
// trigger delayed session load, since kernelspecs arrived later
this.sessions_loaded(this.sessions);
}
};
KernelList.prototype.sessions_loaded = function (d) {
this.sessions = d;
if (!this.kernelspecs) {
return; // wait for kernelspecs before first load
}
this.clear_list();
var item, path, session, info;
for (path in d) {
if (!d.hasOwnProperty(path)) {
// nothing is safe in javascript
continue;
}
session = d[path];
item = this.new_item(-1);
info = this.kernelspecs[session.kernel.name];
this.add_link({
name: path,
path: path,
type: 'notebook',
kernel_display_name: (info && info.spec) ? info.spec.display_name : session.kernel.name
}, item);
}
$('#running_list_placeholder').toggle($.isEmptyObject(d));
};
KernelList.prototype.add_link = function (model, item) {
notebooklist.NotebookList.prototype.add_link.apply(this, [model, item]);
var running_indicator = item.find(".item_buttons")
.text('');
var that = this;
var kernel_name = $('<div/>')
.addClass('kernel-name')
.text(model.kernel_display_name)
.appendTo(running_indicator);
var shutdown_button = $('<button/>')
.addClass('btn btn-warning btn-xs')
.text(i18n._('Shutdown'))
.click(function() {
var parent = $(this).parent().parent().parent();
var path = parent.data('path');
if(!path) {
path = parent.parent().data('path');
}
if(!path) {
throw new Error("Shutdown path not present");
}
that.shutdown_notebook(path);
})
.appendTo(running_indicator);
};
// Backwards compatibility.
IPython.KernelList = KernelList;
return {'KernelList': KernelList};
});

View file

@ -0,0 +1,225 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
// adapted from Mozilla Developer Network example at
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
// shim `bind` for testing under casper.js
var bind = function bind(obj) {
var slice = [].slice;
var args = slice.call(arguments, 1),
self = this,
nop = function() {
},
bound = function() {
return self.apply(this instanceof nop ? this : (obj || {}), args.concat(slice.call(arguments)));
};
nop.prototype = this.prototype || {}; // Firefox cries sometimes if prototype is undefined
bound.prototype = new nop();
return bound;
};
Function.prototype.bind = Function.prototype.bind || bind ;
requirejs([
'jquery',
'contents',
'base/js/namespace',
'base/js/dialog',
'base/js/events',
'base/js/promises',
'base/js/page',
'base/js/utils',
'services/config',
'tree/js/notebooklist',
'tree/js/sessionlist',
'tree/js/kernellist',
'tree/js/terminallist',
'tree/js/newnotebook',
'tree/js/shutdownbutton',
'auth/js/loginwidget',
'bidi/bidi',
], function(
$,
contents_service,
IPython,
dialog,
events,
promises,
page,
utils,
config,
notebooklist,
sesssionlist,
kernellist,
terminallist,
newnotebook,
shutdownbutton,
loginwidget,
bidi){
"use strict";
try{
requirejs(['custom/custom'], function() {});
bidi.loadLocale();
} catch(err) {
console.log("Error loading custom.js from tree service. Continuing and logging");
console.warn(err);
}
console.log('Welcome to Project Jupyter! Explore the various tools available and their corresponding documentation. If you are interested in contributing to the platform, please visit the community resources section at http://jupyter.org/community.html.');
// Setup all of the config related things
var common_options = {
base_url: utils.get_body_data("baseUrl"),
notebook_path: utils.get_body_data("notebookPath"),
};
var cfg = new config.ConfigSection('tree', common_options);
cfg.load();
common_options.config = cfg;
var common_config = new config.ConfigSection('common', common_options);
common_config.load();
// Instantiate the main objects
page = new page.Page('div#header', 'div#site');
var session_list = new sesssionlist.SesssionList($.extend({
events: events},
common_options));
var contents = new contents_service.Contents({
base_url: common_options.base_url,
common_config: common_config
});
IPython.NotebookList = notebooklist.NotebookList;
var notebook_list = new notebooklist.NotebookList('#notebook_list', $.extend({
contents: contents,
session_list: session_list},
common_options));
var kernel_list = new kernellist.KernelList('#running_list', $.extend({
session_list: session_list},
common_options));
var terminal_list;
if (utils.get_body_data("terminalsAvailable") === "True") {
terminal_list = new terminallist.TerminalList('#terminal_list', common_options);
}
var login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
var new_buttons = new newnotebook.NewNotebookWidget("#new-buttons",
$.extend(
{contents: contents, events: events},
common_options
)
);
var interval_id=0;
// auto refresh every xx secondes, no need to be fast,
// update is done most of the time when page get focus
IPython.tree_time_refresh = 60; // in sec
// limit refresh on focus at 1/10sec, otherwise this
// can cause too frequent refresh on switching through windows or tabs.
IPython.min_delta_refresh = 10; // in sec
var _last_refresh = null;
var _refresh_list = function(){
_last_refresh = new Date();
session_list.load_sessions();
if (terminal_list) {
terminal_list.load_terminals();
}
};
var enable_autorefresh = function(){
/**
*refresh immediately , then start interval
*/
var now = new Date();
if (now - _last_refresh < IPython.min_delta_refresh*1000){
console.log("Reenabling autorefresh too close to last tree refresh, not refreshing immediately again.");
} else {
_refresh_list();
}
if (!interval_id){
interval_id = setInterval(_refresh_list,
IPython.tree_time_refresh*1000
);
}
};
var disable_autorefresh = function(){
clearInterval(interval_id);
interval_id = 0;
};
// stop autorefresh when page lose focus
$(window).blur(function() {
disable_autorefresh();
});
//re-enable when page get focus back
$(window).focus(function() {
enable_autorefresh();
});
// finally start it, it will refresh immediately
enable_autorefresh();
page.show();
// For backwards compatibility.
IPython.page = page;
IPython.notebook_list = notebook_list;
IPython.session_list = session_list;
IPython.kernel_list = kernel_list;
IPython.login_widget = login_widget;
IPython.new_notebook_widget = new_buttons;
events.trigger('app_initialized.DashboardApp');
// Now actually load nbextensions
utils.load_extensions_from_config(cfg);
utils.load_extensions_from_config(common_config);
// bound the upload method to the on change of the file select list
$("#alternate_upload").change(function (event){
notebook_list.handleFilesUpload(event,'form');
});
// bound the the span around the input file upload to enable keyboard click
$("#upload_span").keydown(function (event) {
var key = event.which;
if ((key === 13) || (key === 32)) {
event.preventDefault();
$("#upload_span_input").click();
}
})
// set hash on tab click
$("#tabs").find("a").click(function(e) {
// Prevent the document from jumping when the active tab is changed to a
// tab that has a lot of content.
e.preventDefault();
// Set the hash without causing the page to jump.
// https://stackoverflow.com/a/14690177/2824256
var hash = $(this).attr("href");
if(window.history.pushState) {
window.history.pushState(null, null, hash);
} else {
window.location.hash = hash;
}
});
// load tab if url hash
if (window.location.hash) {
$("#tabs").find("a[href='" + window.location.hash + "']").click();
}
shutdownbutton.activate();
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,118 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/namespace',
'base/js/utils',
'base/js/i18n',
'base/js/dialog',
], function ($, IPython, utils, i18n, dialog) {
"use strict";
var NewNotebookWidget = function (selector, options) {
this.selector = selector;
this.base_url = options.base_url;
this.contents = options.contents;
this.events = options.events;
this.default_kernel = null;
this.kernelspecs = {};
if (this.selector !== undefined) {
this.element = $(selector);
this.request_kernelspecs();
}
this.bind_events();
};
NewNotebookWidget.prototype.bind_events = function () {
var that = this;
this.element.find('#new_notebook').click(function () {
that.new_notebook();
});
};
NewNotebookWidget.prototype.request_kernelspecs = function () {
/** request and then load kernel specs */
var url = utils.url_path_join(this.base_url, 'api/kernelspecs');
utils.promising_ajax(url).then($.proxy(this._load_kernelspecs, this));
};
NewNotebookWidget.prototype._load_kernelspecs = function (data) {
/** load kernelspec list */
var that = this;
this.kernelspecs = data.kernelspecs;
var menu = this.element.find("#notebook-kernels");
var keys = Object.keys(data.kernelspecs).sort(function (a, b) {
var da = data.kernelspecs[a].spec.display_name;
var db = data.kernelspecs[b].spec.display_name;
if (da === db) {
return 0;
} else if (da > db) {
return 1;
} else {
return -1;
}
});
// Create the kernel list in reverse order because
// the .after insertion causes each item to be added
// to the top of the list.
for (var i = keys.length - 1; i >= 0; i--) {
var ks = this.kernelspecs[keys[i]];
var li = $("<li>")
.attr("id", "kernel-" +ks.name)
.data('kernelspec', ks).append(
$('<a>')
.attr("aria-label", ks.name)
.attr("role", "menuitem")
.attr('href', '#')
.click($.proxy(this.new_notebook, this, ks.name))
.text(ks.spec.display_name)
.attr('title', i18n.sprintf(i18n._('Create a new notebook with %s'), ks.spec.display_name))
);
menu.after(li);
}
this.events.trigger('kernelspecs_loaded.KernelSpec', data.kernelspecs);
};
NewNotebookWidget.prototype.new_notebook = function (kernel_name, evt) {
/** create and open a new notebook */
var that = this;
kernel_name = kernel_name || this.default_kernel;
var w = window.open(undefined, IPython._target);
var dir_path = $('body').attr('data-notebook-path');
this.contents.new_untitled(dir_path, {type: "notebook"}).then(
function (data) {
var url = utils.url_path_join(
that.base_url, 'notebooks',
utils.encode_uri_components(data.path)
);
if (kernel_name) {
url += "?kernel_name=" + kernel_name;
}
w.location = url;
}).catch(function (e) {
w.close();
// This statement is used simply so that message extraction
// will pick up the strings. The actual setting of the text
// for the button is in dialog.js.
var button_labels = [ i18n._("OK")];
dialog.modal({
title : i18n._('Creating Notebook Failed'),
body : $('<div/>')
.text(i18n._("An error occurred while creating a new notebook."))
.append($('<div/>')
.addClass('alert alert-danger')
.text(e.message || e)),
buttons: {
OK: {'class' : 'btn-primary'}
}
});
});
if (evt !== undefined) {
evt.preventDefault();
}
};
return {'NewNotebookWidget': NewNotebookWidget};
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,93 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/utils',
'bidi/bidi',
], function($, utils, bidi) {
"use strict";
var isRTL = bidi.isMirroringEnabled();
var SesssionList = function (options) {
/**
* Constructor
*
* Parameters:
* options: dictionary
* Dictionary of keyword arguments.
* events: $(Events) instance
* base_url : string
*/
this.events = options.events;
this.sessions = {};
this.base_url = options.base_url || utils.get_body_data("baseUrl");
// Add collapse arrows.
$('#running .panel-group .panel .panel-heading a').each(function(index, el) {
var $link = $(el);
var $icon = $('<i />')
.addClass('fa fa-caret-down');
$link.append($icon);
$link.down = true;
$link.click(function () {
if ($link.down) {
$link.down = false;
// jQeury doesn't know how to animate rotations. Abuse
// jQueries animate function by using an unused css attribute
// to do the animation (borderSpacing).
$icon.animate({ borderSpacing: 90 }, {
step: function(now,fx) {
isRTL ? $icon.css('transform','rotate(' + now + 'deg)') : $icon.css('transform','rotate(-' + now + 'deg)');
}
}, 250);
} else {
$link.down = true;
// See comment above.
$icon.animate({ borderSpacing: 0 }, {
step: function(now,fx) {
isRTL ? $icon.css('transform','rotate(' + now + 'deg)') : $icon.css('transform','rotate(-' + now + 'deg)');
}
}, 250);
}
});
});
};
SesssionList.prototype.load_sessions = function(){
var that = this;
var settings = {
processData : false,
cache : false,
type : "GET",
dataType : "json",
success : $.proxy(that.sessions_loaded, this),
error : utils.log_ajax_error,
};
var url = utils.url_path_join(this.base_url, 'api/sessions');
utils.ajax(url, settings);
};
SesssionList.prototype.sessions_loaded = function(data){
this.sessions = {};
var len = data.length;
var nb_path;
for (var i=0; i<len; i++) {
// The classic notebook only knows about sessions for notebooks,
// but the server now knows about more general sessions for
// things like consoles.
if (data[i].type === 'notebook') {
nb_path = data[i].notebook.path;
this.sessions[nb_path] = {
id: data[i].id,
kernel: {
name: data[i].kernel.name
}
};
}
}
this.events.trigger('sessions_loaded.Dashboard', this.sessions);
};
return {'SesssionList': SesssionList};
});

View file

@ -0,0 +1,48 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/dialog',
'base/js/i18n',
'base/js/utils'
], function(
$,
dialog,
i18n,
utils
){
"use strict";
function display_shutdown_dialog() {
var body = $('<div/>').append(
$('<p/>').text(i18n.msg._("You have shut down Jupyter. You can now close this tab."))
).append(
$('<p/>').text(i18n.msg._("To use Jupyter again, you will need to relaunch it."))
);
dialog.modal({
title: i18n.msg._("Server stopped"),
body: body
})
}
function activate() {
// Add shutdown button
$("button#shutdown").click(function () {
utils.ajax(utils.url_path_join(
utils.get_body_data("baseUrl"),
"api",
"shutdown"
), {
type: "POST",
success: display_shutdown_dialog,
error: function (error) {
console.log(error);
}
});
});
}
return {activate: activate}
});

View file

@ -0,0 +1,128 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
define([
'jquery',
'base/js/namespace',
'base/js/utils',
'base/js/i18n',
'tree/js/notebooklist',
], function($, IPython, utils, i18n, notebooklist) {
"use strict";
var TerminalList = function (selector, options) {
/**
* Constructor
*
* Parameters:
* selector: string
* options: dictionary
* Dictionary of keyword arguments.
* base_url: string
*/
this.base_url = options.base_url || utils.get_body_data("baseUrl");
this.element_name = options.element_name || 'running';
this.selector = selector;
this.terminals = [];
if (this.selector !== undefined) {
this.element = $(selector);
this.style();
this.bind_events();
this.load_terminals();
}
};
TerminalList.prototype = Object.create(notebooklist.NotebookList.prototype);
TerminalList.prototype.bind_events = function () {
var that = this;
$('#refresh_' + this.element_name + '_list').click(function () {
that.load_terminals();
});
$('#new-terminal').click($.proxy(this.new_terminal, this));
};
TerminalList.prototype.new_terminal = function (event) {
if (event) {
event.preventDefault();
}
var w = window.open('#', IPython._target);
var base_url = this.base_url;
var settings = {
type : "POST",
dataType: "json",
success : function (data, status, xhr) {
var name = data.name;
w.location = utils.url_path_join(base_url, 'terminals',
utils.encode_uri_components(name));
},
error : function(jqXHR, status, error){
w.close();
utils.log_ajax_error(jqXHR, status, error);
},
};
var url = utils.url_path_join(
this.base_url,
'api/terminals'
);
utils.ajax(url, settings);
};
TerminalList.prototype.load_terminals = function() {
var url = utils.url_path_join(this.base_url, 'api/terminals');
utils.ajax(url, {
type: "GET",
cache: false,
dataType: "json",
success: $.proxy(this.terminals_loaded, this),
error : utils.log_ajax_error
});
};
TerminalList.prototype.terminals_loaded = function (data) {
this.terminals = data;
this.clear_list();
var item, term;
for (var i=0; i < this.terminals.length; i++) {
term = this.terminals[i];
item = this.new_item(-1);
this.add_link(term.name, item);
this.add_shutdown_button(term.name, item);
}
$('#terminal_list_header').toggle(data.length === 0);
};
TerminalList.prototype.add_link = function(name, item) {
item.data('term-name', name);
item.find(".item_name").text("terminals/" + name);
item.find(".item_icon").addClass("fa fa-terminal");
var link = item.find("a.item_link")
.attr('href', utils.url_path_join(this.base_url, "terminals",
utils.encode_uri_components(name)));
link.attr('target', IPython._target||'_blank');
this.add_shutdown_button(name, item);
};
TerminalList.prototype.add_shutdown_button = function(name, item) {
var that = this;
var shutdown_button = $("<button/>").text(i18n._("Shutdown")).addClass("btn btn-xs btn-warning").
click(function (e) {
var settings = {
processData : false,
type : "DELETE",
dataType : "json",
success : function () {
that.load_terminals();
},
error : utils.log_ajax_error,
};
var url = utils.url_path_join(that.base_url, 'api/terminals',
utils.encode_uri_components(name));
utils.ajax(url, settings);
return false;
});
item.find(".item_buttons").text("").append(shutdown_button);
};
return {TerminalList: TerminalList};
});