npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dialob/dashboard-material

v1.2.3

Published

Material UI dashboard component for Dialob

Downloads

31

Readme

Dialob Material Dashboard

This package provides a Dialob Admin UI View which enables users to easily interact with the Dialob forms. It requires Dialob backend with version of: 2.2.4 or above

Install

pnpm add @dialob/dashboard-material 

Quick-start

import React from 'react';
import { ThemeProvider } from '@mui/material/styles';
import { DialobAdmin, DialobAdminConfig } from "@dialob/dashboard-material";

const config: DialobAdminConfig = {
	csrf : {
		key : 'X-CSRF-TOKEN',													 
		value : '<csrf token value>'
	},
	dialobApiUrl: 'http://localhost:8085/dialob',
	setLoginRequired: cfg.setLoginRequired,
	setTechnicalError: cfg.setTechnicalError,
	language: "en"
}

const App = () => {
 return (
	  <ThemeProvider theme={yourTheme}>
			<DialobAdmin 
				config={config}
			/>
		</ThemeProvider>
 );
}

Local Development Environment

In order to view this component localy without embedding this module into another application, you can run in the root directory:

pnpm dev

And then you can change themes on the fly and see how the component behaves.

Interfaces

interface CsrfShape {
	'key': string,
	'value': string
}

interface DialobAdminConfig {
	dialobApiUrl: string; // base url for Dialob Api
	setLoginRequired: () => void; // function used for requesting possible authentication
	setTechnicalError: () => void; // function used for reporting technical errors
	language: string; // Current locale used by your application in ISO language code format ("en","sv","fi" and similar)
	csrf: CsrfShape | undefined; // Adjust according to your application csrf settings
}

interface DialobAdminViewProps {
	config: DialobAdminConfig;
	showNotification?: (message: string, severity: 'success' | 'error') => void;
}

Additional information

If you want your Dialob Admin view to look good in your application you have to use a ThemeProvier and set styles inside the theme for these components: Table, TableRow, TableCell, OutlinedInput, SvgIcon, IconButton, Button

Dialob Admin component can also take the showNotification callback function, This function is used for viewing snackbars after a successful or unsuccessful RESTful APIs calls.

import React, { createContext, useContext, useState, ReactNode } from 'react';
import Snackbar from '@mui/material/Snackbar';
import MuiAlert, { AlertProps } from '@mui/material/Alert';
import { useTheme, Theme } from '@mui/material/styles';

interface SnackbarContextType {
  showNotification: (message: string, severity: 'success' | 'error') => void;
}

const SnackbarContext = createContext<SnackbarContextType | undefined>(undefined);

export const useSnackbar = (): SnackbarContextType => {
  const context = useContext(SnackbarContext);
  if (!context) {
    throw new Error('useSnackbar must be used within a SnackbarProvider');
  }
  return context;
};

const Alert = React.forwardRef<HTMLDivElement, AlertProps>(function Alert(props, ref) {
  return <MuiAlert elevation={6} ref={ref} variant="filled" {...props} />;
});

interface SnackbarProviderProps {
  children: ReactNode;
}

export const SnackbarProvider: React.FC<SnackbarProviderProps> = ({ children }) => {
  const [snackbarOpen, setSnackbarOpen] = useState(false);
  const [snackbarMessage, setSnackbarMessage] = useState('');
  const [snackbarSeverity, setSnackbarSeverity] = useState<'success' | 'error'>('success');
  const theme = useTheme<Theme>();

  const showNotification = (message: string, severity: 'success' | 'error') => {
    setSnackbarMessage(message);
    setSnackbarSeverity(severity);
    setSnackbarOpen(true);
  };

  const handleClose = () => {
    setSnackbarOpen(false);
  };

  return (
    <SnackbarContext.Provider value={{ showNotification }}>
      {children}
      <Snackbar
        open={snackbarOpen}
        autoHideDuration={6000}
        onClose={handleClose}
        anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }} 
      >
        <Alert 
          onClose={handleClose} 
          severity={snackbarSeverity} 
          sx={{ 
            width: '100%',
            backgroundColor: snackbarSeverity === 'success' ? theme.palette.success.main : theme.palette.error.main,
            color: snackbarSeverity === 'success' ? theme.palette.text.primary : theme.palette.common.white
          }}>
          {snackbarMessage}
        </Alert>
      </Snackbar>
    </SnackbarContext.Provider>
  );
};