def application(application_id): client = docker.get_client() application = applications.get_application(application_id) if not application: flask.abort(404) application_status = None application_domain = None application_version = None application_image_version = docker.get_application_image_version(client, application) form = None if current_user.is_authenticated(): form = forms.ApplicationForm() if form.validate_on_submit(): if form.start.data: docker.create_application(client, current_user, application) if form.stop.data: docker.delete_application(client, current_user, application) return flask.redirect(flask.url_for('application', application_id=application_id)) application_status = docker.get_application_status(client, current_user, application) application_domain = applications.get_application_domain(current_user, application) application_version = docker.get_application_version(client, current_user, application) return flask.render_template('application.html', application=application, application_status=application_status, application_domain=application_domain, application_version=application_version, application_image_version=application_image_version, form=form)
def application_settings(application_id): user = current_user application = applications.get_application(application_id) application_settings = applications.get_application_settings( user.user_id, application_id) default_domain = applications.get_default_application_domain( user, application) form = forms.ApplicationSettingsForm() if form.validate_on_submit(): domain = form.domain.data.strip() if len(domain) != 0 and domain != default_domain: application_settings.settings["domain"] = domain else: application_settings.settings.pop("domain", None) https = form.https.data if https: application_settings.settings["https"] = True else: application_settings.settings.pop("https", None) applications.update_application_settings(application_settings) flask.flash("Settings updated successfully") return flask.redirect( flask.url_for('application', application_id=application_id)) form.domain.data = applications.get_application_domain(user, application) form.https.data = applications.get_application_https(user, application) return flask.render_template('application_settings.html', application=application, application_settings=application_settings, form=form)
def application_settings(application_id): user = current_user application = applications.get_application(application_id) application_settings = applications.get_application_settings( user.user_id, application_id) default_domain = applications.get_default_application_domain( user, application) backups = backup.list(user, application) form = forms.ApplicationSettingsForm() if form.validate_on_submit(): if form.update.data: domain = form.domain.data.strip() if len(domain) != 0 and domain != default_domain: application_settings.settings["domain"] = domain else: application_settings.settings.pop("domain", None) https = form.https.data if https: application_settings.settings["https"] = True else: application_settings.settings.pop("https", None) applications.update_application_settings(application_settings) if form.backup.data: backup.backup(user, application) flask.flash("Backup created successfully.") if form.restore.data: backup.restore(user, application, form.restore.raw_data[0]) flask.flash("Backup restored successfully.") form.domain.data = applications.get_application_domain(user, application) form.https.data = applications.get_application_https(user, application) return flask.render_template('application_settings.html', application=application, application_settings=application_settings, backups=backups, form=form)
def app_list(): started_applications = applications.get_all_started_applications() running_applications = docker.get_all_running_applications() all_applications = sorted(started_applications.union(running_applications), key=lambda a: (a[0].login, a[1].application_id)) line_format = "{:<14} {:<20} {:<3} {:<30}" print(line_format.format("User", "Application", "Run", "Domain")) print("-" * 79) for application in all_applications: running = "Y" if application in running_applications else "N" user = application[0] app = application[1] domain = applications.get_application_domain(user, app) if domain: domain = "http://" + domain print(line_format.format(user.login, app.application_id, running, domain))