2014-05-04 17:26:43 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
oml.ui.appDialog = function() {
|
|
|
|
|
|
|
|
var ui = oml.user.ui,
|
|
|
|
|
2014-05-14 09:57:11 +00:00
|
|
|
tabs = Ox.getObjectById(oml.config.pages, 'app').parts.map(function(tab) {
|
|
|
|
return {
|
|
|
|
id: tab.id,
|
|
|
|
title: tab.title.replace(/ Open Media Library$/, ''),
|
|
|
|
selected: tab.id == ui.part.app
|
|
|
|
};
|
|
|
|
}),
|
2014-05-04 17:26:43 +00:00
|
|
|
|
2014-05-14 09:57:11 +00:00
|
|
|
$panel = Ox.TabPanel({
|
|
|
|
content: function(id) {
|
2014-08-22 16:42:08 +00:00
|
|
|
var $content = Ox.Element(),
|
|
|
|
$logo = Ox.Element(),
|
2014-05-14 09:57:11 +00:00
|
|
|
$text = Ox.Element()
|
2016-01-08 05:36:10 +00:00
|
|
|
.addClass('OxTextPage OxSelectable'),
|
2015-11-17 13:28:10 +00:00
|
|
|
title = Ox._(Ox.getObjectById(
|
2014-05-14 09:57:11 +00:00
|
|
|
Ox.getObjectById(oml.config.pages, 'app').parts,
|
|
|
|
id
|
2015-11-17 13:28:10 +00:00
|
|
|
).title);
|
2014-05-14 09:57:11 +00:00
|
|
|
$('<img>')
|
2014-05-04 17:26:43 +00:00
|
|
|
.attr({
|
|
|
|
src: '/static/png/oml.png'
|
|
|
|
})
|
|
|
|
.css({
|
2014-05-14 09:57:11 +00:00
|
|
|
position: 'absolute',
|
|
|
|
left: '16px',
|
|
|
|
top: '16px',
|
2014-05-04 17:26:43 +00:00
|
|
|
width: '192px',
|
|
|
|
height: '192px'
|
|
|
|
})
|
|
|
|
.appendTo($logo);
|
2014-08-22 16:42:08 +00:00
|
|
|
if (id == 'update') {
|
2016-01-05 16:22:41 +00:00
|
|
|
var titleHTML = '<h1><b>' + title + '</b></h1>'
|
|
|
|
$content.html(titleHTML);
|
2014-08-22 16:42:08 +00:00
|
|
|
oml.api.getVersion(function(response) {
|
|
|
|
if (response.data.update) {
|
2014-09-01 12:01:41 +00:00
|
|
|
if (response.data.current == 'git') {
|
2016-01-05 16:22:41 +00:00
|
|
|
$content.html(
|
|
|
|
titleHTML
|
|
|
|
+ '<p>'
|
2016-01-05 16:24:48 +00:00
|
|
|
+ Ox._('A newer version of Open Media Library is available in git.')
|
2016-01-05 17:08:14 +00:00
|
|
|
+ '</p><p>'
|
2016-01-05 16:19:45 +00:00
|
|
|
+ Ox._('To update run:')
|
2016-01-05 16:33:38 +00:00
|
|
|
+ ' <code>./ctl update</code>'
|
2016-01-05 16:19:45 +00:00
|
|
|
);
|
2014-09-01 12:01:41 +00:00
|
|
|
} else {
|
2016-01-05 16:22:41 +00:00
|
|
|
$content.html(
|
|
|
|
titleHTML
|
|
|
|
+ '<p>'
|
2016-01-05 16:24:48 +00:00
|
|
|
+ Ox._('You are running Open Media Library version {0}.', [response.data.current])
|
2016-01-05 17:08:14 +00:00
|
|
|
+ '</p><p>'
|
2016-01-05 16:24:48 +00:00
|
|
|
+ Ox._('A newer version is available.')
|
2016-01-05 16:19:45 +00:00
|
|
|
+ '</p>'
|
|
|
|
);
|
2014-09-01 12:01:41 +00:00
|
|
|
Ox.Button({
|
|
|
|
id: 'update',
|
2016-01-05 16:42:41 +00:00
|
|
|
title: Ox._('Install Now'),
|
|
|
|
width: 128
|
2014-09-01 12:01:41 +00:00
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
this.options({
|
|
|
|
disabled: true,
|
2016-01-05 16:19:45 +00:00
|
|
|
title: Ox._('Installing...')
|
2014-09-01 12:01:41 +00:00
|
|
|
});
|
2016-01-12 07:38:49 +00:00
|
|
|
oml.isRelaunching = true;
|
|
|
|
oml.api.restart({update: true}, function(response) {
|
2014-09-01 12:01:41 +00:00
|
|
|
if (response.status.code == 200) {
|
|
|
|
setTimeout(reload, 500);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}).appendTo($content);
|
|
|
|
}
|
2014-08-22 16:42:08 +00:00
|
|
|
} else {
|
2015-11-17 13:28:10 +00:00
|
|
|
if (response.data.current == 'git') {
|
2016-01-05 16:22:41 +00:00
|
|
|
$content.html(
|
|
|
|
titleHTML
|
|
|
|
+ '<p>'
|
2016-01-05 16:19:45 +00:00
|
|
|
+ Ox._('You are up to date.')
|
|
|
|
+ '</p>'
|
|
|
|
);
|
2015-11-17 13:28:10 +00:00
|
|
|
} else {
|
2016-01-05 16:22:41 +00:00
|
|
|
$content.html(
|
|
|
|
titleHTML
|
|
|
|
+ '<p>'
|
2016-01-05 16:24:48 +00:00
|
|
|
+ Ox._('You are running Open Media Library version {0}.', [response.data.current])
|
2016-01-05 17:08:14 +00:00
|
|
|
+ '</p><p>'
|
2016-01-05 16:19:45 +00:00
|
|
|
+ Ox._('You are up to date.')
|
|
|
|
+ '</p>'
|
|
|
|
);
|
2015-11-17 13:28:10 +00:00
|
|
|
}
|
2014-08-22 16:42:08 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$content.html('<h1><b>' + title + '</b></h1>'
|
2016-01-05 17:08:14 +00:00
|
|
|
+ '<p>The lazy brown fox jumped over the lazy black fox, but other than that not really much happened here since you last checked.');
|
2014-08-22 16:42:08 +00:00
|
|
|
}
|
2014-05-04 17:26:43 +00:00
|
|
|
$('<div>')
|
2014-05-14 09:57:11 +00:00
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
|
|
|
left: '16px',
|
2014-05-16 08:06:11 +00:00
|
|
|
right: '16px',
|
|
|
|
top: '16px',
|
2014-05-14 09:57:11 +00:00
|
|
|
overflowY: 'auto'
|
|
|
|
})
|
2014-08-22 16:42:08 +00:00
|
|
|
.append($content)
|
2014-05-14 09:57:11 +00:00
|
|
|
.appendTo($text);
|
2014-05-04 17:26:43 +00:00
|
|
|
return Ox.SplitPanel({
|
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: $logo,
|
|
|
|
size: 208
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: $text
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'horizontal'
|
|
|
|
});
|
2014-05-14 09:57:11 +00:00
|
|
|
},
|
2016-01-12 05:33:41 +00:00
|
|
|
style: 'squared',
|
2014-05-14 09:57:11 +00:00
|
|
|
tabs: tabs
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
2014-05-04 17:26:43 +00:00
|
|
|
oml.UI.set({'part.app': data.selected});
|
2014-05-14 09:57:11 +00:00
|
|
|
}
|
|
|
|
}),
|
2014-05-04 17:26:43 +00:00
|
|
|
|
|
|
|
that = Ox.Dialog({
|
|
|
|
buttons: [
|
|
|
|
Ox.Button({
|
|
|
|
id: 'close',
|
|
|
|
title: Ox._('Close')
|
|
|
|
}).bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.close();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
],
|
|
|
|
closeButton: true,
|
|
|
|
content: $panel,
|
|
|
|
fixedSize: true,
|
|
|
|
height: 384,
|
|
|
|
removeOnClose: true,
|
2016-01-12 05:33:41 +00:00
|
|
|
style: 'squared',
|
2014-05-04 17:26:43 +00:00
|
|
|
title: 'Open Media Library',
|
|
|
|
width: 768
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2014-05-14 09:57:11 +00:00
|
|
|
close: function() {
|
2014-05-04 17:26:43 +00:00
|
|
|
if (ui.page == 'app') {
|
|
|
|
oml.UI.set({page: ''});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'oml_part.app': function() {
|
|
|
|
if (ui.page == 'app') {
|
2014-05-17 11:45:57 +00:00
|
|
|
that.updateElement();
|
2014-05-04 17:26:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-05-17 11:45:57 +00:00
|
|
|
that.updateElement = function(section) {
|
2014-05-14 09:57:11 +00:00
|
|
|
$panel.selectTab(section);
|
2014-05-04 17:26:43 +00:00
|
|
|
};
|
|
|
|
|
2014-08-22 16:42:08 +00:00
|
|
|
function reload() {
|
|
|
|
var ws = new WebSocket('ws:' + document.location.host + '/ws');
|
|
|
|
ws.onopen = function(event) {
|
|
|
|
document.location.href = document.location.protocol + '//' + document.location.host;
|
|
|
|
};
|
|
|
|
ws.onerror = function(event) {
|
|
|
|
ws.close();
|
|
|
|
};
|
|
|
|
ws.onclose = function(event) {
|
|
|
|
console.log('waiting...');
|
|
|
|
setTimeout(reload, 500);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-05-04 17:26:43 +00:00
|
|
|
return that;
|
|
|
|
|
2014-08-22 16:42:08 +00:00
|
|
|
};
|