-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DDF-3875 Add admin-federation webapp (#3323)
- Loading branch information
Showing
11 changed files
with
395 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
33
ui/packages/admin-federation-ui/src/main/webapp/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
44
ui/packages/admin-federation-ui/src/main/webapp/js/application.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
47
ui/packages/admin-federation-ui/src/main/webapp/js/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
|
42 changes: 42 additions & 0 deletions
42
ui/packages/admin-federation-ui/src/main/webapp/js/model/Federation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
55
ui/packages/admin-federation-ui/src/main/webapp/js/module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
|
||
}); | ||
}); |
45 changes: 45 additions & 0 deletions
45
ui/packages/admin-federation-ui/src/main/webapp/js/view/Federation.view.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
55
ui/packages/admin-federation-ui/src/main/webapp/styles/styles.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
|
Oops, something went wrong.