Author: bricks
Date: 2017-02-16 10:35:12 +0100 (Thu, 16 Feb 2017)
New Revision: 27679

Added:
   trunk/gsa/src/html/classic/ng/src/web/targets/filterdialog.js
   trunk/gsa/src/html/classic/ng/src/web/targets/row.js
   trunk/gsa/src/html/classic/ng/src/web/targets/table.js
   trunk/gsa/src/html/classic/ng/src/web/targets/targetspage.js
Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/html/classic/ng/CMakeLists.txt
Log:
* src/html/classic/ng/CMakeLists.txt,
src/html/classic/ng/src/web/targets/filterdialog.js,
src/html/classic/ng/src/web/targets/row.js,
src/html/classic/ng/src/web/targets/table.js,
src/html/classic/ng/src/web/targets/targetspage.js: Implement a targets list
page.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog 2017-02-16 09:35:10 UTC (rev 27678)
+++ trunk/gsa/ChangeLog 2017-02-16 09:35:12 UTC (rev 27679)
@@ -1,6 +1,15 @@
 2017-02-16 Bj�rn Ricks <bjoern.ri...@greenbone.net>
 
        * src/html/classic/ng/CMakeLists.txt,
+       src/html/classic/ng/src/web/targets/filterdialog.js,
+       src/html/classic/ng/src/web/targets/row.js,
+       src/html/classic/ng/src/web/targets/table.js,
+       src/html/classic/ng/src/web/targets/targetspage.js: Implement a targets 
list
+       page.
+
+2017-02-16 Bj�rn Ricks <bjoern.ri...@greenbone.net>
+
+       * src/html/classic/ng/CMakeLists.txt,
        src/html/classic/ng/src/web/icons/cloneicon.js: Add new CloneIcon 
component.
 
 2017-02-16 Bj�rn Ricks <bjoern.ri...@greenbone.net>

Modified: trunk/gsa/src/html/classic/ng/CMakeLists.txt
===================================================================
--- trunk/gsa/src/html/classic/ng/CMakeLists.txt        2017-02-16 09:35:10 UTC 
(rev 27678)
+++ trunk/gsa/src/html/classic/ng/CMakeLists.txt        2017-02-16 09:35:12 UTC 
(rev 27679)
@@ -251,6 +251,10 @@
      ${NG_SRC_DIR}/src/web/table/table.js
      ${NG_SRC_DIR}/src/web/targets/dialog.js
      ${NG_SRC_DIR}/src/web/targets/dialogcontainer.js
+     ${NG_SRC_DIR}/src/web/targets/filterdialog.js
+     ${NG_SRC_DIR}/src/web/targets/row.js
+     ${NG_SRC_DIR}/src/web/targets/table.js
+     ${NG_SRC_DIR}/src/web/targets/targetspage.js
      ${NG_SRC_DIR}/src/web/tasks/addresultstoassetsgroup.js
      ${NG_SRC_DIR}/src/web/tasks/autodeletereportsgroup.js
      ${NG_SRC_DIR}/src/web/tasks/charts.js

Added: trunk/gsa/src/html/classic/ng/src/web/targets/filterdialog.js
===================================================================
--- trunk/gsa/src/html/classic/ng/src/web/targets/filterdialog.js               
                (rev 0)
