Skip to content

Commit

Permalink
DDF-3875 Add admin-federation webapp (#3323)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexabird authored and clockard committed Jun 20, 2018
1 parent 1c78143 commit 7faa8b6
Show file tree
Hide file tree
Showing 11 changed files with 395 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ Use the registry to subscribe to and federate with other instances of ${branding
====
The *Node Information* and *Remote Registries* tabs appear in both the ${ddf-registry} application and the ${ddf-catalog} application.
====

[NOTE]
====
For direct federation configuration, sources and registries can be configured at https://{FQDN}:{PORT}/admin/federation.
====
40 changes: 40 additions & 0 deletions ui/packages/admin-federation-ui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "federation-admin-module",
"author": "Codice",
"description": "A frontend UI for federation configuration on DDF.",
"version": "0.1.0",
"license": "LGPL-3.0",
"repository": {
"type": "git",
"url": "https://github.com/codice/ddf.git"
},
"engines": {
"node": ">=0.10.5"
},
"devDependencies": {
"ace": "*"
},
"dependencies": {
"backbone": "1.1.2",
"backbone-associations": "0.6.2",
"backbone.marionette": "2.4.7",
"jquery": "3.2.1"
},
"alias": {
"marionette": "backbone.marionette"
},
"scripts": {
"startplus": "ace start --open",
"start": "ace start",
"pretest": "ace bundle --env=test",
"test": "ace test ./target/test/index.html",
"testplus": "ace start --env=test --open",
"build": "ace bundle",
"postbuild": "ace package"
},
"files": [
"target/webapp"
],
"main": "src/main/webapp/js/main.js",
"context-path": "/admin/federation"
}
33 changes: 33 additions & 0 deletions ui/packages/admin-federation-ui/src/main/webapp/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
/**
* Copyright (c) Codice Foundation
*
* This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser
* General Public License as published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. A copy of the GNU Lesser General Public License
* is distributed along with this program and can be found at
* <http://www.gnu.org/licenses/lgpl.html>.
*
**/
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Federation</title>
<meta http-equiv="x-ua-compatible" content="IE=Edge">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="../../webjars/html5shiv/3.7.3/dist/html5shiv.js"></script>
<![endif]-->
<link href="../../webjars/css/ddf-theme-flatly.css" rel="stylesheet">
</head>
<body>
<main class="container" role="main"></main>
<script data-main="main" src="../../webjars/iframe-resizer/2.6.2/js/iframeResizer.contentWindow.min.js"></script>
<script data-main="main" src="../../webjars/iframe-resizer/2.6.2/js/iframeResizer.min.js"></script>
</body>
</html>
44 changes: 44 additions & 0 deletions ui/packages/admin-federation-ui/src/main/webapp/js/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* Copyright (c) Codice Foundation
*
* This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either
* version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details. A copy of the GNU Lesser General Public License is distributed along with this program and can be found at
* <http://www.gnu.org/licenses/lgpl.html>.
*
**/
/*global define*/

// #Main Application
define([
'underscore',
'backbone',
'marionette',
'ace/handlebars'
],function (_, Backbone, Marionette, hbs) {
'use strict';

var Application = {};

// This was moved from the main.js file into here.
// Since this modules has ui components, and it gets loaded before main.js, we need to init the renderer here for now until we sort this out.
Marionette.Renderer.render = function(template, data, view) {
data._view = view;
if (typeof template === 'function') {
return template(data);
} else {
return hbs.compile(template)(data);
}
};

Application.App = new Marionette.Application();

//add regions
Application.App.addRegions({
mainRegion: 'main'
});

return Application;
});
47 changes: 47 additions & 0 deletions ui/packages/admin-federation-ui/src/main/webapp/js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) Codice Foundation
*
* This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either
* version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details. A copy of the GNU Lesser General Public License is distributed along with this program and can be found at
* <http://www.gnu.org/licenses/lgpl.html>.
*
**/
/*global require, window */
/*jslint nomen:false, -W064 */

require('styles/styles.less');

