This commit is contained in:
syuilo 2017-11-12 05:25:07 +09:00
parent 5e86e6e3c1
commit 28407ce87b
6 changed files with 79 additions and 16 deletions

View file

@ -1,6 +1,8 @@
<mk-activity-home-widget> <mk-activity-home-widget>
<p class="title"><i class="fa fa-bar-chart"></i>%i18n:desktop.tags.mk-activity-home-widget.title%</p> <virtual if={ !data.compact }>
<button onclick={ toggle } title="%i18n:desktop.tags.mk-activity-home-widget.toggle%"><i class="fa fa-sort"></i></button> <p class="title"><i class="fa fa-bar-chart"></i>%i18n:desktop.tags.mk-activity-home-widget.title%</p>
<button onclick={ toggle } title="%i18n:desktop.tags.mk-activity-home-widget.toggle%"><i class="fa fa-sort"></i></button>
</virtual>
<p class="initializing" if={ initializing }><i class="fa fa-spinner fa-pulse fa-fw"></i>%i18n:common.loading%<mk-ellipsis/></p> <p class="initializing" if={ initializing }><i class="fa fa-spinner fa-pulse fa-fw"></i>%i18n:common.loading%<mk-ellipsis/></p>
<mk-activity-home-widget-calender if={ !initializing && data.view == 0 } data={ [].concat(activity) }/> <mk-activity-home-widget-calender if={ !initializing && data.view == 0 } data={ [].concat(activity) }/>
<mk-activity-home-widget-chart if={ !initializing && data.view == 1 } data={ [].concat(activity) }/> <mk-activity-home-widget-chart if={ !initializing && data.view == 1 } data={ [].concat(activity) }/>
@ -51,7 +53,8 @@
</style> </style>
<script> <script>
this.data = { this.data = {
view: 0 view: 0,
compact: false
}; };
this.mixin('widget'); this.mixin('widget');
@ -77,6 +80,11 @@
// Save view state // Save view state
this.save(); this.save();
}; };
this.func = () => {
this.data.compact = !this.data.compact;
this.save();
};
</script> </script>
</mk-activity-home-widget> </mk-activity-home-widget>

View file

@ -1,6 +1,8 @@
<mk-notifications-home-widget> <mk-notifications-home-widget>
<p class="title"><i class="fa fa-bell-o"></i>%i18n:desktop.tags.mk-notifications-home-widget.title%</p> <virtual if={ !data.compact }>
<button onclick={ settings } title="%i18n:desktop.tags.mk-notifications-home-widget.settings%"><i class="fa fa-cog"></i></button> <p class="title"><i class="fa fa-bell-o"></i>%i18n:desktop.tags.mk-notifications-home-widget.title%</p>
<button onclick={ settings } title="%i18n:desktop.tags.mk-notifications-home-widget.settings%"><i class="fa fa-cog"></i></button>
</virtual>
<mk-notifications/> <mk-notifications/>
<style> <style>
:scope :scope
@ -43,9 +45,20 @@
</style> </style>
<script> <script>
this.data = {
compact: false
};
this.mixin('widget');
this.settings = () => { this.settings = () => {
const w = riot.mount(document.body.appendChild(document.createElement('mk-settings-window')))[0]; const w = riot.mount(document.body.appendChild(document.createElement('mk-settings-window')))[0];
w.switch('notification'); w.switch('notification');
}; };
this.func = () => {
this.data.compact = !this.data.compact;
this.save();
};
</script> </script>
</mk-notifications-home-widget> </mk-notifications-home-widget>

View file

@ -1,5 +1,7 @@
<mk-photo-stream-home-widget> <mk-photo-stream-home-widget>
<p class="title"><i class="fa fa-camera"></i>%i18n:desktop.tags.mk-photo-stream-home-widget.title%</p> <virtual if={ !data.compact }>
<p class="title"><i class="fa fa-camera"></i>%i18n:desktop.tags.mk-photo-stream-home-widget.title%</p>
</virtual>
<p class="initializing" if={ initializing }><i class="fa fa-spinner fa-pulse fa-fw"></i>%i18n:common.loading%<mk-ellipsis/></p> <p class="initializing" if={ initializing }><i class="fa fa-spinner fa-pulse fa-fw"></i>%i18n:common.loading%<mk-ellipsis/></p>
<div class="stream" if={ !initializing && images.length > 0 }> <div class="stream" if={ !initializing && images.length > 0 }>
<virtual each={ image in images }> <virtual each={ image in images }>
@ -55,8 +57,11 @@
</style> </style>
<script> <script>
this.mixin('i'); this.data = {
this.mixin('api'); compact: false
};
this.mixin('widget');
this.mixin('stream'); this.mixin('stream');
this.images = []; this.images = [];
@ -87,5 +92,10 @@
this.update(); this.update();
} }
}; };
this.func = () => {
this.data.compact = !this.data.compact;
this.save();
};
</script> </script>
</mk-photo-stream-home-widget> </mk-photo-stream-home-widget>