+++ trunk/gsa/src/html/classic/ng/src/web/targets/filterdialog.js       
2017-02-16 09:35:12 UTC (rev 27679)
@@ -0,0 +1,45 @@
+/* Greenbone Security Assistant
+ *
+ * Authors:
+ * Björn Ricks <bjoern.ri...@greenbone.net>
+ *
+ * Copyright:
+ * Copyright (C) 2017 Greenbone Networks GmbH
+ *
+ * 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.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import  _ from '../../locale.js';
+
+import {withFilterDialog, DefaultFilterDialog} from '../powerfilter/dialog.js';
+
+const SORT_FIELDS = [
+  ['name', _('Name')],
+  ['hosts', _('Hosts')],
+  ['ips', _('IPs')],
+  ['port_list', _('Port List')],
+  ['ssh_credential', _('SSH Credential')],
+  ['smb_credential', _('SMB Credential')],
+  ['esxi_credential', _('ESXi Credential')],
+  ['snmp_credential', _('SNMP Credential')],
+];
+
+export const TargetsFilterDialog = withFilterDialog(DefaultFilterDialog, {
+  sortFields: SORT_FIELDS,
+});
+
+export default TargetsFilterDialog;
+
+// vim: set ts=2 sw=2 tw=80:

Added: trunk/gsa/src/html/classic/ng/src/web/targets/row.js
===================================================================
--- trunk/gsa/src/html/classic/ng/src/web/targets/row.js                        
        (rev 0)
+++ trunk/gsa/src/html/classic/ng/src/web/targets/row.js        2017-02-16 
09:35:12 UTC (rev 27679)
@@ -0,0 +1,158 @@
+/* Greenbone Security Assistant
+ *
+ * Authors:
+ * Björn Ricks <bjoern.ri...@greenbone.net>
+ *
+ * Copyright:
+ * Copyright (C) 2017 Greenbone Networks GmbH
+ *
+ * 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.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import React from 'react';
+
+import _ from '../../locale.js';
+import {is_defined, is_empty, shorten} from '../../utils.js';
+
+import Layout from '../layout.js';
+import LegacyLink from '../legacylink.js';
+import PropTypes from '../proptypes.js';
+import {render_component} from '../render.js';
+
+import {withEntityActions} from '../entities/actions.js';
+import {withEntityRow} from '../entities/row.js';
+
+import Text from '../form/text.js';
+
+import CloneIcon from '../icons/cloneicon.js';
+import EditIcon from '../icons/editicon.js';
+import ExportIcon from '../icons/exporticon.js';
+import TrashIcon from '../icons/trashicon.js';
+
+import TableData from '../table/data.js';
+import TableRow from '../table/row.js';
+
+const IconActions = ({entity, onEntityDelete, onEntityDownload,
+    onEntityClone, onEditTarget}) => {
+  return (
+    <Layout flex align={['center', 'center']}>
+      {entity.isInUse() ?
+        <TrashIcon
+          active={false}
+          title={_('Target is in use')}/> :
+            <TrashIcon
+              value={entity}
+              title={_('Move to Trashcan')}
+              onClick={onEntityDelete}/>
+      }
+      <EditIcon
+        value={entity}
+        title={_('Edit Target')}
+        onClick={onEditTarget}/>
+      <CloneIcon
+        title={_('Clone Target')}
+        value={entity}
+        onClick={onEntityClone}/>
+      <ExportIcon
+        value={entity}
+        title={_('Export Target')}
+        onClick={onEntityDownload}
+      />
+    </Layout>
+  );
+};
+
+IconActions.propTypes = {
+  entity: PropTypes.model,
+  onEntityDelete: React.PropTypes.func,
+  onEntityDownload: React.PropTypes.func,
+  onEditTarget: React.PropTypes.func,
+  onEntityClone: React.PropTypes.func,
+};
+
+const Cred = ({cred, title, links}) => {
+  if (!is_defined(cred) || is_empty(cred.id)) {
+    return null;
+  }
+  return (
+    <Layout flex box>
+      <Text>{title}: </Text>
+      <Layout box>
+        {links ?
+          <LegacyLink cmd="get_credential" credential_id={cred.id}>
+            {cred.name}
+          </LegacyLink> :
+          cred.name
+        }
+      </Layout>
+    </Layout>
+  );
+};
+
+Cred.propTypes = {
+  cred: PropTypes.model,
+  links: React.PropTypes.bool,
+  title: React.PropTypes.string,
+};
+
+
+const Row = ({entity, links = true, actions, ...props}) => {
+  return (
+    <TableRow>
+      <TableData flex="column">
+        {links ?
+          <LegacyLink cmd="get_target" target_id={entity.id}>
+            {entity.name}
+          </LegacyLink> :
+          entity.name
+        }
+        {!is_empty(entity.comment) &&
+          <div className="comment">({entity.comment})</div>
+        }
+      </TableData>
+      <TableData>
+        {shorten(entity.hosts, 500)}
+      </TableData>
+      <TableData flex align="center">
+        {entity.max_hosts}
+      </TableData>
+      <TableData>
+        {links ?
+          <LegacyLink cmd="get_port_list" port_list_id={entity.port_list.id}>
+            {entity.port_list.name}
+          </LegacyLink> :
+          entity.port_list.name
+        }
+      </TableData>
+      <TableData flex="column" align="center">
+        <Cred cred={entity.ssh_credential} title={'SSH'} links={links}/>
+        <Cred cred={entity.smb_credential} title={'SMB'} links={links}/>
+        <Cred cred={entity.esxi_credential} title={'ESXi'} links={links}/>
+        <Cred cred={entity.snmp_credential} title={'SNMP'} links={links}/>
+      </TableData>
+      {render_component(actions, {...props, entity})}
+    </TableRow>
+  );
+};
+
+Row.propTypes = {
+  actions: PropTypes.componentOrFalse,
+  entity: React.PropTypes.object,
+  links: React.PropTypes.bool,
+};
+
+const Actions = withEntityActions(IconActions);
+
+export default withEntityRow(Row, Actions);

Added: trunk/gsa/src/html/classic/ng/src/web/targets/table.js
===================================================================
--- trunk/gsa/src/html/classic/ng/src/web/targets/table.js                      
        (rev 0)
+++ trunk/gsa/src/html/classic/ng/src/web/targets/table.js      2017-02-16 
09:35:12 UTC (rev 27679)
@@ -0,0 +1,95 @@
+/* Greenbone Security Assistant
+ *
+ * Authors:
+ * Björn Ricks <bjoern.ri...@greenbone.net>
+ *
+ * Copyright:
+ * Copyright (C) 2017 Greenbone Networks GmbH
+ *
+ * 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.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import React from 'react';
+
+import _ from '../../locale.js';
+
+import {createEntitiesFooter} from '../entities/footer.js';
+import {withEntitiesHeader} from '../entities/header.js';
+import {createEntitiesTable} from '../entities/table.js';
+
+import TableHead from '../table/head.js';
+import TableHeader from '../table/header.js';
+import TableRow from '../table/row.js';
+
+import TargetRow from './row.js';
+
+const Header = ({onSortChange, links = true, sort = true, actions}) => {
+  return (
+    <TableHeader>
+      <TableRow>
+        <TableHead
+          sortby={sort ? 'name' : false}
+          onSortChange={onSortChange}>
+          {_('Name')}
+        </TableHead>
+        <TableHead
+          sortby={sort ? 'hosts' : false}
+          onSortChange={onSortChange}>
+          {_('Hosts')}
+        </TableHead>
+        <TableHead
+          sortby={sort ? 'ips' : false}
+          onSortChange={onSortChange}>
+          {_('IPs')}
+        </TableHead>
+        <TableHead
+          sortby={sort ? 'port_list' : false}
+          onSortChange={onSortChange}>
+          {_('Port List')}
+        </TableHead>
+        <TableHead>
+          {_('Credentials')}
+        </TableHead>
+        {actions}
+      </TableRow>
+    </TableHeader>
+  );
+};
+
+Header.propTypes = {
+  actions: React.PropTypes.element,
+  links: React.PropTypes.bool,
+  sort: React.PropTypes.bool,
+  onSortChange: React.PropTypes.func,
+};
+
+const TargetsHeader = withEntitiesHeader(Header);
+
+const Footer = createEntitiesFooter({
+  span: 6,
+  trash: true,
+  download: 'targets.xml',
+});
+
+export const TargetsTable = createEntitiesTable({
+  emptyTitle: _('No targets available'),
+  row: TargetRow,
+  header: TargetsHeader,
+  footer: Footer,
+});
+
+export default TargetsTable;
+
+// vim: set ts=2 sw=2 tw=80:

Added: trunk/gsa/src/html/classic/ng/src/web/targets/targetspage.js
===================================================================
--- trunk/gsa/src/html/classic/ng/src/web/targets/targetspage.js                
                (rev 0)
+++ trunk/gsa/src/html/classic/ng/src/web/targets/targetspage.js        
2017-02-16 09:35:12 UTC (rev 27679)
@@ -0,0 +1,130 @@
+/* Greenbone Security Assistant
+ *
+ * Authors:
+ * Björn Ricks <bjoern.ri...@greenbone.net>
+ *
+ * Copyright:
+ * Copyright (C) 2017 Greenbone Networks GmbH
+ *
+ * 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.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+import React from 'react';
+
+import _ from '../../locale.js';
+import {is_defined, is_empty} from '../../utils.js';
+
+import Layout from '../layout.js';
+import PropTypes from '../proptypes.js';
+
+import HelpIcon from '../icons/helpicon.js';
+import NewIcon from '../icons/newicon.js';
+
+import EntitiesPage from '../entities/page.js';
+import {withEntitiesContainer} from '../entities/container.js';
+
+import TargetsFilterDialog from './filterdialog.js';
+import TargetsTable from './table.js';
+import TargetDialogContainer from './dialogcontainer.js';
+
+import {TARGETS_FILTER_FILTER} from '../../gmp/models/filter.js';
+
+const ToolBarIcons = ({onNewTargetClick}) => {
+  return (
+    <Layout flex box>
+      <HelpIcon page="targets"/>
+      <NewIcon
+        title={_('New Target')}
+        onClick={onNewTargetClick}/>
+    </Layout>
+  );
+};
+
+ToolBarIcons.propTypes = {
+  onNewTargetClick: React.PropTypes.func,
+};
+
+const id_or__ = value => {
+  return is_defined(value) && !is_empty(value.id) ? value.id : 0;
+};
+
+class TargetsPage extends React.Component {
+
+  constructor(...args) {
+    super(...args);
+
+    this.openTargetDialog = this.openTargetDialog.bind(this);
+  }
+
+  openTargetDialog(entity) {
+    if (entity && entity.id) {
+      this.target_dialog.show({
+        id: entity.id,
+        alive_tests: entity.alive_tests,
+        comment: entity.comment,
+        esxi_credential_id: id_or__(entity.esxi_credential),
+        exclude_hosts: entity.exclude_hosts,
+        hosts: entity.hosts,
+        in_use: entity.isInUse(),
+        name: entity.name,
+        port_list_id: id_or__(entity.port_list),
+        port: is_empty(entity.ssh_credential.id) ?
+          '22' : entity.ssh_credential.port,
+        reverse_lookup_only: entity.reverse_lookup_only,
+        reverse_lookup_unify: entity.reverse_lookup_unify,
+        smb_credential_id: id_or__(entity.smb_credential),
+        snmp_credential_id: id_or__(entity.snmp_credential),
+        ssh_credential_id: id_or__(entity.ssh_credential),
+        target_source: 'manual',
+      }, {
+        title: _('Edit Target {{name}}', entity),
+      });
+    }
+    else {
+      this.target_dialog.show({});
+    }
+  }
+
+  render() {
+    const {onChanged} = this.props;
+    return (
+      <Layout>
+        <EntitiesPage
+          {...this.props}
+          onEditTarget={this.openTargetDialog}
+          onNewTargetClick={this.openTargetDialog}/>
+        <TargetDialogContainer
+          ref={ref => this.target_dialog = ref}
+          onSave={onChanged}/>
+      </Layout>
+    );
+  };
+}
+
+TargetsPage.propTypes = {
+  entityCommand: PropTypes.entitycommand,
+  onChanged: React.PropTypes.func,
+};
+
+export default withEntitiesContainer(TargetsPage, 'target', {
+  filterEditDialog: TargetsFilterDialog,
+  filtersFilter: TARGETS_FILTER_FILTER,
+  sectionIcon: 'target.svg',
+  table: TargetsTable,
+  title: _('Targets'),
+  toolBarIcons: ToolBarIcons,
+});
+
+// vim: set ts=2 sw=2 tw=80:

_______________________________________________
Openvas-commits mailing list
Openvas-commits@wald.intevation.org
https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-commits

Reply via email to