require([
'jquery',
'backbone',
'js/application'
], function ($, Backbone, Application) {

var app = Application.App;
// Once the application has been initialized (i.e. all initializers have completed), start up
// Backbone.history.
app.on('initialize:after', function () {
Backbone.history.start();
});

if (window) {
// make ddf object available on window. Makes debugging in chrome console much easier
window.app = app;
if (!window.console) {
window.console = {
log: function () {
// no op
}
};
}
}

// Actually start up the application.
app.start();

require('js/module');
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright (c) Codice Foundation
*
* This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either
* version 3 of the License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details. A copy of the GNU Lesser General Public License is distributed along with this program and can be found at
* <http://www.gnu.org/licenses/lgpl.html>.
*
**/
/*global define*/

define([
'backbone',
'backbone-associations'
],
function (Backbone) {
"use strict";

return Backbone.AssociatedModel.extend({
defaults: {
selectedTab: "sources",
url: "../sources",
tabs: {
sources: {
title: "Sources",
url: "../sources"
},
local: {
title: "Local Registry",
url: "../registry/local"
},
remote: {
title: "Remote Registry",
url: "../registry/remote"
}
}
},
initialize: function () {}
});
});
55 changes: 55 additions & 0 deletions ui/packages/admin-federation-ui/src/main/webapp/js/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) Codice Foundation
*
* This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser
* General Public License as published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. A copy of the GNU Lesser General Public License
* is distributed along with this program and can be found at
* <http://www.gnu.org/licenses/lgpl.html>.
*
**/
/*global define*/
define([
'js/application',
'js/view/Federation.view.js',
'js/model/Federation.js'
],
function (Application, FederationView, FederationModel) {

Application.App.module('Federation', function (FederationModule, App, Backbone, Marionette) {

var federationModel = new FederationModel();

var federationPage = new FederationView({model:federationModel});

// Define a controller to run this module
// --------------------------------------

var Controller = Marionette.Controller.extend({

initialize: function (options) {
this.region = options.region;
},

show: function () {
this.region.show(federationPage);
}

});

// Initialize this module when the app starts
// ------------------------------------------

FederationModule.addInitializer(function () {
FederationModule.contentController = new Controller({
region: App.mainRegion
});
FederationModule.contentController.show();
});

});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) Codice Foundation
*
* This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser
* General Public License as published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. A copy of the GNU Lesser General Public License
* is distributed along with this program and can be found at
* <http://www.gnu.org/licenses/lgpl.html>.
*
**/
/*global define require*/
define([
'marionette',
'backbone',
'underscore',
'jquery',
'templates/federationPage.handlebars'
],
function (Marionette, Backbone, _, $, federationPage) {

return Marionette.LayoutView.extend({
template: federationPage,
initialize: function () {
_.bindAll.apply(_, [this].concat(_.functions(this)));
this.listenTo(this.model, 'change', this.render);
},
events: {
'click .tab-item': 'updateTab'
},
onShow: function () {
$('#'+this.model.get('selectedTab')).addClass('is-active');
},
updateTab: function (e) {
$('#'+this.model.get('selectedTab')).removeClass('is-active');
this.model.set('selectedTab', e.target.id);
this.model.set('url', this.model.get('tabs')[this.model.get('selectedTab')].url);
$('#'+this.model.get('selectedTab')).addClass('is-active');
}
});

});
55 changes: 55 additions & 0 deletions ui/packages/admin-federation-ui/src/main/webapp/styles/styles.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#title {
text-align:center;
display:block;
font-size: 2em;
margin:10px;
}

.tab-item-collection {
border-bottom: 1px solid rgba(0,0,0,.3);
display:block;
}

.tab-item {
display: inline-block;
position: relative;
min-width: 2em;
height: 2em;
padding:0.625rem;
font-size:1.4em;
}

.tab-item:not(.is-active):hover,
.tab-item:not(.is-active):focus {
background: rgba(0,0,0,.1);
}

.tab-item.is-active {
border: 1px solid rgba(0,0,0,.3);
border-bottom: 0px;
color: black;
cursor: default;
&:hover, &:focus {
text-decoration: none;
}
}

.tab-item.is-active:after {
display:block;
content: '';
position: absolute;
width: ~'calc(100% + 2px)';
height: 2px;
bottom: -2px;
left: -1px;
background: white;
border-left: 1px solid rgba(0,0,0,.3);
border-right: 1px solid rgba(0,0,0,.3);
}

.tab-content {
display:block;
}



Loading

0 comments on commit 7faa8b6

Please sign in to comment.