Commit 6fd59d0c authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Desacopla lógica, renombra y setea title de página

parent aff3fcbf
Loading
Loading
Loading
Loading
+19 −18
Original line number Diff line number Diff line
var configBox = {
var config = {
	"domain": "redmic.net",
	"pathResources": "resources/",
	"protocol": "https",
	"resourcesPath": "resources/",
	"title": "Bienvenido a OAGdev",
	"items": [{
		"subDomain": "appdev",
		"subdomain": "appdev",
		"img": "redmic.png",
		"title": "REDMIC",
		"description": "Versión de desarrollo de REDMIC (Repositorio de Datos Marinos Integrados de Canarias)"
	},{
		"subDomain": "git",
		"subdomain": "git",
		"img": "gitlab.png",
		"title": "GitLab",
		"description": "Gestor de repositorios de desarrollo"
	},{
		"subDomain": "pgadmin",
		"subdomain": "pgadmin",
		"img": "pgadmin.png",
		"title": "pgAdmin",
		"description": "Administrador para bases de datos de PostgreSQL"
	},{
		"subDomain": "portainer",
		"subdomain": "portainer",
		"img": "portainer.png",
		"title": "Portainer",
		"description": "Gestor de dockers"
	},{
		"subDomain": "webmail",
		"subdomain": "webmail",
		"img": "rainloop.png",
		"title": "Email",
		"description": "Correo"
	},{
		"subDomain": "postfixadmin",
		"subdomain": "postfixadmin",
		"img": "postfixadmin.png",
		"title": "Postfix Admin",
		"description": "Gestor de cuentas de correo"
	},{
		"subDomain": "spam",
		"subdomain": "spam",
		"img": "rspamd.png",
		"title": "RSpamd",
		"description": "Gestor de spam"
	},{
		"subDomain": "minio",
		"subdomain": "minio",
		"img": "minio.svg",
		"title": "Minio",
		"description": "Alamacenamieto de cache"
	},{
		"subDomain": "artifactory",
		"subdomain": "artifactory",
		"img": "artifactory.png",
		"title": "Artifactory",
		"description": "Repositorio de artefactos universal"
	},{
		"subDomain": "kafkatopicsui",
		"subdomain": "kafkatopicsui",
		"img": "kafka.png",
		"title": "Kafka Topics UI",
		"description": "Topics (temas/canales de comunicación) presentes en los brokers de Kafka"
	},{
		"subDomain": "schemaregistryui",
		"subdomain": "schemaregistryui",
		"img": "avro.png",
		"title": "Schema Registry UI",
		"description": "Repositorio de esquemas con soporte Avro"
	},{
		"subDomain": "kafkaconnectui",
		"subdomain": "kafkaconnectui",
		"img": "kafka-connect.png",
		"title": "Kafka Connect UI",
		"description": "Conectores registrados para topics de Kafka"
	},{
		"subDomain": "kafkamanager",
		"subdomain": "kafkamanager",
		"img": "kafka-manager.png",
		"title": "Kafka Manager",
		"description": "Gestión avanzada de topics de Kafka"
	},{
		"subDomain": "prometheus",
		"subdomain": "prometheus",
		"img": "prometheus.svg",
		"title": "Prometheus",
		"description": "Recolección de métricas"
	},{
		"subDomain": "grafana",
		"subdomain": "grafana",
		"img": "grafana.png",
		"title": "Grafana",
		"description": "Representación gráfica de métricas"
+2 −84
Original line number Diff line number Diff line
<html>
	<head>
		<meta charset="utf-8">
		<title>
			OAGdev
		</title>
		<link rel="stylesheet" href="resources/index.css" type="text/css">
		<script type="text/javascript" language="javascript" src="config.json"></script>
		<script type="text/javascript">

			function createItemTitle(item) {

				var node = document.createElement("div"),
					img = document.createElement("img");

				node.setAttribute('class', 'box-title');

				img.setAttribute('src', configBox.pathResources + item.img);
				node.appendChild(img);

				return node;
			}

			function createItemContent(item) {

				var node = document.createElement("div"),
					h2 = document.createElement("h2"),
					h2Content = document.createTextNode(item.title || '');
					p = document.createElement("p"),
					pContent = document.createTextNode(item.description || '');

				node.setAttribute('class', 'box-content');

				h2.appendChild(h2Content);
				node.appendChild(h2);

				p.appendChild(pContent);
				node.appendChild(p);

				return node;
			}

			function hrefItem(item) {

				if (item.subDomain) {
					return 'https://' + item.subDomain + '.' + configBox.domain;
				}

				return item.href;
			}

			function createItemBox(item) {

				var boxNode = document.createElement("a"),
					titleNode = createItemTitle(item),
					contentNode = createItemContent(item);

				boxNode.setAttribute('class', 'box');
				boxNode.setAttribute('href', hrefItem(item));

				boxNode.appendChild(titleNode);
				boxNode.appendChild(contentNode);

				return boxNode;
			}

			function createTitle(item) {

				var titleNode = document.getElementById("title"),
					node = document.createElement("h1"),
					content = document.createTextNode(configBox.title || '');

				node.appendChild(content);
				titleNode.appendChild(node);
			}

			function createContent() {

				createTitle();

				var items = configBox.items,
					boxContainerNode = document.getElementById("boxContainer");

				for (var i = 0; i < items.length; i++) {
					boxContainerNode.appendChild(createItemBox(items[i]));
				}
			}
		</script>
		<script type="text/javascript" language="javascript" src="index.js"></script>
	</head>
	<body onload="createContent()">
	<body onload="createContent(config)">
		<div class="page-title" id="title"></div>
		<div class="box-container" id="boxContainer"></div>
	</body>

oagdev/index.js

0 → 100644
+86 −0
Original line number Diff line number Diff line
function createItemTitle(config, item) {

	var node = document.createElement('div'),
		img = document.createElement('img'),
		imgPath = config.resourcesPath + item.img;

	node.setAttribute('class', 'box-title');
	img.setAttribute('src', imgPath);
	node.appendChild(img);

	return node;
}

function createItemContent(item) {

	var node = document.createElement('div'),
		h2 = document.createElement('h2'),
		h2Content = document.createTextNode(item.title || '');
		p = document.createElement('p'),
		pContent = document.createTextNode(item.description || '');

	node.setAttribute('class', 'box-content');

	h2.appendChild(h2Content);
	node.appendChild(h2);

	p.appendChild(pContent);
	node.appendChild(p);

	return node;
}

function getItemHref(config, item) {

	var href;

	if (item.subdomain) {
		href = config.protocol + '://' + item.subdomain + '.' + config.domain;
	} else {
		href = item.href;
	}

	return href;
}

function createItemBox(config, item) {

	var boxNode = document.createElement('a'),
		titleNode = createItemTitle(config, item),
		contentNode = createItemContent(item);

	boxNode.setAttribute('class', 'box');
	boxNode.setAttribute('href', getItemHref(config, item));

	boxNode.appendChild(titleNode);
	boxNode.appendChild(contentNode);

	return boxNode;
}

function createTitle(config) {

	var parentNode = document.getElementById('title'),
		titleNode = document.createElement('h1'),
		titleText = config.title || '',
		contentNode = document.createTextNode(titleText);

	document.title = titleText;
	titleNode.appendChild(contentNode);
	parentNode.appendChild(titleNode);
}

function createContent(config) {

	createTitle(config);

	var items = config.items,
		boxContainerNode = document.getElementById('boxContainer');

	for (var i = 0; i < items.length; i++) {
		var item = items[i],
			itemBox = createItemBox(config, item);

		boxContainerNode.appendChild(itemBox);
	}
}