"@types/react-dnd": "3.0.2",
"@types/react-dropzone": "4.2.2",
"@types/react-highlight-words": "0.12.0",
- "@types/redux-form": "7.4.5",
+ "@types/redux-form": "7.4.12",
"@types/reselect": "2.2.0",
"@types/shell-quote": "1.6.0",
"axios": "0.18.0",
//
// SPDX-License-Identifier: AGPL-3.0
+import { PropertyValue } from "~/models/search-bar";
+
export const formatDate = (isoDate?: string) => {
if (isoDate) {
const date = new Date(isoDate);
unit: "B"
}
];
+
+export const formatPropertyValue = (pv: PropertyValue) => {
+ if (pv.key) {
+ return pv.value
+ ? `${pv.key}: ${pv.value}`
+ : pv.key;
+ }
+ return "";
+};
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+import * as _ from "lodash";
+
+export function getModifiedKeys(a: any, b: any) {
+ const keys = _.union(_.keys(a), _.keys(b));
+ return _.filter(keys, key => a[key] !== b[key]);
+}
+
+export function getModifiedKeysValues(a: any, b: any) {
+ const keys = getModifiedKeys(a, b);
+ const obj = {};
+ keys.forEach(k => {
+ obj[k] = a[k];
+ });
+ return obj;
+}
// SPDX-License-Identifier: AGPL-3.0
import * as React from 'react';
-import { Input as MuiInput, Chip as MuiChip, Popper as MuiPopper, Paper, FormControl, InputLabel, StyleRulesCallback, withStyles, RootRef, ListItemText, ListItem, List, FormHelperText } from '@material-ui/core';
+import { Input as MuiInput, Chip as MuiChip, Popper as MuiPopper, Paper as MuiPaper, FormControl, InputLabel, StyleRulesCallback, withStyles, RootRef, ListItemText, ListItem, List, FormHelperText } from '@material-ui/core';
import { PopperProps } from '@material-ui/core/Popper';
import { WithStyles } from '@material-ui/core/styles';
import { noop } from 'lodash';
export interface AutocompleteState {
suggestionsOpen: boolean;
+ selectedSuggestionIndex: number;
}
export class Autocomplete<Value, Suggestion> extends React.Component<AutocompleteProps<Value, Suggestion>, AutocompleteState> {
state = {
suggestionsOpen: false,
+ selectedSuggestionIndex: 0,
};
containerRef = React.createRef<HTMLDivElement>();
onBlur={this.handleBlur}
onChange={this.props.onChange}
onKeyPress={this.handleKeyPress}
+ onKeyDown={this.handleNavigationKeyPress}
/>;
}
- renderHelperText(){
+ renderHelperText() {
return <FormHelperText>{this.props.helperText}</FormHelperText>;
}
const { suggestions = [] } = this.props;
return (
<Popper
- open={this.state.suggestionsOpen && suggestions.length > 0}
- anchorEl={this.inputRef.current}>
+ open={this.isSuggestionBoxOpen()}
+ anchorEl={this.inputRef.current}
+ key={suggestions.length}>
<Paper onMouseDown={this.preventBlur}>
<List dense style={{ width: this.getSuggestionsWidth() }}>
{suggestions.map(
(suggestion, index) =>
- <ListItem button key={index} onClick={this.handleSelect(suggestion)}>
+ <ListItem
+ button
+ key={index}
+ onClick={this.handleSelect(suggestion)}
+ selected={index === this.state.selectedSuggestionIndex}>
{this.renderSuggestion(suggestion)}
</ListItem>
)}
);
}
+ isSuggestionBoxOpen() {
+ const { suggestions = [] } = this.props;
+ return this.state.suggestionsOpen && suggestions.length > 0;
+ }
+
handleFocus = (event: React.FocusEvent<HTMLInputElement>) => {
const { onFocus = noop } = this.props;
this.setState({ suggestionsOpen: true });
});
}
- handleKeyPress = ({ key }: React.KeyboardEvent<HTMLInputElement>) => {
- const { onCreate = noop } = this.props;
- if (key === 'Enter' && this.props.value.length > 0) {
- onCreate();
+ handleKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
+ const { onCreate = noop, onSelect = noop, suggestions = [] } = this.props;
+ const { selectedSuggestionIndex } = this.state;
+ if (event.key === 'Enter') {
+ if (this.isSuggestionBoxOpen() && selectedSuggestionIndex < suggestions.length) {
+ // prevent form submissions when selecting a suggestion
+ event.preventDefault();
+ onSelect(suggestions[selectedSuggestionIndex]);
+ } else if (this.props.value.length > 0) {
+ onCreate();
+ }
+ }
+ }
+
+ handleNavigationKeyPress = ({ key }: React.KeyboardEvent<HTMLInputElement>) => {
+ if (key === 'ArrowUp') {
+ this.updateSelectedSuggestionIndex(-1);
+ } else if (key === 'ArrowDown') {
+ this.updateSelectedSuggestionIndex(1);
}
}
+ updateSelectedSuggestionIndex(value: -1 | 1) {
+ const { suggestions = [] } = this.props;
+ this.setState(({ selectedSuggestionIndex }) => ({
+ selectedSuggestionIndex: (selectedSuggestionIndex + value) % suggestions.length
+ }));
+ }
+
renderChips() {
const { items, onDelete } = this.props;
return items.map(
});
const Input = withStyles(inputStyles)(MuiInput);
+
+const Paper = withStyles({
+ root: {
+ maxHeight: '80vh',
+ overflowY: 'auto',
+ }
+})(MuiPaper);
type TextFieldProps = WrappedFieldProps & WithStyles<CssRules>;
export const TextField = withStyles(styles)((props: TextFieldProps & {
- label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, children: React.ReactNode
+ label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, disabled?: boolean, children: React.ReactNode
}) =>
<MaterialTextField
helperText={props.meta.touched && props.meta.error}
className={props.classes.textField}
label={props.label}
- disabled={props.meta.submitting}
+ disabled={props.disabled || props.meta.submitting}
error={props.meta.touched && !!props.meta.error}
autoComplete='off'
autoFocus={props.autoFocus}
import { loadVocabulary } from '~/store/vocabulary/vocabulary-actions';
import { virtualMachineActionSet } from '~/views-components/context-menu/action-sets/virtual-machine-action-set';
import { userActionSet } from '~/views-components/context-menu/action-sets/user-action-set';
+import { computeNodeActionSet } from '~/views-components/context-menu/action-sets/compute-node-action-set';
console.log(`Starting arvados [${getBuildInfo()}]`);
addMenuActionSet(ContextMenuKind.VIRTUAL_MACHINE, virtualMachineActionSet);
addMenuActionSet(ContextMenuKind.KEEP_SERVICE, keepServiceActionSet);
addMenuActionSet(ContextMenuKind.USER, userActionSet);
+addMenuActionSet(ContextMenuKind.NODE, computeNodeActionSet);
fetchConfig()
.then(({ config, apiHost }) => {
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Resource } from '~/models/resource';
+
+export interface NodeResource extends Resource {
+ slotNumber: number;
+ hostname: string;
+ domain: string;
+ ipAddress: string;
+ jobUuid: string;
+ firstPingAt: string;
+ lastPingAt: string;
+ status: string;
+ info: NodeInfo;
+ properties: NodeProperties;
+}
+
+export interface NodeInfo {
+ lastAction: string;
+ pingSecret: string;
+ ec2InstanceId: string;
+ slurmState?: string;
+}
+
+export interface NodeProperties {
+ cloudNode: CloudNode;
+ totalRamMb: number;
+ totalCpuCores: number;
+ totalScratchMb: number;
+}
+
+interface CloudNode {
+ size: string;
+ price: number;
+}
\ No newline at end of file
CONTAINER_REQUEST = "arvados#containerRequest",
GROUP = "arvados#group",
LOG = "arvados#log",
+ NODE = "arvados#node",
PROCESS = "arvados#containerRequest",
PROJECT = "arvados#group",
REPOSITORY = "arvados#repository",
VIRTUAL_MACHINE = '2x53u',
WORKFLOW = '7fd4e',
SSH_KEY = 'fngyi',
- KEEP_SERVICE = 'bi6l4'
+ KEEP_SERVICE = 'bi6l4',
+ NODE = '7ekkf'
}
export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
return ResourceKind.SSH_KEY;
case ResourceObjectType.KEEP_SERVICE:
return ResourceKind.KEEP_SERVICE;
+ case ResourceObjectType.NODE:
+ return ResourceKind.NODE;
default:
return undefined;
}
dateFrom: string;
dateTo: string;
saveQuery: boolean;
- searchQuery: string;
- properties: PropertyValues[];
-} & PropertyValues;
+ queryName: string;
+ searchValue: string;
+ properties: PropertyValue[];
+};
-export interface PropertyValues {
+export interface PropertyValue {
key: string;
value: string;
}
INDIANAPOLIS = "indianapolis",
KAISERAUGST = "kaiseraugst",
PENZBERG = "penzberg"
-}
\ No newline at end of file
+}
import { Resource, ResourceKind } from '~/models/resource';
+export type UserPrefs = {
+ profile?: {
+ organization?: string,
+ organization_email?: string,
+ lab?: string,
+ website_url?: string,
+ role?: string
+ }
+};
+
export interface User {
email: string;
firstName: string;
lastName: string;
uuid: string;
ownerUuid: string;
+ identityUrl: string;
+ prefs: UserPrefs;
isAdmin: boolean;
}
defaultOwnerUuid: string;
isActive: boolean;
writableBy: string[];
-}
-
-export interface UserPrefs {
- profile: {
- lab: string;
- organization: string;
- organizationEmail: string;
- role: string;
- websiteUrl: string;
- };
}
\ No newline at end of file
import { History, Location } from 'history';
import { RootStore } from '~/store/store';
-import {
- matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute,
- matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute,
- matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute, matchVirtualMachineRoute,
- matchKeepServicesRoute, matchUsersRoute
-} from './routes';
-import {
- loadSharedWithMe, loadRunProcess, loadWorkflow, loadSearchResults,
- loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog,
- loadSshKeys, loadRepositories, loadVirtualMachines, loadKeepServices, loadUsers
-} from '~/store/workbench/workbench-actions';
+import * as Routes from '~/routes/routes';
+import * as WorkbenchActions from '~/store/workbench/workbench-actions';
import { navigateToRootProject } from '~/store/navigation/navigation-action';
export const addRouteChangeHandlers = (history: History, store: RootStore) => {
};
const handleLocationChange = (store: RootStore) => ({ pathname }: Location) => {
- const rootMatch = matchRootRoute(pathname);
- const projectMatch = matchProjectRoute(pathname);
- const collectionMatch = matchCollectionRoute(pathname);
- const favoriteMatch = matchFavoritesRoute(pathname);
- const trashMatch = matchTrashRoute(pathname);
- const processMatch = matchProcessRoute(pathname);
- const processLogMatch = matchProcessLogRoute(pathname);
- const repositoryMatch = matchRepositoriesRoute(pathname);
- const searchResultsMatch = matchSearchResultsRoute(pathname);
- const sharedWithMeMatch = matchSharedWithMeRoute(pathname);
- const runProcessMatch = matchRunProcessRoute(pathname);
- const virtualMachineMatch = matchVirtualMachineRoute(pathname);
- const workflowMatch = matchWorkflowRoute(pathname);
- const sshKeysMatch = matchSshKeysRoute(pathname);
- const keepServicesMatch = matchKeepServicesRoute(pathname);
- const userMatch = matchUsersRoute(pathname);
+ const rootMatch = Routes.matchRootRoute(pathname);
+ const projectMatch = Routes.matchProjectRoute(pathname);
+ const collectionMatch = Routes.matchCollectionRoute(pathname);
+ const favoriteMatch = Routes.matchFavoritesRoute(pathname);
+ const trashMatch = Routes.matchTrashRoute(pathname);
+ const processMatch = Routes.matchProcessRoute(pathname);
+ const processLogMatch = Routes.matchProcessLogRoute(pathname);
+ const repositoryMatch = Routes.matchRepositoriesRoute(pathname);
+ const searchResultsMatch = Routes.matchSearchResultsRoute(pathname);
+ const sharedWithMeMatch = Routes.matchSharedWithMeRoute(pathname);
+ const runProcessMatch = Routes.matchRunProcessRoute(pathname);
+ const virtualMachineMatch = Routes.matchVirtualMachineRoute(pathname);
+ const workflowMatch = Routes.matchWorkflowRoute(pathname);
+ const sshKeysMatch = Routes.matchSshKeysRoute(pathname);
+ const keepServicesMatch = Routes.matchKeepServicesRoute(pathname);
+ const computeNodesMatch = Routes.matchComputeNodesRoute(pathname);
+ const myAccountMatch = Routes.matchMyAccountRoute(pathname);
+ const userMatch = Routes.matchUsersRoute(pathname);
if (projectMatch) {
- store.dispatch(loadProject(projectMatch.params.id));
+ store.dispatch(WorkbenchActions.loadProject(projectMatch.params.id));
} else if (collectionMatch) {
- store.dispatch(loadCollection(collectionMatch.params.id));
+ store.dispatch(WorkbenchActions.loadCollection(collectionMatch.params.id));
} else if (favoriteMatch) {
- store.dispatch(loadFavorites());
+ store.dispatch(WorkbenchActions.loadFavorites());
} else if (trashMatch) {
- store.dispatch(loadTrash());
+ store.dispatch(WorkbenchActions.loadTrash());
} else if (processMatch) {
- store.dispatch(loadProcess(processMatch.params.id));
+ store.dispatch(WorkbenchActions.loadProcess(processMatch.params.id));
} else if (processLogMatch) {
- store.dispatch(loadProcessLog(processLogMatch.params.id));
+ store.dispatch(WorkbenchActions.loadProcessLog(processLogMatch.params.id));
} else if (rootMatch) {
store.dispatch(navigateToRootProject);
} else if (sharedWithMeMatch) {
- store.dispatch(loadSharedWithMe);
+ store.dispatch(WorkbenchActions.loadSharedWithMe);
} else if (runProcessMatch) {
- store.dispatch(loadRunProcess);
+ store.dispatch(WorkbenchActions.loadRunProcess);
} else if (workflowMatch) {
- store.dispatch(loadWorkflow);
+ store.dispatch(WorkbenchActions.loadWorkflow);
} else if (searchResultsMatch) {
- store.dispatch(loadSearchResults);
+ store.dispatch(WorkbenchActions.loadSearchResults);
} else if (virtualMachineMatch) {
- store.dispatch(loadVirtualMachines);
+ store.dispatch(WorkbenchActions.loadVirtualMachines);
} else if(repositoryMatch) {
- store.dispatch(loadRepositories);
+ store.dispatch(WorkbenchActions.loadRepositories);
} else if (sshKeysMatch) {
- store.dispatch(loadSshKeys);
+ store.dispatch(WorkbenchActions.loadSshKeys);
} else if (keepServicesMatch) {
- store.dispatch(loadKeepServices);
- } else if (userMatch) {
- store.dispatch(loadUsers);
+ store.dispatch(WorkbenchActions.loadKeepServices);
+ } else if (computeNodesMatch) {
+ store.dispatch(WorkbenchActions.loadComputeNodes);
+ } else if (myAccountMatch) {
+ store.dispatch(WorkbenchActions.loadMyAccount);
+ }else if (userMatch) {
+ store.dispatch(WorkbenchActions.loadUsers);
}
};
WORKFLOWS: '/workflows',
SEARCH_RESULTS: '/search-results',
SSH_KEYS: `/ssh-keys`,
+ MY_ACCOUNT: '/my-account',
KEEP_SERVICES: `/keep-services`,
+ COMPUTE_NODES: `/nodes`,
USERS: '/users'
};
export const matchSshKeysRoute = (route: string) =>
matchPath(route, { path: Routes.SSH_KEYS });
+export const matchMyAccountRoute = (route: string) =>
+ matchPath(route, { path: Routes.MY_ACCOUNT });
+
export const matchKeepServicesRoute = (route: string) =>
matchPath(route, { path: Routes.KEEP_SERVICES });
export const matchUsersRoute = (route: string) =>
matchPath(route, { path: Routes.USERS });
+
+export const matchComputeNodesRoute = (route: string) =>
+ matchPath(route, { path: Routes.COMPUTE_NODES });
return this.addCondition(field, "<=", value, "", "", resourcePrefix);
}
+ public addExists(value?: string, resourcePrefix?: string) {
+ return this.addCondition("properties", "exists", value, "", "", resourcePrefix);
+ }
+
public getFilters() {
return this.filters;
}
? resourcePrefix + "."
: "";
- this.filters += `${this.filters ? "," : ""}["${resPrefix}${_.snakeCase(field)}","${cond}",${value}]`;
+ const fld = field.indexOf('properties.') < 0 ? _.snakeCase(field) : field;
+
+ this.filters += `${this.filters ? "," : ""}["${resPrefix}${fld}","${cond}",${value}]`;
}
return this;
}
//
// SPDX-License-Identifier: AGPL-3.0
-import { User } from "~/models/user";
+import { User, UserPrefs } from "~/models/user";
import { AxiosInstance } from "axios";
import { ApiActions } from "~/services/api/api-actions";
import * as uuid from "uuid/v4";
export const USER_UUID_KEY = 'userUuid';
export const USER_OWNER_UUID_KEY = 'userOwnerUuid';
export const USER_IS_ADMIN = 'isAdmin';
+export const USER_IDENTITY_URL = 'identityUrl';
+export const USER_PREFS = 'prefs';
export interface UserDetailsResponse {
email: string;
uuid: string;
owner_uuid: string;
is_admin: boolean;
+ identity_url: string;
+ prefs: UserPrefs;
}
export class AuthService {
const lastName = localStorage.getItem(USER_LAST_NAME_KEY);
const uuid = this.getUuid();
const ownerUuid = this.getOwnerUuid();
- const isAdmin = this.getIsAdmin();
+ const isAdmin = this.getIsAdmin();
+ const identityUrl = localStorage.getItem(USER_IDENTITY_URL);
+ const prefs = JSON.parse(localStorage.getItem(USER_PREFS) || '{"profile": {}}');
- return email && firstName && lastName && uuid && ownerUuid
- ? { email, firstName, lastName, uuid, ownerUuid, isAdmin }
+ return email && firstName && lastName && uuid && ownerUuid && identityUrl && prefs
+ ? { email, firstName, lastName, uuid, ownerUuid, isAdmin, identityUrl, prefs }
: undefined;
}
localStorage.setItem(USER_UUID_KEY, user.uuid);
localStorage.setItem(USER_OWNER_UUID_KEY, user.ownerUuid);
localStorage.setItem(USER_IS_ADMIN, JSON.stringify(user.isAdmin));
+ localStorage.setItem(USER_IDENTITY_URL, user.identityUrl);
+ localStorage.setItem(USER_PREFS, JSON.stringify(user.prefs));
}
public removeUser() {
localStorage.removeItem(USER_UUID_KEY);
localStorage.removeItem(USER_OWNER_UUID_KEY);
localStorage.removeItem(USER_IS_ADMIN);
+ localStorage.removeItem(USER_IDENTITY_URL);
+ localStorage.removeItem(USER_PREFS);
}
public login() {
.get<UserDetailsResponse>('/users/current')
.then(resp => {
this.actions.progressFn(reqId, false);
+ const prefs = resp.data.prefs.profile ? resp.data.prefs : { profile: {}};
return {
email: resp.data.email,
firstName: resp.data.first_name,
lastName: resp.data.last_name,
uuid: resp.data.uuid,
ownerUuid: resp.data.owner_uuid,
- isAdmin: resp.data.is_admin
+ isAdmin: resp.data.is_admin,
+ identityUrl: resp.data.identity_url,
+ prefs
};
})
.catch(e => {
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { AxiosInstance } from "axios";
+import { CommonResourceService } from "~/services/common-service/common-resource-service";
+import { NodeResource } from '~/models/node';
+import { ApiActions } from '~/services/api/api-actions';
+
+export class NodeService extends CommonResourceService<NodeResource> {
+ constructor(serverApi: AxiosInstance, actions: ApiActions) {
+ super(serverApi, "nodes", actions);
+ }
+}
\ No newline at end of file
}
editSavedQueries(data: SearchBarAdvanceFormData) {
- const itemIndex = this.savedQueries.findIndex(item => item.searchQuery === data.searchQuery);
+ const itemIndex = this.savedQueries.findIndex(item => item.queryName === data.queryName);
this.savedQueries[itemIndex] = {...data};
localStorage.setItem('savedQueries', JSON.stringify(this.savedQueries));
}
import { RepositoriesService } from '~/services/repositories-service/repositories-service';
import { AuthorizedKeysService } from '~/services/authorized-keys-service/authorized-keys-service';
import { VocabularyService } from '~/services/vocabulary-service/vocabulary-service';
+import { NodeService } from '~/services/node-service/node-service';
export type ServiceRepository = ReturnType<typeof createServices>;
const keepService = new KeepService(apiClient, actions);
const linkService = new LinkService(apiClient, actions);
const logService = new LogService(apiClient, actions);
+ const nodeService = new NodeService(apiClient, actions);
const permissionService = new PermissionService(apiClient, actions);
const projectService = new ProjectService(apiClient, actions);
const repositoriesService = new RepositoriesService(apiClient, actions);
keepService,
linkService,
logService,
+ nodeService,
permissionService,
projectService,
repositoriesService,
import { ListResults } from '~/services/common-service/common-resource-service';
import { LinkResource } from '~/models/link';
import { KeepServiceResource } from '~/models/keep-services';
+import { NodeResource } from '~/models/node';
export const ADVANCED_TAB_DIALOG = 'advancedTabDialog';
AUTORIZED_KEYS = 'authorized_keys',
VIRTUAL_MACHINES = 'virtual_machines',
KEEP_SERVICES = 'keep_services',
- USERS = 'users'
+ USERS = 'users',
+ COMPUTE_NODES = 'nodes'
}
enum KeepServiceData {
USERNAME = 'username'
}
-type AdvanceResourceKind = CollectionData | ProcessData | ProjectData | RepositoryData | SshKeyData | VirtualMachineData | KeepServiceData | UserData;
+enum ComputeNodeData {
+ COMPUTE_NODE = 'node',
+ PROPERTIES = 'properties'
+}
+
+type AdvanceResourceKind = CollectionData | ProcessData | ProjectData | RepositoryData | SshKeyData | VirtualMachineData | KeepServiceData | ComputeNodeData | UserData;
type AdvanceResourcePrefix = GroupContentsResourcePrefix | ResourcePrefix;
-type AdvanceResponseData = ContainerRequestResource | ProjectResource | CollectionResource | RepositoryResource | SshKeyResource | VirtualMachinesResource | KeepServiceResource | UserResource | undefined;
+type AdvanceResponseData = ContainerRequestResource | ProjectResource | CollectionResource | RepositoryResource | SshKeyResource | VirtualMachinesResource | KeepServiceResource | NodeResource | UserResource | undefined;
export const openAdvancedTabDialog = (uuid: string) =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
});
dispatch<any>(initAdvancedTabDialog(advanceDataUser));
break;
+ case ResourceKind.NODE:
+ const dataComputeNode = getState().computeNodes.find(node => node.uuid === uuid);
+ const advanceDataComputeNode = advancedTabData({
+ uuid,
+ metadata: '',
+ user: '',
+ apiResponseKind: computeNodeApiResponse,
+ data: dataComputeNode,
+ resourceKind: ComputeNodeData.COMPUTE_NODE,
+ resourcePrefix: ResourcePrefix.COMPUTE_NODES,
+ resourceKindProperty: ComputeNodeData.PROPERTIES,
+ property: dataComputeNode!.properties
+ });
+ dispatch<any>(initAdvancedTabDialog(advanceDataComputeNode));
+ break;
default:
dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Could not open advanced tab for this resource.", hideDuration: 2000, kind: SnackbarKind.ERROR }));
}
const cliUpdateExample = (uuid: string, resourceKind: string, resource: string | string[], resourceName: string) => {
const CLIUpdateCollectionExample = `arv ${resourceKind} update \\
--uuid ${uuid} \\
- --${resourceKind} '{"${resourceName}":${resource}}'`;
+ --${resourceKind} '{"${resourceName}":${JSON.stringify(resource)}}'`;
return CLIUpdateCollectionExample;
};
https://$ARVADOS_API_HOST/arvados/v1/${resourcePrefix}/${uuid} \\
<<EOF
{
- "${resourceName}": ${resource}
+ "${resourceName}": ${JSON.stringify(resource, null, 4)}
}
EOF`;
"default_owner_uuid": "${defaultOwnerUuid},
"username": "${username}"`;
+ return response;
+};
+
+const computeNodeApiResponse = (apiResponse: NodeResource) => {
+ const {
+ uuid, slotNumber, hostname, domain, ipAddress, firstPingAt, lastPingAt, jobUuid,
+ ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid,
+ properties, info
+ } = apiResponse;
+ const response = `"uuid": "${uuid}",
+"owner_uuid": "${ownerUuid}",
+"modified_by_client_uuid": ${stringify(modifiedByClientUuid)},
+"modified_by_user_uuid": ${stringify(modifiedByUserUuid)},
+"modified_at": ${stringify(modifiedAt)},
+"created_at": "${createdAt}",
+"slot_number": "${stringify(slotNumber)}",
+"hostname": "${stringify(hostname)}",
+"domain": "${stringify(domain)}",
+"ip_address": "${stringify(ipAddress)}",
+"first_ping_at": "${stringify(firstPingAt)}",
+"last_ping_at": "${stringify(lastPingAt)}",
+"job_uuid": "${stringify(jobUuid)}",
+"properties": "${JSON.stringify(properties, null, 4)}",
+"info": "${JSON.stringify(info, null, 4)}"`;
+
return response;
};
\ No newline at end of file
import { ofType, unionize, UnionOf } from '~/common/unionize';
import { Dispatch } from "redux";
-import { reset, stopSubmit, startSubmit } from 'redux-form';
+import { reset, stopSubmit, startSubmit, FormErrors } from 'redux-form';
import { AxiosInstance } from "axios";
import { RootState } from "../store";
import { snackbarActions } from '~/store/snackbar/snackbar-actions';
} catch (e) {
const error = getAuthorizedKeysServiceError(e);
if (error === AuthorizedKeysServiceError.UNIQUE_PUBLIC_KEY) {
- dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' }));
+ dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key already exists.' } as FormErrors));
} else if (error === AuthorizedKeysServiceError.INVALID_PUBLIC_KEY) {
- dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' }));
+ dispatch(stopSubmit(SSH_KEY_CREATE_FORM_NAME, { publicKey: 'Public key is invalid' } as FormErrors));
}
}
};
}
};
-
export type AuthAction = UnionOf<typeof authActions>;
lastName: "Doe",
uuid: "uuid",
ownerUuid: "ownerUuid",
+ identityUrl: "identityUrl",
+ prefs: {},
isAdmin: false
};
const state = reducer(initialState, authActions.INIT({ user, token: "token" }));
lastName: "Doe",
uuid: "uuid",
ownerUuid: "ownerUuid",
+ identityUrl: "identityUrl",
+ prefs: {},
isAdmin: false
};
import { dialogActions } from '../../dialog/dialog-actions';
import { getNodeValue } from "~/models/tree";
import { filterCollectionFilesBySelection } from './collection-panel-files-state';
-import { startSubmit, stopSubmit, reset, initialize } from 'redux-form';
+import { startSubmit, stopSubmit, reset, initialize, FormErrors } from 'redux-form';
import { getDialog } from "~/store/dialog/dialog-reducer";
import { getFileFullPath } from "~/services/collection-service/collection-service-files-response";
import { resourcesDataActions } from "~/store/resources-data/resources-data-actions";
dispatch(dialogActions.CLOSE_DIALOG({ id: RENAME_FILE_DIALOG }));
dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'File name changed.', hideDuration: 2000 }));
} catch (e) {
- dispatch(stopSubmit(RENAME_FILE_DIALOG, { name: 'Could not rename the file' }));
+ const errors: FormErrors<RenameFileDialogData, string> = {
+ name: 'Could not rename the file'
+ };
+ dispatch(stopSubmit(RENAME_FILE_DIALOG, errors));
}
}
}
import { Dispatch } from "redux";
import { dialogActions } from "~/store/dialog/dialog-actions";
-import { initialize, startSubmit, stopSubmit } from 'redux-form';
+import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form';
import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree-picker-actions';
import { RootState } from '~/store/store';
import { ServiceRepository } from '~/services/services';
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(COLLECTION_COPY_FORM_NAME, { ownerUuid: 'A collection with the same name already exists in the target project.' }));
+ dispatch(stopSubmit(
+ COLLECTION_COPY_FORM_NAME,
+ { ownerUuid: 'A collection with the same name already exists in the target project.' } as FormErrors
+ ));
} else {
dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_COPY_FORM_NAME }));
throw new Error('Could not copy the collection.');
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { reset, startSubmit, stopSubmit, initialize } from 'redux-form';
+import { reset, startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
import { RootState } from '~/store/store';
import { dialogActions } from "~/store/dialog/dialog-actions";
import { ServiceRepository } from '~/services/services';
export const createCollection = (data: CollectionCreateFormDialogData) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
dispatch(startSubmit(COLLECTION_CREATE_FORM_NAME));
- let newCollection: CollectionResource | null = null;
+ let newCollection: CollectionResource;
try {
dispatch(progressIndicatorActions.START_WORKING(COLLECTION_CREATE_FORM_NAME));
newCollection = await services.collectionService.create(data);
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME, { name: 'Collection with the same name already exists.' }));
+ dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME, { name: 'Collection with the same name already exists.' } as FormErrors));
} else if (error === CommonResourceServiceError.NONE) {
dispatch(stopSubmit(COLLECTION_CREATE_FORM_NAME));
dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_CREATE_FORM_NAME }));
import { Dispatch } from "redux";
import { dialogActions } from "~/store/dialog/dialog-actions";
-import { startSubmit, stopSubmit, initialize } from 'redux-form';
+import { startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
import { ServiceRepository } from '~/services/services';
import { RootState } from '~/store/store';
import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(COLLECTION_MOVE_FORM_NAME, { ownerUuid: 'A collection with the same name already exists in the target project.' }));
+ dispatch(stopSubmit(COLLECTION_MOVE_FORM_NAME, { ownerUuid: 'A collection with the same name already exists in the target project.' } as FormErrors));
} else {
dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_MOVE_FORM_NAME }));
dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move the collection.', hideDuration: 2000 }));
import { Dispatch } from 'redux';
import { RootState } from '~/store/store';
-import { initialize, startSubmit, stopSubmit } from 'redux-form';
+import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form';
import { resetPickerProjectTree } from '~/store/project-tree-picker/project-tree-picker-actions';
import { dialogActions } from '~/store/dialog/dialog-actions';
import { ServiceRepository } from '~/services/services';
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(COLLECTION_PARTIAL_COPY_FORM_NAME, { name: 'Collection with this name already exists.' }));
+ dispatch(stopSubmit(COLLECTION_PARTIAL_COPY_FORM_NAME, { name: 'Collection with this name already exists.' } as FormErrors));
} else if (error === CommonResourceServiceError.UNKNOWN) {
dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_PARTIAL_COPY_FORM_NAME }));
dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not create a copy of collection', hideDuration: 2000 }));
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { initialize, startSubmit, stopSubmit } from 'redux-form';
+import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form';
import { RootState } from "~/store/store";
import { collectionPanelActions } from "~/store/collection-panel/collection-panel-action";
import { dialogActions } from "~/store/dialog/dialog-actions";
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(COLLECTION_UPDATE_FORM_NAME, { name: 'Collection with the same name already exists.' }));
+ dispatch(stopSubmit(COLLECTION_UPDATE_FORM_NAME, { name: 'Collection with the same name already exists.' } as FormErrors));
}
dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_UPDATE_FORM_NAME));
return;
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from "redux";
+import { unionize, ofType, UnionOf } from "~/common/unionize";
+import { RootState } from '~/store/store';
+import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
+import { ServiceRepository } from "~/services/services";
+import { NodeResource } from '~/models/node';
+import { dialogActions } from '~/store/dialog/dialog-actions';
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { navigateToRootProject } from '~/store/navigation/navigation-action';
+
+export const computeNodesActions = unionize({
+ SET_COMPUTE_NODES: ofType<NodeResource[]>(),
+ REMOVE_COMPUTE_NODE: ofType<string>()
+});
+
+export type ComputeNodesActions = UnionOf<typeof computeNodesActions>;
+
+export const COMPUTE_NODE_REMOVE_DIALOG = 'computeNodeRemoveDialog';
+export const COMPUTE_NODE_ATTRIBUTES_DIALOG = 'computeNodeAttributesDialog';
+
+export const loadComputeNodesPanel = () =>
+ async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ const user = getState().auth.user;
+ if (user && user.isAdmin) {
+ try {
+ dispatch(setBreadcrumbs([{ label: 'Compute Nodes' }]));
+ const response = await services.nodeService.list();
+ dispatch(computeNodesActions.SET_COMPUTE_NODES(response.items));
+ } catch (e) {
+ return;
+ }
+ } else {
+ dispatch(navigateToRootProject);
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: "You don't have permissions to view this page", hideDuration: 2000 }));
+ }
+ };
+
+export const openComputeNodeAttributesDialog = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ const computeNode = getState().computeNodes.find(node => node.uuid === uuid);
+ dispatch(dialogActions.OPEN_DIALOG({ id: COMPUTE_NODE_ATTRIBUTES_DIALOG, data: { computeNode } }));
+ };
+
+export const openComputeNodeRemoveDialog = (uuid: string) =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ dispatch(dialogActions.OPEN_DIALOG({
+ id: COMPUTE_NODE_REMOVE_DIALOG,
+ data: {
+ title: 'Remove compute node',
+ text: 'Are you sure you want to remove this compute node?',
+ confirmButtonLabel: 'Remove',
+ uuid
+ }
+ }));
+ };
+
+export const removeComputeNode = (uuid: string) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Removing ...' }));
+ try {
+ await services.nodeService.delete(uuid);
+ dispatch(computeNodesActions.REMOVE_COMPUTE_NODE(uuid));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Compute node has been successfully removed.', hideDuration: 2000 }));
+ } catch (e) {
+ return;
+ }
+ };
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { computeNodesActions, ComputeNodesActions } from '~/store/compute-nodes/compute-nodes-actions';
+import { NodeResource } from '~/models/node';
+
+export type ComputeNodesState = NodeResource[];
+
+const initialState: ComputeNodesState = [];
+
+export const computeNodesReducer = (state: ComputeNodesState = initialState, action: ComputeNodesActions): ComputeNodesState =>
+ computeNodesActions.match(action, {
+ SET_COMPUTE_NODES: nodes => nodes,
+ REMOVE_COMPUTE_NODE: (uuid: string) => state.filter((computeNode) => computeNode.uuid !== uuid),
+ default: () => state
+ });
\ No newline at end of file
import { SshKeyResource } from '~/models/ssh-key';
import { VirtualMachinesResource } from '~/models/virtual-machines';
import { KeepServiceResource } from '~/models/keep-services';
+import { NodeResource } from '~/models/node';
export const contextMenuActions = unionize({
OPEN_CONTEXT_MENU: ofType<{ position: ContextMenuPosition, resource: ContextMenuResource }>(),
}));
};
+export const openComputeNodeContextMenu = (event: React.MouseEvent<HTMLElement>, computeNode: NodeResource) =>
+ (dispatch: Dispatch) => {
+ dispatch<any>(openContextMenu(event, {
+ name: '',
+ uuid: computeNode.uuid,
+ ownerUuid: computeNode.ownerUuid,
+ kind: ResourceKind.NODE,
+ menuKind: ContextMenuKind.NODE
+ }));
+ };
+
export const openRootProjectContextMenu = (event: React.MouseEvent<HTMLElement>, projectUuid: string) =>
(dispatch: Dispatch, getState: () => RootState) => {
const res = getResource<UserResource>(projectUuid)(getState().resources);
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from "redux";
+import { RootState } from "~/store/store";
+import { initialize } from "redux-form";
+import { ServiceRepository } from "~/services/services";
+import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
+import { authActions } from "~/store/auth/auth-action";
+import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
+
+export const MY_ACCOUNT_FORM = 'myAccountForm';
+
+export const loadMyAccountPanel = () =>
+ (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ dispatch(setBreadcrumbs([{ label: 'User profile'}]));
+ };
+
+export const saveEditedUser = (resource: any) =>
+ async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ try {
+ await services.userService.update(resource.uuid, resource);
+ services.authService.saveUser(resource);
+ dispatch(authActions.USER_DETAILS_SUCCESS(resource));
+ dispatch(initialize(MY_ACCOUNT_FORM, resource));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Profile has been updated.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
+ } catch(e) {
+ return;
+ }
+ };
export const navigateToSshKeys= push(Routes.SSH_KEYS);
+export const navigateToMyAccount = push(Routes.MY_ACCOUNT);
+
export const navigateToKeepServices = push(Routes.KEEP_SERVICES);
-export const navigateToUsers = push(Routes.USERS);
\ No newline at end of file
+export const navigateToComputeNodes = push(Routes.COMPUTE_NODES);
+
+export const navigateToUsers = push(Routes.USERS);
import { Dispatch } from "redux";
import { dialogActions } from "~/store/dialog/dialog-actions";
-import { startSubmit, stopSubmit, initialize } from 'redux-form';
+import { startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
import { ServiceRepository } from '~/services/services';
import { RootState } from '~/store/store';
import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(PROCESS_MOVE_FORM_NAME, { ownerUuid: 'A process with the same name already exists in the target project.' }));
+ dispatch(stopSubmit(PROCESS_MOVE_FORM_NAME, { ownerUuid: 'A process with the same name already exists in the target project.' } as FormErrors));
} else {
dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_MOVE_FORM_NAME }));
dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move the process.', hideDuration: 2000 }));
}
return;
}
- };
\ No newline at end of file
+ };
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { initialize, startSubmit, stopSubmit } from 'redux-form';
+import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form';
import { RootState } from "~/store/store";
import { dialogActions } from "~/store/dialog/dialog-actions";
import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(PROCESS_UPDATE_FORM_NAME, { name: 'Process with the same name already exists.' }));
+ dispatch(stopSubmit(PROCESS_UPDATE_FORM_NAME, { name: 'Process with the same name already exists.' } as FormErrors));
} else {
dispatch(dialogActions.CLOSE_DIALOG({ id: PROCESS_UPDATE_FORM_NAME }));
dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not update the process.', hideDuration: 2000 }));
}
return;
}
- };
\ No newline at end of file
+ };
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { reset, startSubmit, stopSubmit, initialize } from 'redux-form';
+import { reset, startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
import { RootState } from '~/store/store';
import { dialogActions } from "~/store/dialog/dialog-actions";
import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
dispatch(initialize(PROJECT_CREATE_FORM_NAME, { userUuid }));
} else {
dispatch(initialize(PROJECT_CREATE_FORM_NAME, { ownerUuid }));
- }
+ }
dispatch(dialogActions.OPEN_DIALOG({ id: PROJECT_CREATE_FORM_NAME, data: {} }));
};
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(PROJECT_CREATE_FORM_NAME, { name: 'Project with the same name already exists.' }));
+ dispatch(stopSubmit(PROJECT_CREATE_FORM_NAME, { name: 'Project with the same name already exists.' } as FormErrors));
}
return undefined;
}
import { Dispatch } from "redux";
import { dialogActions } from "~/store/dialog/dialog-actions";
-import { startSubmit, stopSubmit, initialize } from 'redux-form';
+import { startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
import { ServiceRepository } from '~/services/services';
import { RootState } from '~/store/store';
import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(PROJECT_MOVE_FORM_NAME, { ownerUuid: 'A project with the same name already exists in the target project.' }));
+ dispatch(stopSubmit(PROJECT_MOVE_FORM_NAME, { ownerUuid: 'A project with the same name already exists in the target project.' } as FormErrors));
} else if (error === CommonResourceServiceError.OWNERSHIP_CYCLE) {
- dispatch(stopSubmit(PROJECT_MOVE_FORM_NAME, { ownerUuid: 'Cannot move a project into itself.' }));
+ dispatch(stopSubmit(PROJECT_MOVE_FORM_NAME, { ownerUuid: 'Cannot move a project into itself.' } as FormErrors));
} else {
dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_MOVE_FORM_NAME }));
throw new Error('Could not move the project.');
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { initialize, startSubmit, stopSubmit } from 'redux-form';
+import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form';
import { RootState } from "~/store/store";
import { dialogActions } from "~/store/dialog/dialog-actions";
import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
- dispatch(stopSubmit(PROJECT_UPDATE_FORM_NAME, { name: 'Project with the same name already exists.' }));
+ dispatch(stopSubmit(PROJECT_UPDATE_FORM_NAME, { name: 'Project with the same name already exists.' } as FormErrors));
}
return ;
}
import { unionize, ofType, UnionOf } from "~/common/unionize";
import { dialogActions } from '~/store/dialog/dialog-actions';
import { RepositoryResource } from "~/models/repositories";
-import { startSubmit, reset, stopSubmit } from "redux-form";
+import { startSubmit, reset, stopSubmit, FormErrors } from "redux-form";
import { getCommonResourceServiceError, CommonResourceServiceError } from "~/services/common-service/common-resource-service";
import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
const newRepository = await services.repositoriesService.create({ name: `${user.username}/${repository.name}` });
dispatch(dialogActions.CLOSE_DIALOG({ id: REPOSITORY_CREATE_FORM_NAME }));
dispatch(reset(REPOSITORY_CREATE_FORM_NAME));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Repository has been successfully created.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
- dispatch<any>(loadRepositoriesData());
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Repository has been successfully created.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
+ dispatch<any>(loadRepositoriesData());
return newRepository;
} catch (e) {
const error = getCommonResourceServiceError(e);
if (error === CommonResourceServiceError.NAME_HAS_ALREADY_BEEN_TAKEN) {
- dispatch(stopSubmit(REPOSITORY_CREATE_FORM_NAME, { name: 'Repository with the same name already exists.' }));
+ dispatch(stopSubmit(REPOSITORY_CREATE_FORM_NAME, { name: 'Repository with the same name already exists.' } as FormErrors));
}
return undefined;
}
export const loadRepositoriesPanel = () =>
(dispatch: Dispatch) => {
dispatch(repositoriesBindedActions.REQUEST_ITEMS());
- };
\ No newline at end of file
+ };
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { getAdvancedDataFromQuery, getQueryFromAdvancedData, parseSearchQuery } from "~/store/search-bar/search-bar-actions";
+import { ResourceKind } from "~/models/resource";
+import { ClusterObjectType } from "~/models/search-bar";
+
+describe('search-bar-actions', () => {
+ describe('parseSearchQuery', () => {
+ it('should correctly parse query #1', () => {
+ const q = 'val0 is:trashed val1';
+ const r = parseSearchQuery(q);
+ expect(r.hasKeywords).toBeTruthy();
+ expect(r.values).toEqual(['val0', 'val1']);
+ expect(r.properties).toEqual({
+ is: ['trashed']
+ });
+ });
+
+ it('should correctly parse query #2 (value with keyword should be ignored)', () => {
+ const q = 'val0 is:from:trashed val1';
+ const r = parseSearchQuery(q);
+ expect(r.hasKeywords).toBeTruthy();
+ expect(r.values).toEqual(['val0', 'val1']);
+ expect(r.properties).toEqual({
+ from: ['trashed']
+ });
+ });
+
+ it('should correctly parse query #3 (many keywords)', () => {
+ const q = 'val0 is:trashed val2 from:2017-04-01 val1';
+ const r = parseSearchQuery(q);
+ expect(r.hasKeywords).toBeTruthy();
+ expect(r.values).toEqual(['val0', 'val2', 'val1']);
+ expect(r.properties).toEqual({
+ is: ['trashed'],
+ from: ['2017-04-01']
+ });
+ });
+
+ it('should correctly parse query #4 (no duplicated values)', () => {
+ const q = 'val0 is:trashed val2 val2 val0';
+ const r = parseSearchQuery(q);
+ expect(r.hasKeywords).toBeTruthy();
+ expect(r.values).toEqual(['val0', 'val2']);
+ expect(r.properties).toEqual({
+ is: ['trashed']
+ });
+ });
+
+ it('should correctly parse query #5 (properties)', () => {
+ const q = 'val0 has:filesize:100mb val2 val2 val0';
+ const r = parseSearchQuery(q);
+ expect(r.hasKeywords).toBeTruthy();
+ expect(r.values).toEqual(['val0', 'val2']);
+ expect(r.properties).toEqual({
+ 'has': ['filesize:100mb']
+ });
+ });
+
+ it('should correctly parse query #6 (multiple properties, multiple is)', () => {
+ const q = 'val0 has:filesize:100mb val2 has:user:daniel is:starred val2 val0 is:trashed';
+ const r = parseSearchQuery(q);
+ expect(r.hasKeywords).toBeTruthy();
+ expect(r.values).toEqual(['val0', 'val2']);
+ expect(r.properties).toEqual({
+ 'has': ['filesize:100mb', 'user:daniel'],
+ 'is': ['starred', 'trashed']
+ });
+ });
+ });
+
+ describe('getAdvancedDataFromQuery', () => {
+ it('should correctly build advanced data record from query #1', () => {
+ const r = getAdvancedDataFromQuery('val0 has:filesize:100mb val2 has:user:daniel is:starred val2 val0 is:trashed');
+ expect(r).toEqual({
+ searchValue: 'val0 val2',
+ type: undefined,
+ cluster: undefined,
+ projectUuid: undefined,
+ inTrash: true,
+ dateFrom: undefined,
+ dateTo: undefined,
+ properties: [{
+ key: 'filesize',
+ value: '100mb'
+ }, {
+ key: 'user',
+ value: 'daniel'
+ }],
+ saveQuery: false,
+ queryName: ''
+ });
+ });
+
+ it('should correctly build advanced data record from query #2', () => {
+ const r = getAdvancedDataFromQuery('document from:2017-08-01 pdf has:filesize:101mb is:trashed type:arvados#collection cluster:indianapolis');
+ expect(r).toEqual({
+ searchValue: 'document pdf',
+ type: ResourceKind.COLLECTION,
+ cluster: ClusterObjectType.INDIANAPOLIS,
+ projectUuid: undefined,
+ inTrash: true,
+ dateFrom: '2017-08-01',
+ dateTo: undefined,
+ properties: [{
+ key: 'filesize',
+ value: '101mb'
+ }],
+ saveQuery: false,
+ queryName: ''
+ });
+ });
+ });
+
+ describe('getQueryFromAdvancedData', () => {
+ it('should build query from advanced data', () => {
+ const q = getQueryFromAdvancedData({
+ searchValue: 'document pdf',
+ type: ResourceKind.COLLECTION,
+ cluster: ClusterObjectType.INDIANAPOLIS,
+ projectUuid: undefined,
+ inTrash: true,
+ dateFrom: '2017-08-01',
+ dateTo: '',
+ properties: [{
+ key: 'filesize',
+ value: '101mb'
+ }],
+ saveQuery: false,
+ queryName: ''
+ });
+ expect(q).toBe('document pdf type:arvados#collection cluster:indianapolis is:trashed from:2017-08-01 has:filesize:101mb');
+ });
+ });
+});
//
// SPDX-License-Identifier: AGPL-3.0
-import { unionize, ofType, UnionOf } from "~/common/unionize";
+import { ofType, unionize, UnionOf } from "~/common/unionize";
import { GroupContentsResource, GroupContentsResourcePrefix } from '~/services/groups-service/groups-service';
import { Dispatch } from 'redux';
-import { change, arrayPush } from 'redux-form';
+import { arrayPush, change, initialize } from 'redux-form';
import { RootState } from '~/store/store';
-import { initUserProject } from '~/store/tree-picker/tree-picker-actions';
+import { initUserProject, treePickerActions } from '~/store/tree-picker/tree-picker-actions';
import { ServiceRepository } from '~/services/services';
import { FilterBuilder } from "~/services/api/filter-builder";
import { ResourceKind } from '~/models/resource';
import { GroupClass } from '~/models/group';
import { SearchView } from '~/store/search-bar/search-bar-reducer';
-import { navigateToSearchResults, navigateTo } from '~/store/navigation/navigation-action';
+import { navigateTo, navigateToSearchResults } from '~/store/navigation/navigation-action';
import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions';
-import { initialize } from 'redux-form';
-import { SearchBarAdvanceFormData, PropertyValues } from '~/models/search-bar';
+import { ClusterObjectType, PropertyValue, SearchBarAdvanceFormData } from '~/models/search-bar';
import { debounce } from 'debounce';
+import * as _ from "lodash";
+import { getModifiedKeysValues } from "~/common/objects";
+import { activateSearchBarProject } from "~/store/search-bar/search-bar-tree-actions";
export const searchBarActions = unionize({
SET_CURRENT_VIEW: ofType<string>(),
const currentView = getState().searchBar.currentView;
dispatch(searchBarActions.SET_SEARCH_VALUE(searchValue));
if (searchValue.length > 0) {
- dispatch<any>(searchGroups(searchValue, 5, {}));
+ dispatch<any>(searchGroups(searchValue, 5));
if (currentView === SearchView.BASIC) {
dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
dispatch(navigateToSearchResults);
dispatch(navigateToSearchResults);
};
+export const setSearchValueFromAdvancedData = (data: SearchBarAdvanceFormData, prevData?: SearchBarAdvanceFormData) =>
+ (dispatch: Dispatch, getState: () => RootState) => {
+ const searchValue = getState().searchBar.searchValue;
+ const value = getQueryFromAdvancedData({
+ ...data,
+ searchValue
+ }, prevData);
+ dispatch(searchBarActions.SET_SEARCH_VALUE(value));
+ };
+
+export const setAdvancedDataFromSearchValue = (search: string) =>
+ async (dispatch: Dispatch) => {
+ const data = getAdvancedDataFromQuery(search);
+ dispatch<any>(initialize(SEARCH_BAR_ADVANCE_FORM_NAME, data));
+ if (data.projectUuid) {
+ await dispatch<any>(activateSearchBarProject(data.projectUuid));
+ dispatch(treePickerActions.ACTIVATE_TREE_PICKER_NODE({ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID, id: data.projectUuid }));
+ }
+ };
+
const saveQuery = (data: SearchBarAdvanceFormData) =>
(dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
const savedQueries = services.searchService.getSavedQueries();
- if (data.saveQuery && data.searchQuery) {
- const filteredQuery = savedQueries.find(query => query.searchQuery === data.searchQuery);
+ if (data.saveQuery && data.queryName) {
+ const filteredQuery = savedQueries.find(query => query.queryName === data.queryName);
+ data.searchValue = getState().searchBar.searchValue;
if (filteredQuery) {
services.searchService.editSavedQueries(data);
dispatch(searchBarActions.UPDATE_SAVED_QUERY(savedQueries));
export const editSavedQuery = (data: SearchBarAdvanceFormData) =>
(dispatch: Dispatch<any>) => {
dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.ADVANCED));
- dispatch(searchBarActions.SET_SEARCH_VALUE(data.searchQuery));
+ dispatch(searchBarActions.SET_SEARCH_VALUE(getQueryFromAdvancedData(data)));
dispatch<any>(initialize(SEARCH_BAR_ADVANCE_FORM_NAME, data));
};
export const closeAdvanceView = () =>
(dispatch: Dispatch<any>) => {
dispatch(searchBarActions.SET_SEARCH_VALUE(''));
+ dispatch(treePickerActions.DEACTIVATE_TREE_PICKER_NODE({ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID }));
dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.BASIC));
};
const searchValuePresent = searchValue.length > 0;
if (currentView === SearchView.ADVANCED) {
-
+ dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.AUTOCOMPLETE));
} else if (searchValuePresent) {
dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.AUTOCOMPLETE));
dispatch(searchBarActions.SET_SELECTED_ITEM(searchValue));
dispatch<any>(searchData(searchValue));
};
-const searchGroups = (searchValue: string, limit: number, {...props}) =>
+const searchGroups = (searchValue: string, limit: number) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
const currentView = getState().searchBar.currentView;
if (searchValue || currentView === SearchView.ADVANCED) {
- const filters = getFilters('name', searchValue, props);
+ const filters = getFilters('name', searchValue);
const { items } = await services.groupsService.contents('', {
filters,
limit,
}
};
-export const getFilters = (filterName: string, searchValue: string, props: any): string => {
- const { resourceKind, dateTo, dateFrom } = props;
- return new FilterBuilder()
- .addIsA("uuid", buildUuidFilter(resourceKind))
- .addILike(filterName, searchValue, GroupContentsResourcePrefix.COLLECTION)
- .addILike(filterName, searchValue, GroupContentsResourcePrefix.PROCESS)
- .addILike(filterName, searchValue, GroupContentsResourcePrefix.PROJECT)
- .addLte('modified_at', buildDateFilter(dateTo))
- .addGte('modified_at', buildDateFilter(dateFrom))
+const buildQueryFromKeyMap = (data: any, keyMap: string[][], mode: 'rebuild' | 'reuse') => {
+ let value = data.searchValue;
+
+ const addRem = (field: string, key: string) => {
+ const v = data[key];
+
+ if (data.hasOwnProperty(key)) {
+ const pattern = v === false
+ ? `${field.replace(':', '\\:\\s*')}\\s*`
+ : `${field.replace(':', '\\:\\s*')}\\:\\s*[\\w|\\#|\\-|\\/]*\\s*`;
+ value = value.replace(new RegExp(pattern), '');
+ }
+
+ if (v) {
+ const nv = v === true
+ ? `${field}`
+ : `${field}:${v}`;
+
+ if (mode === 'rebuild') {
+ value = value + ' ' + nv;
+ } else {
+ value = nv + ' ' + value;
+ }
+ }
+ };
+
+ keyMap.forEach(km => addRem(km[0], km[1]));
+
+ return value;
+};
+
+export const getQueryFromAdvancedData = (data: SearchBarAdvanceFormData, prevData?: SearchBarAdvanceFormData) => {
+ let value = '';
+
+ const flatData = (data: SearchBarAdvanceFormData) => {
+ const fo = {
+ searchValue: data.searchValue,
+ type: data.type,
+ cluster: data.cluster,
+ projectUuid: data.projectUuid,
+ inTrash: data.inTrash,
+ dateFrom: data.dateFrom,
+ dateTo: data.dateTo,
+ };
+ (data.properties || []).forEach(p => fo[`prop-${p.key}`] = p.value);
+ return fo;
+ };
+
+ const keyMap = [
+ ['type', 'type'],
+ ['cluster', 'cluster'],
+ ['project', 'projectUuid'],
+ ['is:trashed', 'inTrash'],
+ ['from', 'dateFrom'],
+ ['to', 'dateTo']
+ ];
+ _.union(data.properties, prevData ? prevData.properties : [])
+ .forEach(p => keyMap.push([`has:${p.key}`, `prop-${p.key}`]));
+
+ if (prevData) {
+ const obj = getModifiedKeysValues(flatData(data), flatData(prevData));
+ value = buildQueryFromKeyMap({
+ searchValue: data.searchValue,
+ ...obj
+ } as SearchBarAdvanceFormData, keyMap, "reuse");
+ } else {
+ value = buildQueryFromKeyMap(flatData(data), keyMap, "rebuild");
+ }
+
+ value = value.trim();
+ return value;
+};
+
+export interface ParseSearchQuery {
+ hasKeywords: boolean;
+ values: string[];
+ properties: {
+ [key: string]: string[]
+ };
+}
+
+export const parseSearchQuery: (query: string) => ParseSearchQuery = (searchValue: string) => {
+ const keywords = [
+ 'type:',
+ 'cluster:',
+ 'project:',
+ 'is:',
+ 'from:',
+ 'to:',
+ 'has:'
+ ];
+
+ const hasKeywords = (search: string) => keywords.reduce((acc, keyword) => acc + (search.includes(keyword) ? 1 : 0), 0);
+ let keywordsCnt = 0;
+
+ const properties = {};
+
+ keywords.forEach(k => {
+ let p = searchValue.indexOf(k);
+ const key = k.substr(0, k.length - 1);
+
+ while (p >= 0) {
+ const l = searchValue.length;
+ keywordsCnt += 1;
+
+ let v = '';
+ let i = p + k.length;
+ while (i < l && searchValue[i] === ' ') {
+ ++i;
+ }
+ const vp = i;
+ while (i < l && searchValue[i] !== ' ') {
+ v += searchValue[i];
+ ++i;
+ }
+
+ if (hasKeywords(v)) {
+ searchValue = searchValue.substr(0, p) + searchValue.substr(vp);
+ } else {
+ if (v !== '') {
+ if (!properties[key]) {
+ properties[key] = [];
+ }
+ properties[key].push(v);
+ }
+ searchValue = searchValue.substr(0, p) + searchValue.substr(i);
+ }
+ p = searchValue.indexOf(k);
+ }
+ });
+
+ const values = _.uniq(searchValue.split(' ').filter(v => v.length > 0));
+
+ return { hasKeywords: keywordsCnt > 0, values, properties };
+};
+
+const getFirstProp = (sq: ParseSearchQuery, name: string) => sq.properties[name] && sq.properties[name][0];
+const getPropValue = (sq: ParseSearchQuery, name: string, value: string) => sq.properties[name] && sq.properties[name].find((v: string) => v === value);
+const getProperties = (sq: ParseSearchQuery): PropertyValue[] => {
+ if (sq.properties.has) {
+ return sq.properties.has.map((value: string) => {
+ const v = value.split(':');
+ return {
+ key: v[0],
+ value: v[1]
+ };
+ });
+ }
+ return [];
+};
+
+export const getAdvancedDataFromQuery = (query: string): SearchBarAdvanceFormData => {
+ const sq = parseSearchQuery(query);
+
+ return {
+ searchValue: sq.values.join(' '),
+ type: getFirstProp(sq, 'type') as ResourceKind,
+ cluster: getFirstProp(sq, 'cluster') as ClusterObjectType,
+ projectUuid: getFirstProp(sq, 'project'),
+ inTrash: getPropValue(sq, 'is', 'trashed') !== undefined,
+ dateFrom: getFirstProp(sq, 'from'),
+ dateTo: getFirstProp(sq, 'to'),
+ properties: getProperties(sq),
+ saveQuery: false,
+ queryName: ''
+ };
+};
+
+export const getFilters = (filterName: string, searchValue: string): string => {
+ const filter = new FilterBuilder();
+ const sq = parseSearchQuery(searchValue);
+
+ const resourceKind = getFirstProp(sq, 'type') as ResourceKind;
+
+ let prefix = '';
+ switch (resourceKind) {
+ case ResourceKind.COLLECTION:
+ prefix = GroupContentsResourcePrefix.COLLECTION;
+ break;
+ case ResourceKind.PROCESS:
+ prefix = GroupContentsResourcePrefix.PROCESS;
+ break;
+ default:
+ prefix = GroupContentsResourcePrefix.PROJECT;
+ break;
+ }
+
+ if (!sq.hasKeywords) {
+ filter
+ .addILike(filterName, searchValue, GroupContentsResourcePrefix.COLLECTION)
+ .addILike(filterName, searchValue, GroupContentsResourcePrefix.PROCESS)
+ .addILike(filterName, searchValue, GroupContentsResourcePrefix.PROJECT);
+ } else {
+ if (prefix) {
+ sq.values.forEach(v =>
+ filter.addILike(filterName, v, prefix)
+ );
+ } else {
+ sq.values.forEach(v => {
+ filter
+ .addILike(filterName, v, GroupContentsResourcePrefix.COLLECTION)
+ .addILike(filterName, v, GroupContentsResourcePrefix.PROCESS)
+ .addILike(filterName, v, GroupContentsResourcePrefix.PROJECT);
+ });
+ }
+
+ if (getPropValue(sq, 'is', 'trashed')) {
+ filter.addEqual("is_trashed", true);
+ }
+
+ const projectUuid = getFirstProp(sq, 'project');
+ if (projectUuid) {
+ filter.addEqual('uuid', projectUuid, prefix);
+ }
+
+ const dateFrom = getFirstProp(sq, 'from');
+ if (dateFrom) {
+ filter.addGte('modified_at', buildDateFilter(dateFrom));
+ }
+
+ const dateTo = getFirstProp(sq, 'to');
+ if (dateTo) {
+ filter.addLte('modified_at', buildDateFilter(dateTo));
+ }
+
+ const props = getProperties(sq);
+ props.forEach(p => {
+ // filter.addILike(`properties.${p.key}`, p.value);
+ filter.addExists(p.key);
+ });
+ }
+
+ return filter
.addEqual('groupClass', GroupClass.PROJECT, GroupContentsResourcePrefix.PROJECT)
+ .addIsA("uuid", buildUuidFilter(resourceKind))
.getFilters();
};
dispatch<any>(initUserProject(SEARCH_BAR_ADVANCE_FORM_PICKER_ID));
};
-export const changeAdvanceFormProperty = (property: string, value: PropertyValues[] | string = '') =>
+export const changeAdvanceFormProperty = (property: string, value: PropertyValue[] | string = '') =>
(dispatch: Dispatch) => {
dispatch(change(SEARCH_BAR_ADVANCE_FORM_NAME, property, value));
};
-export const updateAdvanceFormProperties = (propertyValues: PropertyValues) =>
+export const updateAdvanceFormProperties = (propertyValues: PropertyValue) =>
(dispatch: Dispatch) => {
dispatch(arrayPush(SEARCH_BAR_ADVANCE_FORM_NAME, 'properties', propertyValues));
};
//
// SPDX-License-Identifier: AGPL-3.0
-import { searchBarActions, SearchBarActions } from '~/store/search-bar/search-bar-actions';
+import {
+ getQueryFromAdvancedData,
+ searchBarActions,
+ SearchBarActions
+} from '~/store/search-bar/search-bar-actions';
import { GroupContentsResource } from '~/services/groups-service/groups-service';
import { SearchBarAdvanceFormData } from '~/models/search-bar';
const makeQueryList = (recentQueries: string[], savedQueries: SearchBarAdvanceFormData[]) => {
const recentIds = recentQueries.map((q, idx) => makeSelectedItem(`RQ-${idx}-${q}`, q));
- const savedIds = savedQueries.map((q, idx) => makeSelectedItem(`SQ-${idx}-${q.searchQuery}`, q.searchQuery));
+ const savedIds = savedQueries.map((q, idx) => makeSelectedItem(`SQ-${idx}-${q.queryName}`, getQueryFromAdvancedData(q)));
return recentIds.concat(savedIds);
};
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { getTreePicker, TreePicker } from "~/store/tree-picker/tree-picker";
+import { getNode, getNodeAncestorsIds, initTreeNode, TreeNodeStatus } from "~/models/tree";
+import { Dispatch } from "redux";
+import { RootState } from "~/store/store";
+import { ServiceRepository } from "~/services/services";
+import { treePickerActions } from "~/store/tree-picker/tree-picker-actions";
+import { FilterBuilder } from "~/services/api/filter-builder";
+import { OrderBuilder } from "~/services/api/order-builder";
+import { ProjectResource } from "~/models/project";
+import { resourcesActions } from "~/store/resources/resources-actions";
+import { SEARCH_BAR_ADVANCE_FORM_PICKER_ID } from "~/store/search-bar/search-bar-actions";
+
+const getSearchBarTreeNode = (id: string) => (treePicker: TreePicker) => {
+ const searchTree = getTreePicker(SEARCH_BAR_ADVANCE_FORM_PICKER_ID)(treePicker);
+ return searchTree
+ ? getNode(id)(searchTree)
+ : undefined;
+};
+
+export const loadSearchBarTreeProjects = (projectUuid: string) =>
+ async (dispatch: Dispatch, getState: () => RootState) => {
+ const treePicker = getTreePicker(SEARCH_BAR_ADVANCE_FORM_PICKER_ID)(getState().treePicker);
+ const node = treePicker ? getNode(projectUuid)(treePicker) : undefined;
+ if (node || projectUuid === '') {
+ await dispatch<any>(loadSearchBarProject(projectUuid));
+ }
+ };
+
+export const getSearchBarTreeNodeAncestorsIds = (id: string) => (treePicker: TreePicker) => {
+ const searchTree = getTreePicker(SEARCH_BAR_ADVANCE_FORM_PICKER_ID)(treePicker);
+ return searchTree
+ ? getNodeAncestorsIds(id)(searchTree)
+ : [];
+};
+
+export const activateSearchBarTreeBranch = (id: string) =>
+ async (dispatch: Dispatch, _: void, services: ServiceRepository) => {
+ const ancestors = await services.ancestorsService.ancestors(id, services.authService.getUuid() || '');
+
+ for (const ancestor of ancestors) {
+ await dispatch<any>(loadSearchBarTreeProjects(ancestor.uuid));
+ }
+ dispatch(treePickerActions.EXPAND_TREE_PICKER_NODES({
+ ids: [
+ ...[],
+ ...ancestors.map(ancestor => ancestor.uuid)
+ ],
+ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID
+ }));
+ dispatch(treePickerActions.ACTIVATE_TREE_PICKER_NODE({ id, pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID }));
+ };
+
+export const expandSearchBarTreeItem = (id: string) =>
+ async (dispatch: Dispatch, getState: () => RootState) => {
+ const node = getSearchBarTreeNode(id)(getState().treePicker);
+ if (node && !node.expanded) {
+ dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_COLLAPSE({ id, pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID }));
+ }
+ };
+
+export const activateSearchBarProject = (id: string) =>
+ async (dispatch: Dispatch, getState: () => RootState) => {
+ const { treePicker } = getState();
+ const node = getSearchBarTreeNode(id)(treePicker);
+ if (node && node.status !== TreeNodeStatus.LOADED) {
+ await dispatch<any>(loadSearchBarTreeProjects(id));
+ } else if (node === undefined) {
+ await dispatch<any>(activateSearchBarTreeBranch(id));
+ }
+ dispatch(treePickerActions.EXPAND_TREE_PICKER_NODES({
+ ids: getSearchBarTreeNodeAncestorsIds(id)(treePicker),
+ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID
+ }));
+ dispatch<any>(expandSearchBarTreeItem(id));
+ };
+
+
+const loadSearchBarProject = (projectUuid: string) =>
+ async (dispatch: Dispatch, _: () => RootState, services: ServiceRepository) => {
+ dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: projectUuid, pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID }));
+ const params = {
+ filters: new FilterBuilder()
+ .addEqual('ownerUuid', projectUuid)
+ .getFilters(),
+ order: new OrderBuilder<ProjectResource>()
+ .addAsc('name')
+ .getOrder()
+ };
+ const { items } = await services.projectService.list(params);
+ dispatch(treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
+ id: projectUuid,
+ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID,
+ nodes: items.map(item => initTreeNode({ id: item.uuid, value: item })),
+ }));
+ dispatch(resourcesActions.SET_RESOURCES(items));
+ };
+
export const getParams = (dataExplorer: DataExplorer, searchValue: string) => ({
...dataExplorerToListParams(dataExplorer),
- filters: getFilters('name', searchValue, {}),
+ filters: getFilters('name', searchValue),
order: getOrder(dataExplorer)
});
import { keepServicesReducer } from '~/store/keep-services/keep-services-reducer';
import { UserMiddlewareService } from '~/store/users/user-panel-middleware-service';
import { USERS_PANEL_ID } from '~/store/users/users-actions';
+import { computeNodesReducer } from '~/store/compute-nodes/compute-nodes-reducer';
const composeEnhancers =
(process.env.NODE_ENV === 'development' &&
searchBar: searchBarReducer,
virtualMachines: virtualMachinesReducer,
repositories: repositoriesReducer,
- keepServices: keepServicesReducer
+ keepServices: keepServicesReducer,
+ computeNodes: computeNodesReducer
});
import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions';
import { loadSshKeysPanel } from '~/store/auth/auth-action';
+import { loadMyAccountPanel } from '~/store/my-account/my-account-panel-actions';
import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
import { getProgressIndicator } from '~/store/progress-indicator/progress-indicator-reducer';
import { loadKeepServicesPanel } from '~/store/keep-services/keep-services-actions';
import { loadUsersPanel, userBindedActions } from '~/store/users/users-actions';
import { userPanelColumns } from '~/views/user-panel/user-panel';
+import { loadComputeNodesPanel } from '~/store/compute-nodes/compute-nodes-actions';
export const WORKBENCH_LOADING_SCREEN = 'workbenchLoadingScreen';
const userUuid = services.authService.getUuid();
dispatch(setIsProjectPanelTrashed(false));
if (userUuid) {
- if (extractUuidKind(uuid) === ResourceKind.USER && userUuid!==uuid) {
+ if (extractUuidKind(uuid) === ResourceKind.USER && userUuid !== uuid) {
// Load another users home projects
dispatch(finishLoadingProject(uuid));
} else if (userUuid !== uuid) {
await dispatch(loadSshKeysPanel());
});
+export const loadMyAccount = handleFirstTimeLoad(
+ (dispatch: Dispatch<any>) => {
+ dispatch(loadMyAccountPanel());
+ });
+
export const loadKeepServices = handleFirstTimeLoad(
async (dispatch: Dispatch<any>) => {
await dispatch(loadKeepServicesPanel());
dispatch(setBreadcrumbs([{ label: 'Users' }]));
});
+export const loadComputeNodes = handleFirstTimeLoad(
+ async (dispatch: Dispatch<any>) => {
+ await dispatch(loadComputeNodesPanel());
+ });
+
const finishLoadingProject = (project: GroupContentsResource | string) =>
async (dispatch: Dispatch<any>) => {
const uuid = typeof project === 'string' ? project : project.uuid;
export const SSH_KEY_PUBLIC_VALIDATION = [require, isRsaKey, maxLength(1024)];
export const SSH_KEY_NAME_VALIDATION = [require, maxLength(255)];
+
+export const MY_ACCOUNT_VALIDATION = [require];
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { compose } from 'redux';
+import {
+ withStyles, Dialog, DialogTitle, DialogContent, DialogActions,
+ Button, StyleRulesCallback, WithStyles, Grid
+} from '@material-ui/core';
+import { WithDialogProps, withDialog } from "~/store/dialog/with-dialog";
+import { COMPUTE_NODE_ATTRIBUTES_DIALOG } from '~/store/compute-nodes/compute-nodes-actions';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { NodeResource, NodeProperties, NodeInfo } from '~/models/node';
+import * as classnames from "classnames";
+
+type CssRules = 'root' | 'grid';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ root: {
+ fontSize: '0.875rem',
+ '& div:nth-child(odd):not(.nestedRoot)': {
+ textAlign: 'right',
+ color: theme.palette.grey["500"]
+ },
+ '& div:nth-child(even)': {
+ overflowWrap: 'break-word'
+ }
+ },
+ grid: {
+ padding: '8px 0 0 0'
+ }
+});
+
+interface AttributesComputeNodeDialogDataProps {
+ computeNode: NodeResource;
+}
+
+export const AttributesComputeNodeDialog = compose(
+ withDialog(COMPUTE_NODE_ATTRIBUTES_DIALOG),
+ withStyles(styles))(
+ ({ open, closeDialog, data, classes }: WithDialogProps<AttributesComputeNodeDialogDataProps> & WithStyles<CssRules>) =>
+ <Dialog open={open} onClose={closeDialog} fullWidth maxWidth='sm'>
+ <DialogTitle>Attributes</DialogTitle>
+ <DialogContent>
+ {data.computeNode && <div>
+ {renderPrimaryInfo(data.computeNode, classes)}
+ {renderInfo(data.computeNode.info, classes)}
+ {renderProperties(data.computeNode.properties, classes)}
+ </div>}
+ </DialogContent>
+ <DialogActions>
+ <Button
+ variant='flat'
+ color='primary'
+ onClick={closeDialog}>
+ Close
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+
+const renderPrimaryInfo = (computeNode: NodeResource, classes: any) => {
+ const { uuid, ownerUuid, createdAt, modifiedAt, modifiedByClientUuid, modifiedByUserUuid } = computeNode;
+ return (
+ <Grid container direction="row" spacing={16} className={classes.root}>
+ <Grid item xs={5}>UUID</Grid>
+ <Grid item xs={7}>{uuid}</Grid>
+ <Grid item xs={5}>Owner uuid</Grid>
+ <Grid item xs={7}>{ownerUuid}</Grid>
+ <Grid item xs={5}>Created at</Grid>
+ <Grid item xs={7}>{createdAt}</Grid>
+ <Grid item xs={5}>Modified at</Grid>
+ <Grid item xs={7}>{modifiedAt}</Grid>
+ <Grid item xs={5}>Modified by user uuid</Grid>
+ <Grid item xs={7}>{modifiedByUserUuid}</Grid>
+ <Grid item xs={5}>Modified by client uuid</Grid>
+ <Grid item xs={7}>{modifiedByClientUuid || '(none)'}</Grid>
+ </Grid>
+ );
+};
+
+const renderInfo = (info: NodeInfo, classes: any) => {
+ const { lastAction, pingSecret, ec2InstanceId, slurmState } = info;
+ return (
+ <Grid container direction="row" spacing={16} className={classnames([classes.root, classes.grid])}>
+ <Grid item xs={5}>Info - Last action</Grid>
+ <Grid item xs={7}>{lastAction || '(none)'}</Grid>
+ <Grid item xs={5}>Info - Ping secret</Grid>
+ <Grid item xs={7}>{pingSecret || '(none)'}</Grid>
+ <Grid item xs={5}>Info - ec2 instance id</Grid>
+ <Grid item xs={7}>{ec2InstanceId || '(none)'}</Grid>
+ <Grid item xs={5}>Info - Slurm state</Grid>
+ <Grid item xs={7}>{slurmState || '(none)'}</Grid>
+ </Grid>
+ );
+};
+
+const renderProperties = (properties: NodeProperties, classes: any) => {
+ const { totalRamMb, totalCpuCores, totalScratchMb, cloudNode } = properties;
+ return (
+ <Grid container direction="row" spacing={16} className={classnames([classes.root, classes.grid])}>
+ <Grid item xs={5}>Properties - Total ram mb</Grid>
+ <Grid item xs={7}>{totalRamMb || '(none)'}</Grid>
+ <Grid item xs={5}>Properties - Total scratch mb</Grid>
+ <Grid item xs={7}>{totalScratchMb || '(none)'}</Grid>
+ <Grid item xs={5}>Properties - Total cpu cores</Grid>
+ <Grid item xs={7}>{totalCpuCores || '(none)'}</Grid>
+ <Grid item xs={5}>Properties - Cloud node size </Grid>
+ <Grid item xs={7}>{cloudNode ? cloudNode.size : '(none)'}</Grid>
+ <Grid item xs={5}>Properties - Cloud node price</Grid>
+ <Grid item xs={7}>{cloudNode ? cloudNode.price : '(none)'}</Grid>
+ </Grid>
+ );
+};
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch, compose } from 'redux';
+import { connect } from "react-redux";
+import { ConfirmationDialog } from "~/components/confirmation-dialog/confirmation-dialog";
+import { withDialog, WithDialogProps } from "~/store/dialog/with-dialog";
+import { COMPUTE_NODE_REMOVE_DIALOG, removeComputeNode } from '~/store/compute-nodes/compute-nodes-actions';
+
+const mapDispatchToProps = (dispatch: Dispatch, props: WithDialogProps<any>) => ({
+ onConfirm: () => {
+ props.closeDialog();
+ dispatch<any>(removeComputeNode(props.data.uuid));
+ }
+});
+
+export const RemoveComputeNodeDialog = compose(
+ withDialog(COMPUTE_NODE_REMOVE_DIALOG),
+ connect(null, mapDispatchToProps)
+)(ConfirmationDialog);
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { openComputeNodeRemoveDialog, openComputeNodeAttributesDialog } from '~/store/compute-nodes/compute-nodes-actions';
+import { openAdvancedTabDialog } from '~/store/advanced-tab/advanced-tab';
+import { ContextMenuActionSet } from "~/views-components/context-menu/context-menu-action-set";
+import { AdvancedIcon, RemoveIcon, AttributesIcon } from "~/components/icon/icon";
+
+export const computeNodeActionSet: ContextMenuActionSet = [[{
+ name: "Attributes",
+ icon: AttributesIcon,
+ execute: (dispatch, { uuid }) => {
+ dispatch<any>(openComputeNodeAttributesDialog(uuid));
+ }
+}, {
+ name: "Advanced",
+ icon: AdvancedIcon,
+ execute: (dispatch, { uuid }) => {
+ dispatch<any>(openAdvancedTabDialog(uuid));
+ }
+}, {
+ name: "Remove",
+ icon: RemoveIcon,
+ execute: (dispatch, { uuid }) => {
+ dispatch<any>(openComputeNodeRemoveDialog(uuid));
+ }
+}]];
SSH_KEY = "SshKey",
VIRTUAL_MACHINE = "VirtualMachine",
KEEP_SERVICE = "KeepService",
- USER = "User"
+ USER = "User",
+ NODE = "Node"
}
import { HomeTreePicker } from '~/views-components/projects-tree-picker/home-tree-picker';
import { SEARCH_BAR_ADVANCE_FORM_PICKER_ID } from '~/store/search-bar/search-bar-actions';
import { SearchBarAdvancedPropertiesView } from '~/views-components/search-bar/search-bar-advanced-properties-view';
+import { TreeItem } from "~/components/tree/tree";
+import { ProjectsTreePickerItem } from "~/views-components/projects-tree-picker/generic-projects-tree-picker";
export const SearchBarTypeField = () =>
<Field
const ProjectsPicker = (props: WrappedFieldProps) =>
<div style={{ height: '100px', display: 'flex', flexDirection: 'column', overflow: 'overlay' }}>
- <HomeTreePicker pickerId={SEARCH_BAR_ADVANCE_FORM_PICKER_ID} />
+ <HomeTreePicker
+ pickerId={SEARCH_BAR_ADVANCE_FORM_PICKER_ID}
+ toggleItemActive={
+ (_: any, { id }: TreeItem<ProjectsTreePickerItem>) => {
+ props.input.onChange(id);
+ }
+ }/>
</div>;
export const SearchBarTrashField = () =>
<Field
name='saveQuery'
component={CheckboxField}
- label="Save search query" />;
+ label="Save query" />;
export const SearchBarQuerySearchField = () =>
<Field
- name='searchQuery'
+ name='queryName'
component={TextField}
- label="Search query name" />;
\ No newline at end of file
+ label="Query name" />;
import { RootState } from "~/store/store";
import { openCurrentTokenDialog } from '~/store/current-token-dialog/current-token-dialog-actions';
import { openRepositoriesPanel } from "~/store/repositories/repositories-actions";
-import { navigateToSshKeys, navigateToKeepServices } from '~/store/navigation/navigation-action';
+import { navigateToSshKeys, navigateToKeepServices, navigateToComputeNodes, navigateToMyAccount } from '~/store/navigation/navigation-action';
import { openVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
import { navigateToUsers } from '~/store/navigation/navigation-action';
<MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
<MenuItem onClick={() => dispatch(navigateToSshKeys)}>Ssh Keys</MenuItem>
<MenuItem onClick={() => dispatch(navigateToUsers)}>Users</MenuItem>
- {user.isAdmin && <MenuItem onClick={() => dispatch(navigateToKeepServices)}>Keep Services</MenuItem>}
- <MenuItem>My account</MenuItem>
+ { user.isAdmin && <MenuItem onClick={() => dispatch(navigateToKeepServices)}>Keep Services</MenuItem> }
+ { user.isAdmin && <MenuItem onClick={() => dispatch(navigateToComputeNodes)}>Compute Nodes</MenuItem> }
+ <MenuItem onClick={() => dispatch(navigateToMyAccount)}>My account</MenuItem>
<MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
</DropdownMenu>
: null);
import { Breadcrumbs } from "~/views-components/breadcrumbs/breadcrumbs";
import { connect } from 'react-redux';
import { RootState } from '~/store/store';
-import { matchWorkflowRoute, matchSshKeysRoute, matchRepositoriesRoute, matchVirtualMachineRoute, matchKeepServicesRoute, matchUsersRoute } from '~/routes/routes';
+import * as Routes from '~/routes/routes';
import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
interface MainContentBarProps {
const isButtonVisible = ({ router }: RootState) => {
const pathname = router.location ? router.location.pathname : '';
- return !matchWorkflowRoute(pathname) && !matchVirtualMachineRoute(pathname) &&
- !matchRepositoriesRoute(pathname) && !matchSshKeysRoute(pathname) && !matchKeepServicesRoute(pathname) &&
- !matchUsersRoute(pathname);
+ return !Routes.matchWorkflowRoute(pathname) && !Routes.matchVirtualMachineRoute(pathname) &&
+ !Routes.matchRepositoriesRoute(pathname) && !Routes.matchSshKeysRoute(pathname) &&
+ !Routes.matchKeepServicesRoute(pathname) && !Routes.matchComputeNodesRoute(pathname) &&
+ !Routes.matchUsersRoute(pathname);
};
export const MainContentBar = connect((state: RootState) => ({
changeAdvanceFormProperty,
updateAdvanceFormProperties
} from '~/store/search-bar/search-bar-actions';
-import { PropertyValues } from '~/models/search-bar';
+import { PropertyValue } from '~/models/search-bar';
import { ArvadosTheme } from '~/common/custom-theme';
import { SearchBarKeyField, SearchBarValueField } from '~/views-components/form-fields/search-bar-form-fields';
import { Chips } from '~/components/chips/chips';
+import { formatPropertyValue } from "~/common/formatters";
type CssRules = 'label' | 'button';
submitting: boolean;
invalid: boolean;
pristine: boolean;
- propertyValues: PropertyValues;
- fields: PropertyValues[];
+ propertyValues: PropertyValue;
+ fields: PropertyValue[];
}
interface SearchBarAdvancedPropertiesViewActionProps {
setProps: () => void;
- addProp: (propertyValues: PropertyValues) => void;
- getAllFields: (propertyValues: PropertyValues[]) => PropertyValues[] | [];
+ addProp: (propertyValues: PropertyValue) => void;
+ getAllFields: (propertyValues: PropertyValue[]) => PropertyValue[] | [];
}
type SearchBarAdvancedPropertiesViewProps = SearchBarAdvancedPropertiesViewDataProps
};
const mapDispatchToProps = (dispatch: Dispatch) => ({
- setProps: (propertyValues: PropertyValues[]) => {
+ setProps: (propertyValues: PropertyValue[]) => {
dispatch<any>(changeAdvanceFormProperty('properties', propertyValues));
},
- addProp: (propertyValues: PropertyValues) => {
+ addProp: (propertyValues: PropertyValue) => {
dispatch<any>(updateAdvanceFormProperties(propertyValues));
dispatch<any>(changeAdvanceFormProperty('key'));
dispatch<any>(changeAdvanceFormProperty('value'));
<Chips values={getAllFields(fields)}
deletable
onChange={setProps}
- getLabel={(field: PropertyValues) => `${field.key}: ${field.value}`} />
+ getLabel={(field: PropertyValue) => formatPropertyValue(field)} />
</Grid>
</Grid>
)
-);
\ No newline at end of file
+);
import { reduxForm, InjectedFormProps, reset } from 'redux-form';
import { compose, Dispatch } from 'redux';
import { Paper, StyleRulesCallback, withStyles, WithStyles, Button, Grid, IconButton, CircularProgress } from '@material-ui/core';
-import { SEARCH_BAR_ADVANCE_FORM_NAME, searchAdvanceData } from '~/store/search-bar/search-bar-actions';
+import {
+ SEARCH_BAR_ADVANCE_FORM_NAME, SEARCH_BAR_ADVANCE_FORM_PICKER_ID,
+ searchAdvanceData,
+ setSearchValueFromAdvancedData
+} from '~/store/search-bar/search-bar-actions';
import { ArvadosTheme } from '~/common/custom-theme';
import { CloseIcon } from '~/components/icon/icon';
import { SearchBarAdvanceFormData } from '~/models/search-bar';
SearchBarDateFromField, SearchBarDateToField, SearchBarPropertiesField,
SearchBarSaveSearchField, SearchBarQuerySearchField
} from '~/views-components/form-fields/search-bar-form-fields';
+import { treePickerActions } from "~/store/tree-picker/tree-picker-actions";
type CssRules = 'container' | 'closeIcon' | 'label' | 'buttonWrapper'
| 'button' | 'circularProgress' | 'searchView' | 'selectGrid';
// ToDo: maybe we should remove tags
export interface SearchBarAdvancedViewDataProps {
tags: any;
+ saveQuery: boolean;
}
export interface SearchBarAdvancedViewActionProps {
onSubmit: (data: SearchBarAdvanceFormData, dispatch: Dispatch) => {
dispatch<any>(searchAdvanceData(data));
dispatch(reset(SEARCH_BAR_ADVANCE_FORM_NAME));
- }
+ dispatch(treePickerActions.DEACTIVATE_TREE_PICKER_NODE({ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID }));
+ },
+ onChange: (data: SearchBarAdvanceFormData, dispatch: Dispatch, props: any, prevData: SearchBarAdvanceFormData) => {
+ dispatch<any>(setSearchValueFromAdvancedData(data, prevData));
+ },
}),
withStyles(styles))(
- ({ classes, closeAdvanceView, handleSubmit, submitting, invalid, pristine, tags }: SearchBarAdvancedViewFormProps) =>
+ ({ classes, closeAdvanceView, handleSubmit, submitting, invalid, pristine, tags, saveQuery }: SearchBarAdvancedViewFormProps) =>
<Paper className={classes.searchView}>
<form onSubmit={handleSubmit}>
<Grid container direction="column" justify="flex-start" alignItems="flex-start">
</Grid>
<Grid item container xs={12}>
<Grid item xs={2} className={classes.label}>Project</Grid>
- <Grid item xs={5}>
+ <Grid item xs={10}>
<SearchBarProjectField />
</Grid>
</Grid>
<SearchBarSaveSearchField />
</Grid>
<Grid item xs={4}>
- <SearchBarQuerySearchField />
+ {saveQuery && <SearchBarQuerySearchField />}
</Grid>
</Grid>
<Grid container item xs={12} justify='flex-end'>
color: theme.palette.primary.main
},
label: {
- fontSize: '0.875rem',
+ fontSize: '0.775rem',
padding: `${theme.spacing.unit}px ${theme.spacing.unit}px `,
color: theme.palette.grey["900"],
- background: theme.palette.grey["200"]
+ background: 'white',
+ textAlign: 'right',
+ fontWeight: 'bold'
}
};
};
export const SearchBarBasicView = withStyles(styles)(
({ classes, onSetView, loadRecentQueries, deleteSavedQuery, savedQueries, onSearch, editSavedQuery, selectedItem }: SearchBarBasicViewProps) =>
<Paper className={classes.root}>
- <div className={classes.label}>Recent search queries</div>
+ <div className={classes.label}>{"Recent queries"}</div>
<SearchBarRecentQueries
onSearch={onSearch}
loadRecentQueries={loadRecentQueries}
selectedItem={selectedItem} />
- <div className={classes.label}>Saved search queries</div>
+ <div className={classes.label}>{"Saved queries"}</div>
<SearchBarSavedQueries
onSearch={onSearch}
savedQueries={savedQueries}
editSavedQuery={editSavedQuery}
deleteSavedQuery={deleteSavedQuery}
selectedItem={selectedItem} />
- <div className={classes.advanced} onClick={() => onSetView(SearchView.ADVANCED)}>Advanced search</div>
</Paper>
);
import { RemoveIcon, EditSavedQueryIcon } from '~/components/icon/icon';
import { SearchBarAdvanceFormData } from '~/models/search-bar';
import { SearchBarSelectedItem } from "~/store/search-bar/search-bar-reducer";
+import { getQueryFromAdvancedData } from "~/store/search-bar/search-bar-actions";
type CssRules = 'root' | 'listItem' | 'listItemText' | 'button';
({ classes, savedQueries, onSearch, editSavedQuery, deleteSavedQuery, selectedItem }: SearchBarSavedQueriesProps) =>
<List component="nav" className={classes.root}>
{savedQueries.map((query, index) =>
- <ListItem button key={index} className={classes.listItem} selected={`SQ-${index}-${query.searchQuery}` === selectedItem.id}>
+ <ListItem button key={index} className={classes.listItem} selected={`SQ-${index}-${query.queryName}` === selectedItem.id}>
<ListItemText disableTypography
- secondary={query.searchQuery}
- onClick={() => onSearch(query.searchQuery)}
+ secondary={query.queryName}
+ onClick={() => onSearch(getQueryFromAdvancedData(query))}
className={classes.listItemText} />
<ListItemSecondaryAction>
<Tooltip title="Edit">
ClickAwayListener
} from '@material-ui/core';
import SearchIcon from '@material-ui/icons/Search';
+import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
import { ArvadosTheme } from '~/common/custom-theme';
import { SearchView } from '~/store/search-bar/search-bar-reducer';
import {
},
input: {
border: 'none',
- padding: `0px ${theme.spacing.unit}px`
+ padding: `0`
},
view: {
position: 'absolute',
loadRecentQueries: () => string[];
moveUp: () => void;
moveDown: () => void;
+ setAdvancedDataFromSearchValue: (search: string) => void;
}
type SearchBarViewProps = SearchBarDataProps & SearchBarActionProps & WithStyles<CssRules>;
if (e.keyCode === KEY_CODE_DOWN) {
e.preventDefault();
if (!props.isPopoverOpen) {
+ props.onSetView(SearchView.AUTOCOMPLETE);
props.openSearchView();
} else {
props.moveDown();
}
};
+const handleInputClick = (e: React.MouseEvent, props: SearchBarViewProps) => {
+ if (props.searchValue) {
+ props.onSetView(SearchView.AUTOCOMPLETE);
+ props.openSearchView();
+ } else {
+ props.closeView();
+ }
+};
+
+const handleDropdownClick = (e: React.MouseEvent, props: SearchBarViewProps) => {
+ e.stopPropagation();
+ if (props.isPopoverOpen) {
+ if (props.currentView === SearchView.ADVANCED) {
+ props.closeView();
+ } else {
+ props.setAdvancedDataFromSearchValue(props.searchValue);
+ props.onSetView(SearchView.ADVANCED);
+ }
+ } else {
+ props.setAdvancedDataFromSearchValue(props.searchValue);
+ props.onSetView(SearchView.ADVANCED);
+ }
+};
+
export const SearchBarView = withStyles(styles)(
(props : SearchBarViewProps) => {
const { classes, isPopoverOpen } = props;
value={props.searchValue}
fullWidth={true}
disableUnderline={true}
- onClick={props.openSearchView}
+ onClick={e => handleInputClick(e, props)}
onKeyDown={e => handleKeyDown(e, props)}
- endAdornment={
- <InputAdornment position="end">
+ startAdornment={
+ <InputAdornment position="start">
<Tooltip title='Search'>
<IconButton type="submit">
<SearchIcon />
</IconButton>
</Tooltip>
</InputAdornment>
+ }
+ endAdornment={
+ <InputAdornment position="end">
+ <Tooltip title='Advanced search'>
+ <IconButton onClick={e => handleDropdownClick(e, props)}>
+ <ArrowDropDownIcon />
+ </IconButton>
+ </Tooltip>
+ </InputAdornment>
} />
</form>
<div className={classes.view}>
case SearchView.ADVANCED:
return <SearchBarAdvancedView
closeAdvanceView={props.closeAdvanceView}
- tags={props.tags} />;
+ tags={props.tags}
+ saveQuery={props.saveQuery} />;
default:
return <SearchBarBasicView
onSetView={props.onSetView}
navigateToItem,
editSavedQuery,
changeData,
- submitData, moveUp, moveDown
+ submitData, moveUp, moveDown, setAdvancedDataFromSearchValue
} from '~/store/search-bar/search-bar-actions';
import { SearchBarView, SearchBarActionProps, SearchBarDataProps } from '~/views-components/search-bar/search-bar-view';
import { SearchBarAdvanceFormData } from '~/models/search-bar';
searchResults: searchBar.searchResults,
selectedItem: searchBar.selectedItem,
savedQueries: searchBar.savedQueries,
- tags: form.searchBarAdvanceFormName
+ tags: form.searchBarAdvanceFormName,
+ saveQuery: form.searchBarAdvanceFormName &&
+ form.searchBarAdvanceFormName.values &&
+ form.searchBarAdvanceFormName.values.saveQuery
};
};
navigateTo: (uuid: string) => dispatch<any>(navigateToItem(uuid)),
editSavedQuery: (data: SearchBarAdvanceFormData) => dispatch<any>(editSavedQuery(data)),
moveUp: () => dispatch<any>(moveUp()),
- moveDown: () => dispatch<any>(moveDown())
+ moveDown: () => dispatch<any>(moveDown()),
+ setAdvancedDataFromSearchValue: (search: string) => dispatch<any>(setAdvancedDataFromSearchValue(search))
});
export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);
import * as React from 'react';
import { Grid, StyleRulesCallback, Divider, IconButton, Typography } from '@material-ui/core';
-import { Field, WrappedFieldProps, WrappedFieldArrayProps, FieldArray, FieldsProps } from 'redux-form';
+import {
+ Field,
+ WrappedFieldProps,
+ WrappedFieldArrayProps,
+ FieldArray,
+ FieldArrayFieldsProps
+} from 'redux-form';
import { PermissionSelect, formatPermissionLevel, parsePermissionLevel } from './permission-select';
import { WithStyles } from '@material-ui/core/styles';
import withStyles from '@material-ui/core/styles/withStyles';
}
});
const PermissionManagementRow = withStyles(permissionManagementRowStyles)(
- ({ field, index, fields, classes }: { field: string, index: number, fields: FieldsProps<{ email: string }> } & WithStyles<'root'>) =>
+ ({ field, index, fields, classes }: { field: string, index: number, fields: FieldArrayFieldsProps<{ email: string }> } & WithStyles<'root'>) =>
<>
<Divider />
<Grid container alignItems='center' spacing={8} wrap='nowrap' className={classes.root}>
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import {
+ StyleRulesCallback, WithStyles, withStyles, Card, CardContent, Grid, Table,
+ TableHead, TableRow, TableCell, TableBody, Tooltip, IconButton
+} from '@material-ui/core';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { MoreOptionsIcon } from '~/components/icon/icon';
+import { NodeResource } from '~/models/node';
+import { formatDate } from '~/common/formatters';
+
+type CssRules = 'root' | 'tableRow';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ root: {
+ width: '100%',
+ overflow: 'auto'
+ },
+ tableRow: {
+ '& td, th': {
+ whiteSpace: 'nowrap'
+ }
+ }
+});
+
+export interface ComputeNodePanelRootActionProps {
+ openRowOptions: (event: React.MouseEvent<HTMLElement>, computeNode: NodeResource) => void;
+}
+
+export interface ComputeNodePanelRootDataProps {
+ computeNodes: NodeResource[];
+ hasComputeNodes: boolean;
+}
+
+type ComputeNodePanelRootProps = ComputeNodePanelRootActionProps & ComputeNodePanelRootDataProps & WithStyles<CssRules>;
+
+export const ComputeNodePanelRoot = withStyles(styles)(
+ ({ classes, hasComputeNodes, computeNodes, openRowOptions }: ComputeNodePanelRootProps) =>
+ <Card className={classes.root}>
+ <CardContent>
+ {hasComputeNodes && <Grid container direction="row">
+ <Grid item xs={12}>
+ <Table>
+ <TableHead>
+ <TableRow className={classes.tableRow}>
+ <TableCell>Info</TableCell>
+ <TableCell>UUID</TableCell>
+ <TableCell>Domain</TableCell>
+ <TableCell>First ping at</TableCell>
+ <TableCell>Hostname</TableCell>
+ <TableCell>IP Address</TableCell>
+ <TableCell>Job</TableCell>
+ <TableCell>Last ping at</TableCell>
+ <TableCell />
+ </TableRow>
+ </TableHead>
+ <TableBody>
+ {computeNodes.map((computeNode, index) =>
+ <TableRow key={index} className={classes.tableRow}>
+ <TableCell>{computeNode.uuid}</TableCell>
+ <TableCell>{computeNode.uuid}</TableCell>
+ <TableCell>{computeNode.domain}</TableCell>
+ <TableCell>{formatDate(computeNode.firstPingAt) || '(none)'}</TableCell>
+ <TableCell>{computeNode.hostname || '(none)'}</TableCell>
+ <TableCell>{computeNode.ipAddress || '(none)'}</TableCell>
+ <TableCell>{computeNode.jobUuid || '(none)'}</TableCell>
+ <TableCell>{formatDate(computeNode.lastPingAt) || '(none)'}</TableCell>
+ <TableCell>
+ <Tooltip title="More options" disableFocusListener>
+ <IconButton onClick={event => openRowOptions(event, computeNode)}>
+ <MoreOptionsIcon />
+ </IconButton>
+ </Tooltip>
+ </TableCell>
+ </TableRow>)}
+ </TableBody>
+ </Table>
+ </Grid>
+ </Grid>}
+ </CardContent>
+ </Card>
+);
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { RootState } from '~/store/store';
+import { Dispatch } from 'redux';
+import { connect } from 'react-redux';
+import { } from '~/store/compute-nodes/compute-nodes-actions';
+import {
+ ComputeNodePanelRoot,
+ ComputeNodePanelRootDataProps,
+ ComputeNodePanelRootActionProps
+} from '~/views/compute-node-panel/compute-node-panel-root';
+import { openComputeNodeContextMenu } from '~/store/context-menu/context-menu-actions';
+
+const mapStateToProps = (state: RootState): ComputeNodePanelRootDataProps => {
+ return {
+ computeNodes: state.computeNodes,
+ hasComputeNodes: state.computeNodes.length > 0
+ };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch): ComputeNodePanelRootActionProps => ({
+ openRowOptions: (event, computeNode) => {
+ dispatch<any>(openComputeNodeContextMenu(event, computeNode));
+ }
+});
+
+export const ComputeNodePanel = connect(mapStateToProps, mapDispatchToProps)(ComputeNodePanelRoot);
\ No newline at end of file
import { RootState } from '~/store/store';
import { Dispatch } from 'redux';
import { connect } from 'react-redux';
-import { } from '~/store/keep-services/keep-services-actions';
import {
KeepServicePanelRoot,
KeepServicePanelRootDataProps,
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { Field, InjectedFormProps } from "redux-form";
+import { TextField } from "~/components/text-field/text-field";
+import { NativeSelectField } from "~/components/select-field/select-field";
+import {
+ StyleRulesCallback,
+ WithStyles,
+ withStyles,
+ Card,
+ CardContent,
+ Button,
+ Typography,
+ Grid,
+ InputLabel
+} from '@material-ui/core';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { User } from "~/models/user";
+import { MY_ACCOUNT_VALIDATION} from "~/validators/validators";
+
+type CssRules = 'root' | 'gridItem' | 'label' | 'title' | 'actions';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ root: {
+ width: '100%',
+ overflow: 'auto'
+ },
+ gridItem: {
+ height: 45,
+ marginBottom: 20
+ },
+ label: {
+ fontSize: '0.675rem'
+ },
+ title: {
+ marginBottom: theme.spacing.unit * 3,
+ color: theme.palette.grey["600"]
+ },
+ actions: {
+ display: 'flex',
+ justifyContent: 'flex-end'
+ }
+});
+
+export interface MyAccountPanelRootActionProps {}
+
+export interface MyAccountPanelRootDataProps {
+ isPristine: boolean;
+ isValid: boolean;
+ initialValues?: User;
+}
+
+const RoleTypes = [
+ {key: 'Bio-informatician', value: 'Bio-informatician'},
+ {key: 'Data Scientist', value: 'Data Scientist'},
+ {key: 'Analyst', value: 'Analyst'},
+ {key: 'Researcher', value: 'Researcher'},
+ {key: 'Software Developer', value: 'Software Developer'},
+ {key: 'System Administrator', value: 'System Administrator'},
+ {key: 'Other', value: 'Other'}
+];
+
+type MyAccountPanelRootProps = InjectedFormProps<MyAccountPanelRootActionProps> & MyAccountPanelRootDataProps & WithStyles<CssRules>;
+
+export const MyAccountPanelRoot = withStyles(styles)(
+ ({ classes, isValid, handleSubmit, reset, isPristine, invalid, submitting }: MyAccountPanelRootProps) => {
+ return <Card className={classes.root}>
+ <CardContent>
+ <Typography variant="title" className={classes.title}>User profile</Typography>
+ <form onSubmit={handleSubmit}>
+ <Grid container direction="row" spacing={24}>
+ <Grid item xs={6}>
+ <Grid item className={classes.gridItem}>
+ <Field
+ label="E-mail"
+ name="email"
+ component={TextField}
+ disabled
+ />
+ </Grid>
+ <Grid item className={classes.gridItem}>
+ <Field
+ label="First name"
+ name="firstName"
+ component={TextField}
+ disabled
+ />
+ </Grid>
+ <Grid item className={classes.gridItem}>
+ <Field
+ label="Identity URL"
+ name="identityUrl"
+ component={TextField}
+ disabled
+ />
+ </Grid>
+ <Grid item className={classes.gridItem}>
+ <Field
+ label="Organization"
+ name="prefs.profile.organization"
+ component={TextField}
+ validate={MY_ACCOUNT_VALIDATION}
+ required
+ />
+ </Grid>
+ <Grid item className={classes.gridItem}>
+ <Field
+ label="Website"
+ name="prefs.profile.website_url"
+ component={TextField}
+ />
+ </Grid>
+ <Grid item className={classes.gridItem}>
+ <InputLabel className={classes.label} htmlFor="prefs.profile.role">Organization</InputLabel>
+ <Field
+ id="prefs.profile.role"
+ name="prefs.profile.role"
+ component={NativeSelectField}
+ items={RoleTypes}
+ />
+ </Grid>
+ </Grid>
+ <Grid item xs={6}>
+ <Grid item className={classes.gridItem} />
+ <Grid item className={classes.gridItem}>
+ <Field
+ label="Last name"
+ name="lastName"
+ component={TextField}
+ disabled
+ />
+ </Grid>
+ <Grid item className={classes.gridItem} />
+ <Grid item className={classes.gridItem}>
+ <Field
+ label="E-mail at Organization"
+ name="prefs.profile.organization_email"
+ component={TextField}
+ validate={MY_ACCOUNT_VALIDATION}
+ required
+ />
+ </Grid>
+ </Grid>
+ <Grid item xs={12} className={classes.actions}>
+ <Button color="primary" onClick={reset} disabled={isPristine}>Discard changes</Button>
+ <Button
+ color="primary"
+ variant="contained"
+ type="submit"
+ disabled={isPristine || invalid || submitting}>
+ Save changes
+ </Button>
+ </Grid>
+ </Grid>
+ </form>
+ </CardContent>
+ </Card>;}
+);
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { RootState } from '~/store/store';
+import { compose } from 'redux';
+import { reduxForm, isPristine, isValid } from 'redux-form';
+import { connect } from 'react-redux';
+import { saveEditedUser } from '~/store/my-account/my-account-panel-actions';
+import { MyAccountPanelRoot, MyAccountPanelRootDataProps } from '~/views/my-account-panel/my-account-panel-root';
+import { MY_ACCOUNT_FORM } from "~/store/my-account/my-account-panel-actions";
+
+const mapStateToProps = (state: RootState): MyAccountPanelRootDataProps => ({
+ isPristine: isPristine(MY_ACCOUNT_FORM)(state),
+ isValid: isValid(MY_ACCOUNT_FORM)(state),
+ initialValues: state.auth.user
+});
+
+export const MyAccountPanel = compose(
+ connect(mapStateToProps),
+ reduxForm({
+ form: MY_ACCOUNT_FORM,
+ onSubmit: (data, dispatch) => {
+ dispatch(saveEditedUser(data));
+ }
+}))(MyAccountPanelRoot);
\ No newline at end of file
import { WorkflowPanel } from '~/views/workflow-panel/workflow-panel';
import { SearchResultsPanel } from '~/views/search-results-panel/search-results-panel';
import { SshKeyPanel } from '~/views/ssh-key-panel/ssh-key-panel';
+import { MyAccountPanel } from '~/views/my-account-panel/my-account-panel';
import { SharingDialog } from '~/views-components/sharing-dialog/sharing-dialog';
import { AdvancedTabDialog } from '~/views-components/advanced-tab-dialog/advanced-tab-dialog';
import { ProcessInputDialog } from '~/views-components/process-input-dialog/process-input-dialog';
import { ProjectPropertiesDialog } from '~/views-components/project-properties-dialog/project-properties-dialog';
import { RepositoriesPanel } from '~/views/repositories-panel/repositories-panel';
import { KeepServicePanel } from '~/views/keep-service-panel/keep-service-panel';
+import { ComputeNodePanel } from '~/views/compute-node-panel/compute-node-panel';
import { RepositoriesSampleGitDialog } from '~/views-components/repositories-sample-git-dialog/repositories-sample-git-dialog';
import { RepositoryAttributesDialog } from '~/views-components/repository-attributes-dialog/repository-attributes-dialog';
import { CreateRepositoryDialog } from '~/views-components/dialog-forms/create-repository-dialog';
import { RemoveRepositoryDialog } from '~/views-components/repository-remove-dialog/repository-remove-dialog';
import { CreateSshKeyDialog } from '~/views-components/dialog-forms/create-ssh-key-dialog';
import { PublicKeyDialog } from '~/views-components/ssh-keys-dialog/public-key-dialog';
+import { RemoveComputeNodeDialog } from '~/views-components/compute-nodes-dialog/remove-dialog';
import { RemoveKeepServiceDialog } from '~/views-components/keep-services-dialog/remove-dialog';
import { RemoveSshKeyDialog } from '~/views-components/ssh-keys-dialog/remove-dialog';
+import { RemoveVirtualMachineDialog } from '~/views-components/virtual-machines-dialog/remove-dialog';
+import { AttributesComputeNodeDialog } from '~/views-components/compute-nodes-dialog/attributes-dialog';
import { AttributesKeepServiceDialog } from '~/views-components/keep-services-dialog/attributes-dialog';
import { AttributesSshKeyDialog } from '~/views-components/ssh-keys-dialog/attributes-dialog';
import { VirtualMachineAttributesDialog } from '~/views-components/virtual-machines-dialog/attributes-dialog';
-import { RemoveVirtualMachineDialog } from '~/views-components/virtual-machines-dialog/remove-dialog';
import { UserPanel } from '~/views/user-panel/user-panel';
import { UserAttributesDialog } from '~/views-components/user-dialog/attributes-dialog';
import { CreateUserDialog } from '~/views-components/dialog-forms/create-user-dialog';
<Route path={Routes.SSH_KEYS} component={SshKeyPanel} />
<Route path={Routes.KEEP_SERVICES} component={KeepServicePanel} />
<Route path={Routes.USERS} component={UserPanel} />
+ <Route path={Routes.COMPUTE_NODES} component={ComputeNodePanel} />
+ <Route path={Routes.MY_ACCOUNT} component={MyAccountPanel} />
</Switch>
</Grid>
</Grid>
<DetailsPanel />
</Grid>
<AdvancedTabDialog />
+ <AttributesComputeNodeDialog />
<AttributesKeepServiceDialog />
<AttributesSshKeyDialog />
<ChangeWorkflowDialog />
<ProcessCommandDialog />
<ProcessInputDialog />
<ProjectPropertiesDialog />
+ <RemoveComputeNodeDialog />
<RemoveKeepServiceDialog />
<RemoveProcessDialog />
<RemoveRepositoryDialog />
"@types/react" "*"
redux "^3.6.0"
-"@types/redux-form@7.4.5":
- version "7.4.5"
- resolved "https://registry.yarnpkg.com/@types/redux-form/-/redux-form-7.4.5.tgz#fae0fa6cfbc613867093d1e0f6a84db17177305e"
- integrity sha512-PY74tuDamNhStB+87TQJXAKoa7uf5Ue/MJvnIrQowgjyRUo2Ky/THUfDec9U7IKRGzLnX7vWVTsoN1EvLnwAEQ==
+"@types/redux-form@7.4.12":
+ version "7.4.12"
+ resolved "https://registry.yarnpkg.com/@types/redux-form/-/redux-form-7.4.12.tgz#2afb0615e3b7417d460ab14a4802ede4a98f9c79"
+ integrity sha512-qHRkJcgdc5MntQHrkYCg5o6oySh+OdVKA90yELTdi9XlNvSGRxd6K230aTckVrwdUjdxtwZ31UqFgLoU5SiWYQ==
dependencies:
"@types/react" "*"
redux "^3.6.0 || ^4.0.0"