View file

@ -1,6 +1,8 @@
<mk-server-home-widget> <mk-server-home-widget>
<p class="title"><i class="fa fa-server"></i>%i18n:desktop.tags.mk-server-home-widget.title%</p> <virtual if={ !data.compact }>
<button onclick={ toggle } title="%i18n:desktop.tags.mk-server-home-widget.toggle%"><i class="fa fa-sort"></i></button> <p class="title"><i class="fa fa-server"></i>%i18n:desktop.tags.mk-server-home-widget.title%</p>
<button onclick={ toggle } title="%i18n:desktop.tags.mk-server-home-widget.toggle%"><i class="fa fa-sort"></i></button>
</virtual>
<p class="initializing" if={ initializing }><i class="fa fa-spinner fa-pulse fa-fw"></i>%i18n:common.loading%<mk-ellipsis/></p> <p class="initializing" if={ initializing }><i class="fa fa-spinner fa-pulse fa-fw"></i>%i18n:common.loading%<mk-ellipsis/></p>
<mk-server-home-widget-cpu-and-memory-usage if={ !initializing } show={ data.view == 0 } connection={ connection }/> <mk-server-home-widget-cpu-and-memory-usage if={ !initializing } show={ data.view == 0 } connection={ connection }/>
<mk-server-home-widget-cpu if={ !initializing } show={ data.view == 1 } connection={ connection } meta={ meta }/> <mk-server-home-widget-cpu if={ !initializing } show={ data.view == 1 } connection={ connection } meta={ meta }/>
@ -57,7 +59,8 @@
import Connection from '../../../common/scripts/server-stream'; import Connection from '../../../common/scripts/server-stream';
this.data = { this.data = {
view: 0 view: 0,
compact: false
}; };
this.mixin('widget'); this.mixin('widget');
@ -85,6 +88,11 @@
// Save widget state // Save widget state
this.save(); this.save();
}; };
this.func = () => {
this.data.compact = !this.data.compact;
this.save();
};
</script> </script>
</mk-server-home-widget> </mk-server-home-widget>

View file

@ -1,6 +1,8 @@
<mk-user-recommendation-home-widget> <mk-user-recommendation-home-widget>
<p class="title"><i class="fa fa-users"></i>%i18n:desktop.tags.mk-user-recommendation-home-widget.title%</p> <virtual if={ !data.compact }>
<button onclick={ refresh } title="%i18n:desktop.tags.mk-user-recommendation-home-widget.refresh%"><i class="fa fa-refresh"></i></button> <p class="title"><i class="fa fa-users"></i>%i18n:desktop.tags.mk-user-recommendation-home-widget.title%</p>
<button onclick={ refresh } title="%i18n:desktop.tags.mk-user-recommendation-home-widget.refresh%"><i class="fa fa-refresh"></i></button>
</virtual>
<div class="user" if={ !loading && users.length != 0 } each={ _user in users }> <div class="user" if={ !loading && users.length != 0 } each={ _user in users }>
<a class="avatar-anchor" href={ '/' + _user.username }> <a class="avatar-anchor" href={ '/' + _user.username }>
<img class="avatar" src={ _user.avatar_url + '?thumbnail&size=42' } alt="" data-user-preview={ _user.id }/> <img class="avatar" src={ _user.avatar_url + '?thumbnail&size=42' } alt="" data-user-preview={ _user.id }/>
@ -111,7 +113,11 @@
</style> </style>
<script> <script>
this.mixin('api'); this.data = {
compact: false
};
this.mixin('widget');
this.mixin('user-preview'); this.mixin('user-preview');
this.users = null; this.users = null;
@ -148,5 +154,10 @@
} }
this.fetch(); this.fetch();
}; };
this.func = () => {
this.data.compact = !this.data.compact;
this.save();
};
</script> </script>
</mk-user-recommendation-home-widget> </mk-user-recommendation-home-widget>

View file

@ -23,6 +23,8 @@
<option value="tips">ヒント</option> <option value="tips">ヒント</option>
</select> </select>
<button onclick={ addWidget }>追加</button> <button onclick={ addWidget }>追加</button>
<br>
<p>Tip: 一部のウィジェットは、<strong><strong></strong>クリック</strong>することで表示を変更することができます。</p>
</div> </div>
<div class="trash"> <div class="trash">
<div ref="trash"></div> <div ref="trash"></div>
@ -213,11 +215,22 @@
break; break;
} }
this.home.push(riot.mount(el, { const tag = riot.mount(el, {
id: widget.id, id: widget.id,
data: widget.data, data: widget.data,
tl: this.refs.tl tl: this.refs.tl
})[0]); })[0];
this.home.push(tag);
if (this.opts.customize) {
actualEl.oncontextmenu = e => {
e.preventDefault();
e.stopImmediatePropagation();
if (tag.func) tag.func();
return false;
};
}
}; };
this.addWidget = () => { this.addWidget = () => {