Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New directive wz-config-viewer #982

Merged
merged 4 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/directives/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ import './wz-welcome-card/wz-welcome-card';
import './wz-no-config/wz-no-config';
import './wz-config-item/wz-config-item';
import './wz-config-item/wz-config-item.less';
import './wz-config-viewer/wz-config-viewer';
53 changes: 53 additions & 0 deletions public/directives/wz-config-viewer/wz-config-viewer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<div layout="row">
<!-- JSON card -->
<md-card flex="auto" class="wz-md-card" ng-if="jsoncontent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">JSON viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw JSON format</span>
</div>
</div>
<span flex></span>
<span ng-class="jsoncontent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="callgetjson()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="xmlcontent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="callgetxml()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The JSON viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre><code wz-dynamic="jsoncontent"></code></pre>
</div>
<!-- End JSON viewer -->
</md-card-content>
</md-card>
<!-- End JSON card -->

<!-- XML card -->
<md-card flex="auto" class="wz-md-card" ng-if="xmlcontent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">XML viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw XML format</span>
</div>
</div>
<span flex></span>
<span ng-class="jsoncontent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="callgetjson()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="xmlcontent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="callgetxml()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The XML viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre>{{ xmlcontent }}</pre>
</div>
<!-- End XML viewer -->
</md-card-content>
</md-card>
<!-- End XML card -->
</div>
39 changes: 39 additions & 0 deletions public/directives/wz-config-viewer/wz-config-viewer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Wazuh app - Wazuh config viewer directive
* Copyright (C) 2018 Wazuh, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Find more information about this on the LICENSE file.
*/

import template from './wz-config-viewer.html';
import { uiModules } from 'ui/modules';

const app = uiModules.get('app/wazuh', []);

class WzConfigViewer {
constructor() {
this.restrict = 'E';
this.scope = {
getjson: '&',
getxml: '&',
jsoncontent: '=jsoncontent',
xmlcontent: '=xmlcontent'
};
this.replace = true;
this.template = template;
}

link(scope, elm, attrs) {
scope.callgetjson = () => {
scope.getjson();
};
scope.callgetxml = () => scope.getxml();
}
}

app.directive('wzConfigViewer', () => new WzConfigViewer());
Original file line number Diff line number Diff line change
Expand Up @@ -92,57 +92,7 @@
</md-card>
<!-- End main card with all the settings -->

<!-- JSON card -->
<md-card flex="auto" class="wz-md-card" ng-if="JSONContent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">JSON viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw JSON format</span>
</div>
</div>
<span flex></span>
<span ng-class="JSONContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getJSON()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="XMLContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getXML()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The JSON viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre><code wz-dynamic="JSONContent"></code></pre>
</div>
<!-- End JSON viewer -->
</md-card-content>
</md-card>
<!-- End JSON card -->

<!-- XML card -->
<md-card flex="auto" class="wz-md-card" ng-if="XMLContent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">XML viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw XML format</span>
</div>
</div>
<span flex></span>
<span ng-class="JSONContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getJSON()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="XMLContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getXML()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The XML viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre>{{ XMLContent }}</pre>
</div>
<!-- End XML viewer -->
</md-card-content>
</md-card>
<!-- End XML card -->
<wz-config-viewer flex getjson="getJSON()" getxml="getXML()" jsoncontent="JSONContent" xmlcontent="XMLContent" />

</div>
<!-- End main content section -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,57 +60,7 @@
</md-card>
<!-- End main card with all the settings -->

<!-- JSON card -->
<md-card flex="auto" class="wz-md-card" ng-if="JSONContent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">JSON viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw JSON format</span>
</div>
</div>
<span flex></span>
<span ng-class="JSONContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getJSON()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="XMLContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getXML()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The JSON viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre><code wz-dynamic="JSONContent"></code></pre>
</div>
<!-- End JSON viewer -->
</md-card-content>
</md-card>
<!-- End JSON card -->

<!-- XML card -->
<md-card flex="auto" class="wz-md-card" ng-if="XMLContent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">XML viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw XML format</span>
</div>
</div>
<span flex></span>
<span ng-class="JSONContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getJSON()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="XMLContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getXML()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The XML viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre>{{ XMLContent }}</pre>
</div>
<!-- End XML viewer -->
</md-card-content>
</md-card>
<!-- End XML card -->
<wz-config-viewer flex getjson="getJSON()" getxml="getXML()" jsoncontent="JSONContent" xmlcontent="XMLContent" />

