1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-13 05:39:59 +00:00

add notification (#2353)

This commit is contained in:
C_Q
2018-09-10 18:24:49 +08:00
committed by Daniel Pan
parent 5222c49b29
commit dcf35018c1
5 changed files with 26 additions and 11 deletions

View File

@@ -1,3 +1,5 @@
let slug, repoID, serviceUrl, initialFilePath;
export const dirPath = '/'; export const dirPath = '/';
export const gettext = window.gettext; export const gettext = window.gettext;
@@ -9,7 +11,11 @@ export const siteTitle = window.app.config.siteTitle;
export const logoWidth = window.app.config.logoWidth; export const logoWidth = window.app.config.logoWidth;
export const logoHeight = window.app.config.logoHeight; export const logoHeight = window.app.config.logoHeight;
export const slug = window.wiki.config.slug; if (window.wiki) {
export const repoID = window.wiki.config.repoId; slug = window.wiki.config.slug;
export const serviceUrl = window.wiki.config.serviceUrl; repoID = window.wiki.config.repoId;
export const initialFilePath = window.wiki.config.initial_file_path; serviceUrl = window.wiki.config.serviceUrl;
initialFilePath = window.wiki.config.initial_file_path;
}
export { slug, repoID, serviceUrl, initialFilePath }

View File

@@ -175,7 +175,7 @@ class FilesActivities extends Component {
componentDidMount() { componentDidMount() {
const pageNum = 1 const pageNum = 1
this.props.seafileAPI.getActivities(pageNum) this.props.seafileAPI.listActivities(pageNum)
.then(res => { .then(res => {
// not logged in // not logged in
if (res.status == 403) { if (res.status == 403) {

View File

@@ -32,7 +32,7 @@ class MainSideNav extends React.Component {
loadGroups = () => { loadGroups = () => {
let _this = this; let _this = this;
this.props.seafileAPI.getGroups().then(res =>{ this.props.seafileAPI.listGroups().then(res =>{
let data = res.data.groups; let data = res.data.groups;
this.groupsHeight = (data.length + 1) * _this.listHeight; this.groupsHeight = (data.length + 1) * _this.listHeight;
_this.setState({ _this.setState({

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
const gettext = window.gettext; const gettext = window.gettext;
class Notification extends React.Component { class Notification extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -14,13 +15,18 @@ class Notification extends React.Component {
this.setState({ this.setState({
showNotice: !this.state.showNotice showNotice: !this.state.showNotice
}) })
if (!this.state.showNotice) { if (!this.state.showNotice) {
this.loadNotices() this.loadNotices()
} }
if (this.state.showNotice) {
this.props.seafileAPI.updateNotifications()
}
} }
loadNotices = () => { loadNotices = () => {
this.props.seafileAPI.getPopupNotices().then(res => { this.props.seafileAPI.listPopupNotices().then(res => {
this.setState({ this.setState({
notice_html: res.data.notice_html notice_html: res.data.notice_html
}) })
@@ -28,6 +34,8 @@ class Notification extends React.Component {
} }
render() { render() {
const { notice_html } = this.state;
return ( return (
<div id="notifications"> <div id="notifications">
<a href="#" onClick={this.onClick} className="no-deco" id="notice-icon" title="Notifications" aria-label="Notifications"> <a href="#" onClick={this.onClick} className="no-deco" id="notice-icon" title="Notifications" aria-label="Notifications">
@@ -41,7 +49,8 @@ class Notification extends React.Component {
<a href="#" onClick={this.onClick} title={gettext('Close')} aria-label={gettext('Close')} className="sf-popover-close js-close sf2-icon-x1 op-icon float-right"></a> <a href="#" onClick={this.onClick} title={gettext('Close')} aria-label={gettext('Close')} className="sf-popover-close js-close sf2-icon-x1 op-icon float-right"></a>
</div> </div>
<div className="sf-popover-con"> <div className="sf-popover-con">
<ul className="notice-list" dangerouslySetInnerHTML={{__html: this.state.notice_html}}></ul> <ul className="notice-list" dangerouslySetInnerHTML={{__html: notice_html}}>
</ul>
<a href="/notification/list/" className="view-all">{gettext('See All Notifications')}</a> <a href="/notification/list/" className="view-all">{gettext('See All Notifications')}</a>
</div> </div>
</div> </div>

View File

@@ -6,7 +6,7 @@ import MainPanel from './pages/dashboard/main-panel';
import Account from './components/account'; import Account from './components/account';
import Notification from './components/notification'; import Notification from './components/notification';
import { SeafileAPI } from './seafile-api'; import { SeafileAPI } from 'seafile-js';
import cookie from 'react-cookies'; import cookie from 'react-cookies';
import 'seafile-ui'; import 'seafile-ui';
@@ -15,7 +15,7 @@ import './css/dashboard.css';
const siteRoot = window.app.config.siteRoot; const siteRoot = window.app.config.siteRoot;
let seafileAPI = new SeafileAPI(); let seafileAPI = new SeafileAPI();
let xcsrfHeaders = cookie.load('csrftoken'); let xcsrfHeaders = cookie.load('sfcsrftoken');
seafileAPI.initForSeahubUsage({ siteRoot, xcsrfHeaders }); seafileAPI.initForSeahubUsage({ siteRoot, xcsrfHeaders });
class DashBoard extends Component { class DashBoard extends Component {