"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
///
///
var colorMap = { "Running": "blue", "Planing": "yellow", "Failed": "red" };
var snip;
(function (snip) {
class Platform {
constructor() {
this.loaded = false;
}
run() {
$("span.button").each(function () {
var text = $(this).text();
$(this).empty();
var size = "";
if ($(this).hasClass("mini")) {
size = "mini";
$(this).removeClass("mini");
}
var icon = $(this).removeClass("button").attr("class");
if (icon != "") {
$("").addClass(icon + " icon").appendTo(this);
}
$("").text(text).appendTo(this);
$(this).attr("class", "ui bold " + size + " circular button");
switch (icon) {
case "check":
case "upload":
// case "plus":
$(this).addClass("green");
break;
case "minus":
case "delete":
$(this).addClass("red");
break;
default:
$(this).addClass("grey");
break;
}
});
$("span.item").each(function () {
var text = $(this).text();
$(this).empty();
var icon = $(this).removeClass("item").attr("class");
if (icon != "") {
$("").addClass(icon + " icon").appendTo(this);
}
$("").text(text).appendTo(this);
$(this).attr("class", "item");
});
// @ts-ignore
$("#dimmer").dimmer({ "closable": false });
// @ts-ignore
$("#header_bar").find(".dropdown").dropdown();
$("#header_bar").sid("reset_btn").click(function () {
localStorage.clear();
window.location.href = "/";
});
$("#header_bar").sid("shutdown_btn").click(
// @ts-ignore
() => __awaiter(this, void 0, void 0, function* () {
if (yield snip.ui.confirm("シャットダウンします。よろしいてすか")) {
snip.hamadeck.shutdown();
}
}));
$("#header_bar").sid("gc_btn").click(
// @ts-ignore
() => __awaiter(this, void 0, void 0, function* () {
if (yield snip.ui.confirm("メモリ解放します。よろしいてすか")) {
snip.hamadeck.gc();
}
}));
$("#header_bar").sid("dellog_btn").click(
// @ts-ignore
() => __awaiter(this, void 0, void 0, function* () {
if (yield snip.ui.confirm("ログを削除します。よろしいてすか")) {
snip.hamadeck.dellog();
}
}));
}
loadProject(project_id, callback) {
snip.hamadeck.read(project_id, function (res) {
callback(res.data);
}, true);
}
saveProject(project, callback) {
return __awaiter(this, void 0, void 0, function* () {
var self = this;
// @ts-ignore
if (yield snip.ui.confirm("保存します。よろしいですか?")) {
snip.hamadeck.save(project, function (res) {
if (res.status == "success") {
snip.ui.message("info", "保存しました。");
//storage.set("project" , project );
}
else {
snip.ui.message("error", "失敗しました。");
}
callback(res);
}, true);
}
});
}
}
snip.Platform = Platform;
snip.platform = new Platform();
class JarFileRef {
preload(pid) {
var self = this;
var jarfiles = new snip.ui.ListComponent($("#jarfiles"));
snip.hamadeck.jarfiles(pid, function (res) {
for (let rowdata of res.data) {
let row = jarfiles.addRow(rowdata);
row.bind(rowdata).$sid("name").click(function () {
self.callback(row.raw);
$("#jarfiles_modal").modal("hide");
});
}
});
}
show(callback) {
$("#jarfiles_modal").modal({ "duration": 0 }).modal("show");
this.callback = callback;
}
}
snip.JarFileRef = JarFileRef;
snip.jarFilesRef = new JarFileRef();
})(snip || (snip = {}));
(function (snip) {
var hamadeck;
(function (hamadeck) {
var common;
(function (common) {
function statusColor(status) {
var colorMap = { "completed": "blue", "running": "green", "planed": "yellow", "failed": "red" };
return colorMap[status];
}
common.statusColor = statusColor;
function execTime(time) {
var text = "";
var second = time % 60;
time -= second;
var minute = (time / 60) % 60;
time -= minute * 60;
var hour = (time / 3600) % 12;
time -= hour * 3600;
var day = time / 43200;
text = ('00' + minute).slice(-2) + ":" + ('00' + second).slice(-2);
if (hour > 0)
text = ('00' + hour).slice(-2) + ":" + text;
if (day > 0)
text = day + " " + text;
return text;
}
common.execTime = execTime;
})(common = hamadeck.common || (hamadeck.common = {}));
})(hamadeck = snip.hamadeck || (snip.hamadeck = {}));
})(snip || (snip = {}));