</div>
<!-- End main content section -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,57 +79,7 @@
</md-card>
<!-- End main card with all the settings -->

<!-- JSON card -->
<md-card flex="auto" class="wz-md-card" ng-if="JSONContent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">JSON viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw JSON format</span>
</div>
</div>
<span flex></span>
<span ng-class="JSONContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getJSON()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="XMLContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getXML()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The JSON viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre><code wz-dynamic="JSONContent"></code></pre>
</div>
<!-- End JSON viewer -->
</md-card-content>
</md-card>
<!-- End JSON card -->

<!-- XML card -->
<md-card flex="auto" class="wz-md-card" ng-if="XMLContent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">XML viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw XML format</span>
</div>
</div>
<span flex></span>
<span ng-class="JSONContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getJSON()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="XMLContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getXML()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The XML viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre>{{ XMLContent }}</pre>
</div>
<!-- End XML viewer -->
</md-card-content>
</md-card>
<!-- End XML card -->
<wz-config-viewer flex getjson="getJSON()" getxml="getXML()" jsoncontent="JSONContent" xmlcontent="XMLContent" />

</div>
<!-- End main content section -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,57 +92,7 @@
</md-card>
<!-- End main card with all the settings -->

<!-- JSON card -->
<md-card flex="auto" class="wz-md-card" ng-if="JSONContent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">JSON viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw JSON format</span>
</div>
</div>
<span flex></span>
<span ng-class="JSONContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getJSON()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="XMLContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getXML()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The JSON viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre><code wz-dynamic="JSONContent"></code></pre>
</div>
<!-- End JSON viewer -->
</md-card-content>
</md-card>
<!-- End JSON card -->

<!-- XML card -->
<md-card flex="auto" class="wz-md-card" ng-if="XMLContent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">XML viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw XML format</span>
</div>
</div>
<span flex></span>
<span ng-class="JSONContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getJSON()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="XMLContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getXML()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The XML viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre>{{ XMLContent }}</pre>
</div>
<!-- End XML viewer -->
</md-card-content>
</md-card>
<!-- End XML card -->
<wz-config-viewer flex getjson="getJSON()" getxml="getXML()" jsoncontent="JSONContent" xmlcontent="XMLContent" />

</div>
<!-- End main content section -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,57 +90,7 @@
</md-card>
<!-- End main card with all the settings -->

<!-- JSON card -->
<md-card flex="auto" class="wz-md-card" ng-if="JSONContent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">JSON viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw JSON format</span>
</div>
</div>
<span flex></span>
<span ng-class="JSONContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getJSON()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="XMLContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getXML()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The JSON viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre><code wz-dynamic="JSONContent"></code></pre>
</div>
<!-- End JSON viewer -->
</md-card-content>
</md-card>
<!-- End JSON card -->

<!-- XML card -->
<md-card flex="auto" class="wz-md-card" ng-if="XMLContent">
<md-card-content flex layout="column">
<div layout="row" layout-align="start center">
<div>
<span class="font-size-16">XML viewer</span>
<div class="wz-margin-top-10">
<span class="md-subheader small">View this configuration in raw XML format</span>
</div>
</div>
<span flex></span>
<span ng-class="JSONContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getJSON()">JSON</span>
<span class="small">&nbsp;&centerdot;&nbsp;</span>
<span ng-class="XMLContent ? 'wz-text-active' : ''" class="wz-text-link small" ng-click="getXML()">XML</span>
</div>
<md-divider class="wz-margin-top-10"></md-divider>

<!-- The XML viewer -->
<div flex="auto" class="wz-margin-top-10 wz-code-viewer">
<pre>{{ XMLContent }}</pre>
</div>
<!-- End XML viewer -->
</md-card-content>
</md-card>
<!-- End XML card -->
<wz-config-viewer flex getjson="getJSON()" getxml="getXML()" jsoncontent="JSONContent" xmlcontent="XMLContent" />

</div>
<!-- End main content section -->
Expand Down
Loading